| 102 | #if MGB_CUDA |
| 103 | #if CUDA_VERSION >= 10020 |
| 104 | TEST(TestLayoutTransform, Resnet18_QS8) { |
| 105 | REQUIRE_GPU(1); |
| 106 | auto cn = CompNode::load("gpu0"); |
| 107 | auto&& prop = CompNodeEnv::from_comp_node(cn).cuda_env().device_prop; |
| 108 | auto sm_ver = prop.major * 10 + prop.minor; |
| 109 | if (sm_ver < 75) { |
| 110 | printf("This testcast ignored due to insufficient cuda cap(got: %d, " |
| 111 | "expected: %d)\n", |
| 112 | sm_ver, 75); |
| 113 | return; |
| 114 | } |
| 115 | Network network(cn); |
| 116 | /// batch size = 1 reduce test time |
| 117 | auto output = make_resnet18(network, 16, dtype::QuantizedS8{1.f}); |
| 118 | using S = opr::mixin::AlgoChooserHelper::ExecutionPolicy::Strategy; |
| 119 | S strategy = S::PROFILE; |
| 120 | gopt::modify_opr_algo_strategy_inplace({{output}}, strategy); |
| 121 | |
| 122 | HostTensorND t1; |
| 123 | auto func1 = network.graph->compile({make_callback_copy(output, t1)}); |
| 124 | func1->execute(); |
| 125 | |
| 126 | using OprFormatConfigID = LayoutTransformContext::OprFormatConfigID; |
| 127 | using OprList = LayoutTransformContext::OprList; |
| 128 | using Target = LayoutTransformContext::Target; |
| 129 | using ReformatAttribute = LayoutTransformContext::ReformatAttribute; |
| 130 | using Attribute = LayoutTransformContext::Attribute; |
| 131 | OprList opr_list = { |
| 132 | opr::ConvBiasForward::typeinfo(), opr::ElemwiseMultiType::typeinfo(), |
| 133 | opr::Elemwise::typeinfo(), opr::TypeCvt::typeinfo(), |
| 134 | opr::PoolingForward::typeinfo(), opr::WarpPerspectiveForward::typeinfo(), |
| 135 | }; |
| 136 | SmallVector<TensorFormats> available_tensor_formats = { |
| 137 | TensorFormats::NCHW, TensorFormats::NHWC, TensorFormats::NCHWc4, |
| 138 | TensorFormats::NCHWc32, TensorFormats::CHWNc4}; |
| 139 | Attribute attribute = { |
| 140 | OprFormatConfigID::NCHW, TensorFormats::NCHW, Target::UNSPEC, |
| 141 | ReformatAttribute::AUTO_PADDING_NHWC}; |
| 142 | auto ctx = std::make_unique<LayoutTransformContext>( |
| 143 | std::move(opr_list), std::move(available_tensor_formats), attribute); |
| 144 | ctx->add_opr_config( |
| 145 | opr::ConvBiasForward::typeinfo(), |
| 146 | {OprFormatConfigID::NCHW4, OprFormatConfigID::NCHW32, |
| 147 | OprFormatConfigID::CHWN4, OprFormatConfigID::NHWC}) |
| 148 | .add_opr_config( |
| 149 | opr::PoolingForward::typeinfo(), |
| 150 | {OprFormatConfigID::NCHW4, OprFormatConfigID::NCHW32, |
| 151 | OprFormatConfigID::NHWC, OprFormatConfigID::CHWN4}); |
| 152 | #if MGB_WITH_CACHED_TEST |
| 153 | auto profiler = std::make_unique<ProfilerMock>( |
| 154 | static_cast<const uint8_t*>(TestLayoutTransform_Resnet18_QS8.data()), |
| 155 | TestLayoutTransform_Resnet18_QS8.size()); |
| 156 | #else |
| 157 | auto profiler = ProfilerBase::make_cached_profiler( |
| 158 | "TestLayoutTransform.Resnet18_QS8.cache"); |
| 159 | #endif |
| 160 | std::unique_ptr<SolverBase> solver{ |
| 161 | new DynamicProgrammingSolver(std::move(profiler))}; |
nothing calls this directly
no test coverage detected