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

Method set_data

oneflow/core/framework/tensor.h:457–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455
456 virtual user_op::TensorDesc* mut_tensor_meta() override { return tensor_->mut_tensor_meta(); }
457 virtual Maybe<void> set_data(const std::shared_ptr<Tensor>& other) override {
458 bool old_requires_grad = tensor_->requires_grad();
459 this->tensor_ = JUST(other->detach());
460 JUST(this->tensor_->set_requires_grad(old_requires_grad));
461 if (other->is_lazy()) { JUST(this->BorrowTensorName(other.get())); }
462 return Maybe<void>::Ok();
463 }
464
465 virtual Maybe<void> offload() override {
466 JUST(tensor_->offload());

Callers

nothing calls this directly

Calls 6

BorrowTensorNameMethod · 0.80
requires_gradMethod · 0.45
detachMethod · 0.45
set_requires_gradMethod · 0.45
is_lazyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected