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

Method MegDNNHandle

src/core/impl/comp_node_env.cpp:39–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39MegDNNHandle::MegDNNHandle(const CompNodeEnv& env) {
40 auto megdnn_version = megdnn::get_version();
41 mgb_throw_if(
42 megdnn_version.major != MEGDNN_MAJOR || megdnn_version.minor < MEGDNN_MINOR,
43 SystemError,
44 "incompatible dnn version: compiled with %d.%d, get %d.%d.%d "
45 "at runtime",
46 MEGDNN_MAJOR, MEGDNN_MINOR, megdnn_version.major, megdnn_version.minor,
47 megdnn_version.patch);
48 bool init = false;
49#if MGB_CUDA
50 if (env.property().type == CompNode::DeviceType::CUDA) {
51 megcoreCreateDeviceHandle(
52 &m_dev_hdl, megcorePlatformCUDA, env.cuda_env().device, 0);
53 megcore::createComputingHandleWithCUDAContext(
54 &m_comp_hdl, m_dev_hdl, 0,
55 {env.cuda_env().stream, make_async_error_info(env)});
56 init = true;
57 }
58#endif
59
60#if MGB_ROCM
61 if (env.property().type == CompNode::DeviceType::ROCM) {
62 megcoreCreateDeviceHandle(
63 &m_dev_hdl, megcorePlatformROCM, env.rocm_env().device, 0);
64 megcore::createComputingHandleWithROCMContext(
65 &m_comp_hdl, m_dev_hdl, 0,
66 {env.rocm_env().stream, make_async_error_info(env)});
67 init = true;
68 }
69#endif
70#if MGB_CAMBRICON
71 if (env.property().type == CompNode::DeviceType::CAMBRICON) {
72 CompNodeEnv::CnrtEnv::init_status.init();
73 megcoreCreateDeviceHandle(
74 &m_dev_hdl, megcorePlatformCambricon, env.cnrt_env().device, 0);
75 megcore::createComputingHandleWithCambriconContext(
76 &m_comp_hdl, m_dev_hdl, 0,
77 {env.cnrt_env().queue, env.cnrt_env().cnnl_handle,
78 env.cnrt_env().mem_mgr.get()});
79 init = true;
80 }
81#endif
82
83#if MGB_ATLAS
84 if (env.property().type == CompNode::DeviceType::ATLAS) {
85 CompNodeEnv::AtlasEnv::init_status.init();
86 megcore::createAtlasDeviceHandleWithGlobalInitStatus(
87 &m_dev_hdl, env.atlas_env().device, 0, true);
88 megcore::createComputingHandleWithAtlasContext(
89 &m_comp_hdl, m_dev_hdl, 0, {env.atlas_env().stream});
90
91 init = true;
92 }
93#endif
94
95 if (env.property().type == CompNode::DeviceType::CPU) {
96 megcoreCreateDeviceHandle(&m_dev_hdl, megcorePlatformCPU);

Callers

nothing calls this directly

Calls 6

makeFunction · 0.50
propertyMethod · 0.45
initMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected