| 42 | : m_computing_handle(computing_handle), m_handle_type(type) {} |
| 43 | |
| 44 | std::unique_ptr<Handle> Handle::make( |
| 45 | megcoreComputingHandle_t computing_handle, int debug_level) { |
| 46 | (void)debug_level; |
| 47 | megcoreDeviceHandle_t device_handle; |
| 48 | megcorePlatform_t platform; |
| 49 | megcoreGetDeviceHandle(computing_handle, &device_handle); |
| 50 | |
| 51 | megcoreGetPlatform(device_handle, &platform); |
| 52 | if (platform == megcorePlatformCPU) { |
| 53 | // only enable midout for CPU, becuase CPU might be unused when some |
| 54 | // other platforms are used |
| 55 | MIDOUT_BEGIN(HandlePlatform, midout_iv(megcorePlatformCPU)) { |
| 56 | // CPU |
| 57 | #if MEGDNN_NAIVE |
| 58 | return make_unique<naive::HandleImpl>(computing_handle); |
| 59 | #else |
| 60 | if (debug_level == 0) { |
| 61 | #if MEGDNN_X86 |
| 62 | // Because of ICC bug, we cannot use make_unique here. It will |
| 63 | // trigger an internal compiler error. |
| 64 | return std::unique_ptr<x86::HandleImpl>( |
| 65 | new x86::HandleImpl(computing_handle)); |
| 66 | // return make_unique<x86::HandleImpl>(computing_handle); |
| 67 | #elif MEGDNN_ARMV7 |
| 68 | return make_unique<armv7::HandleImpl>(computing_handle); |
| 69 | #elif MEGDNN_AARCH64 |
| 70 | return make_unique<aarch64::HandleImpl>(computing_handle); |
| 71 | #else |
| 72 | return make_unique<fallback::HandleImpl>(computing_handle); |
| 73 | #endif |
| 74 | } else if (debug_level == 1) { |
| 75 | return make_unique<fallback::HandleImpl>(computing_handle); |
| 76 | } else if (debug_level == 2) { |
| 77 | return make_unique<naive::HandleImpl>(computing_handle); |
| 78 | } else { |
| 79 | megdnn_throw("Debug level must be 0/1/2."); |
| 80 | } |
| 81 | #endif |
| 82 | } |
| 83 | MIDOUT_END(); |
| 84 | |
| 85 | } |
| 86 | else if (platform == megcorePlatformROCM) { |
| 87 | #if MEGDNN_WITH_ROCM |
| 88 | return make_rocm_handle(computing_handle); |
| 89 | #else |
| 90 | return nullptr; |
| 91 | #endif |
| 92 | } else if (platform == megcorePlatformCambricon) { |
| 93 | #if MEGDNN_WITH_CAMBRICON |
| 94 | return make_unique<cambricon::HandleImpl>(computing_handle); |
| 95 | #else |
| 96 | return nullptr; |
| 97 | #endif |
| 98 | } else if (platform == megcorePlatformAtlas) { |
| 99 | #if MEGDNN_WITH_ATLAS |
| 100 | return make_unique<atlas::HandleImpl>(computing_handle); |
| 101 | #else |
nothing calls this directly
no test coverage detected