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

Method set_data

oneflow/core/framework/tensor.cpp:76–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 }
75}
76Maybe<void> Parameter::set_data(const std::shared_ptr<Tensor>& other) {
77 if (is_local() && is_eager()) {
78 auto rematable_storage = std::dynamic_pointer_cast<vm::RematableTensorStorage>(
79 CHECK_JUST(tensor_->eager_blob_object())->tensor_storage());
80 bool enable_remat = rematable_storage != nullptr && tensor_->is_local() && tensor_->is_eager();
81 if (enable_remat) { rematable_storage->set_eviction_disabled(false); }
82 JUST(tensor_->set_data(other));
83 if (enable_remat) { rematable_storage->set_eviction_disabled(true); }
84 } else {
85 JUST(tensor_->set_data(other));
86 }
87 return Maybe<void>::Ok();
88}
89
90std::shared_ptr<Tensor> Parameter::contiguous() const {
91 const auto& tensor = std::const_pointer_cast<Tensor>(shared_from_this());

Callers 3

PyTensorObject_zero_gradFunction · 0.45
PyTensorObject_set_dataFunction · 0.45

Calls 11

is_leafMethod · 0.95
is_leafMethod · 0.95
set_eviction_disabledMethod · 0.80
BorrowTensorNameMethod · 0.80
tensor_storageMethod · 0.45
eager_blob_objectMethod · 0.45
is_localMethod · 0.45
is_eagerMethod · 0.45
detachMethod · 0.45
is_lazyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected