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

Method load

oneflow/core/framework/tensor.cpp:193–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193Maybe<void> LocalTensor::load() {
194 TENSOR_OFFLOAD_CHECK(true, "loaded");
195
196 // Load cpu to cuda.
197 int64_t device_id = JUST(this->device())->device_id();
198 std::shared_ptr<Tensor> cpu_tensor = std::make_shared<LocalTensor>(offloaded_impl_);
199 auto loaded_tensor = JUST(functional::Copy(cpu_tensor, "cuda", device_id,
200 /*pin_memory=*/JUST(cpu_tensor->is_pinned())));
201 JUST(vm::CurrentRankSync());
202 JUST(set_data(loaded_tensor));
203
204 // Release cpu memory.
205 cpu_tensor.reset();
206 offloaded_impl_.reset();
207 auto* vm = JUST(SingletonMaybe<VirtualMachine>());
208 JUST(vm->ShrinkAllMem());
209
210 is_offloaded_ = false;
211 return Maybe<void>::Ok();
212}
213
214std::shared_ptr<Tensor> GlobalTensor::contiguous() const {
215 std::shared_ptr<Tensor> tensor = std::const_pointer_cast<Tensor>(shared_from_this());

Callers 7

__init__Method · 0.45
CloseMethod · 0.45
StartLoadThreadMethod · 0.45
comm_net_tokenMethod · 0.45
sizeMethod · 0.45
SetOrAddMethod · 0.45

Calls 8

deviceMethod · 0.95
CopyClass · 0.85
CurrentRankSyncFunction · 0.85
ClusterSyncFunction · 0.85
ShrinkAllMemMethod · 0.80
device_idMethod · 0.45
is_pinnedMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected