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

Function ToOneFlowDevice

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

Source from the content-addressed store, hash-verified

26namespace oneflow {
27
28Maybe<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
38Maybe<DataType> ToOneFlowDataType(const DLDataType& dtype) {
39 DataType ofdtype = DataType::kInvalidDataType;

Callers 1

fromDLPackFunction · 0.85

Calls 1

NewFunction · 0.50

Tested by

no test coverage detected