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

Method clone

oneflow/core/framework/tensor.cpp:138–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138Maybe<Tensor> LocalTensor::clone() const {
139 std::shared_ptr<Tensor> input = std::const_pointer_cast<Tensor>(shared_from_this());
140 const bool pin_memory = JUST(JUST(input->AsLocalTensor())->is_pinned());
141 return JUST(functional::Copy(input, JUST(this->device()), /*pin_memory=*/pin_memory));
142}
143
144Maybe<void> LocalTensor::set_data(const std::shared_ptr<Tensor>& other) {
145 CHECK_OR_RETURN(this->is_leaf()) << "Can only set leaf tensor's data.";

Callers 15

get_args_copyFunction · 0.45
identityMethod · 0.45
trainFunction · 0.45
helperFunction · 0.45
backwardMethod · 0.45
forwardMethod · 0.45

Calls 4

deviceMethod · 0.95
CopyClass · 0.85
is_pinnedMethod · 0.45
AsLocalTensorMethod · 0.45

Tested by 15

trainFunction · 0.36
helperFunction · 0.36
backwardMethod · 0.36
forwardMethod · 0.36
test_identity_pruningMethod · 0.36