MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / zeros_

Method zeros_

oneflow/api/cpp/framework/tensor.cpp:69–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67DType Tensor::dtype() const { return static_cast<DType>(tensor_->dtype()->data_type()); }
68
69void 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
84Tensor Tensor::from_buffer(const void* buffer, const Shape& shape, const Device& device,
85 const DType& dtype) {

Callers 9

__init__Method · 0.80
_init_weightsFunction · 0.80
__init__Method · 0.80
reset_parametersMethod · 0.80
reset_parametersMethod · 0.80
reset_parametersMethod · 0.80
reset_parametersMethod · 0.80
TESTFunction · 0.80

Calls 8

PhysicalRunFunction · 0.85
AutoMemsetFunction · 0.85
GetPtrOrThrowMethod · 0.80
AccessBlobByCallbackMethod · 0.80
AsLocalTensorMethod · 0.45
GetOrThrowMethod · 0.45
mut_dptrMethod · 0.45
ByteSizeOfBlobBodyMethod · 0.45

Tested by 2

TESTFunction · 0.64