| 26 | namespace oneflow { |
| 27 | |
| 28 | Maybe<Symbol<Device>> ToOneFlowDevice(const DLDevice& ctx) { |
| 29 | switch (ctx.device_type) { |
| 30 | case DLDeviceType::kDLCPU: return JUST(Device::New("cpu")); |
| 31 | #ifdef WITH_CUDA |
| 32 | case DLDeviceType::kDLCUDA: return JUST(Device::New("cuda", ctx.device_id)); |
| 33 | #endif |
| 34 | default: UNIMPLEMENTED_THEN_RETURN() << "Unsupported device type: " << ctx.device_type; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | Maybe<DataType> ToOneFlowDataType(const DLDataType& dtype) { |
| 39 | DataType ofdtype = DataType::kInvalidDataType; |