MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / ToDLDevice

Function ToDLDevice

oneflow/api/python/dlpack/converter.cpp:132–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132Maybe<DLDevice> ToDLDevice(Symbol<Device> ofdevice) {
133 DLDevice ctx;
134 ctx.device_id = ofdevice->device_id();
135 switch (ofdevice->enum_type()) {
136 case DeviceType::kCPU: ctx.device_type = DLDeviceType::kDLCPU; break;
137#ifdef WITH_CUDA
138 case DeviceType::kCUDA: ctx.device_type = DLDeviceType::kDLCUDA; break;
139#endif
140 default: UNIMPLEMENTED_THEN_RETURN() << "Unsupported device type: " << ofdevice->type();
141 }
142 return ctx;
143}
144
145Maybe<DLDataType> ToDLDataType(DataType ofdtype) {
146 DLDataType dtype;

Callers 1

toDLPackFunction · 0.85

Calls 3

enum_typeMethod · 0.80
device_idMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected