diff options
author | Edward Yang <ezyang@fb.com> | 2018-09-25 10:12:24 -0700 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2018-09-25 10:13:43 -0700 |
commit | d7e11e3aaec8f6dcec261e85a330a437336ab8c9 (patch) | |
tree | a051cbcf3a65d29698fe38cbf0bd69911d80c8a2 /caffe2/proto | |
parent | 3deb4791c3fd6e4ce63b708006e75fa43fe3d971 (diff) | |
download | pytorch-d7e11e3aaec8f6dcec261e85a330a437336ab8c9.tar.gz pytorch-d7e11e3aaec8f6dcec261e85a330a437336ab8c9.tar.bz2 pytorch-d7e11e3aaec8f6dcec261e85a330a437336ab8c9.zip |
Revert "Move CreateContext to global registry (#11688)" (#12049)
Summary:
This reverts commit 3ae6ee4ebded136da30aa53fd3873d84acfbc9f0.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12049
Differential Revision: D10030954
Pulled By: ezyang
fbshipit-source-id: 6ca9de65b707c5b4c68280fc6f1b8e5ad7251efc
Diffstat (limited to 'caffe2/proto')
-rw-r--r-- | caffe2/proto/caffe2_pb.h | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/caffe2/proto/caffe2_pb.h b/caffe2/proto/caffe2_pb.h index a0d455d451..0a08c8db24 100644 --- a/caffe2/proto/caffe2_pb.h +++ b/caffe2/proto/caffe2_pb.h @@ -1,5 +1,5 @@ #pragma once -#include <ATen/core/Device.h> +#include <ATen/core/DeviceType.h> #include <ATen/core/Error.h> #include <caffe2/proto/caffe2.pb.h> @@ -47,10 +47,6 @@ inline CAFFE2_API DeviceType ProtoToType(const caffe2::DeviceTypeProto p) { } } -inline CAFFE2_API DeviceType ProtoToType(int p) { - return ProtoToType(static_cast<caffe2::DeviceTypeProto>(p)); -} - inline CAFFE2_API DeviceTypeProto TypeToProto(const DeviceType& t) { switch (t) { case DeviceType::CPU: @@ -81,30 +77,4 @@ inline CAFFE2_API DeviceTypeProto TypeToProto(const DeviceType& t) { } } -inline CAFFE2_API caffe2::DeviceOption DeviceToOption( - const at::Device& device) { - caffe2::DeviceOption option; - auto type = device.type(); - option.set_device_type(TypeToProto(type)); - // sets the gpu_id to -1 means we'll use the current gpu id when the function - // is being called, see context_gpu.cu for more info. - if (type == at::DeviceType::CUDA) { - option.set_cuda_gpu_id(device.index()); - } else if (type == at::DeviceType::HIP) { - option.set_hip_gpu_id(device.index()); - } - return option; -} - -inline CAFFE2_API at::Device OptionToDevice(const caffe2::DeviceOption option) { - at::Device device(ProtoToType(option.device_type())); - auto type = device.type(); - if (type == at::DeviceType::CUDA) { - device.set_index(option.cuda_gpu_id()); - } else if (type == at::DeviceType::HIP) { - device.set_index(option.hip_gpu_id()); - } - return device; -} - } // namespace caffe2 |