#include "caffe2/onnx/device.h" #include #include namespace caffe2 { namespace onnx { static const std::unordered_map 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