mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/67624 Test Plan: Visual inspection. Sandcastle. Reviewed By: malfet Differential Revision: D31986628 fbshipit-source-id: c872bded7325997a2945dbf5d4d052628dcb3659
19 lines
473 B
C++
19 lines
473 B
C++
#include "caffe2/onnx/device.h"
|
|
|
|
#include <cstdlib>
|
|
#include <unordered_map>
|
|
|
|
namespace caffe2 {
|
|
namespace onnx {
|
|
static const std::unordered_map<std::string, DeviceType> kDeviceMap = {
|
|
{"CPU", DeviceType::CPU},
|
|
{"CUDA", DeviceType::CUDA}};
|
|
|
|
Device::Device(const std::string& spec) {
|
|
auto pos = spec.find_first_of(':');
|
|
type = kDeviceMap.at(spec.substr(0, pos - 1));
|
|
device_id = atoi(spec.substr(pos + 1).c_str());
|
|
}
|
|
} // namespace onnx
|
|
} // namespace caffe2
|