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

Method HandleImpl

dnn/src/cambricon/handle.cpp:41–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39namespace cambricon {
40
41HandleImpl::HandleImpl(megcoreComputingHandle_t comp_handle)
42 : HandleImplHelper(comp_handle, HandleType::CAMBRICON) {
43 // Get megcore device handle
44 megcoreDeviceHandle_t dev_handle;
45 megcoreGetDeviceHandle(comp_handle, &dev_handle);
46 int dev_id;
47 megcoreGetDeviceID(dev_handle, &dev_id);
48 unsigned int dev_num;
49 cnrt_check(cnrtGetDeviceCount(&dev_num));
50 MEGDNN_MARK_USED_VAR(dev_num);
51 // check validity of device_id
52 megdnn_assert(dev_id >= 0 && static_cast<unsigned int>(dev_id) < dev_num);
53 m_device_id = dev_id;
54 cnrt_check(cnrtGetDeviceProperties(&m_device_info, dev_id));
55 megcore::getCambriconContext(comp_handle, &m_megcore_context);
56}
57
58HandleImpl::~HandleImpl() noexcept = default;
59

Callers

nothing calls this directly

Calls 2

megcoreGetDeviceHandleFunction · 0.85
megcoreGetDeviceIDFunction · 0.85

Tested by

no test coverage detected