MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / get_tensor_device

Method get_tensor_device

imperative/python/src/dlpack_convertor.cpp:94–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94CompNode mgb::imperative::get_tensor_device(const DLDevice& ctx, int stream) {
95 int id = ctx.device_id;
96 switch (ctx.device_type) {
97 case DLDeviceType::kDLCPU: {
98 auto device = "cpu" + std::to_string(id);
99 return as_comp_node(device);
100 }
101 case DLDeviceType::kDLCUDA: {
102 auto device = "gpu" + std::to_string(id) + ":" + std::to_string(stream);
103 return as_comp_node(device);
104 }
105 default:
106 mgb_throw(MegBrainError, "Unsupported device_type");
107 }
108}
109
110DType mgb::imperative::get_tensor_type(const DLDataType& dtype) {
111 DType tensortype;

Callers

nothing calls this directly

Calls 2

to_stringFunction · 0.85
as_comp_nodeFunction · 0.70

Tested by

no test coverage detected