|
| 1 | +/******************************************************************************* |
| 2 | + * |
| 3 | + * MIT License |
| 4 | + * |
| 5 | + * Copyright (c) 2025 Advanced Micro Devices, Inc. |
| 6 | + * |
| 7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | + * of this software and associated documentation files (the "Software"), to deal |
| 9 | + * in the Software without restriction, including without limitation the rights |
| 10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | + * copies of the Software, and to permit persons to whom the Software is |
| 12 | + * furnished to do so, subject to the following conditions: |
| 13 | + * |
| 14 | + * The above copyright notice and this permission notice shall be included in all |
| 15 | + * copies or substantial portions of the Software. |
| 16 | + * |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | + * SOFTWARE. |
| 24 | + * |
| 25 | + *******************************************************************************/ |
| 26 | + |
| 27 | +#include "unit_conv_solver.hpp" |
| 28 | + |
| 29 | +namespace { |
| 30 | + |
| 31 | +auto GetConvSmokeTestCases(miopenDataType_t datatype) |
| 32 | +{ |
| 33 | + using TestCase = miopen::unit_tests::ConvTestCase; |
| 34 | + |
| 35 | + return std::vector{ |
| 36 | + // clang-format off |
| 37 | + TestCase{{datatype, miopenTensorNHWC, {1, 32, 8, 8}}, |
| 38 | + {datatype, miopenTensorNHWC, {32, 32, 1, 1}}, |
| 39 | + datatype, {{0, 0}, {1, 1}, {1, 1}}}, |
| 40 | + // clang-format on |
| 41 | + }; |
| 42 | +} |
| 43 | + |
| 44 | +auto GetConvFullTestCases(miopenDataType_t datatype) |
| 45 | +{ |
| 46 | + using TestCase = miopen::unit_tests::ConvTestCase; |
| 47 | + |
| 48 | + return std::vector{ |
| 49 | + // clang-format off |
| 50 | + TestCase{{datatype, miopenTensorNHWC, {1, 32, 8, 8}}, |
| 51 | + {datatype, miopenTensorNHWC, {32, 32, 3, 3}}, |
| 52 | + datatype, {{1, 1}, {1, 1}, {1, 1}}}, // non-zero padding |
| 53 | + TestCase{{datatype, miopenTensorNHWC, {1, 64, 24, 48}}, |
| 54 | + {datatype, miopenTensorNHWC, {96, 64, 1, 1}}, |
| 55 | + datatype, {{0, 0}, {2, 2}, {1, 1}}}, // stride > 1 |
| 56 | + TestCase{{datatype, miopenTensorNHWC, {1, 32, 8, 8}}, |
| 57 | + {datatype, miopenTensorNHWC, {32, 32, 3, 3}}, |
| 58 | + datatype, {{0, 0}, {1, 1}, {3, 3}}}, // dilation > 1 |
| 59 | + TestCase{{datatype, miopenTensorNHWC, {1, 64, 24, 48}}, |
| 60 | + {datatype, miopenTensorNHWC, {96, 64, 1, 1}}, |
| 61 | + datatype, {{0, 0}, {1, 1}, {1, 1}}}, // some different NCHW and k parameters |
| 62 | + // clang-format on |
| 63 | + }; |
| 64 | +} |
| 65 | + |
| 66 | +auto GetTestParams(miopenDataType_t datatype) |
| 67 | +{ |
| 68 | + Gpu supportedDevices = Gpu::gfx908 | Gpu::gfx90A | Gpu::gfx94X; |
| 69 | + auto params = miopen::unit_tests::UnitTestConvSolverParams(supportedDevices); |
| 70 | + params.Tunable(5); |
| 71 | + if(datatype == miopenHalf) |
| 72 | + { |
| 73 | + // Enable the backward solver on MI200 for fp16 by disabling the alternate implementation |
| 74 | + params.SetConvAttrFp16Alt(0); |
| 75 | + } |
| 76 | + |
| 77 | + return params; |
| 78 | +} |
| 79 | + |
| 80 | +} // namespace |
| 81 | + |
| 82 | +using GPU_UnitTestConvSolverImplicitGemmBwdXdlops_FP16 = GPU_UnitTestConvSolverBwd_FP16; |
| 83 | +using GPU_UnitTestConvSolverImplicitGemmBwdXdlops_BFP16 = GPU_UnitTestConvSolverBwd_BFP16; |
| 84 | +using GPU_UnitTestConvSolverImplicitGemmBwdXdlops_FP32 = GPU_UnitTestConvSolverBwd_FP32; |
| 85 | +using CPU_UnitTestConvSolverImplicitGemmBwdXdlopsDevApplicability_FP16 = |
| 86 | + CPU_UnitTestConvSolverDevApplicabilityBwd_NONE; |
| 87 | + |
| 88 | +TEST_P(GPU_UnitTestConvSolverImplicitGemmBwdXdlops_FP16, ConvHipImplicitGemmBwdXdlops) |
| 89 | +{ |
| 90 | + this->RunTest(miopen::solver::conv::ConvHipImplicitGemmBwdXdlops{}); |
| 91 | +}; |
| 92 | + |
| 93 | +TEST_P(GPU_UnitTestConvSolverImplicitGemmBwdXdlops_BFP16, ConvHipImplicitGemmBwdXdlops) |
| 94 | +{ |
| 95 | + this->RunTest(miopen::solver::conv::ConvHipImplicitGemmBwdXdlops{}); |
| 96 | +}; |
| 97 | + |
| 98 | +TEST_P(GPU_UnitTestConvSolverImplicitGemmBwdXdlops_FP32, ConvHipImplicitGemmBwdXdlops) |
| 99 | +{ |
| 100 | + this->RunTest(miopen::solver::conv::ConvHipImplicitGemmBwdXdlops{}); |
| 101 | +}; |
| 102 | + |
| 103 | +TEST_P(CPU_UnitTestConvSolverImplicitGemmBwdXdlopsDevApplicability_FP16, |
| 104 | + ConvHipImplicitGemmBwdXdlops) |
| 105 | +{ |
| 106 | + this->RunTest(miopen::solver::conv::ConvHipImplicitGemmBwdXdlops{}); |
| 107 | +}; |
| 108 | + |
| 109 | +// Smoke tests |
| 110 | +INSTANTIATE_TEST_SUITE_P(Smoke, |
| 111 | + GPU_UnitTestConvSolverImplicitGemmBwdXdlops_FP16, |
| 112 | + testing::Combine(testing::Values(GetTestParams(miopenHalf)), |
| 113 | + testing::Values(miopenConvolutionAlgoImplicitGEMM), |
| 114 | + testing::ValuesIn(GetConvSmokeTestCases(miopenHalf)))); |
| 115 | + |
| 116 | +INSTANTIATE_TEST_SUITE_P( |
| 117 | + Smoke, |
| 118 | + GPU_UnitTestConvSolverImplicitGemmBwdXdlops_BFP16, |
| 119 | + testing::Combine(testing::Values(GetTestParams(miopenBFloat16)), |
| 120 | + testing::Values(miopenConvolutionAlgoImplicitGEMM), |
| 121 | + testing::ValuesIn(GetConvSmokeTestCases(miopenBFloat16)))); |
| 122 | + |
| 123 | +INSTANTIATE_TEST_SUITE_P(Smoke, |
| 124 | + GPU_UnitTestConvSolverImplicitGemmBwdXdlops_FP32, |
| 125 | + testing::Combine(testing::Values(GetTestParams(miopenFloat)), |
| 126 | + testing::Values(miopenConvolutionAlgoImplicitGEMM), |
| 127 | + testing::ValuesIn(GetConvSmokeTestCases(miopenFloat)))); |
| 128 | + |
| 129 | +// Full tests |
| 130 | +INSTANTIATE_TEST_SUITE_P(Full, |
| 131 | + GPU_UnitTestConvSolverImplicitGemmBwdXdlops_FP16, |
| 132 | + testing::Combine(testing::Values(GetTestParams(miopenHalf)), |
| 133 | + testing::Values(miopenConvolutionAlgoImplicitGEMM), |
| 134 | + testing::ValuesIn(GetConvFullTestCases(miopenHalf)))); |
| 135 | + |
| 136 | +INSTANTIATE_TEST_SUITE_P(Full, |
| 137 | + GPU_UnitTestConvSolverImplicitGemmBwdXdlops_BFP16, |
| 138 | + testing::Combine(testing::Values(GetTestParams(miopenBFloat16)), |
| 139 | + testing::Values(miopenConvolutionAlgoImplicitGEMM), |
| 140 | + testing::ValuesIn(GetConvFullTestCases(miopenBFloat16)))); |
| 141 | + |
| 142 | +INSTANTIATE_TEST_SUITE_P(Full, |
| 143 | + GPU_UnitTestConvSolverImplicitGemmBwdXdlops_FP32, |
| 144 | + testing::Combine(testing::Values(GetTestParams(miopenFloat)), |
| 145 | + testing::Values(miopenConvolutionAlgoImplicitGEMM), |
| 146 | + testing::ValuesIn(GetConvFullTestCases(miopenFloat)))); |
| 147 | + |
| 148 | +// Device applicability tests |
| 149 | +INSTANTIATE_TEST_SUITE_P(Smoke, |
| 150 | + CPU_UnitTestConvSolverImplicitGemmBwdXdlopsDevApplicability_FP16, |
| 151 | + testing::Combine(testing::Values(GetTestParams(miopenHalf)), |
| 152 | + testing::Values(GetConvSmokeTestCases(miopenHalf)[0]))); |
0 commit comments