| 39 | namespace cambricon { |
| 40 | |
| 41 | HandleImpl::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 | |
| 58 | HandleImpl::~HandleImpl() noexcept = default; |
| 59 |
nothing calls this directly
no test coverage detected