MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / Get

Method Get

paddle/phi/api/lib/context_pool.cc:45–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45const phi::DeviceContext* DeviceContextPool::Get(const Place& place) {
46 auto it = context_map_.find(place);
47 if (it == context_map_.end()) {
48 if (!phi::DeviceContextPool::IsInitialized()) {
49 phi::memory_utils::InitDevices();
50 }
51 // only when we need the specific DeviceContext, get and cache it
52 auto* dev_ctx = phi::DeviceContextPool::Instance().Get(place);
53 {
54 std::lock_guard<std::mutex> lock(mutex_);
55 context_map_[place] = dev_ctx;
56 }
57 return dev_ctx;
58 }
59 return it->second;
60}
61
62phi::DeviceContext* DeviceContextPool::GetMutable(const Place& place) {
63 return const_cast<phi::DeviceContext*>(Get(place)); // NOLINT

Callers 9

TransDataLayoutFunction · 0.45
TransDataTypeFunction · 0.45
TransDataPlaceFunction · 0.45
Trans2ContiguousFunction · 0.45
SyncDeviceContextMethod · 0.45
context_pool.ccFile · 0.45
_PD_PhiDDimToIntArrayRefFunction · 0.45
getCurrentGPUContextFunction · 0.45

Calls 4

InstanceFunction · 0.85
InitDevicesFunction · 0.50
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected