blob: 7808c54f307a9f9fa54d8fd925b482aaf42c0d39 [file] [log] [blame]
#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());
}
}}