Caffe2 - C++ API
A deep learning, cross platform ML framework
blob_serialization_gpu.cc
1 #include "caffe2/core/blob.h"
2 #include "caffe2/core/blob_serialization.h"
3 #include "caffe2/core/context_gpu.h"
4 
5 namespace caffe2 {
6 
7 template <>
8 void TensorSerializer<CUDAContext>::StoreDeviceDetail(
9  const Tensor<CUDAContext>& input, TensorProto* proto) {
10  auto* device_detail = proto->mutable_device_detail();
11  device_detail->set_device_type(CUDA);
12  device_detail->set_cuda_gpu_id(
13  GetGPUIDForPointer(input.raw_data()));
14 }
15 
16 namespace {
17 REGISTER_BLOB_SERIALIZER(
18  (TypeMeta::Id<TensorCUDA>()),
19  TensorSerializer<CUDAContext>);
20 REGISTER_BLOB_DESERIALIZER(TensorCUDA, TensorDeserializer<CUDAContext>);
21 }
22 } // namespace caffe2
23 
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
int GetGPUIDForPointer(const void *ptr)
Gets the GPU id that the current pointer is located at.
Definition: common_gpu.cc:133