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

Function GetPlaceFromPtr

paddle/phi/api/lib/tensor_utils.cc:36–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34PD_REGISTER_API(from_blob)
35
36PADDLE_API phi::Place GetPlaceFromPtr(void* data) {
37#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
38#ifdef PADDLE_WITH_CUDA
39 cudaPointerAttributes attr = {};
40 cudaError_t status = cudaPointerGetAttributes(&attr, data);
41 if (status == cudaSuccess && attr.type == cudaMemoryTypeDevice) {
42 return phi::GPUPlace(attr.device);
43 }
44#else
45 hipPointerAttribute_t attr = {};
46 hipError_t status = hipPointerGetAttributes(&attr, data);
47 if (status == hipSuccess && attr.memoryType == hipMemoryTypeDevice) {
48 return phi::GPUPlace(attr.device);
49 }
50#endif
51#endif
52 return phi::CPUPlace();
53}
54
55struct DeleterManager {
56 static DeleterManager* Instance() {

Callers 2

FromBlobImplFunction · 0.85
TESTFunction · 0.85

Calls 2

GPUPlaceClass · 0.85
CPUPlaceClass · 0.50

Tested by 1

TESTFunction · 0.68