| 67 | DType Tensor::dtype() const { return static_cast<DType>(tensor_->dtype()->data_type()); } |
| 68 | |
| 69 | void Tensor::zeros_() { |
| 70 | std::shared_ptr<of::one::LocalTensor> local_tensor = tensor_->AsLocalTensor().GetPtrOrThrow(); |
| 71 | of::PhysicalRun([&](of::InstructionsBuilder* builder) -> of::Maybe<void> { |
| 72 | JUST(builder->AccessBlobByCallback( |
| 73 | local_tensor, |
| 74 | [](of::ep::Stream* stream, |
| 75 | const std::shared_ptr<of::vm::EagerBlobObject>& eager_blob_object) { |
| 76 | of::AutoMemset(stream, eager_blob_object->mut_dptr(), 0, |
| 77 | eager_blob_object->ByteSizeOfBlobBody(), eager_blob_object->mem_case()); |
| 78 | }, |
| 79 | "mut")); |
| 80 | return of::Maybe<void>::Ok(); |
| 81 | }).GetOrThrow(); |
| 82 | } |
| 83 | |
| 84 | Tensor Tensor::from_buffer(const void* buffer, const Shape& shape, const Device& device, |
| 85 | const DType& dtype) { |