From faac07200776efba2eb8906b1a730fcf9b0466c8 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Mon, 11 Dec 2023 22:35:42 +0000 Subject: [PATCH 01/25] draft changes for combining gtest binaries --- src/kernels/hip_f8_impl.hpp | 11 +- test/gtest/CMakeLists.txt | 68 +++++++---- test/gtest/ai_heuristics.hpp | 2 +- test/gtest/bad_fusion_plan.cpp | 10 +- test/gtest/bn_test_data.cpp | 63 ++++++++++ test/gtest/bn_test_data.hpp | 36 +----- test/gtest/cba.hpp | 4 +- test/gtest/cba_find2.hpp | 4 +- test/gtest/cba_find2_infer.cpp | 10 +- test/gtest/cba_infer.cpp | 10 +- test/gtest/conv3d_test_case.hpp | 22 +--- test/gtest/conv_embed_db.cpp | 4 + test/gtest/conv_f8_bwd.cpp | 7 +- test/gtest/conv_f8_fwd.cpp | 3 +- test/gtest/conv_f8_wrw.cpp | 3 +- test/gtest/conv_hip_igemm_xdlops.cpp | 4 + test/gtest/conv_igemm_dynamic.cpp | 4 + test/gtest/conv_tensor_gen.cpp | 142 ++++++++++++++++++++++ test/gtest/conv_tensor_gen.hpp | 83 +------------ test/gtest/conv_test_base.cpp | 172 +++++++++++++++++++++++++++ test/gtest/conv_test_base.hpp | 139 ++-------------------- test/gtest/conv_trans.cpp | 4 + test/gtest/fusion_test.cpp | 2 +- test/gtest/group_conv3d_bwd.cpp | 2 +- test/gtest/group_conv3d_fwd.cpp | 2 +- test/gtest/group_conv3d_fwd.hpp | 1 + test/gtest/group_conv3d_wrw.cpp | 2 +- test/gtest/group_conv3d_wrw.hpp | 1 + test/gtest/group_conv_fwd.cpp | 6 +- test/gtest/group_solver.cpp | 40 +++++++ test/gtest/group_solver.hpp | 42 +------ test/gtest/na.hpp | 2 +- test/gtest/na_infer.cpp | 4 +- test/gtest/nonpack_conv3d_fwd.cpp | 2 +- test/gtest/nonpack_conv3d_fwd.hpp | 1 + test/gtest/solver_bwd.hpp | 4 +- test/gtest/solver_bwd_f8.cpp | 4 +- test/gtest/solver_convasm3x3u.cpp | 2 +- test/gtest/solver_f8.cpp | 78 ++++++++++++ test/gtest/solver_f8.hpp | 71 ++--------- test/gtest/solver_fwd.hpp | 4 +- test/gtest/solver_fwd_f8.cpp | 4 +- test/gtest/solver_wrw.hpp | 4 +- test/gtest/solver_wrw_f8.cpp | 2 +- 44 files changed, 656 insertions(+), 429 deletions(-) create mode 100644 test/gtest/bn_test_data.cpp create mode 100644 test/gtest/conv_tensor_gen.cpp create mode 100644 test/gtest/conv_test_base.cpp create mode 100644 test/gtest/group_solver.cpp create mode 100644 test/gtest/solver_f8.cpp diff --git a/src/kernels/hip_f8_impl.hpp b/src/kernels/hip_f8_impl.hpp index c8d49cd474..6767d6470d 100644 --- a/src/kernels/hip_f8_impl.hpp +++ b/src/kernels/hip_f8_impl.hpp @@ -23,14 +23,15 @@ * SOFTWARE. * *******************************************************************************/ -// #include -// #include -namespace miopen_hip_f8_impl { +#include +#include -#ifndef __HIP_PLATFORM_HCC__ +//#ifndef __HIP_PLATFORM_HCC__ using hip_bfloat16 = bfloat16; using half = half_float::half; -#endif +//#endif + +namespace miopen_hip_f8_impl { template MIOPEN_HIP_HOST_DEVICE uint8_t cast_to_f8_no_range_reduce(T _x, diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index c5d51e2652..90749bc252 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -13,38 +13,58 @@ set(SOURCES ) if(MIOPEN_BACKEND_OPENCL) - set(SKIP_TESTS dumpTensorTest) + set(SKIP_TESTS dumpTensorTest.cpp) endif() -function(add_gtest TEST_NAME) - if( NOT (TEST_NAME IN_LIST SKIP_TESTS)) - message("Adding Test: " ${TEST_NAME}) - add_executable(test_${TEST_NAME} ${TEST_NAME}.cpp ${SOURCES}) - add_dependencies(tests test_${TEST_NAME}) - add_dependencies(check test_${TEST_NAME}) - target_compile_options(test_${TEST_NAME} PRIVATE -Wno-global-constructors -Wno-undef) - target_include_directories(test_${TEST_NAME} PRIVATE ../ ../../src/kernels) - if(MIOPEN_ENABLE_AI_KERNEL_TUNING) - target_include_directories(test_${TEST_NAME} SYSTEM PRIVATE $) - target_include_directories(test_${TEST_NAME} SYSTEM PRIVATE $) - endif() - target_link_libraries(test_${TEST_NAME} GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $) - if(NOT MIOPEN_EMBED_DB STREQUAL "") - target_link_libraries(test_${TEST_NAME} $) - endif() - # Enable CMake to discover the test binary - gtest_discover_tests(test_${TEST_NAME} PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL}") - - endif() -endfunction() file(GLOB TESTS *.cpp) +file(GLOB HEADERS *.hpp) # Remove files that do not contain tests foreach(SOURCE ${SOURCES}) list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}) endforeach() +foreach(SOURCE ${SKIP_TESTS}) + list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}) +endforeach() + +message("Test files: " ${TESTS}) foreach(TEST ${TESTS}) - get_filename_component(BASE_NAME ${TEST} NAME_WE) - add_gtest(${BASE_NAME}) + get_filename_component(BASE_NAME ${TEST} NAME) + list(APPEND TESTS_CPP ${BASE_NAME}) endforeach() + + + +#function(add_gtest TEST_NAME) +if( NOT (TEST_NAME IN_LIST SKIP_TESTS)) + message("Adding miopen_gtest: " ${TESTS_CPP}) + add_executable(miopen_gtest ${TESTS_CPP} ${SOURCES}) + add_dependencies(tests miopen_gtest) + add_dependencies(check miopen_gtest) + target_compile_options(miopen_gtest PRIVATE -Wno-global-constructors -Wno-undef) + target_include_directories(miopen_gtest PRIVATE ../ ../../src/kernels) + if(MIOPEN_ENABLE_AI_KERNEL_TUNING) + target_include_directories(miopen_gtest SYSTEM PRIVATE $) + target_include_directories(miopen_gtest SYSTEM PRIVATE $) + endif() + target_link_libraries(miopen_gtest GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $) + if(NOT MIOPEN_EMBED_DB STREQUAL "") + target_link_libraries(miopen_gtest $) + endif() + # Enable CMake to discover the test binary + gtest_discover_tests(miopen_gtest PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL}") + +endif() +#endfunction() + +#file(GLOB TESTS *.cpp) +## Remove files that do not contain tests +#foreach(SOURCE ${SOURCES}) +# list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}) +#endforeach() +# +#foreach(TEST ${TESTS}) +# get_filename_component(BASE_NAME ${TEST} NAME_WE) +# add_gtest(${BASE_NAME}) +#endforeach() diff --git a/test/gtest/ai_heuristics.hpp b/test/gtest/ai_heuristics.hpp index 235c3e7f02..3898ad9bf6 100644 --- a/test/gtest/ai_heuristics.hpp +++ b/test/gtest/ai_heuristics.hpp @@ -31,7 +31,7 @@ struct AIModelTestCase { - struct ConvTestCase conv; + struct ConvTestCaseBase conv; miopen::conv::Direction direction; miopenDataType_t data_type; miopenTensorLayout_t layout; diff --git a/test/gtest/bad_fusion_plan.cpp b/test/gtest/bad_fusion_plan.cpp index 80cd6bdd10..75dbdf71a9 100644 --- a/test/gtest/bad_fusion_plan.cpp +++ b/test/gtest/bad_fusion_plan.cpp @@ -30,6 +30,8 @@ #include "tensor_holder.hpp" #include "get_handle.hpp" +namespace bad_fusion_plan { + #if MIOPEN_BACKEND_HIP void setEnvironmentVariable(const std::string& name, const std::string& value) @@ -54,7 +56,7 @@ miopenDataType_t GetDataType() return miopenHalf; } -struct ConvTestCase +struct ConvTestCaseFusion { size_t N; size_t C; @@ -69,7 +71,7 @@ struct ConvTestCase size_t stride_y; size_t dilation_x; size_t dilation_y; - friend std::ostream& operator<<(std::ostream& os, const ConvTestCase& tc) + friend std::ostream& operator<<(std::ostream& os, const ConvTestCaseFusion& tc) { return os << "(N: " << tc.N << " C:" << tc.C << " H:" << tc.H << " W:" << tc.W << " k: " << tc.k << " y:" << tc.y << " x:" << tc.x << " pad_y:" << tc.pad_y @@ -88,7 +90,7 @@ struct ConvTestCase } }; -const static ConvTestCase conv_config = {64, 64, 56, 56, 64, 3, 3, 1, 1, 1, 1, 1, 1}; +const static ConvTestCaseFusion conv_config = {64, 64, 56, 56, 64, 3, 3, 1, 1, 1, 1, 1, 1}; template class TestFusionPlan @@ -263,3 +265,5 @@ TEST(TestFusionPlan, UnSupportedFusionPlanDuringSearchMode) } #endif + +} //namespace bad_fusion_plan diff --git a/test/gtest/bn_test_data.cpp b/test/gtest/bn_test_data.cpp new file mode 100644 index 0000000000..f29b024cbb --- /dev/null +++ b/test/gtest/bn_test_data.cpp @@ -0,0 +1,63 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +#include "bn_test_data.hpp" + +std::vector Network1() +{ + // pyt_mlperf_resnet50v1.5 + return { + {192, 1, 8, 8, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 1, 0}, + {16, 8, 128, 256, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 0}, + {16, 8, 128, 256, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}}; +} + diff --git a/test/gtest/bn_test_data.hpp b/test/gtest/bn_test_data.hpp index 06a16be427..dbeb085b0c 100644 --- a/test/gtest/bn_test_data.hpp +++ b/test/gtest/bn_test_data.hpp @@ -55,41 +55,7 @@ struct BNTestCase std::vector GetInput() const { return {N, C, H, W}; } }; -std::vector Network1() -{ - // pyt_mlperf_resnet50v1.5 - return { - {192, 1, 8, 8, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 1, 0}, - {16, 8, 128, 256, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 0}, - {16, 8, 128, 256, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}}; -} +extern std::vector Network1(); template struct BNTestData diff --git a/test/gtest/cba.hpp b/test/gtest/cba.hpp index 70091e107c..4c0b554c7f 100644 --- a/test/gtest/cba.hpp +++ b/test/gtest/cba.hpp @@ -43,7 +43,7 @@ template struct ConvBiasActivInferTest : public ::testing::TestWithParam< - std::tuple>, + std::tuple>, ConvFwdSolverTestBase { protected: @@ -90,7 +90,7 @@ struct ConvBiasActivInferTest cfsb::ref_out.data); cfsb::ThresholdChecks(); } - ConvTestCase conv_config; + ConvTestCaseBase conv_config; miopen::ActivationDescriptor activ_desc; tensor bias; miopen::Allocator::ManageDataPtr bias_dev; diff --git a/test/gtest/cba_find2.hpp b/test/gtest/cba_find2.hpp index 7e2b443d6e..263eebb0e9 100644 --- a/test/gtest/cba_find2.hpp +++ b/test/gtest/cba_find2.hpp @@ -45,11 +45,11 @@ template struct ConvBiasActivInferFind2Test : public ::testing::TestWithParam< - std::tuple>, + std::tuple>, ConvFwdSolverTestBase { protected: - ConvTestCase conv_config; + ConvTestCaseBase conv_config; miopen::ActivationDescriptor activ_desc; tensor bias; miopen::Allocator::ManageDataPtr bias_dev; diff --git a/test/gtest/cba_find2_infer.cpp b/test/gtest/cba_find2_infer.cpp index 67da2c2053..2c747ecbfa 100644 --- a/test/gtest/cba_find2_infer.cpp +++ b/test/gtest/cba_find2_infer.cpp @@ -38,6 +38,8 @@ #include "get_handle.hpp" #include "cba_find2.hpp" +namespace cba_find2_infer { + struct ConvBiasActivFind2InferTestFloat : ConvBiasActivInferFind2Test { }; @@ -78,7 +80,7 @@ void RunSolver(miopen::FusedProblem& problem, template void RunTunableSolver(miopen::FusedProblem& problem, const miopen::AnyInvokeParams& invoke_ctx, - const ConvTestCase& conv_config, + const ConvTestCaseBase& conv_config, bool& test_skipped) { auto& handle = get_handle(); @@ -164,11 +166,13 @@ INSTANTIATE_TEST_SUITE_P(CBAFind2InferSolverTest, INSTANTIATE_TEST_SUITE_P(CBAFind2InferSolverTest, ConvBiasActivFind2InferTestFloat, testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(GetNetwork1()), + testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNCHW))); INSTANTIATE_TEST_SUITE_P(CBAFind2InferSolverTest, ConvBiasActivFind2InferTestHalf, testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(GetNetwork1()), + testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNHWC))); + +} //namespace cba_find2_infer diff --git a/test/gtest/cba_infer.cpp b/test/gtest/cba_infer.cpp index 8690824ff4..996b2cadd8 100644 --- a/test/gtest/cba_infer.cpp +++ b/test/gtest/cba_infer.cpp @@ -36,6 +36,8 @@ #include "get_handle.hpp" #include "cba.hpp" +namespace cba_infer { + struct ConvBiasActivInferTestFloat : ConvBiasActivInferTest { }; @@ -87,7 +89,7 @@ void RunSolver(miopen::FusionPlanDescriptor& fusePlanDesc, template void RunTunableSolver(miopen::FusionPlanDescriptor& fusePlanDesc, const std::unique_ptr& plan_params, - const ConvTestCase& conv_config, + const ConvTestCaseBase& conv_config, bool& test_skipped) { auto& handle = get_handle(); @@ -169,11 +171,13 @@ INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest, INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest, ConvBiasActivInferTestFloat, testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(GetNetwork1()), + testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNCHW))); INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest, ConvBiasActivInferTestHalf, testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(GetNetwork1()), + testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNHWC))); + +} //namespace cba_infer diff --git a/test/gtest/conv3d_test_case.hpp b/test/gtest/conv3d_test_case.hpp index 242615077f..2edb1741e9 100644 --- a/test/gtest/conv3d_test_case.hpp +++ b/test/gtest/conv3d_test_case.hpp @@ -32,27 +32,7 @@ #include "../driver/tensor_driver.hpp" #include "conv_common.hpp" - -template -miopenDataType_t GetDataType(); - -template <> -miopenDataType_t GetDataType() -{ - return miopenFloat; -} - -template <> -miopenDataType_t GetDataType() -{ - return miopenHalf; -} - -template <> -miopenDataType_t GetDataType() -{ - return miopenInt8; -} +#include "conv_test_base.hpp" struct Conv3DTestCase { diff --git a/test/gtest/conv_embed_db.cpp b/test/gtest/conv_embed_db.cpp index d20a4d2956..1a9e082426 100644 --- a/test/gtest/conv_embed_db.cpp +++ b/test/gtest/conv_embed_db.cpp @@ -34,6 +34,8 @@ MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) +namespace conv_embed_db { + static bool IsTestRunWith(const char* float_arg) { assert(float_arg != nullptr); @@ -228,3 +230,5 @@ INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConfigWithInt8, testing::Values(GetTestCas INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConfigWithBFloat16, testing::Values(GetTestCases("--bfloat16"))); + +} //namespace conv_embed_db diff --git a/test/gtest/conv_f8_bwd.cpp b/test/gtest/conv_f8_bwd.cpp index 156260f875..58a0680bf4 100644 --- a/test/gtest/conv_f8_bwd.cpp +++ b/test/gtest/conv_f8_bwd.cpp @@ -32,6 +32,8 @@ #include "conv3d_test_case.hpp" #include "f8_cast_util.hpp" + +template<> std::vector ConvTestConfigs() { // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z return {{1, 16, 16, 1, 14, 14, 16, 1, 3, 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}, @@ -43,6 +45,7 @@ std::vector ConvTestConfigs() {4, 128, 4, 1, 28, 28, 4, 1, 3, 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}, {2, 128, 2, 1, 28, 28, 2, 1, 3, 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}}; } +namespace conv_f8_bwd { template struct ConvBwdSolverTest @@ -190,5 +193,7 @@ TEST_P(ConvBwdSolverTestF8, CKConvF8Bwd) INSTANTIATE_TEST_SUITE_P(ConvBwdTest, ConvBwdSolverTestF8, testing::Combine(testing::Values(miopenConvolutionBwdDataAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); + +} //namespace conv_f8_bwd diff --git a/test/gtest/conv_f8_fwd.cpp b/test/gtest/conv_f8_fwd.cpp index 433f9f7fa7..c622c24dde 100644 --- a/test/gtest/conv_f8_fwd.cpp +++ b/test/gtest/conv_f8_fwd.cpp @@ -32,6 +32,7 @@ #include "get_handle.hpp" #include "f8_cast_util.hpp" +template<> std::vector ConvTestConfigs() { // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z return {{1, 16, 16, 1, 14, 14, 16, 1, 3, 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}, @@ -189,5 +190,5 @@ TEST_P(ConvFwdSolverTestF8, CKConvF8Fwd) INSTANTIATE_TEST_SUITE_P(ConvFwdTest, ConvFwdSolverTestF8, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); diff --git a/test/gtest/conv_f8_wrw.cpp b/test/gtest/conv_f8_wrw.cpp index 925590833f..244cc92b31 100644 --- a/test/gtest/conv_f8_wrw.cpp +++ b/test/gtest/conv_f8_wrw.cpp @@ -33,6 +33,7 @@ #include "get_handle.hpp" #include "f8_cast_util.hpp" +template<> std::vector ConvTestConfigs() { // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z return {{1, 16, 16, 1, 14, 14, 16, 1, 3, 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}, @@ -195,5 +196,5 @@ INSTANTIATE_TEST_SUITE_P( ConvWrwTest, ConvWrwSolverTestF8, testing::Combine(testing::Values(miopenConvolutionBwdWeightsAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); diff --git a/test/gtest/conv_hip_igemm_xdlops.cpp b/test/gtest/conv_hip_igemm_xdlops.cpp index 26c51ba7e1..3fb6f8c6e0 100644 --- a/test/gtest/conv_hip_igemm_xdlops.cpp +++ b/test/gtest/conv_hip_igemm_xdlops.cpp @@ -36,6 +36,8 @@ MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_COMPOSABLEKERNEL) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) +namespace conv_hip_igem_xdlops { + static bool IsTestRunWith(const char* float_arg) { assert(float_arg != nullptr); @@ -167,3 +169,5 @@ std::vector GetTestCases(const std::string& precision) INSTANTIATE_TEST_SUITE_P(ConvHipIgemmXdlops, ConfigWithInt8, testing::Values(GetTestCases("--int8"))); + +} //namespace conv_hip_igem_xdlops diff --git a/test/gtest/conv_igemm_dynamic.cpp b/test/gtest/conv_igemm_dynamic.cpp index 4decf80c2b..4fb2110d9e 100644 --- a/test/gtest/conv_igemm_dynamic.cpp +++ b/test/gtest/conv_igemm_dynamic.cpp @@ -35,6 +35,8 @@ using TestCase = std::tuple, std::string>; MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_GPU_XNACK_ENABLED) +namespace conv_igemm_dynamic { + static bool SkipTest(void) { return miopen::IsEnabled(ENV(MIOPEN_TEST_GPU_XNACK_ENABLED)); } void GetArgs(const TestCase& param, std::vector& tokens) @@ -186,3 +188,5 @@ std::vector GetTestCases(const std::string& precision) } INSTANTIATE_TEST_SUITE_P(ConvIgemmDynamic, Conv2dFloat, testing::Values(GetTestCases("--float"))); + +} //namespace conv_igemm_dynamic diff --git a/test/gtest/conv_tensor_gen.cpp b/test/gtest/conv_tensor_gen.cpp new file mode 100644 index 0000000000..1c500d5000 --- /dev/null +++ b/test/gtest/conv_tensor_gen.cpp @@ -0,0 +1,142 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +#include + +#include +#include "conv_tensor_gen.hpp" + +// Copied from conv_driver.hpp + +template +inline T FRAND() +{ + double d = static_cast(rand() / (static_cast(RAND_MAX))); + return static_cast(d); +} + +template +inline T RAN_GEN(T A, T B) +{ + T r = (FRAND() * (B - A)) + A; + return r; +} +template +T RanGenData() +{ + return RAN_GEN(static_cast(0.0f), static_cast(1.0f)); +} + +template <> +float8 RanGenData() +{ + return RAN_GEN(static_cast(-1.0f), static_cast(1.0f)); +} + +template <> +bfloat8 RanGenData() +{ + const auto tmp = RAN_GEN(static_cast(-1.0f), static_cast(1.0f)); + return static_cast(tmp); +} + +/* +template +struct GenData +{ + template + T operator()(Ts...) const + { + return RanGenData(); + } +}; +*/ + +template +template +T GenData::operator()(Ts...) const +{ + return RanGenData(); +} + +template +T RanGenWeights() +{ + return RAN_GEN(static_cast(-0.5), static_cast(0.5)); +} + +// Shift FP16 distribution towards positive numbers, +// otherwise Winograd FP16 validation fails. +template <> +half_float::half RanGenWeights() +{ + return RAN_GEN(static_cast(-1.0 / 3.0), + static_cast(0.5)); +} + +template <> +float8 RanGenWeights() +{ + const auto tmp = + RAN_GEN(0.0, 1.0) > 0.5 ? static_cast(0.0) : static_cast(1.0); + // 1 in 2 chance of number being positive + const float sign = + (RAN_GEN(0.0, 1.0) > 0.5) ? static_cast(-1) : static_cast(1); + const auto tmp2 = static_cast(std::numeric_limits::epsilon()) * + static_cast(2) * sign * static_cast(tmp); + return static_cast(tmp2); +} + +template <> +bfloat8 RanGenWeights() +{ + const auto tmp = + RAN_GEN(0.0, 1.0) > 0.5 ? static_cast(0.0) : static_cast(1.0); + // 1 in 2 chance of number being positive + const float sign = + (RAN_GEN(0.0, 1.0) > 0.5) ? static_cast(-1) : static_cast(1); + const auto tmp2 = static_cast(std::numeric_limits::epsilon()) * + static_cast(2) * sign * static_cast(tmp); + return static_cast(tmp2); +} + +/* +template +struct GenWeights +{ + template + T operator()(Ts...) const + { + return RanGenWeights(); + } +}; +*/ + +template +template +T GenWeights::operator()(Ts...) const +{ + return RanGenWeights(); +} diff --git a/test/gtest/conv_tensor_gen.hpp b/test/gtest/conv_tensor_gen.hpp index f578e91973..12c4116497 100644 --- a/test/gtest/conv_tensor_gen.hpp +++ b/test/gtest/conv_tensor_gen.hpp @@ -26,100 +26,27 @@ #pragma once #include - #include +#include "hip_float8.hpp" // Copied from conv_driver.hpp template -inline T FRAND() -{ - double d = static_cast(rand() / (static_cast(RAND_MAX))); - return static_cast(d); -} - -template -inline T RAN_GEN(T A, T B) -{ - T r = (FRAND() * (B - A)) + A; - return r; -} -template -T RanGenData() -{ - return RAN_GEN(static_cast(0.0f), static_cast(1.0f)); -} - -template <> -float8 RanGenData() -{ - return RAN_GEN(static_cast(-1.0f), static_cast(1.0f)); -} - -template <> -bfloat8 RanGenData() -{ - const auto tmp = RAN_GEN(static_cast(-1.0f), static_cast(1.0f)); - return static_cast(tmp); -} +extern T RanGenData(); template struct GenData { template - T operator()(Ts...) const - { - return RanGenData(); - } + T operator()(Ts...) const; }; template -T RanGenWeights() -{ - return RAN_GEN(static_cast(-0.5), static_cast(0.5)); -} - -// Shift FP16 distribution towards positive numbers, -// otherwise Winograd FP16 validation fails. -template <> -half_float::half RanGenWeights() -{ - return RAN_GEN(static_cast(-1.0 / 3.0), - static_cast(0.5)); -} - -template <> -float8 RanGenWeights() -{ - const auto tmp = - RAN_GEN(0.0, 1.0) > 0.5 ? static_cast(0.0) : static_cast(1.0); - // 1 in 2 chance of number being positive - const float sign = - (RAN_GEN(0.0, 1.0) > 0.5) ? static_cast(-1) : static_cast(1); - const auto tmp2 = static_cast(std::numeric_limits::epsilon()) * - static_cast(2) * sign * static_cast(tmp); - return static_cast(tmp2); -} - -template <> -bfloat8 RanGenWeights() -{ - const auto tmp = - RAN_GEN(0.0, 1.0) > 0.5 ? static_cast(0.0) : static_cast(1.0); - // 1 in 2 chance of number being positive - const float sign = - (RAN_GEN(0.0, 1.0) > 0.5) ? static_cast(-1) : static_cast(1); - const auto tmp2 = static_cast(std::numeric_limits::epsilon()) * - static_cast(2) * sign * static_cast(tmp); - return static_cast(tmp2); -} +extern T RanGenWeights(); template struct GenWeights { template - T operator()(Ts...) const - { - return RanGenWeights(); - } + T operator()(Ts...) const; }; diff --git a/test/gtest/conv_test_base.cpp b/test/gtest/conv_test_base.cpp new file mode 100644 index 0000000000..06b5611811 --- /dev/null +++ b/test/gtest/conv_test_base.cpp @@ -0,0 +1,172 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +#include "conv_test_base.hpp" + +template +miopenDataType_t GetDataType(); + +template <> +miopenDataType_t GetDataType() +{ + return miopenFloat; +} + +template <> +miopenDataType_t GetDataType() +{ + return miopenHalf; +} + +template <> +miopenDataType_t GetDataType>() +{ + return miopenFloat8; +} + +template <> +miopenDataType_t GetDataType>() +{ + return miopenBFloat8; +} + +template <> +miopenDataType_t GetDataType() +{ + return miopenInt8; +} + + +template<> +std::vector GetNetworkForFusionCompileStepTest() +{ + return {{1, 64, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {1, 64, 56, 56, 64, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} + +template<> +std::vector GetNetwork1() +{ + // pyt_mlperf_resnet50v1.5 + return {{64, 1024, 14, 14, 2048, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, + {64, 1024, 14, 14, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 1024, 14, 14, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 28, 28, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 28, 28, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 56, 56, 128, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, + {64, 2048, 7, 7, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 14, 14, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 14, 14, 256, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 28, 28, 256, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, + {64, 256, 56, 56, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 56, 56, 512, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, + {64, 256, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 3, 224, 224, 64, 7, 7, 3, 3, 2, 2, 1, 1, miopenConvolution}, + {64, 512, 14, 14, 512, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, + {64, 512, 28, 28, 1024, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, + {64, 512, 28, 28, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 512, 28, 28, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 512, 7, 7, 2048, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 512, 7, 7, 512, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 64, 56, 56, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 64, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 64, 56, 56, 64, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} + +template<> +std::vector ConvTestConfigs() +{ // n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y + return {{16, 128, 16, 16, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 28, 28, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 14, 14, 256, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 512, 7, 7, 512, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 1024, 14, 14, 1024, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} + + +template +void ConvFwdSolverTestBase::SetUpImpl(ConvTestCaseBase conv_config, miopenTensorLayout_t tensor_layout) +{ + input = tensor{tensor_layout, conv_config.GetInput()}; + weights = tensor{tensor_layout, conv_config.GetWeights()}; + input.generate(GenData{}); + weights.generate(GenWeights{}); + + conv_desc = conv_config.GetConv(); + + miopen::TensorDescriptor output_desc = + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + + output = tensor{tensor_layout, output_desc.GetLengths()}; + std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); + + auto&& handle = get_handle(); + in_dev = handle.Write(input.data); + wei_dev = handle.Write(weights.data); + out_dev = handle.Write(output.data); +} + +template +void ConvFwdSolverTestBase::TearDownConv() +{ + miopen::TensorDescriptor output_desc = + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + ref_out = tensor{output.desc.GetLayout_t(), output_desc.GetLengths()}; + if(use_cpu_ref) + { + cpu_convolution_forward(conv_desc.GetSpatialDimension(), + input, + weights, + ref_out, + conv_desc.GetConvPads(), + conv_desc.GetConvStrides(), + conv_desc.GetConvDilations(), + conv_desc.GetGroupCount()); + } + else + { + ref_out = ref_conv_fwd(input, weights, ref_out, conv_desc); + } +} + +template +void ConvFwdSolverTestBase::ThresholdChecks() +{ + auto&& handle = get_handle(); + output.data = handle.Read(out_dev, output.data.size()); + EXPECT_FALSE(miopen::range_zero(ref_out)) << "Cpu data is all zeros"; + EXPECT_FALSE(miopen::range_zero(output)) << "Gpu data is all zeros"; + EXPECT_TRUE(miopen::range_distance(ref_out) == miopen::range_distance(output)); + + const double tolerance = 80; + double threshold = std::numeric_limits::epsilon() * tolerance; + auto error = miopen::rms_range(ref_out, output); + + EXPECT_FALSE(miopen::find_idx(ref_out, miopen::not_finite) >= 0) + << "Non finite number found in the CPU data"; + + EXPECT_TRUE(error < threshold) + << "Error beyond tolerance Error:" << error << ", Threshold: " << threshold; +} diff --git a/test/gtest/conv_test_base.hpp b/test/gtest/conv_test_base.hpp index d41af1d898..b241bd59ea 100644 --- a/test/gtest/conv_test_base.hpp +++ b/test/gtest/conv_test_base.hpp @@ -32,33 +32,9 @@ #include "conv_tensor_gen.hpp" template -miopenDataType_t GetDataType(); +extern miopenDataType_t GetDataType(); -template <> -miopenDataType_t GetDataType() -{ - return miopenFloat; -} - -template <> -miopenDataType_t GetDataType() -{ - return miopenHalf; -} - -template <> -miopenDataType_t GetDataType>() -{ - return miopenFloat8; -} - -template <> -miopenDataType_t GetDataType>() -{ - return miopenBFloat8; -} - -struct ConvTestCase +struct ConvTestCaseBase { size_t N; size_t C; @@ -74,7 +50,8 @@ struct ConvTestCase size_t dilation_x; size_t dilation_y; miopenConvolutionMode_t conv_mode; - friend std::ostream& operator<<(std::ostream& os, const ConvTestCase& tc) + + friend std::ostream& operator<<(std::ostream& os, const ConvTestCaseBase& tc) { return os << "(N: " << tc.N << " C:" << tc.C << " H:" << tc.H << " W:" << tc.W << " k: " << tc.k << " y:" << tc.y << " x:" << tc.x << " pad_y:" << tc.pad_y @@ -93,114 +70,24 @@ struct ConvTestCase } }; -std::vector GetNetworkForFusionCompileStepTest() -{ - return {{1, 64, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {1, 64, 56, 56, 64, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} +template +extern std::vector GetNetworkForFusionCompileStepTest(); -std::vector GetNetwork1() -{ - // pyt_mlperf_resnet50v1.5 - return {{64, 1024, 14, 14, 2048, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, - {64, 1024, 14, 14, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 1024, 14, 14, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 28, 28, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 28, 28, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 56, 56, 128, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, - {64, 2048, 7, 7, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 14, 14, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 14, 14, 256, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 28, 28, 256, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, - {64, 256, 56, 56, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 56, 56, 512, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, - {64, 256, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 3, 224, 224, 64, 7, 7, 3, 3, 2, 2, 1, 1, miopenConvolution}, - {64, 512, 14, 14, 512, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, - {64, 512, 28, 28, 1024, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, - {64, 512, 28, 28, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 512, 28, 28, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 512, 7, 7, 2048, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 512, 7, 7, 512, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 64, 56, 56, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 64, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 64, 56, 56, 64, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} +template +extern std::vector GetNetwork1(); -std::vector ConvTestConfigs() -{ // n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y - return {{16, 128, 16, 16, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 28, 28, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 14, 14, 256, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 512, 7, 7, 512, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 1024, 14, 14, 1024, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} +template +extern std::vector ConvTestConfigs(); template struct ConvFwdSolverTestBase { protected: - void SetUpImpl(ConvTestCase conv_config, miopenTensorLayout_t tensor_layout) - { - input = tensor{tensor_layout, conv_config.GetInput()}; - weights = tensor{tensor_layout, conv_config.GetWeights()}; - input.generate(GenData{}); - weights.generate(GenWeights{}); + void SetUpImpl(ConvTestCaseBase conv_config, miopenTensorLayout_t tensor_layout); - conv_desc = conv_config.GetConv(); + void TearDownConv(); - miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); - - output = tensor{tensor_layout, output_desc.GetLengths()}; - std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); - - auto&& handle = get_handle(); - in_dev = handle.Write(input.data); - wei_dev = handle.Write(weights.data); - out_dev = handle.Write(output.data); - } - - void TearDownConv() - { - miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); - ref_out = tensor{output.desc.GetLayout_t(), output_desc.GetLengths()}; - if(use_cpu_ref) - { - cpu_convolution_forward(conv_desc.GetSpatialDimension(), - input, - weights, - ref_out, - conv_desc.GetConvPads(), - conv_desc.GetConvStrides(), - conv_desc.GetConvDilations(), - conv_desc.GetGroupCount()); - } - else - { - ref_out = ref_conv_fwd(input, weights, ref_out, conv_desc); - } - } - - void ThresholdChecks() - { - auto&& handle = get_handle(); - output.data = handle.Read(out_dev, output.data.size()); - EXPECT_FALSE(miopen::range_zero(ref_out)) << "Cpu data is all zeros"; - EXPECT_FALSE(miopen::range_zero(output)) << "Gpu data is all zeros"; - EXPECT_TRUE(miopen::range_distance(ref_out) == miopen::range_distance(output)); - - const double tolerance = 80; - double threshold = std::numeric_limits::epsilon() * tolerance; - auto error = miopen::rms_range(ref_out, output); - - EXPECT_FALSE(miopen::find_idx(ref_out, miopen::not_finite) >= 0) - << "Non finite number found in the CPU data"; - - EXPECT_TRUE(error < threshold) - << "Error beyond tolerance Error:" << error << ", Threshold: " << threshold; - } + void ThresholdChecks(); miopen::ConvolutionDescriptor conv_desc; tensor input; diff --git a/test/gtest/conv_trans.cpp b/test/gtest/conv_trans.cpp index 1c887fe24c..41072a7662 100644 --- a/test/gtest/conv_trans.cpp +++ b/test/gtest/conv_trans.cpp @@ -32,6 +32,8 @@ MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) +namespace conv_trans { + void GetArgs(const std::string& param, std::vector& tokens) { std::stringstream ss(param); @@ -151,3 +153,5 @@ std::vector GetTestCases(void) } INSTANTIATE_TEST_SUITE_P(ConvTrans, ConfigWithFloat, testing::Values(GetTestCases())); + +} //namespace conv_trans diff --git a/test/gtest/fusion_test.cpp b/test/gtest/fusion_test.cpp index e442b4d741..6046fa7e75 100644 --- a/test/gtest/fusion_test.cpp +++ b/test/gtest/fusion_test.cpp @@ -99,7 +99,7 @@ TEST_P(FusionSetArgTestFloat, TestSetArgApiCall) INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest, FusionSetArgTestFloat, testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(GetNetwork1()), + testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNCHW))); #endif diff --git a/test/gtest/group_conv3d_bwd.cpp b/test/gtest/group_conv3d_bwd.cpp index 439dbb5eb7..d9114d56e4 100644 --- a/test/gtest/group_conv3d_bwd.cpp +++ b/test/gtest/group_conv3d_bwd.cpp @@ -94,5 +94,5 @@ TEST_P(ConvBwdSolverTest3D, CKGroupConvBwd3D) INSTANTIATE_TEST_SUITE_P(ConvBwdTest, ConvBwdSolverTest3D, testing::Combine(testing::Values(miopenConvolutionBwdDataAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); diff --git a/test/gtest/group_conv3d_fwd.cpp b/test/gtest/group_conv3d_fwd.cpp index 5e17aa7c0d..3c9c1cb27f 100644 --- a/test/gtest/group_conv3d_fwd.cpp +++ b/test/gtest/group_conv3d_fwd.cpp @@ -94,5 +94,5 @@ TEST_P(ConvFwdSolverTest3D, CKGroupConvFwd3D) INSTANTIATE_TEST_SUITE_P(ConvFwdTest, ConvFwdSolverTest3D, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); diff --git a/test/gtest/group_conv3d_fwd.hpp b/test/gtest/group_conv3d_fwd.hpp index c5fc432e8b..fdf1d0c404 100644 --- a/test/gtest/group_conv3d_fwd.hpp +++ b/test/gtest/group_conv3d_fwd.hpp @@ -27,6 +27,7 @@ #include "conv3d_test_case.hpp" +template<> std::vector ConvTestConfigs() { // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z return {{1, 128, 64, 14, 28, 28, 64, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, diff --git a/test/gtest/group_conv3d_wrw.cpp b/test/gtest/group_conv3d_wrw.cpp index 8633b78b1e..2f5e5f8279 100644 --- a/test/gtest/group_conv3d_wrw.cpp +++ b/test/gtest/group_conv3d_wrw.cpp @@ -95,5 +95,5 @@ INSTANTIATE_TEST_SUITE_P( ConvWrwTest, ConvWrwSolverTest3D, testing::Combine(testing::Values(miopenConvolutionBwdWeightsAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); diff --git a/test/gtest/group_conv3d_wrw.hpp b/test/gtest/group_conv3d_wrw.hpp index a0e504a000..144df06497 100644 --- a/test/gtest/group_conv3d_wrw.hpp +++ b/test/gtest/group_conv3d_wrw.hpp @@ -27,6 +27,7 @@ #include "conv3d_test_case.hpp" +template<> std::vector ConvTestConfigs() { // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z return {{1, 128, 64, 14, 28, 28, 64, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, diff --git a/test/gtest/group_conv_fwd.cpp b/test/gtest/group_conv_fwd.cpp index 4efea68c1d..b842ff5a1c 100644 --- a/test/gtest/group_conv_fwd.cpp +++ b/test/gtest/group_conv_fwd.cpp @@ -32,7 +32,7 @@ #include "get_handle.hpp" #include "group_solver.hpp" -struct ConvFwdSolverTestFloat : ConvFwdSolverTest +struct ConvFwdSolverTestFloat : ConvFwdSolverTestBase { }; @@ -44,7 +44,7 @@ void SolverFwd(const miopen::TensorDescriptor& inputDesc, const miopen::TensorDescriptor& outputDesc, Data_t output, const miopen::ConvolutionDescriptor& convDesc, - const ConvTestCase& conv_config, + const ConvTestCaseGroup& conv_config, bool& test_skipped) { auto&& handle = get_handle(); @@ -94,5 +94,5 @@ TEST_P(ConvFwdSolverTestFloat, CKGroupConvFwd) INSTANTIATE_TEST_SUITE_P(ConvFwdTest, ConvFwdSolverTestFloat, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNHWC))); diff --git a/test/gtest/group_solver.cpp b/test/gtest/group_solver.cpp new file mode 100644 index 0000000000..2eb398f45d --- /dev/null +++ b/test/gtest/group_solver.cpp @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ + +#include "group_solver.hpp" + + +template<> +std::vector ConvTestConfigs() +{ // g n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y + return {{1, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {1, 256, 12, 28, 28, 12, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {4, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {8, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {8, 256, 384, 28, 28, 384, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {32, 256, 1024, 28, 28, 2048, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} + diff --git a/test/gtest/group_solver.hpp b/test/gtest/group_solver.hpp index 10faed9880..ee6fa3c057 100644 --- a/test/gtest/group_solver.hpp +++ b/test/gtest/group_solver.hpp @@ -32,29 +32,9 @@ #include "../driver/tensor_driver.hpp" #include "conv_common.hpp" +#include "conv_test_base.hpp" -template -miopenDataType_t GetDataType(); - -template <> -miopenDataType_t GetDataType() -{ - return miopenFloat; -} - -template <> -miopenDataType_t GetDataType() -{ - return miopenHalf; -} - -template <> -miopenDataType_t GetDataType() -{ - return miopenInt8; -} - -struct ConvTestCase +struct ConvTestCaseGroup { size_t G; size_t N; @@ -71,7 +51,7 @@ struct ConvTestCase size_t dilation_x; size_t dilation_y; miopenConvolutionMode_t conv_mode; - friend std::ostream& operator<<(std::ostream& os, const ConvTestCase& tc) + friend std::ostream& operator<<(std::ostream& os, const ConvTestCaseGroup& tc) { return os << " G:" << tc.G << " N:" << tc.N << " C:" << tc.C << " H:" << tc.H << " W:" << tc.W << " k:" << tc.k << " y:" << tc.y << " x:" << tc.x @@ -101,16 +81,6 @@ struct ConvTestCase } }; -std::vector ConvTestConfigs() -{ // g n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y - return {{1, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {1, 256, 12, 28, 28, 12, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {4, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {8, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {8, 256, 384, 28, 28, 384, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {32, 256, 1024, 28, 28, 2048, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} - inline int SetTensorLayout(miopen::TensorDescriptor& desc) { // get layout string names @@ -124,9 +94,9 @@ inline int SetTensorLayout(miopen::TensorDescriptor& desc) } template -struct ConvFwdSolverTest +struct ConvGroupFwdSolverTest : public ::testing::TestWithParam< - std::tuple> + std::tuple> { protected: void SetUp() override @@ -183,7 +153,7 @@ struct ConvFwdSolverTest EXPECT_TRUE(error < threshold) << "Error beyond tolerance Error:" << error << ", Threshold: " << threshold; } - ConvTestCase conv_config; + ConvTestCaseGroup conv_config; miopen::ConvolutionDescriptor conv_desc; tensor input; tensor weights; diff --git a/test/gtest/na.hpp b/test/gtest/na.hpp index 387f88e12c..663b84962e 100644 --- a/test/gtest/na.hpp +++ b/test/gtest/na.hpp @@ -54,7 +54,7 @@ struct BNTestCase std::vector GetInput() { return {N, C, H, W}; } }; -std::vector Network1() +std::vector Networkna1() { // pyt_mlperf_resnet50v1.5 return { diff --git a/test/gtest/na_infer.cpp b/test/gtest/na_infer.cpp index f0d3407b2b..d14b0cf8d0 100644 --- a/test/gtest/na_infer.cpp +++ b/test/gtest/na_infer.cpp @@ -71,7 +71,7 @@ TEST_P(BNActivInferFloat, BnFwdInferActivationFused) INSTANTIATE_TEST_SUITE_P(BNActivInferFloatSuite, BNActivInferFloat, testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(Network1()))); + testing::ValuesIn(Networkna1()))); TEST_P(BNActivInferHalf, DISABLED_BnFwdInferActivationFused) { const auto plan_params = miopen::fusion::FusionInvokeParams( @@ -83,4 +83,4 @@ TEST_P(BNActivInferHalf, DISABLED_BnFwdInferActivationFused) INSTANTIATE_TEST_SUITE_P(BNActivInferHalfSuite, BNActivInferHalf, testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(Network1()))); + testing::ValuesIn(Networkna1()))); diff --git a/test/gtest/nonpack_conv3d_fwd.cpp b/test/gtest/nonpack_conv3d_fwd.cpp index 0d08e5215a..e0a9a55ccb 100644 --- a/test/gtest/nonpack_conv3d_fwd.cpp +++ b/test/gtest/nonpack_conv3d_fwd.cpp @@ -94,5 +94,5 @@ TEST_P(ConvFwdSolverTest3D, CKNonPackConvFwd3D) INSTANTIATE_TEST_SUITE_P(ConvFwdTest, ConvFwdSolverTest3D, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); diff --git a/test/gtest/nonpack_conv3d_fwd.hpp b/test/gtest/nonpack_conv3d_fwd.hpp index 5e521d7455..a1e242a405 100644 --- a/test/gtest/nonpack_conv3d_fwd.hpp +++ b/test/gtest/nonpack_conv3d_fwd.hpp @@ -49,6 +49,7 @@ struct NonPackTestCase : Conv3DTestCase std::vector GetOutputStrides() { return {o0, o1, o2, o3, o4}; } }; +template<> std::vector ConvTestConfigs() { // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z return {{{1, 4, 16, 4, 9, 16, 16, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, diff --git a/test/gtest/solver_bwd.hpp b/test/gtest/solver_bwd.hpp index cb55a5951b..5049783e53 100644 --- a/test/gtest/solver_bwd.hpp +++ b/test/gtest/solver_bwd.hpp @@ -43,7 +43,7 @@ template struct ConvBwdSolverTest - : public ::testing::TestWithParam> + : public ::testing::TestWithParam> { template @@ -168,7 +168,7 @@ struct ConvBwdSolverTest EXPECT_TRUE(error < threshold) << "Error beyond tolerance Error:" << error << ", Threshold: " << threshold; } - ConvTestCase conv_config; + ConvTestCaseBase conv_config; miopen::ConvolutionDescriptor conv_desc; tensor input; tensor weights; diff --git a/test/gtest/solver_bwd_f8.cpp b/test/gtest/solver_bwd_f8.cpp index 6f2cda02bf..cb601e4b55 100644 --- a/test/gtest/solver_bwd_f8.cpp +++ b/test/gtest/solver_bwd_f8.cpp @@ -60,10 +60,10 @@ TEST_P(ConvBwdFp8Naive, DISABLED_Bwd) INSTANTIATE_TEST_SUITE_P(ConvBwdTest, ConvBwdFp8, testing::Combine(testing::Values(miopenConvolutionAlgoGEMM), - testing::ValuesIn(GetNetwork1()))); + testing::ValuesIn(GetNetwork1()))); // Since NaiveConv is verified against the CPU, we are conservative in the number and type // of test cases we instantiate INSTANTIATE_TEST_SUITE_P(ConvBwdTest, ConvBwdFp8Naive, testing::Combine(testing::Values(miopenConvolutionAlgoGEMM), - testing::ValuesIn(ConvTestConfigs()))); + testing::ValuesIn(ConvTestConfigs()))); diff --git a/test/gtest/solver_convasm3x3u.cpp b/test/gtest/solver_convasm3x3u.cpp index 3ed1e466dc..e6422e7892 100644 --- a/test/gtest/solver_convasm3x3u.cpp +++ b/test/gtest/solver_convasm3x3u.cpp @@ -38,5 +38,5 @@ TEST_P(ConvFwdSolverTestFloat, ConvASM3x3UFwd) INSTANTIATE_TEST_SUITE_P(ConvFwdTest, ConvFwdSolverTestFloat, testing::Combine(testing::Values(miopenConvolutionFwdAlgoDirect), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNCHW))); diff --git a/test/gtest/solver_f8.cpp b/test/gtest/solver_f8.cpp new file mode 100644 index 0000000000..a420d45c43 --- /dev/null +++ b/test/gtest/solver_f8.cpp @@ -0,0 +1,78 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2022 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +#include "solver_f8.hpp" + +template <> +miopenDataType_t GetDataType() +{ + return miopenFloat8; +} + +template <> +miopenDataType_t GetDataType() +{ + return miopenBFloat8; +} + +template<> +std::vector ConvTestConfigs() +{ // n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y + return {// New tests begin + {1, 32, 4, 4, 16, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {2, 32, 4, 4, 16, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {4, 32, 4, 4, 16, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {8, 32, 4, 4, 16, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {16, 32, 4, 4, 16, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {16, 128, 16, 16, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 28, 28, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 64, 64, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 128, 64, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 128, 128, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 128, 128, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 128, 128, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 256, 128, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 256, 256, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 256, 256, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {128, 256, 256, 256, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {128, 256, 512, 256, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {128, 256, 512, 512, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {128, 256, 1024, 512, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {128, 256, 1024, 1024, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {128, 512, 1024, 1024, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {128, 512, 1024, 1024, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {128, 1024, 1024, 1024, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {128, 1024, 1024, 1024, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {256, 1024, 1024, 1024, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {1024, 1024, 1024, 1024, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {1024, 2048, 2048, 2048, 2048, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + // New tests end + {16, 128, 16, 16, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 28, 28, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 14, 14, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 512, 7, 7, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 1024, 14, 14, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}}; +} + diff --git a/test/gtest/solver_f8.hpp b/test/gtest/solver_f8.hpp index bf77347ef8..68ef538a03 100644 --- a/test/gtest/solver_f8.hpp +++ b/test/gtest/solver_f8.hpp @@ -34,31 +34,12 @@ #include "conv_common.hpp" #include #include "verify.hpp" + +#include "conv_test_base.hpp" using float8 = miopen_f8::hip_f8; using bfloat8 = miopen_f8::hip_f8; -template -miopenDataType_t GetDataType(); - -template <> -miopenDataType_t GetDataType() -{ - return miopenFloat8; -} - -template <> -miopenDataType_t GetDataType() -{ - return miopenBFloat8; -} - -template <> -miopenDataType_t GetDataType() -{ - return miopenFloat; -} - -struct ConvTestCase +struct ConvTestCaseF8 { size_t N; size_t C; @@ -74,7 +55,7 @@ struct ConvTestCase size_t dialtion_x; size_t dilation_y; miopenConvolutionMode_t conv_mode; - friend std::ostream& operator<<(std::ostream& os, const ConvTestCase& tc) + friend std::ostream& operator<<(std::ostream& os, const ConvTestCaseF8& tc) { return os << "N: " << tc.N << " C:" << tc.C << " H:" << tc.H << " W:" << tc.W << " k: " << tc.k << " y:" << tc.y << " x:" << tc.x << " pad_y:" << tc.pad_y @@ -91,44 +72,6 @@ struct ConvTestCase } }; -std::vector ConvTestConfigs() -{ // n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y - return {// New tests begin - {1, 32, 4, 4, 16, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {2, 32, 4, 4, 16, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {4, 32, 4, 4, 16, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {8, 32, 4, 4, 16, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {16, 32, 4, 4, 16, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {16, 128, 16, 16, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 28, 28, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 64, 64, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 128, 64, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 128, 128, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 128, 128, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 128, 128, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 256, 128, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 256, 256, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 256, 256, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {128, 256, 256, 256, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {128, 256, 512, 256, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {128, 256, 512, 512, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {128, 256, 1024, 512, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {128, 256, 1024, 1024, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {128, 512, 1024, 1024, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {128, 512, 1024, 1024, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {128, 1024, 1024, 1024, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {128, 1024, 1024, 1024, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {256, 1024, 1024, 1024, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {1024, 1024, 1024, 1024, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {1024, 2048, 2048, 2048, 2048, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - // New tests end - {16, 128, 16, 16, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 28, 28, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 14, 14, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 512, 7, 7, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 1024, 14, 14, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}}; -} - template struct Fp8Cast { @@ -151,8 +94,8 @@ struct Fp8Cast }; template -struct ConvFwdSolverTest - : public ::testing::TestWithParam> +struct ConvFwdSolverTestF8 + : public ::testing::TestWithParam> { protected: void SetUp() override @@ -249,7 +192,7 @@ struct ConvFwdSolverTest EXPECT_TRUE(error < threshold) << "Error beyond tolerance Error:" << error << ", Threshold: " << threshold; } - ConvTestCase conv_config; + ConvTestCaseF8 conv_config; miopen::ConvolutionDescriptor conv_desc; tensor input; tensor weights; diff --git a/test/gtest/solver_fwd.hpp b/test/gtest/solver_fwd.hpp index 88fa9a9c55..228390f358 100644 --- a/test/gtest/solver_fwd.hpp +++ b/test/gtest/solver_fwd.hpp @@ -42,7 +42,7 @@ template struct ConvFwdSolverTest : public ::testing::TestWithParam< - std::tuple>, + std::tuple>, ConvFwdSolverTestBase { template @@ -115,7 +115,7 @@ struct ConvFwdSolverTest this->ThresholdChecks(); } - ConvTestCase conv_config; + ConvTestCaseBase conv_config; miopen::Allocator::ManageDataPtr workspace_dev; size_t workspace_size; miopenConvFwdAlgorithm_t algo = miopenConvolutionFwdAlgoDirect; diff --git a/test/gtest/solver_fwd_f8.cpp b/test/gtest/solver_fwd_f8.cpp index a48513480c..eecada9c96 100644 --- a/test/gtest/solver_fwd_f8.cpp +++ b/test/gtest/solver_fwd_f8.cpp @@ -60,12 +60,12 @@ TEST_P(ConvFwdFp8Naive, DISABLED_Fwd) INSTANTIATE_TEST_SUITE_P(ConvFwdTest, ConvFwdFp8, testing::Combine(testing::Values(miopenConvolutionAlgoGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNCHW))); // Since NaiveConv is verified against the CPU, we are conservative in the number and type // of test cases we instantiate INSTANTIATE_TEST_SUITE_P(ConvFwdTest, ConvFwdFp8Naive, testing::Combine(testing::Values(miopenConvolutionAlgoGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNCHW))); diff --git a/test/gtest/solver_wrw.hpp b/test/gtest/solver_wrw.hpp index dde92e2071..fbe4dd7728 100644 --- a/test/gtest/solver_wrw.hpp +++ b/test/gtest/solver_wrw.hpp @@ -43,7 +43,7 @@ template struct ConvWrwSolverTest - : public ::testing::TestWithParam> + : public ::testing::TestWithParam> { template @@ -170,7 +170,7 @@ struct ConvWrwSolverTest EXPECT_TRUE(error < threshold) << "Error beyond tolerance Error:" << error << ", Threshold: " << threshold; } - ConvTestCase conv_config; + ConvTestCaseBase conv_config; miopen::ConvolutionDescriptor conv_desc; tensor input; tensor weights; diff --git a/test/gtest/solver_wrw_f8.cpp b/test/gtest/solver_wrw_f8.cpp index a970effd02..95f85e79da 100644 --- a/test/gtest/solver_wrw_f8.cpp +++ b/test/gtest/solver_wrw_f8.cpp @@ -40,4 +40,4 @@ TEST_P(ConvWrwFp8Naive, DISABLED_Wrw) INSTANTIATE_TEST_SUITE_P(ConvWrwTest, ConvWrwFp8Naive, testing::Combine(testing::Values(miopenConvolutionAlgoGEMM), - testing::ValuesIn(ConvTestConfigs()))); + testing::ValuesIn(ConvTestConfigs()))); From ad3e487be271565ee8385f326497410c4f2f24be Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Tue, 12 Dec 2023 18:48:01 +0000 Subject: [PATCH 02/25] more linking fixes --- test/gtest/bad_fusion_plan.cpp | 10 +--------- test/gtest/bn_bwd.cpp | 8 ++++---- test/gtest/bn_fwd_train.cpp | 8 ++++---- test/gtest/bn_infer.cpp | 8 ++++---- test/gtest/bn_test_data.cpp | 1 + test/gtest/bn_test_data.hpp | 3 ++- test/gtest/cba_find2_infer.cpp | 2 +- test/gtest/cba_infer.cpp | 2 +- test/gtest/conv_f8_bwd.cpp | 7 +++---- test/gtest/conv_f8_fwd.cpp | 9 ++++++--- test/gtest/conv_f8_wrw.cpp | 9 ++++++--- test/gtest/conv_igemm_mlir.cpp | 4 ++++ test/gtest/conv_igemm_mlir_xdlops.cpp | 4 ++++ test/gtest/group_conv3d_bwd.cpp | 17 ++++++++++++++++- test/gtest/group_conv3d_bwd.hpp | 11 ----------- test/gtest/group_conv3d_fwd.cpp | 23 ++++++++++++++++++++++- test/gtest/group_conv3d_fwd.hpp | 18 ------------------ test/gtest/group_conv3d_wrw.cpp | 19 ++++++++++++++++++- test/gtest/group_conv3d_wrw.hpp | 14 -------------- test/gtest/group_conv_fwd.cpp | 2 +- test/gtest/layernorm.cpp | 4 ++++ test/gtest/solver_f8.cpp | 12 ------------ test/gtest/solver_f8.hpp | 11 +++++++++-- test/gtest/sum.cpp | 4 ++++ 24 files changed, 115 insertions(+), 95 deletions(-) diff --git a/test/gtest/bad_fusion_plan.cpp b/test/gtest/bad_fusion_plan.cpp index 75dbdf71a9..333c212774 100644 --- a/test/gtest/bad_fusion_plan.cpp +++ b/test/gtest/bad_fusion_plan.cpp @@ -29,6 +29,7 @@ #include "tensor_holder.hpp" #include "get_handle.hpp" +#include "conv_test_base.hpp" namespace bad_fusion_plan { @@ -47,15 +48,6 @@ void setEnvironmentVariable(const std::string& name, const std::string& value) EXPECT_EQ(ret, 0); } -template -miopenDataType_t GetDataType(); - -template <> -miopenDataType_t GetDataType() -{ - return miopenHalf; -} - struct ConvTestCaseFusion { size_t N; diff --git a/test/gtest/bn_bwd.cpp b/test/gtest/bn_bwd.cpp index 722b42e872..e36dfe4374 100644 --- a/test/gtest/bn_bwd.cpp +++ b/test/gtest/bn_bwd.cpp @@ -54,20 +54,20 @@ TEST_P(BNBwdTestDouble, DISABLED_BnBwdCKDouble) {} INSTANTIATE_TEST_SUITE_P(BNBwdTestTestHalfNHWCSuite, BNBwdTestTestHalf, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); INSTANTIATE_TEST_SUITE_P(BNBwdTestFloatNHWCSuite, BNBwdTestFloat, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); INSTANTIATE_TEST_SUITE_P(BNBwdTestBFloat16NHWCSuite, BNBwdTestBFloat16, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); INSTANTIATE_TEST_SUITE_P(BNBwdTestDoubleNHWCSuite, BNBwdTestDouble, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); diff --git a/test/gtest/bn_fwd_train.cpp b/test/gtest/bn_fwd_train.cpp index 4a4dd4c728..f7f3352a45 100644 --- a/test/gtest/bn_fwd_train.cpp +++ b/test/gtest/bn_fwd_train.cpp @@ -54,20 +54,20 @@ TEST_P(BNFwdTrainTestBFloat16, DISABLED_BnFwdTrainCKBFloat16) {} INSTANTIATE_TEST_SUITE_P(BNFwdTrainTestHalfNHWCSuite, BNFwdTrainTestHalf, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); INSTANTIATE_TEST_SUITE_P(BNFwdTrainTestFloatNHWCSuite, BNFwdTrainTestFloat, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); INSTANTIATE_TEST_SUITE_P(BNFwdTrainTestFloatNHWCSuite, BNFwdTrainTestDouble, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); INSTANTIATE_TEST_SUITE_P(BNFwdTrainTestFloatNHWCSuite, BNFwdTrainTestBFloat16, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); diff --git a/test/gtest/bn_infer.cpp b/test/gtest/bn_infer.cpp index 0dceaa1ba5..ef742d6afb 100644 --- a/test/gtest/bn_infer.cpp +++ b/test/gtest/bn_infer.cpp @@ -54,20 +54,20 @@ TEST_P(BNInferTestBFloat16, DISABLED_BnInferCKBFloat16) {} INSTANTIATE_TEST_SUITE_P(BNInferTestHalfNHWCSuite, BNInferTestHalf, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); INSTANTIATE_TEST_SUITE_P(BNInferTestFloatNHWCSuite, BNInferTestFloat, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); INSTANTIATE_TEST_SUITE_P(BNInferTestFloatNHWCSuite, BNInferTestDouble, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); INSTANTIATE_TEST_SUITE_P(BNInferTestFloatNHWCSuite, BNInferTestBFloat16, - testing::Combine(testing::ValuesIn(Network1()), + testing::Combine(testing::ValuesIn(Network1()), testing::Values(miopenTensorNHWC))); diff --git a/test/gtest/bn_test_data.cpp b/test/gtest/bn_test_data.cpp index f29b024cbb..8e64487714 100644 --- a/test/gtest/bn_test_data.cpp +++ b/test/gtest/bn_test_data.cpp @@ -25,6 +25,7 @@ *******************************************************************************/ #include "bn_test_data.hpp" +template<> std::vector Network1() { // pyt_mlperf_resnet50v1.5 diff --git a/test/gtest/bn_test_data.hpp b/test/gtest/bn_test_data.hpp index dbeb085b0c..054d07f880 100644 --- a/test/gtest/bn_test_data.hpp +++ b/test/gtest/bn_test_data.hpp @@ -55,7 +55,8 @@ struct BNTestCase std::vector GetInput() const { return {N, C, H, W}; } }; -extern std::vector Network1(); +template +extern std::vector Network1(); template struct BNTestData diff --git a/test/gtest/cba_find2_infer.cpp b/test/gtest/cba_find2_infer.cpp index 2c747ecbfa..0b16c0520a 100644 --- a/test/gtest/cba_find2_infer.cpp +++ b/test/gtest/cba_find2_infer.cpp @@ -158,7 +158,7 @@ TEST_P(ConvBiasActivFind2InferTestFloatFusionFind, ConvBiasActivFind2Float_testF INSTANTIATE_TEST_SUITE_P(CBAFind2InferSolverTest, ConvBiasActivFind2InferTestFloatFusionFind, testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(GetNetworkForFusionCompileStepTest()), + testing::ValuesIn(GetNetworkForFusionCompileStepTest()), testing::Values(miopenTensorNCHW))); #endif diff --git a/test/gtest/cba_infer.cpp b/test/gtest/cba_infer.cpp index 996b2cadd8..f5870688e3 100644 --- a/test/gtest/cba_infer.cpp +++ b/test/gtest/cba_infer.cpp @@ -163,7 +163,7 @@ TEST_P(ConvBiasActivInferTestFloatFusionCompileStep, ConvBiasActivAsm1x1UFloat_t INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest, ConvBiasActivInferTestFloatFusionCompileStep, testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(GetNetworkForFusionCompileStepTest()), + testing::ValuesIn(GetNetworkForFusionCompileStepTest()), testing::Values(miopenTensorNCHW))); #endif diff --git a/test/gtest/conv_f8_bwd.cpp b/test/gtest/conv_f8_bwd.cpp index 58a0680bf4..e82eaf3f4e 100644 --- a/test/gtest/conv_f8_bwd.cpp +++ b/test/gtest/conv_f8_bwd.cpp @@ -29,11 +29,11 @@ #include #include "tensor_util.hpp" #include "get_handle.hpp" -#include "conv3d_test_case.hpp" #include "f8_cast_util.hpp" +#include "conv3d_test_case.hpp" +namespace conv_f8_bwd { -template<> std::vector ConvTestConfigs() { // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z return {{1, 16, 16, 1, 14, 14, 16, 1, 3, 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}, @@ -45,7 +45,6 @@ std::vector ConvTestConfigs() {4, 128, 4, 1, 28, 28, 4, 1, 3, 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}, {2, 128, 2, 1, 28, 28, 2, 1, 3, 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}}; } -namespace conv_f8_bwd { template struct ConvBwdSolverTest @@ -193,7 +192,7 @@ TEST_P(ConvBwdSolverTestF8, CKConvF8Bwd) INSTANTIATE_TEST_SUITE_P(ConvBwdTest, ConvBwdSolverTestF8, testing::Combine(testing::Values(miopenConvolutionBwdDataAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); } //namespace conv_f8_bwd diff --git a/test/gtest/conv_f8_fwd.cpp b/test/gtest/conv_f8_fwd.cpp index c622c24dde..50adf357e0 100644 --- a/test/gtest/conv_f8_fwd.cpp +++ b/test/gtest/conv_f8_fwd.cpp @@ -23,7 +23,6 @@ * SOFTWARE. * *******************************************************************************/ -#include "conv3d_test_case.hpp" #include #include #include @@ -31,8 +30,10 @@ #include "tensor_util.hpp" #include "get_handle.hpp" #include "f8_cast_util.hpp" +#include "conv3d_test_case.hpp" + +namespace conv_f8_fwd { -template<> std::vector ConvTestConfigs() { // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z return {{1, 16, 16, 1, 14, 14, 16, 1, 3, 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}, @@ -190,5 +191,7 @@ TEST_P(ConvFwdSolverTestF8, CKConvF8Fwd) INSTANTIATE_TEST_SUITE_P(ConvFwdTest, ConvFwdSolverTestF8, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); + +} //namespace conv_f8_fwd diff --git a/test/gtest/conv_f8_wrw.cpp b/test/gtest/conv_f8_wrw.cpp index 244cc92b31..4b5879e339 100644 --- a/test/gtest/conv_f8_wrw.cpp +++ b/test/gtest/conv_f8_wrw.cpp @@ -24,7 +24,6 @@ * *******************************************************************************/ -#include "conv3d_test_case.hpp" #include #include #include @@ -32,8 +31,10 @@ #include "tensor_util.hpp" #include "get_handle.hpp" #include "f8_cast_util.hpp" +#include "conv3d_test_case.hpp" + +namespace conv_f8_wrw { -template<> std::vector ConvTestConfigs() { // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z return {{1, 16, 16, 1, 14, 14, 16, 1, 3, 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}, @@ -196,5 +197,7 @@ INSTANTIATE_TEST_SUITE_P( ConvWrwTest, ConvWrwSolverTestF8, testing::Combine(testing::Values(miopenConvolutionBwdWeightsAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); + +} //namespace conv_f8_wrw diff --git a/test/gtest/conv_igemm_mlir.cpp b/test/gtest/conv_igemm_mlir.cpp index 23ea66efc1..9a06a3be79 100644 --- a/test/gtest/conv_igemm_mlir.cpp +++ b/test/gtest/conv_igemm_mlir.cpp @@ -36,6 +36,8 @@ MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_MLIR) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) +namespace conv_igemm_mlir { + using TestCase = std::tuple, std::string>; std::string GetFloatArg() @@ -248,3 +250,5 @@ INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConfigWithFloat, testing::Values(GetTest INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConfigWithHalf, testing::Values(GetTestCases("--half"))); // Int8 for FWD INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConfigWithInt8, testing::Values(GetTestCases("--int8"))); + +} //namespace conv_igemm_mlir diff --git a/test/gtest/conv_igemm_mlir_xdlops.cpp b/test/gtest/conv_igemm_mlir_xdlops.cpp index bcc9495204..30950fe2ea 100644 --- a/test/gtest/conv_igemm_mlir_xdlops.cpp +++ b/test/gtest/conv_igemm_mlir_xdlops.cpp @@ -11,6 +11,8 @@ MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_MLIR) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) +namespace conv_igemm_mlir_xdlops { + using TestCase = std::tuple, std::string>; std::string GetFloatArg() @@ -202,3 +204,5 @@ INSTANTIATE_TEST_SUITE_P(ConvIgemmMlirXdlops, INSTANTIATE_TEST_SUITE_P(ConvIgemmMlirXdlops, ConfigWithInt8, testing::Values(GetTestCases("--int8"))); + +} //namespace conv_igemm_mlir_xdlops diff --git a/test/gtest/group_conv3d_bwd.cpp b/test/gtest/group_conv3d_bwd.cpp index d9114d56e4..a1d908c95e 100644 --- a/test/gtest/group_conv3d_bwd.cpp +++ b/test/gtest/group_conv3d_bwd.cpp @@ -32,6 +32,19 @@ #include "get_handle.hpp" #include "group_conv3d_bwd.hpp" +namespace group_conv3d_bwd { + +std::vector ConvTestConfigs() +{ // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z + return {{1, 128, 64, 14, 28, 28, 64, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {1, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {32, 128, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {16, 128, 16, 28, 28, 28, 16, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {8, 128, 8, 28, 28, 28, 8, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {4, 128, 4, 28, 28, 28, 4, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {2, 128, 2, 28, 28, 28, 2, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} + struct ConvBwdSolverTest3D : ConvBwdSolverTest { }; @@ -94,5 +107,7 @@ TEST_P(ConvBwdSolverTest3D, CKGroupConvBwd3D) INSTANTIATE_TEST_SUITE_P(ConvBwdTest, ConvBwdSolverTest3D, testing::Combine(testing::Values(miopenConvolutionBwdDataAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); + +} //namespace group_conv3d_bwd diff --git a/test/gtest/group_conv3d_bwd.hpp b/test/gtest/group_conv3d_bwd.hpp index 5653a18138..5f9adadd7a 100644 --- a/test/gtest/group_conv3d_bwd.hpp +++ b/test/gtest/group_conv3d_bwd.hpp @@ -27,17 +27,6 @@ #include "conv3d_test_case.hpp" -std::vector ConvTestConfigs() -{ // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z - return {{1, 128, 64, 14, 28, 28, 64, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {1, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {32, 128, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {16, 128, 16, 28, 28, 28, 16, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {8, 128, 8, 28, 28, 28, 8, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {4, 128, 4, 28, 28, 28, 4, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {2, 128, 2, 28, 28, 28, 2, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} - inline int SetTensorLayout(miopen::TensorDescriptor& desc) { // get layout string names diff --git a/test/gtest/group_conv3d_fwd.cpp b/test/gtest/group_conv3d_fwd.cpp index 3c9c1cb27f..551b9bb79b 100644 --- a/test/gtest/group_conv3d_fwd.cpp +++ b/test/gtest/group_conv3d_fwd.cpp @@ -32,6 +32,25 @@ #include "get_handle.hpp" #include "group_conv3d_fwd.hpp" +namespace group_conv3d_fwd { + +std::vector ConvTestConfigs() +{ // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z + return {{1, 128, 64, 14, 28, 28, 64, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {1, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {2, 128, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {32, 128, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {2, 128, 32, 28, 28, 28, 32, 3, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {8, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {16, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {2, 128, 32, 28, 28, 28, 32, 3, 3, 3, 0, 0, 0, 2, 2, 2, 1, 1, 1, miopenConvolution}, + {8, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 2, 2, 2, 1, 1, 1, miopenConvolution}, + {16, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 2, 2, 2, 1, 1, 1, miopenConvolution}, + {3, 48, 48, 28, 28, 28, 48, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {3, 48, 39, 28, 28, 28, 39, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {5, 120, 60, 28, 28, 28, 60, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} + struct ConvFwdSolverTest3D : ConvFwdSolverTest { }; @@ -94,5 +113,7 @@ TEST_P(ConvFwdSolverTest3D, CKGroupConvFwd3D) INSTANTIATE_TEST_SUITE_P(ConvFwdTest, ConvFwdSolverTest3D, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); + +} //namespace group_conv3d_fwd diff --git a/test/gtest/group_conv3d_fwd.hpp b/test/gtest/group_conv3d_fwd.hpp index fdf1d0c404..8d7db3f2e9 100644 --- a/test/gtest/group_conv3d_fwd.hpp +++ b/test/gtest/group_conv3d_fwd.hpp @@ -27,24 +27,6 @@ #include "conv3d_test_case.hpp" -template<> -std::vector ConvTestConfigs() -{ // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z - return {{1, 128, 64, 14, 28, 28, 64, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {1, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {2, 128, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {32, 128, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {2, 128, 32, 28, 28, 28, 32, 3, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {8, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {16, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {2, 128, 32, 28, 28, 28, 32, 3, 3, 3, 0, 0, 0, 2, 2, 2, 1, 1, 1, miopenConvolution}, - {8, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 2, 2, 2, 1, 1, 1, miopenConvolution}, - {16, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 2, 2, 2, 1, 1, 1, miopenConvolution}, - {3, 48, 48, 28, 28, 28, 48, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {3, 48, 39, 28, 28, 28, 39, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {5, 120, 60, 28, 28, 28, 60, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} - inline int SetTensorLayout(miopen::TensorDescriptor& desc) { // get layout string names diff --git a/test/gtest/group_conv3d_wrw.cpp b/test/gtest/group_conv3d_wrw.cpp index 2f5e5f8279..acb28f3058 100644 --- a/test/gtest/group_conv3d_wrw.cpp +++ b/test/gtest/group_conv3d_wrw.cpp @@ -32,6 +32,21 @@ #include "get_handle.hpp" #include "group_conv3d_wrw.hpp" +namespace group_conv3d_wrw { + +std::vector ConvTestConfigs() +{ // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z + return {{1, 128, 64, 14, 28, 28, 64, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {1, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {2, 128, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {32, 128, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {8, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {16, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {3, 48, 48, 28, 28, 28, 48, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {3, 48, 39, 28, 28, 28, 39, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {5, 120, 60, 28, 28, 28, 60, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} + struct ConvWrwSolverTest3D : ConvWrwSolverTest { }; @@ -95,5 +110,7 @@ INSTANTIATE_TEST_SUITE_P( ConvWrwTest, ConvWrwSolverTest3D, testing::Combine(testing::Values(miopenConvolutionBwdWeightsAlgoImplicitGEMM), - testing::ValuesIn(ConvTestConfigs()), + testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); + +} //namespace group_conv3d_wrw diff --git a/test/gtest/group_conv3d_wrw.hpp b/test/gtest/group_conv3d_wrw.hpp index 144df06497..c771f3803a 100644 --- a/test/gtest/group_conv3d_wrw.hpp +++ b/test/gtest/group_conv3d_wrw.hpp @@ -27,20 +27,6 @@ #include "conv3d_test_case.hpp" -template<> -std::vector ConvTestConfigs() -{ // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z - return {{1, 128, 64, 14, 28, 28, 64, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {1, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {2, 128, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {32, 128, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {8, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {16, 64, 32, 28, 28, 28, 32, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {3, 48, 48, 28, 28, 28, 48, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {3, 48, 39, 28, 28, 28, 39, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {5, 120, 60, 28, 28, 28, 60, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} - inline int SetTensorLayout(miopen::TensorDescriptor& desc) { // get layout string names diff --git a/test/gtest/group_conv_fwd.cpp b/test/gtest/group_conv_fwd.cpp index b842ff5a1c..ffa3d30b05 100644 --- a/test/gtest/group_conv_fwd.cpp +++ b/test/gtest/group_conv_fwd.cpp @@ -32,7 +32,7 @@ #include "get_handle.hpp" #include "group_solver.hpp" -struct ConvFwdSolverTestFloat : ConvFwdSolverTestBase +struct ConvFwdSolverTestFloat : ConvGroupFwdSolverTest { }; diff --git a/test/gtest/layernorm.cpp b/test/gtest/layernorm.cpp index 8827aec465..a5c2c7cfdc 100644 --- a/test/gtest/layernorm.cpp +++ b/test/gtest/layernorm.cpp @@ -29,6 +29,8 @@ MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) +namespace layernorm { + std::string GetFloatArg() { const auto& tmp = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLOAT_ARG)); @@ -63,3 +65,5 @@ TEST_P(LayerNormTestFloat, LayerNormTestFw) INSTANTIATE_TEST_SUITE_P(LayerNormTestSet, LayerNormTestFloat, testing::ValuesIn(LayerNormTestConfigs())); + +} //namespace layernorm diff --git a/test/gtest/solver_f8.cpp b/test/gtest/solver_f8.cpp index a420d45c43..c6032ada5c 100644 --- a/test/gtest/solver_f8.cpp +++ b/test/gtest/solver_f8.cpp @@ -25,18 +25,6 @@ *******************************************************************************/ #include "solver_f8.hpp" -template <> -miopenDataType_t GetDataType() -{ - return miopenFloat8; -} - -template <> -miopenDataType_t GetDataType() -{ - return miopenBFloat8; -} - template<> std::vector ConvTestConfigs() { // n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y diff --git a/test/gtest/solver_f8.hpp b/test/gtest/solver_f8.hpp index 68ef538a03..f910f93037 100644 --- a/test/gtest/solver_f8.hpp +++ b/test/gtest/solver_f8.hpp @@ -26,19 +26,26 @@ #pragma once #include +#include #include "cpu_conv.hpp" #include "get_handle.hpp" #include "tensor_util.hpp" #include #include #include "conv_common.hpp" -#include +#include "hip_float8.hpp" #include "verify.hpp" #include "conv_test_base.hpp" using float8 = miopen_f8::hip_f8; using bfloat8 = miopen_f8::hip_f8; +float scalar_gen_random_float(float low, float high) +{ + float r = static_cast(rand()) / static_cast(RAND_MAX) * (high+low) - low; + return r; +} + struct ConvTestCaseF8 { size_t N; @@ -106,7 +113,7 @@ struct ConvFwdSolverTestF8 weights = tensor{conv_config.k, conv_config.C, conv_config.y, conv_config.x}; auto gen_fp8_value = [=](auto...) { - const auto tmp = float8(scalar_gen_random_float{-0.5, 0.5}()); + const auto tmp = float8(scalar_gen_random_float(-0.5, 0.5)); return tmp; }; diff --git a/test/gtest/sum.cpp b/test/gtest/sum.cpp index 0965649c23..b6aa5daff3 100644 --- a/test/gtest/sum.cpp +++ b/test/gtest/sum.cpp @@ -29,6 +29,8 @@ MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) +namespace sum { + std::string GetFloatArg() { const auto& tmp = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLOAT_ARG)); @@ -57,3 +59,5 @@ TEST_P(SumTestFloat, SumTestFw) }; INSTANTIATE_TEST_SUITE_P(SumTestSet, SumTestFloat, testing::ValuesIn(SumTestConfigs())); + +} //namespace sum From 645e289bff0bf4e39d36f36812aa710dc66f15b2 Mon Sep 17 00:00:00 2001 From: "M. Amber Hassaan" Date: Tue, 12 Dec 2023 19:06:55 +0000 Subject: [PATCH 03/25] add inline to avoid duplicate definition error --- test/gtest/test_operations.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gtest/test_operations.hpp b/test/gtest/test_operations.hpp index da41212302..298ac55e3e 100644 --- a/test/gtest/test_operations.hpp +++ b/test/gtest/test_operations.hpp @@ -134,7 +134,7 @@ void AddActiv(miopen::FusionPlanDescriptor& fusePlanDesc, miopenStatusSuccess); } -bool Skip(miopen::Handle& handle) +inline bool Skip(miopen::Handle& handle) { const std::string arch = handle.GetDeviceName(); bool skip_test = (arch != "gfx908" && arch != "gfx90a"); From f094cc9caf907a9a2b8d66915921096bfb1db277 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Tue, 12 Dec 2023 19:08:29 +0000 Subject: [PATCH 04/25] replace GetDataType with miopen_type --- test/gtest/conv_f8_bwd.cpp | 2 +- test/gtest/conv_f8_fwd.cpp | 4 ++-- test/gtest/conv_f8_wrw.cpp | 2 +- test/gtest/conv_test_base.cpp | 38 ++----------------------------- test/gtest/conv_test_base.hpp | 4 +--- test/gtest/group_conv3d_bwd.hpp | 2 +- test/gtest/group_conv3d_fwd.hpp | 4 ++-- test/gtest/group_conv3d_wrw.hpp | 2 +- test/gtest/group_solver.hpp | 4 ++-- test/gtest/nonpack_conv3d_fwd.hpp | 4 ++-- test/gtest/solver_bwd.hpp | 4 ++-- test/gtest/solver_f8.hpp | 4 ++-- test/gtest/solver_wrw.hpp | 4 ++-- 13 files changed, 21 insertions(+), 57 deletions(-) diff --git a/test/gtest/conv_f8_bwd.cpp b/test/gtest/conv_f8_bwd.cpp index e82eaf3f4e..72f47a459d 100644 --- a/test/gtest/conv_f8_bwd.cpp +++ b/test/gtest/conv_f8_bwd.cpp @@ -67,7 +67,7 @@ struct ConvBwdSolverTest conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{tensor_layout, output_desc.GetLengths()}; output.generate(gen_value); diff --git a/test/gtest/conv_f8_fwd.cpp b/test/gtest/conv_f8_fwd.cpp index 50adf357e0..9886a5e3b3 100644 --- a/test/gtest/conv_f8_fwd.cpp +++ b/test/gtest/conv_f8_fwd.cpp @@ -67,7 +67,7 @@ struct ConvFwdSolverTest weights.desc.SetCastType(miopenFloat8); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{tensor_layout, output_desc.GetLengths()}; std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); auto&& handle = get_handle(); @@ -83,7 +83,7 @@ struct ConvFwdSolverTest auto&& handle = get_handle(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); ref_out = tensor{tensor_layout, output_desc.GetLengths()}; using FI = Fp8Cast; using FW = Fp8Cast; diff --git a/test/gtest/conv_f8_wrw.cpp b/test/gtest/conv_f8_wrw.cpp index 4b5879e339..c2472c9683 100644 --- a/test/gtest/conv_f8_wrw.cpp +++ b/test/gtest/conv_f8_wrw.cpp @@ -70,7 +70,7 @@ struct ConvWrwSolverTest conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{tensor_layout, output_desc.GetLengths()}; output.generate(gen_value); auto&& handle = get_handle(); diff --git a/test/gtest/conv_test_base.cpp b/test/gtest/conv_test_base.cpp index 06b5611811..4e2f93a81b 100644 --- a/test/gtest/conv_test_base.cpp +++ b/test/gtest/conv_test_base.cpp @@ -25,40 +25,6 @@ *******************************************************************************/ #include "conv_test_base.hpp" -template -miopenDataType_t GetDataType(); - -template <> -miopenDataType_t GetDataType() -{ - return miopenFloat; -} - -template <> -miopenDataType_t GetDataType() -{ - return miopenHalf; -} - -template <> -miopenDataType_t GetDataType>() -{ - return miopenFloat8; -} - -template <> -miopenDataType_t GetDataType>() -{ - return miopenBFloat8; -} - -template <> -miopenDataType_t GetDataType() -{ - return miopenInt8; -} - - template<> std::vector GetNetworkForFusionCompileStepTest() { @@ -117,7 +83,7 @@ void ConvFwdSolverTestBase::SetUpImpl(ConvTestCaseBase con conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{tensor_layout, output_desc.GetLengths()}; std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); @@ -132,7 +98,7 @@ template void ConvFwdSolverTestBase::TearDownConv() { miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); ref_out = tensor{output.desc.GetLayout_t(), output_desc.GetLengths()}; if(use_cpu_ref) { diff --git a/test/gtest/conv_test_base.hpp b/test/gtest/conv_test_base.hpp index b241bd59ea..12fd12b3bf 100644 --- a/test/gtest/conv_test_base.hpp +++ b/test/gtest/conv_test_base.hpp @@ -28,12 +28,10 @@ #include #include +#include "tensor_holder.hpp" #include "conv_common.hpp" #include "conv_tensor_gen.hpp" -template -extern miopenDataType_t GetDataType(); - struct ConvTestCaseBase { size_t N; diff --git a/test/gtest/group_conv3d_bwd.hpp b/test/gtest/group_conv3d_bwd.hpp index 5f9adadd7a..41241b605a 100644 --- a/test/gtest/group_conv3d_bwd.hpp +++ b/test/gtest/group_conv3d_bwd.hpp @@ -62,7 +62,7 @@ struct ConvBwdSolverTest conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{tensor_layout, output_desc.GetLengths()}; SetTensorLayout(output.desc); output.generate(gen_value); diff --git a/test/gtest/group_conv3d_fwd.hpp b/test/gtest/group_conv3d_fwd.hpp index 8d7db3f2e9..49a2261537 100644 --- a/test/gtest/group_conv3d_fwd.hpp +++ b/test/gtest/group_conv3d_fwd.hpp @@ -62,7 +62,7 @@ struct ConvFwdSolverTest conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{tensor_layout, output_desc.GetLengths()}; SetTensorLayout(output.desc); std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); @@ -79,7 +79,7 @@ struct ConvFwdSolverTest auto&& handle = get_handle(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); ref_out = tensor{tensor_layout, output_desc.GetLengths()}; ref_out = ref_conv_fwd(input, weights, output, conv_desc); output.data = handle.Read(out_dev, output.data.size()); diff --git a/test/gtest/group_conv3d_wrw.hpp b/test/gtest/group_conv3d_wrw.hpp index c771f3803a..492d332892 100644 --- a/test/gtest/group_conv3d_wrw.hpp +++ b/test/gtest/group_conv3d_wrw.hpp @@ -62,7 +62,7 @@ struct ConvWrwSolverTest conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{tensor_layout, output_desc.GetLengths()}; output.generate(gen_value); auto&& handle = get_handle(); diff --git a/test/gtest/group_solver.hpp b/test/gtest/group_solver.hpp index ee6fa3c057..746822c644 100644 --- a/test/gtest/group_solver.hpp +++ b/test/gtest/group_solver.hpp @@ -117,7 +117,7 @@ struct ConvGroupFwdSolverTest conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{tensor_layout, output_desc.GetLengths()}; SetTensorLayout(output.desc); std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); @@ -135,7 +135,7 @@ struct ConvGroupFwdSolverTest auto&& handle = get_handle(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); ref_out = tensor{tensor_layout, output_desc.GetLengths()}; ref_out = ref_conv_fwd(input, weights, output, conv_desc); output.data = handle.Read(out_dev, output.data.size()); diff --git a/test/gtest/nonpack_conv3d_fwd.hpp b/test/gtest/nonpack_conv3d_fwd.hpp index a1e242a405..916e3ba3ab 100644 --- a/test/gtest/nonpack_conv3d_fwd.hpp +++ b/test/gtest/nonpack_conv3d_fwd.hpp @@ -108,7 +108,7 @@ struct ConvFwdSolverTest conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{tensor_layout, output_desc.GetLengths()}; std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); auto&& handle = get_handle(); @@ -124,7 +124,7 @@ struct ConvFwdSolverTest auto&& handle = get_handle(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); ref_out = tensor{tensor_layout, output_desc.GetLengths()}; ref_out = ref_conv_fwd(input, weights, output, conv_desc); output.data = handle.Read(out_dev, output.data.size()); diff --git a/test/gtest/solver_bwd.hpp b/test/gtest/solver_bwd.hpp index 5049783e53..80bd914f96 100644 --- a/test/gtest/solver_bwd.hpp +++ b/test/gtest/solver_bwd.hpp @@ -106,7 +106,7 @@ struct ConvBwdSolverTest conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{output_desc.GetLengths()}; output.generate(GenData{}); @@ -126,7 +126,7 @@ struct ConvBwdSolverTest auto&& handle = get_handle(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); ref_in = tensor{output_desc.GetLengths()}; if(use_cpu_ref) { diff --git a/test/gtest/solver_f8.hpp b/test/gtest/solver_f8.hpp index f910f93037..587fe99a57 100644 --- a/test/gtest/solver_f8.hpp +++ b/test/gtest/solver_f8.hpp @@ -123,7 +123,7 @@ struct ConvFwdSolverTestF8 conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = conv_desc.GetForwardOutputTensor( - input.desc, weights.desc, GetDataType()); // Tgpu Datatype? + input.desc, weights.desc, miopen_type{}); // Tgpu Datatype? output = tensor{output_desc.GetLengths()}; // half_float::half instead? @@ -142,7 +142,7 @@ struct ConvFwdSolverTestF8 auto&& handle = get_handle(); miopen::TensorDescriptor output_desc = conv_desc.GetForwardOutputTensor( - input.desc, weights.desc, GetDataType()); // miopenFloat or GetDataType() ? + input.desc, weights.desc, miopen_type{}); // miopenFloat or miopen_type{} ? ref_out = tensor{output_desc.GetLengths()}; using FI = Fp8Cast; diff --git a/test/gtest/solver_wrw.hpp b/test/gtest/solver_wrw.hpp index fbe4dd7728..f9b349a12e 100644 --- a/test/gtest/solver_wrw.hpp +++ b/test/gtest/solver_wrw.hpp @@ -106,7 +106,7 @@ struct ConvWrwSolverTest conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{output_desc.GetLengths()}; output.generate(GenData{}); @@ -126,7 +126,7 @@ struct ConvWrwSolverTest auto&& handle = get_handle(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); ref_weights = tensor{output_desc.GetLengths()}; if(use_cpu_ref) { From 47ee6e02df55117665975005dcb770112cfacaec Mon Sep 17 00:00:00 2001 From: "M. Amber Hassaan" Date: Tue, 12 Dec 2023 19:15:27 +0000 Subject: [PATCH 05/25] fix template body missing error --- test/gtest/conv_test_base.cpp | 1 - test/gtest/conv_test_base.hpp | 65 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/test/gtest/conv_test_base.cpp b/test/gtest/conv_test_base.cpp index 4e2f93a81b..df7f946c4b 100644 --- a/test/gtest/conv_test_base.cpp +++ b/test/gtest/conv_test_base.cpp @@ -71,7 +71,6 @@ std::vector ConvTestConfigs() {64, 1024, 14, 14, 1024, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; } - template void ConvFwdSolverTestBase::SetUpImpl(ConvTestCaseBase conv_config, miopenTensorLayout_t tensor_layout) { diff --git a/test/gtest/conv_test_base.hpp b/test/gtest/conv_test_base.hpp index 12fd12b3bf..8a74d5c3a7 100644 --- a/test/gtest/conv_test_base.hpp +++ b/test/gtest/conv_test_base.hpp @@ -96,3 +96,68 @@ struct ConvFwdSolverTestBase miopen::Allocator::ManageDataPtr wei_dev; miopen::Allocator::ManageDataPtr out_dev; }; + +template +void ConvFwdSolverTestBase::SetUpImpl(ConvTestCaseBase conv_config, miopenTensorLayout_t tensor_layout) +{ + input = tensor{tensor_layout, conv_config.GetInput()}; + weights = tensor{tensor_layout, conv_config.GetWeights()}; + input.generate(GenData{}); + weights.generate(GenWeights{}); + + conv_desc = conv_config.GetConv(); + + miopen::TensorDescriptor output_desc = + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + + output = tensor{tensor_layout, output_desc.GetLengths()}; + std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); + + auto&& handle = get_handle(); + in_dev = handle.Write(input.data); + wei_dev = handle.Write(weights.data); + out_dev = handle.Write(output.data); +} + +template +void ConvFwdSolverTestBase::TearDownConv() +{ + miopen::TensorDescriptor output_desc = + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + ref_out = tensor{output.desc.GetLayout_t(), output_desc.GetLengths()}; + if(use_cpu_ref) + { + cpu_convolution_forward(conv_desc.GetSpatialDimension(), + input, + weights, + ref_out, + conv_desc.GetConvPads(), + conv_desc.GetConvStrides(), + conv_desc.GetConvDilations(), + conv_desc.GetGroupCount()); + } + else + { + ref_out = ref_conv_fwd(input, weights, ref_out, conv_desc); + } +} + +template +void ConvFwdSolverTestBase::ThresholdChecks() +{ + auto&& handle = get_handle(); + output.data = handle.Read(out_dev, output.data.size()); + EXPECT_FALSE(miopen::range_zero(ref_out)) << "Cpu data is all zeros"; + EXPECT_FALSE(miopen::range_zero(output)) << "Gpu data is all zeros"; + EXPECT_TRUE(miopen::range_distance(ref_out) == miopen::range_distance(output)); + + const double tolerance = 80; + double threshold = std::numeric_limits::epsilon() * tolerance; + auto error = miopen::rms_range(ref_out, output); + + EXPECT_FALSE(miopen::find_idx(ref_out, miopen::not_finite) >= 0) + << "Non finite number found in the CPU data"; + + EXPECT_TRUE(error < threshold) + << "Error beyond tolerance Error:" << error << ", Threshold: " << threshold; +} From 457d26595e1b48fd65305f56d5a485bca2cb59e2 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Tue, 12 Dec 2023 20:20:21 +0000 Subject: [PATCH 06/25] fix linking issues --- test/gtest/conv_embed_db.cpp | 34 +++--- test/gtest/conv_hip_igemm_xdlops.cpp | 10 +- test/gtest/conv_igemm_mlir.cpp | 26 ++--- test/gtest/conv_igemm_mlir_xdlops.cpp | 18 ++-- test/gtest/conv_tensor_gen.cpp | 142 -------------------------- test/gtest/conv_tensor_gen.hpp | 85 ++++++++++++++- test/gtest/conv_test_base.cpp | 65 ------------ test/gtest/conv_test_base.hpp | 4 +- test/gtest/group_conv3d_fwd.cpp | 6 +- test/gtest/nonpack_conv3d_fwd.cpp | 6 +- test/gtest/solver_f8.hpp | 24 +---- 11 files changed, 133 insertions(+), 287 deletions(-) delete mode 100644 test/gtest/conv_tensor_gen.cpp diff --git a/test/gtest/conv_embed_db.cpp b/test/gtest/conv_embed_db.cpp index 1a9e082426..7b21b9c535 100644 --- a/test/gtest/conv_embed_db.cpp +++ b/test/gtest/conv_embed_db.cpp @@ -52,16 +52,16 @@ void GetArgs(const std::string& param, std::vector& tokens) tokens.push_back(*begin++); } -class ConfigWithHalf : public testing::TestWithParam> +class ConvEmbedConfigHalf : public testing::TestWithParam> { }; -class ConfigWithInt8 : public testing::TestWithParam> +class ConvEmbedConfigInt8 : public testing::TestWithParam> { }; -class ConfigWithBFloat16 : public testing::TestWithParam> +class ConvEmbedConfigBFloat16 : public testing::TestWithParam> { }; -class ConfigWithFloat : public testing::TestWithParam> +class ConvEmbedConfigFloat : public testing::TestWithParam> { }; @@ -71,10 +71,10 @@ void Run2dDriver(miopenDataType_t prec) std::vector params; switch(prec) { - case miopenFloat: params = ConfigWithFloat::GetParam(); break; - case miopenHalf: params = ConfigWithHalf::GetParam(); break; - case miopenInt8: params = ConfigWithInt8::GetParam(); break; - case miopenBFloat16: params = ConfigWithBFloat16::GetParam(); break; + case miopenFloat: params = ConvEmbedConfigFloat::GetParam(); break; + case miopenHalf: params = ConvEmbedConfigHalf::GetParam(); break; + case miopenInt8: params = ConvEmbedConfigInt8::GetParam(); break; + case miopenBFloat16: params = ConvEmbedConfigBFloat16::GetParam(); break; case miopenInt32: case miopenFloat8: case miopenBFloat8: @@ -82,7 +82,7 @@ void Run2dDriver(miopenDataType_t prec) FAIL() << "miopenInt32, miopenFloat8, miopenBFloat8, miopenDouble data type " "not supported by conv_embed_db test"; - default: params = ConfigWithFloat::GetParam(); + default: params = ConvEmbedConfigFloat::GetParam(); } for(const auto& test_value : params) @@ -111,7 +111,7 @@ bool IsTestSupportedForDevice(const miopen::Handle& handle) return false; } -TEST_P(ConfigWithFloat, FloatTest) +TEST_P(ConvEmbedConfigFloat, FloatTest) { #if MIOPEN_EMBED_DB @@ -130,7 +130,7 @@ TEST_P(ConfigWithFloat, FloatTest) #endif }; -TEST_P(ConfigWithHalf, HalfTest) +TEST_P(ConvEmbedConfigHalf, HalfTest) { #if MIOPEN_EMBED_DB @@ -149,7 +149,7 @@ TEST_P(ConfigWithHalf, HalfTest) #endif }; -TEST_P(ConfigWithInt8, Int8Test) +TEST_P(ConvEmbedConfigInt8, Int8Test) { #if MIOPEN_EMBED_DB @@ -168,7 +168,7 @@ TEST_P(ConfigWithInt8, Int8Test) #endif }; -TEST_P(ConfigWithBFloat16, BFloat16Test) +TEST_P(ConvEmbedConfigBFloat16, BFloat16Test) { #if MIOPEN_EMBED_DB @@ -224,11 +224,11 @@ std::vector GetTestCases(const std::string& precision) return test_cases; } -INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConfigWithFloat, testing::Values(GetTestCases("--float"))); -INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConfigWithHalf, testing::Values(GetTestCases("--half"))); -INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConfigWithInt8, testing::Values(GetTestCases("--int8"))); +INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConvEmbedConfigFloat, testing::Values(GetTestCases("--float"))); +INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConvEmbedConfigHalf, testing::Values(GetTestCases("--half"))); +INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConvEmbedConfigInt8, testing::Values(GetTestCases("--int8"))); INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, - ConfigWithBFloat16, + ConvEmbedConfigBFloat16, testing::Values(GetTestCases("--bfloat16"))); } //namespace conv_embed_db diff --git a/test/gtest/conv_hip_igemm_xdlops.cpp b/test/gtest/conv_hip_igemm_xdlops.cpp index 3fb6f8c6e0..bf121c549d 100644 --- a/test/gtest/conv_hip_igemm_xdlops.cpp +++ b/test/gtest/conv_hip_igemm_xdlops.cpp @@ -54,7 +54,7 @@ void GetArgs(const std::string& param, std::vector& tokens) tokens.push_back(*begin++); } -class ConfigWithInt8 : public testing::TestWithParam> +class ConvHipIgemmXdlopsConfigInt8 : public testing::TestWithParam> { }; @@ -63,7 +63,7 @@ void Run2dDriver(miopenDataType_t prec) std::vector params; switch(prec) { - case miopenInt8: params = ConfigWithInt8::GetParam(); break; + case miopenInt8: params = ConvHipIgemmXdlopsConfigInt8::GetParam(); break; case miopenFloat8: case miopenBFloat8: case miopenHalf: @@ -76,7 +76,7 @@ void Run2dDriver(miopenDataType_t prec) "type not supported by " "test_conv_hip_igemm_xdlops test"; - default: params = ConfigWithInt8::GetParam(); + default: params = ConvHipIgemmXdlopsConfigInt8::GetParam(); } for(const auto& test_value : params) @@ -105,7 +105,7 @@ bool IsTestSupportedForDevice(const miopen::Handle& handle) return false; } -TEST_P(ConfigWithInt8, Int8Test) +TEST_P(ConvHipIgemmXdlopsConfigInt8, Int8Test) { #if MIOPEN_BACKEND_OPENCL @@ -167,7 +167,7 @@ std::vector GetTestCases(const std::string& precision) } INSTANTIATE_TEST_SUITE_P(ConvHipIgemmXdlops, - ConfigWithInt8, + ConvHipIgemmXdlopsConfigInt8, testing::Values(GetTestCases("--int8"))); } //namespace conv_hip_igem_xdlops diff --git a/test/gtest/conv_igemm_mlir.cpp b/test/gtest/conv_igemm_mlir.cpp index 9a06a3be79..53c846a95a 100644 --- a/test/gtest/conv_igemm_mlir.cpp +++ b/test/gtest/conv_igemm_mlir.cpp @@ -67,13 +67,13 @@ void GetArgs(const TestCase& param, std::vector& tokens) tokens.push_back(*begin++); } -class ConfigWithFloat : public testing::TestWithParam> +class ConvIgemmMlirConfigFloat : public testing::TestWithParam> { }; -class ConfigWithHalf : public testing::TestWithParam> +class ConvIgemmMlirConfigHalf : public testing::TestWithParam> { }; -class ConfigWithInt8 : public testing::TestWithParam> +class ConvIgemmMlirConfigInt8 : public testing::TestWithParam> { }; @@ -83,9 +83,9 @@ void Run2dDriver(miopenDataType_t prec) std::vector params; switch(prec) { - case miopenHalf: params = ConfigWithHalf::GetParam(); break; - case miopenInt8: params = ConfigWithInt8::GetParam(); break; - case miopenFloat: params = ConfigWithFloat::GetParam(); break; + case miopenHalf: params = ConvIgemmMlirConfigHalf::GetParam(); break; + case miopenInt8: params = ConvIgemmMlirConfigInt8::GetParam(); break; + case miopenFloat: params = ConvIgemmMlirConfigFloat::GetParam(); break; case miopenBFloat16: case miopenInt32: case miopenFloat8: @@ -95,7 +95,7 @@ void Run2dDriver(miopenDataType_t prec) "miopenBFloat16, miopenInt32, miopenFloat8, miopenBFloat8, " "miopenDouble data type not supported by conv_igemm_mlir test"); - default: params = ConfigWithFloat::GetParam(); + default: params = ConvIgemmMlirConfigFloat::GetParam(); } for(const auto& test_value : params) @@ -115,7 +115,7 @@ void Run2dDriver(miopenDataType_t prec) } }; -TEST_P(ConfigWithFloat, FloatTest) +TEST_P(ConvIgemmMlirConfigFloat, FloatTest) { #if MIOPEN_USE_MLIR @@ -137,7 +137,7 @@ TEST_P(ConfigWithFloat, FloatTest) #endif }; -TEST_P(ConfigWithHalf, HalfTest) +TEST_P(ConvIgemmMlirConfigHalf, HalfTest) { #if MIOPEN_USE_MLIR @@ -159,7 +159,7 @@ TEST_P(ConfigWithHalf, HalfTest) #endif }; -TEST_P(ConfigWithInt8, Int8Test) +TEST_P(ConvIgemmMlirConfigInt8, Int8Test) { #if MIOPEN_USE_MLIR @@ -245,10 +245,10 @@ std::vector GetTestCases(const std::string& precision) return test_cases; } // Float for FWD, BWD, WRW -INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConfigWithFloat, testing::Values(GetTestCases("--float"))); +INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConvIgemmMlirConfigFloat, testing::Values(GetTestCases("--float"))); // Half for FWD, BWD, WRW -INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConfigWithHalf, testing::Values(GetTestCases("--half"))); +INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConvIgemmMlirConfigHalf, testing::Values(GetTestCases("--half"))); // Int8 for FWD -INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConfigWithInt8, testing::Values(GetTestCases("--int8"))); +INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConvIgemmMlirConfigInt8, testing::Values(GetTestCases("--int8"))); } //namespace conv_igemm_mlir diff --git a/test/gtest/conv_igemm_mlir_xdlops.cpp b/test/gtest/conv_igemm_mlir_xdlops.cpp index 30950fe2ea..b0622bff46 100644 --- a/test/gtest/conv_igemm_mlir_xdlops.cpp +++ b/test/gtest/conv_igemm_mlir_xdlops.cpp @@ -42,10 +42,10 @@ void GetArgs(const TestCase& param, std::vector& tokens) tokens.push_back(*begin++); } -class ConfigWithHalf : public testing::TestWithParam> +class ConvIgemmMlirXdlopsConfigHalf : public testing::TestWithParam> { }; -class ConfigWithInt8 : public testing::TestWithParam> +class ConvIgemmMlirXdlopsConfigInt8 : public testing::TestWithParam> { }; @@ -55,8 +55,8 @@ void Run2dDriver(miopenDataType_t prec) std::vector params; switch(prec) { - case miopenHalf: params = ConfigWithHalf::GetParam(); break; - case miopenInt8: params = ConfigWithInt8::GetParam(); break; + case miopenHalf: params = ConvIgemmMlirXdlopsConfigHalf::GetParam(); break; + case miopenInt8: params = ConvIgemmMlirXdlopsConfigInt8::GetParam(); break; case miopenBFloat16: case miopenFloat: case miopenInt32: @@ -68,7 +68,7 @@ void Run2dDriver(miopenDataType_t prec) "type not supported by " "conv_igemm_mlir_xdlops test"); - default: params = ConfigWithHalf::GetParam(); + default: params = ConvIgemmMlirXdlopsConfigHalf::GetParam(); } for(const auto& test_value : params) @@ -88,7 +88,7 @@ void Run2dDriver(miopenDataType_t prec) } }; -TEST_P(ConfigWithHalf, HalfTest) +TEST_P(ConvIgemmMlirXdlopsConfigHalf, HalfTest) { #if MIOPEN_USE_MLIR @@ -110,7 +110,7 @@ TEST_P(ConfigWithHalf, HalfTest) #endif }; -TEST_P(ConfigWithInt8, Int8Test) +TEST_P(ConvIgemmMlirXdlopsConfigInt8, Int8Test) { #if MIOPEN_USE_MLIR @@ -198,11 +198,11 @@ std::vector GetTestCases(const std::string& precision) } // Half for FWD, BWD, WRW INSTANTIATE_TEST_SUITE_P(ConvIgemmMlirXdlops, - ConfigWithHalf, + ConvIgemmMlirXdlopsConfigHalf, testing::Values(GetTestCases("--half"))); // Int8 for FWD INSTANTIATE_TEST_SUITE_P(ConvIgemmMlirXdlops, - ConfigWithInt8, + ConvIgemmMlirXdlopsConfigInt8, testing::Values(GetTestCases("--int8"))); } //namespace conv_igemm_mlir_xdlops diff --git a/test/gtest/conv_tensor_gen.cpp b/test/gtest/conv_tensor_gen.cpp deleted file mode 100644 index 1c500d5000..0000000000 --- a/test/gtest/conv_tensor_gen.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * - * MIT License - * - * Copyright (c) 2023 Advanced Micro Devices, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - *******************************************************************************/ -#include - -#include -#include "conv_tensor_gen.hpp" - -// Copied from conv_driver.hpp - -template -inline T FRAND() -{ - double d = static_cast(rand() / (static_cast(RAND_MAX))); - return static_cast(d); -} - -template -inline T RAN_GEN(T A, T B) -{ - T r = (FRAND() * (B - A)) + A; - return r; -} -template -T RanGenData() -{ - return RAN_GEN(static_cast(0.0f), static_cast(1.0f)); -} - -template <> -float8 RanGenData() -{ - return RAN_GEN(static_cast(-1.0f), static_cast(1.0f)); -} - -template <> -bfloat8 RanGenData() -{ - const auto tmp = RAN_GEN(static_cast(-1.0f), static_cast(1.0f)); - return static_cast(tmp); -} - -/* -template -struct GenData -{ - template - T operator()(Ts...) const - { - return RanGenData(); - } -}; -*/ - -template -template -T GenData::operator()(Ts...) const -{ - return RanGenData(); -} - -template -T RanGenWeights() -{ - return RAN_GEN(static_cast(-0.5), static_cast(0.5)); -} - -// Shift FP16 distribution towards positive numbers, -// otherwise Winograd FP16 validation fails. -template <> -half_float::half RanGenWeights() -{ - return RAN_GEN(static_cast(-1.0 / 3.0), - static_cast(0.5)); -} - -template <> -float8 RanGenWeights() -{ - const auto tmp = - RAN_GEN(0.0, 1.0) > 0.5 ? static_cast(0.0) : static_cast(1.0); - // 1 in 2 chance of number being positive - const float sign = - (RAN_GEN(0.0, 1.0) > 0.5) ? static_cast(-1) : static_cast(1); - const auto tmp2 = static_cast(std::numeric_limits::epsilon()) * - static_cast(2) * sign * static_cast(tmp); - return static_cast(tmp2); -} - -template <> -bfloat8 RanGenWeights() -{ - const auto tmp = - RAN_GEN(0.0, 1.0) > 0.5 ? static_cast(0.0) : static_cast(1.0); - // 1 in 2 chance of number being positive - const float sign = - (RAN_GEN(0.0, 1.0) > 0.5) ? static_cast(-1) : static_cast(1); - const auto tmp2 = static_cast(std::numeric_limits::epsilon()) * - static_cast(2) * sign * static_cast(tmp); - return static_cast(tmp2); -} - -/* -template -struct GenWeights -{ - template - T operator()(Ts...) const - { - return RanGenWeights(); - } -}; -*/ - -template -template -T GenWeights::operator()(Ts...) const -{ - return RanGenWeights(); -} diff --git a/test/gtest/conv_tensor_gen.hpp b/test/gtest/conv_tensor_gen.hpp index 12c4116497..572480123d 100644 --- a/test/gtest/conv_tensor_gen.hpp +++ b/test/gtest/conv_tensor_gen.hpp @@ -26,27 +26,102 @@ #pragma once #include + #include -#include "hip_float8.hpp" + +#include // Copied from conv_driver.hpp template -extern T RanGenData(); +inline T FRAND() +{ + double d = static_cast(rand() / (static_cast(RAND_MAX))); + return static_cast(d); +} + +template +inline T RAN_GEN(T A, T B) +{ + T r = (FRAND() * (B - A)) + A; + return r; +} +template +inline T RanGenData() +{ + return RAN_GEN(static_cast(0.0f), static_cast(1.0f)); +} + +template <> +inline float8 RanGenData() +{ + return RAN_GEN(static_cast(-1.0f), static_cast(1.0f)); +} + +template <> +inline bfloat8 RanGenData() +{ + const auto tmp = RAN_GEN(static_cast(-1.0f), static_cast(1.0f)); + return static_cast(tmp); +} template struct GenData { template - T operator()(Ts...) const; + T operator()(Ts...) const + { + return RanGenData(); + } }; template -extern T RanGenWeights(); +T RanGenWeights() +{ + return RAN_GEN(static_cast(-0.5), static_cast(0.5)); +} + +// Shift FP16 distribution towards positive numbers, +// otherwise Winograd FP16 validation fails. +template <> +inline half_float::half RanGenWeights() +{ + return RAN_GEN(static_cast(-1.0 / 3.0), + static_cast(0.5)); +} + +template <> +inline float8 RanGenWeights() +{ + const auto tmp = + RAN_GEN(0.0, 1.0) > 0.5 ? static_cast(0.0) : static_cast(1.0); + // 1 in 2 chance of number being positive + const float sign = + (RAN_GEN(0.0, 1.0) > 0.5) ? static_cast(-1) : static_cast(1); + const auto tmp2 = static_cast(std::numeric_limits::epsilon()) * + static_cast(2) * sign * static_cast(tmp); + return static_cast(tmp2); +} + +template <> +inline bfloat8 RanGenWeights() +{ + const auto tmp = + RAN_GEN(0.0, 1.0) > 0.5 ? static_cast(0.0) : static_cast(1.0); + // 1 in 2 chance of number being positive + const float sign = + (RAN_GEN(0.0, 1.0) > 0.5) ? static_cast(-1) : static_cast(1); + const auto tmp2 = static_cast(std::numeric_limits::epsilon()) * + static_cast(2) * sign * static_cast(tmp); + return static_cast(tmp2); +} template struct GenWeights { template - T operator()(Ts...) const; + T operator()(Ts...) const + { + return RanGenWeights(); + } }; diff --git a/test/gtest/conv_test_base.cpp b/test/gtest/conv_test_base.cpp index df7f946c4b..51c7bed699 100644 --- a/test/gtest/conv_test_base.cpp +++ b/test/gtest/conv_test_base.cpp @@ -70,68 +70,3 @@ std::vector ConvTestConfigs() {64, 512, 7, 7, 512, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, {64, 1024, 14, 14, 1024, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; } - -template -void ConvFwdSolverTestBase::SetUpImpl(ConvTestCaseBase conv_config, miopenTensorLayout_t tensor_layout) -{ - input = tensor{tensor_layout, conv_config.GetInput()}; - weights = tensor{tensor_layout, conv_config.GetWeights()}; - input.generate(GenData{}); - weights.generate(GenWeights{}); - - conv_desc = conv_config.GetConv(); - - miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); - - output = tensor{tensor_layout, output_desc.GetLengths()}; - std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); - - auto&& handle = get_handle(); - in_dev = handle.Write(input.data); - wei_dev = handle.Write(weights.data); - out_dev = handle.Write(output.data); -} - -template -void ConvFwdSolverTestBase::TearDownConv() -{ - miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); - ref_out = tensor{output.desc.GetLayout_t(), output_desc.GetLengths()}; - if(use_cpu_ref) - { - cpu_convolution_forward(conv_desc.GetSpatialDimension(), - input, - weights, - ref_out, - conv_desc.GetConvPads(), - conv_desc.GetConvStrides(), - conv_desc.GetConvDilations(), - conv_desc.GetGroupCount()); - } - else - { - ref_out = ref_conv_fwd(input, weights, ref_out, conv_desc); - } -} - -template -void ConvFwdSolverTestBase::ThresholdChecks() -{ - auto&& handle = get_handle(); - output.data = handle.Read(out_dev, output.data.size()); - EXPECT_FALSE(miopen::range_zero(ref_out)) << "Cpu data is all zeros"; - EXPECT_FALSE(miopen::range_zero(output)) << "Gpu data is all zeros"; - EXPECT_TRUE(miopen::range_distance(ref_out) == miopen::range_distance(output)); - - const double tolerance = 80; - double threshold = std::numeric_limits::epsilon() * tolerance; - auto error = miopen::rms_range(ref_out, output); - - EXPECT_FALSE(miopen::find_idx(ref_out, miopen::not_finite) >= 0) - << "Non finite number found in the CPU data"; - - EXPECT_TRUE(error < threshold) - << "Error beyond tolerance Error:" << error << ", Threshold: " << threshold; -} diff --git a/test/gtest/conv_test_base.hpp b/test/gtest/conv_test_base.hpp index 8a74d5c3a7..7099633b3f 100644 --- a/test/gtest/conv_test_base.hpp +++ b/test/gtest/conv_test_base.hpp @@ -108,7 +108,7 @@ void ConvFwdSolverTestBase::SetUpImpl(ConvTestCaseBase con conv_desc = conv_config.GetConv(); miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); output = tensor{tensor_layout, output_desc.GetLengths()}; std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); @@ -123,7 +123,7 @@ template void ConvFwdSolverTestBase::TearDownConv() { miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, GetDataType()); + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); ref_out = tensor{output.desc.GetLayout_t(), output_desc.GetLengths()}; if(use_cpu_ref) { diff --git a/test/gtest/group_conv3d_fwd.cpp b/test/gtest/group_conv3d_fwd.cpp index 551b9bb79b..a0d009122b 100644 --- a/test/gtest/group_conv3d_fwd.cpp +++ b/test/gtest/group_conv3d_fwd.cpp @@ -51,7 +51,7 @@ std::vector ConvTestConfigs() {5, 120, 60, 28, 28, 28, 60, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}}; } -struct ConvFwdSolverTest3D : ConvFwdSolverTest +struct ConvGroupFwdSolverTest3D : ConvFwdSolverTest { }; @@ -97,7 +97,7 @@ void SolverFwd(const miopen::TensorDescriptor& inputDesc, handle.Finish(); } -TEST_P(ConvFwdSolverTest3D, CKGroupConvFwd3D) +TEST_P(ConvGroupFwdSolverTest3D, CKGroupConvFwd3D) { SolverFwd(input.desc, in_dev.get(), @@ -111,7 +111,7 @@ TEST_P(ConvFwdSolverTest3D, CKGroupConvFwd3D) } INSTANTIATE_TEST_SUITE_P(ConvFwdTest, - ConvFwdSolverTest3D, + ConvGroupFwdSolverTest3D, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); diff --git a/test/gtest/nonpack_conv3d_fwd.cpp b/test/gtest/nonpack_conv3d_fwd.cpp index e0a9a55ccb..6b00e43eb2 100644 --- a/test/gtest/nonpack_conv3d_fwd.cpp +++ b/test/gtest/nonpack_conv3d_fwd.cpp @@ -32,7 +32,7 @@ #include "get_handle.hpp" #include "nonpack_conv3d_fwd.hpp" -struct ConvFwdSolverTest3D : ConvFwdSolverTest +struct ConvNonpackFwdSolverTest3D : ConvFwdSolverTest { }; @@ -78,7 +78,7 @@ void SolverFwd(const miopen::TensorDescriptor& inputDesc, handle.Finish(); } -TEST_P(ConvFwdSolverTest3D, CKNonPackConvFwd3D) +TEST_P(ConvNonpackFwdSolverTest3D, CKNonPackConvFwd3D) { SolverFwd(input.desc, in_dev.get(), @@ -92,7 +92,7 @@ TEST_P(ConvFwdSolverTest3D, CKNonPackConvFwd3D) } INSTANTIATE_TEST_SUITE_P(ConvFwdTest, - ConvFwdSolverTest3D, + ConvNonpackFwdSolverTest3D, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); diff --git a/test/gtest/solver_f8.hpp b/test/gtest/solver_f8.hpp index 587fe99a57..d987025544 100644 --- a/test/gtest/solver_f8.hpp +++ b/test/gtest/solver_f8.hpp @@ -37,8 +37,7 @@ #include "verify.hpp" #include "conv_test_base.hpp" -using float8 = miopen_f8::hip_f8; -using bfloat8 = miopen_f8::hip_f8; +#include "f8_cast_util.hpp" float scalar_gen_random_float(float low, float high) { @@ -79,27 +78,6 @@ struct ConvTestCaseF8 } }; -template -struct Fp8Cast -{ - uint64_t seed = 1234; - bool is_stoch = true; - V operator()(U x) - { - if(is_stoch) - { - auto tmp = - float8(static_cast(x), miopen_f8::hip_f8_rounding_mode::stochastic, seed); - return static_cast(tmp); - } - else - { - auto tmp = float8(static_cast(x)); - return static_cast(tmp); - } - } -}; - template struct ConvFwdSolverTestF8 : public ::testing::TestWithParam> From 3dc71ef31a6d05edb03b3607826eae02d74e29f0 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Tue, 12 Dec 2023 22:41:16 +0000 Subject: [PATCH 07/25] resolve compile errors --- test/gtest/group_conv_fwd.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/gtest/group_conv_fwd.cpp b/test/gtest/group_conv_fwd.cpp index ffa3d30b05..7523ca964f 100644 --- a/test/gtest/group_conv_fwd.cpp +++ b/test/gtest/group_conv_fwd.cpp @@ -32,7 +32,7 @@ #include "get_handle.hpp" #include "group_solver.hpp" -struct ConvFwdSolverTestFloat : ConvGroupFwdSolverTest +struct ConvGroupFwdSolverTestFloat : ConvGroupFwdSolverTest { }; @@ -78,7 +78,7 @@ void SolverFwd(const miopen::TensorDescriptor& inputDesc, handle.Finish(); } -TEST_P(ConvFwdSolverTestFloat, CKGroupConvFwd) +TEST_P(ConvGroupFwdSolverTestFloat, CKGroupConvFwd) { SolverFwd(input.desc, in_dev.get(), @@ -92,7 +92,7 @@ TEST_P(ConvFwdSolverTestFloat, CKGroupConvFwd) } INSTANTIATE_TEST_SUITE_P(ConvFwdTest, - ConvFwdSolverTestFloat, + ConvGroupFwdSolverTestFloat, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNHWC))); From 532c75f98100545be85f317d4768068419efd038 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Tue, 12 Dec 2023 22:52:03 +0000 Subject: [PATCH 08/25] reset hip_f8_impl --- src/kernels/hip_f8_impl.hpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/kernels/hip_f8_impl.hpp b/src/kernels/hip_f8_impl.hpp index 6767d6470d..c8d49cd474 100644 --- a/src/kernels/hip_f8_impl.hpp +++ b/src/kernels/hip_f8_impl.hpp @@ -23,15 +23,14 @@ * SOFTWARE. * *******************************************************************************/ -#include -#include +// #include +// #include +namespace miopen_hip_f8_impl { -//#ifndef __HIP_PLATFORM_HCC__ +#ifndef __HIP_PLATFORM_HCC__ using hip_bfloat16 = bfloat16; using half = half_float::half; -//#endif - -namespace miopen_hip_f8_impl { +#endif template MIOPEN_HIP_HOST_DEVICE uint8_t cast_to_f8_no_range_reduce(T _x, From 3e9d843ef880d18131790e6f186188d32a6405ae Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Tue, 12 Dec 2023 23:39:30 +0000 Subject: [PATCH 09/25] resolve warnings, cleanup --- test/gtest/CMakeLists.txt | 13 ----- test/gtest/bad_fusion_plan.cpp | 2 +- test/gtest/bn_test_data.cpp | 64 ------------------------ test/gtest/bn_test_data.hpp | 41 ++++++++++++++- test/gtest/cba_find2_infer.cpp | 13 ++--- test/gtest/cba_infer.cpp | 13 ++--- test/gtest/conv_embed_db.cpp | 6 ++- test/gtest/conv_f8_bwd.cpp | 2 +- test/gtest/conv_f8_fwd.cpp | 2 +- test/gtest/conv_f8_wrw.cpp | 2 +- test/gtest/conv_hip_igemm_xdlops.cpp | 2 +- test/gtest/conv_igemm_dynamic.cpp | 2 +- test/gtest/conv_igemm_mlir.cpp | 14 ++++-- test/gtest/conv_igemm_mlir_xdlops.cpp | 2 +- test/gtest/conv_test_base.cpp | 72 --------------------------- test/gtest/conv_test_base.hpp | 61 ++++++++++++++++++++--- test/gtest/conv_trans.cpp | 2 +- test/gtest/group_conv3d_bwd.cpp | 2 +- test/gtest/group_conv3d_fwd.cpp | 2 +- test/gtest/group_conv3d_wrw.cpp | 2 +- test/gtest/group_solver.cpp | 40 --------------- test/gtest/group_solver.hpp | 11 ++++ test/gtest/layernorm.cpp | 2 +- test/gtest/nonpack_conv3d_fwd.hpp | 2 +- test/gtest/solver_f8.cpp | 3 +- test/gtest/solver_f8.hpp | 2 +- test/gtest/sum.cpp | 2 +- 27 files changed, 148 insertions(+), 233 deletions(-) delete mode 100644 test/gtest/bn_test_data.cpp delete mode 100644 test/gtest/conv_test_base.cpp delete mode 100644 test/gtest/group_solver.cpp diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index 90749bc252..380e831b31 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -36,7 +36,6 @@ endforeach() -#function(add_gtest TEST_NAME) if( NOT (TEST_NAME IN_LIST SKIP_TESTS)) message("Adding miopen_gtest: " ${TESTS_CPP}) add_executable(miopen_gtest ${TESTS_CPP} ${SOURCES}) @@ -56,15 +55,3 @@ if( NOT (TEST_NAME IN_LIST SKIP_TESTS)) gtest_discover_tests(miopen_gtest PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL}") endif() -#endfunction() - -#file(GLOB TESTS *.cpp) -## Remove files that do not contain tests -#foreach(SOURCE ${SOURCES}) -# list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}) -#endforeach() -# -#foreach(TEST ${TESTS}) -# get_filename_component(BASE_NAME ${TEST} NAME_WE) -# add_gtest(${BASE_NAME}) -#endforeach() diff --git a/test/gtest/bad_fusion_plan.cpp b/test/gtest/bad_fusion_plan.cpp index 333c212774..4f4c6e4df8 100644 --- a/test/gtest/bad_fusion_plan.cpp +++ b/test/gtest/bad_fusion_plan.cpp @@ -258,4 +258,4 @@ TEST(TestFusionPlan, UnSupportedFusionPlanDuringSearchMode) #endif -} //namespace bad_fusion_plan +} // namespace bad_fusion_plan diff --git a/test/gtest/bn_test_data.cpp b/test/gtest/bn_test_data.cpp deleted file mode 100644 index 8e64487714..0000000000 --- a/test/gtest/bn_test_data.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * - * MIT License - * - * Copyright (c) 2023 Advanced Micro Devices, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - *******************************************************************************/ -#include "bn_test_data.hpp" - -template<> -std::vector Network1() -{ - // pyt_mlperf_resnet50v1.5 - return { - {192, 1, 8, 8, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 1, 0}, - {16, 8, 128, 256, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 0}, - {16, 8, 128, 256, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, - {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, - {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, - {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}}; -} - diff --git a/test/gtest/bn_test_data.hpp b/test/gtest/bn_test_data.hpp index 054d07f880..5304055fcb 100644 --- a/test/gtest/bn_test_data.hpp +++ b/test/gtest/bn_test_data.hpp @@ -55,8 +55,45 @@ struct BNTestCase std::vector GetInput() const { return {N, C, H, W}; } }; -template -extern std::vector Network1(); +template +std::vector Network1(); + +template <> +inline std::vector Network1() +{ + // pyt_mlperf_resnet50v1.5 + return { + {192, 1, 8, 8, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 1, 0}, + {16, 8, 128, 256, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 0}, + {16, 8, 128, 256, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 2048, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 256, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 256, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 256, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 512, 14, 14, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 512, 28, 28, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 512, 7, 7, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 64, 112, 112, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}, + {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::Backward, 0, 1}, + {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardTraining, 1, 1}, + {64, 64, 56, 56, miopenBNSpatial, miopen::batchnorm::Direction::ForwardInference, 1, 0}}; +} template struct BNTestData diff --git a/test/gtest/cba_find2_infer.cpp b/test/gtest/cba_find2_infer.cpp index 0b16c0520a..7aaa96c0fc 100644 --- a/test/gtest/cba_find2_infer.cpp +++ b/test/gtest/cba_find2_infer.cpp @@ -155,11 +155,12 @@ TEST_P(ConvBiasActivFind2InferTestFloatFusionFind, ConvBiasActivFind2Float_testF } } -INSTANTIATE_TEST_SUITE_P(CBAFind2InferSolverTest, - ConvBiasActivFind2InferTestFloatFusionFind, - testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(GetNetworkForFusionCompileStepTest()), - testing::Values(miopenTensorNCHW))); +INSTANTIATE_TEST_SUITE_P( + CBAFind2InferSolverTest, + ConvBiasActivFind2InferTestFloatFusionFind, + testing::Combine(testing::Values(miopenActivationRELU), + testing::ValuesIn(GetNetworkForFusionCompileStepTest()), + testing::Values(miopenTensorNCHW))); #endif @@ -175,4 +176,4 @@ INSTANTIATE_TEST_SUITE_P(CBAFind2InferSolverTest, testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNHWC))); -} //namespace cba_find2_infer +} // namespace cba_find2_infer diff --git a/test/gtest/cba_infer.cpp b/test/gtest/cba_infer.cpp index f5870688e3..f92bce732c 100644 --- a/test/gtest/cba_infer.cpp +++ b/test/gtest/cba_infer.cpp @@ -160,11 +160,12 @@ TEST_P(ConvBiasActivInferTestFloatFusionCompileStep, ConvBiasActivAsm1x1UFloat_t fusePlanDesc, plan_params, conv_config, test_skipped); } -INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest, - ConvBiasActivInferTestFloatFusionCompileStep, - testing::Combine(testing::Values(miopenActivationRELU), - testing::ValuesIn(GetNetworkForFusionCompileStepTest()), - testing::Values(miopenTensorNCHW))); +INSTANTIATE_TEST_SUITE_P( + CBAInferSolverTest, + ConvBiasActivInferTestFloatFusionCompileStep, + testing::Combine(testing::Values(miopenActivationRELU), + testing::ValuesIn(GetNetworkForFusionCompileStepTest()), + testing::Values(miopenTensorNCHW))); #endif @@ -180,4 +181,4 @@ INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest, testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNHWC))); -} //namespace cba_infer +} // namespace cba_infer diff --git a/test/gtest/conv_embed_db.cpp b/test/gtest/conv_embed_db.cpp index 7b21b9c535..57e82cea64 100644 --- a/test/gtest/conv_embed_db.cpp +++ b/test/gtest/conv_embed_db.cpp @@ -224,11 +224,13 @@ std::vector GetTestCases(const std::string& precision) return test_cases; } -INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConvEmbedConfigFloat, testing::Values(GetTestCases("--float"))); +INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, + ConvEmbedConfigFloat, + testing::Values(GetTestCases("--float"))); INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConvEmbedConfigHalf, testing::Values(GetTestCases("--half"))); INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConvEmbedConfigInt8, testing::Values(GetTestCases("--int8"))); INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConvEmbedConfigBFloat16, testing::Values(GetTestCases("--bfloat16"))); -} //namespace conv_embed_db +} // namespace conv_embed_db diff --git a/test/gtest/conv_f8_bwd.cpp b/test/gtest/conv_f8_bwd.cpp index 72f47a459d..9b48e01887 100644 --- a/test/gtest/conv_f8_bwd.cpp +++ b/test/gtest/conv_f8_bwd.cpp @@ -195,4 +195,4 @@ INSTANTIATE_TEST_SUITE_P(ConvBwdTest, testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); -} //namespace conv_f8_bwd +} // namespace conv_f8_bwd diff --git a/test/gtest/conv_f8_fwd.cpp b/test/gtest/conv_f8_fwd.cpp index 9886a5e3b3..8432c2220c 100644 --- a/test/gtest/conv_f8_fwd.cpp +++ b/test/gtest/conv_f8_fwd.cpp @@ -194,4 +194,4 @@ INSTANTIATE_TEST_SUITE_P(ConvFwdTest, testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); -} //namespace conv_f8_fwd +} // namespace conv_f8_fwd diff --git a/test/gtest/conv_f8_wrw.cpp b/test/gtest/conv_f8_wrw.cpp index c2472c9683..ce0808ab64 100644 --- a/test/gtest/conv_f8_wrw.cpp +++ b/test/gtest/conv_f8_wrw.cpp @@ -200,4 +200,4 @@ INSTANTIATE_TEST_SUITE_P( testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); -} //namespace conv_f8_wrw +} // namespace conv_f8_wrw diff --git a/test/gtest/conv_hip_igemm_xdlops.cpp b/test/gtest/conv_hip_igemm_xdlops.cpp index bf121c549d..ab746e2011 100644 --- a/test/gtest/conv_hip_igemm_xdlops.cpp +++ b/test/gtest/conv_hip_igemm_xdlops.cpp @@ -170,4 +170,4 @@ INSTANTIATE_TEST_SUITE_P(ConvHipIgemmXdlops, ConvHipIgemmXdlopsConfigInt8, testing::Values(GetTestCases("--int8"))); -} //namespace conv_hip_igem_xdlops +} // namespace conv_hip_igem_xdlops diff --git a/test/gtest/conv_igemm_dynamic.cpp b/test/gtest/conv_igemm_dynamic.cpp index 4fb2110d9e..a5217e176a 100644 --- a/test/gtest/conv_igemm_dynamic.cpp +++ b/test/gtest/conv_igemm_dynamic.cpp @@ -189,4 +189,4 @@ std::vector GetTestCases(const std::string& precision) INSTANTIATE_TEST_SUITE_P(ConvIgemmDynamic, Conv2dFloat, testing::Values(GetTestCases("--float"))); -} //namespace conv_igemm_dynamic +} // namespace conv_igemm_dynamic diff --git a/test/gtest/conv_igemm_mlir.cpp b/test/gtest/conv_igemm_mlir.cpp index 53c846a95a..231c24f535 100644 --- a/test/gtest/conv_igemm_mlir.cpp +++ b/test/gtest/conv_igemm_mlir.cpp @@ -245,10 +245,16 @@ std::vector GetTestCases(const std::string& precision) return test_cases; } // Float for FWD, BWD, WRW -INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConvIgemmMlirConfigFloat, testing::Values(GetTestCases("--float"))); +INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, + ConvIgemmMlirConfigFloat, + testing::Values(GetTestCases("--float"))); // Half for FWD, BWD, WRW -INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConvIgemmMlirConfigHalf, testing::Values(GetTestCases("--half"))); +INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, + ConvIgemmMlirConfigHalf, + testing::Values(GetTestCases("--half"))); // Int8 for FWD -INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConvIgemmMlirConfigInt8, testing::Values(GetTestCases("--int8"))); +INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, + ConvIgemmMlirConfigInt8, + testing::Values(GetTestCases("--int8"))); -} //namespace conv_igemm_mlir +} // namespace conv_igemm_mlir diff --git a/test/gtest/conv_igemm_mlir_xdlops.cpp b/test/gtest/conv_igemm_mlir_xdlops.cpp index b0622bff46..4117f3c761 100644 --- a/test/gtest/conv_igemm_mlir_xdlops.cpp +++ b/test/gtest/conv_igemm_mlir_xdlops.cpp @@ -205,4 +205,4 @@ INSTANTIATE_TEST_SUITE_P(ConvIgemmMlirXdlops, ConvIgemmMlirXdlopsConfigInt8, testing::Values(GetTestCases("--int8"))); -} //namespace conv_igemm_mlir_xdlops +} // namespace conv_igemm_mlir_xdlops diff --git a/test/gtest/conv_test_base.cpp b/test/gtest/conv_test_base.cpp deleted file mode 100644 index 51c7bed699..0000000000 --- a/test/gtest/conv_test_base.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * - * MIT License - * - * Copyright (c) 2023 Advanced Micro Devices, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - *******************************************************************************/ -#include "conv_test_base.hpp" - -template<> -std::vector GetNetworkForFusionCompileStepTest() -{ - return {{1, 64, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {1, 64, 56, 56, 64, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} - -template<> -std::vector GetNetwork1() -{ - // pyt_mlperf_resnet50v1.5 - return {{64, 1024, 14, 14, 2048, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, - {64, 1024, 14, 14, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 1024, 14, 14, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 28, 28, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 28, 28, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 56, 56, 128, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, - {64, 2048, 7, 7, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 14, 14, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 14, 14, 256, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 28, 28, 256, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, - {64, 256, 56, 56, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 56, 56, 512, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, - {64, 256, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 3, 224, 224, 64, 7, 7, 3, 3, 2, 2, 1, 1, miopenConvolution}, - {64, 512, 14, 14, 512, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, - {64, 512, 28, 28, 1024, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, - {64, 512, 28, 28, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 512, 28, 28, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 512, 7, 7, 2048, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 512, 7, 7, 512, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 64, 56, 56, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 64, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, - {64, 64, 56, 56, 64, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} - -template<> -std::vector ConvTestConfigs() -{ // n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y - return {{16, 128, 16, 16, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 128, 28, 28, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 256, 14, 14, 256, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 512, 7, 7, 512, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {64, 1024, 14, 14, 1024, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} diff --git a/test/gtest/conv_test_base.hpp b/test/gtest/conv_test_base.hpp index 7099633b3f..5649624c72 100644 --- a/test/gtest/conv_test_base.hpp +++ b/test/gtest/conv_test_base.hpp @@ -68,14 +68,60 @@ struct ConvTestCaseBase } }; -template -extern std::vector GetNetworkForFusionCompileStepTest(); +template +std::vector GetNetworkForFusionCompileStepTest(); -template -extern std::vector GetNetwork1(); +template <> +inline std::vector GetNetworkForFusionCompileStepTest() +{ + return {{1, 64, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {1, 64, 56, 56, 64, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} -template -extern std::vector ConvTestConfigs(); +template +std::vector GetNetwork1(); + +template <> +inline std::vector GetNetwork1() +{ + // pyt_mlperf_resnet50v1.5 + return {{64, 1024, 14, 14, 2048, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, + {64, 1024, 14, 14, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 1024, 14, 14, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 28, 28, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 28, 28, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 56, 56, 128, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, + {64, 2048, 7, 7, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 14, 14, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 14, 14, 256, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 28, 28, 256, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, + {64, 256, 56, 56, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 56, 56, 512, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, + {64, 256, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 3, 224, 224, 64, 7, 7, 3, 3, 2, 2, 1, 1, miopenConvolution}, + {64, 512, 14, 14, 512, 3, 3, 1, 1, 2, 2, 1, 1, miopenConvolution}, + {64, 512, 28, 28, 1024, 1, 1, 0, 0, 2, 2, 1, 1, miopenConvolution}, + {64, 512, 28, 28, 128, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 512, 28, 28, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 512, 7, 7, 2048, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 512, 7, 7, 512, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 64, 56, 56, 256, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 64, 56, 56, 64, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, + {64, 64, 56, 56, 64, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} + +template +std::vector ConvTestConfigs(); + +template <> +inline std::vector ConvTestConfigs() +{ // n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y + return {{16, 128, 16, 16, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 128, 28, 28, 128, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 256, 14, 14, 256, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 512, 7, 7, 512, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {64, 1024, 14, 14, 1024, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} template struct ConvFwdSolverTestBase @@ -98,7 +144,8 @@ struct ConvFwdSolverTestBase }; template -void ConvFwdSolverTestBase::SetUpImpl(ConvTestCaseBase conv_config, miopenTensorLayout_t tensor_layout) +void ConvFwdSolverTestBase::SetUpImpl(ConvTestCaseBase conv_config, + miopenTensorLayout_t tensor_layout) { input = tensor{tensor_layout, conv_config.GetInput()}; weights = tensor{tensor_layout, conv_config.GetWeights()}; diff --git a/test/gtest/conv_trans.cpp b/test/gtest/conv_trans.cpp index 41072a7662..2aa1dd825c 100644 --- a/test/gtest/conv_trans.cpp +++ b/test/gtest/conv_trans.cpp @@ -154,4 +154,4 @@ std::vector GetTestCases(void) INSTANTIATE_TEST_SUITE_P(ConvTrans, ConfigWithFloat, testing::Values(GetTestCases())); -} //namespace conv_trans +} // namespace conv_trans diff --git a/test/gtest/group_conv3d_bwd.cpp b/test/gtest/group_conv3d_bwd.cpp index a1d908c95e..a427a1a907 100644 --- a/test/gtest/group_conv3d_bwd.cpp +++ b/test/gtest/group_conv3d_bwd.cpp @@ -110,4 +110,4 @@ INSTANTIATE_TEST_SUITE_P(ConvBwdTest, testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); -} //namespace group_conv3d_bwd +} // namespace group_conv3d_bwd diff --git a/test/gtest/group_conv3d_fwd.cpp b/test/gtest/group_conv3d_fwd.cpp index a0d009122b..de8001e722 100644 --- a/test/gtest/group_conv3d_fwd.cpp +++ b/test/gtest/group_conv3d_fwd.cpp @@ -116,4 +116,4 @@ INSTANTIATE_TEST_SUITE_P(ConvFwdTest, testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); -} //namespace group_conv3d_fwd +} // namespace group_conv3d_fwd diff --git a/test/gtest/group_conv3d_wrw.cpp b/test/gtest/group_conv3d_wrw.cpp index acb28f3058..7ba2ba2b60 100644 --- a/test/gtest/group_conv3d_wrw.cpp +++ b/test/gtest/group_conv3d_wrw.cpp @@ -113,4 +113,4 @@ INSTANTIATE_TEST_SUITE_P( testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); -} //namespace group_conv3d_wrw +} // namespace group_conv3d_wrw diff --git a/test/gtest/group_solver.cpp b/test/gtest/group_solver.cpp deleted file mode 100644 index 2eb398f45d..0000000000 --- a/test/gtest/group_solver.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * - * MIT License - * - * Copyright (c) 2023 Advanced Micro Devices, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - *******************************************************************************/ - -#include "group_solver.hpp" - - -template<> -std::vector ConvTestConfigs() -{ // g n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y - return {{1, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {1, 256, 12, 28, 28, 12, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {4, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {8, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {8, 256, 384, 28, 28, 384, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, - {32, 256, 1024, 28, 28, 2048, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; -} - diff --git a/test/gtest/group_solver.hpp b/test/gtest/group_solver.hpp index 746822c644..ee03f880d5 100644 --- a/test/gtest/group_solver.hpp +++ b/test/gtest/group_solver.hpp @@ -81,6 +81,17 @@ struct ConvTestCaseGroup } }; +template <> +inline std::vector ConvTestConfigs() +{ // g n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y + return {{1, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {1, 256, 12, 28, 28, 12, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {4, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {8, 256, 192, 28, 28, 192, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {8, 256, 384, 28, 28, 384, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}, + {32, 256, 1024, 28, 28, 2048, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; +} + inline int SetTensorLayout(miopen::TensorDescriptor& desc) { // get layout string names diff --git a/test/gtest/layernorm.cpp b/test/gtest/layernorm.cpp index a5c2c7cfdc..7bb3a8f94f 100644 --- a/test/gtest/layernorm.cpp +++ b/test/gtest/layernorm.cpp @@ -66,4 +66,4 @@ INSTANTIATE_TEST_SUITE_P(LayerNormTestSet, LayerNormTestFloat, testing::ValuesIn(LayerNormTestConfigs())); -} //namespace layernorm +} // namespace layernorm diff --git a/test/gtest/nonpack_conv3d_fwd.hpp b/test/gtest/nonpack_conv3d_fwd.hpp index 916e3ba3ab..b69ba977cc 100644 --- a/test/gtest/nonpack_conv3d_fwd.hpp +++ b/test/gtest/nonpack_conv3d_fwd.hpp @@ -49,7 +49,7 @@ struct NonPackTestCase : Conv3DTestCase std::vector GetOutputStrides() { return {o0, o1, o2, o3, o4}; } }; -template<> +template <> std::vector ConvTestConfigs() { // g n c d h w k z y x pad_x pad_y pad_z stri_x stri_y stri_z dia_x dia_y dia_z return {{{1, 4, 16, 4, 9, 16, 16, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, miopenConvolution}, diff --git a/test/gtest/solver_f8.cpp b/test/gtest/solver_f8.cpp index c6032ada5c..0caa2f70a7 100644 --- a/test/gtest/solver_f8.cpp +++ b/test/gtest/solver_f8.cpp @@ -25,7 +25,7 @@ *******************************************************************************/ #include "solver_f8.hpp" -template<> +template <> std::vector ConvTestConfigs() { // n c h w k y x pad_x pad_y stri_x stri_y dia_x dia_y return {// New tests begin @@ -63,4 +63,3 @@ std::vector ConvTestConfigs() {64, 512, 7, 7, 512, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}, {64, 1024, 14, 14, 1024, 1, 1, 0, 0, 1, 1, 1, 1, miopenConvolution}}; } - diff --git a/test/gtest/solver_f8.hpp b/test/gtest/solver_f8.hpp index d987025544..bf6fccc163 100644 --- a/test/gtest/solver_f8.hpp +++ b/test/gtest/solver_f8.hpp @@ -41,7 +41,7 @@ float scalar_gen_random_float(float low, float high) { - float r = static_cast(rand()) / static_cast(RAND_MAX) * (high+low) - low; + float r = static_cast(rand()) / static_cast(RAND_MAX) * (high + low) - low; return r; } diff --git a/test/gtest/sum.cpp b/test/gtest/sum.cpp index b6aa5daff3..d847d5550b 100644 --- a/test/gtest/sum.cpp +++ b/test/gtest/sum.cpp @@ -60,4 +60,4 @@ TEST_P(SumTestFloat, SumTestFw) INSTANTIATE_TEST_SUITE_P(SumTestSet, SumTestFloat, testing::ValuesIn(SumTestConfigs())); -} //namespace sum +} // namespace sum From 9c45745751e8aef0092fccedeaf0c7ab2b883022 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Wed, 13 Dec 2023 22:10:43 +0000 Subject: [PATCH 10/25] remove if block from cmake --- test/gtest/CMakeLists.txt | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index 380e831b31..70ed14ca50 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -36,22 +36,19 @@ endforeach() -if( NOT (TEST_NAME IN_LIST SKIP_TESTS)) - message("Adding miopen_gtest: " ${TESTS_CPP}) - add_executable(miopen_gtest ${TESTS_CPP} ${SOURCES}) - add_dependencies(tests miopen_gtest) - add_dependencies(check miopen_gtest) - target_compile_options(miopen_gtest PRIVATE -Wno-global-constructors -Wno-undef) - target_include_directories(miopen_gtest PRIVATE ../ ../../src/kernels) - if(MIOPEN_ENABLE_AI_KERNEL_TUNING) - target_include_directories(miopen_gtest SYSTEM PRIVATE $) - target_include_directories(miopen_gtest SYSTEM PRIVATE $) - endif() - target_link_libraries(miopen_gtest GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $) - if(NOT MIOPEN_EMBED_DB STREQUAL "") - target_link_libraries(miopen_gtest $) - endif() - # Enable CMake to discover the test binary - gtest_discover_tests(miopen_gtest PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL}") - +message("Adding miopen_gtest: " ${TESTS_CPP}) +add_executable(miopen_gtest ${TESTS_CPP} ${SOURCES}) +add_dependencies(tests miopen_gtest) +add_dependencies(check miopen_gtest) +target_compile_options(miopen_gtest PRIVATE -Wno-global-constructors -Wno-undef) +target_include_directories(miopen_gtest PRIVATE ../ ../../src/kernels) +if(MIOPEN_ENABLE_AI_KERNEL_TUNING) + target_include_directories(miopen_gtest SYSTEM PRIVATE $) + target_include_directories(miopen_gtest SYSTEM PRIVATE $) +endif() +target_link_libraries(miopen_gtest GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $) +if(NOT MIOPEN_EMBED_DB STREQUAL "") + target_link_libraries(miopen_gtest $) endif() +# Enable CMake to discover the test binary +gtest_discover_tests(miopen_gtest PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL}") From 89f478263cab3beb61ceeb9e94fcbdf87b114267 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Thu, 14 Dec 2023 20:19:49 +0000 Subject: [PATCH 11/25] add gtest binary to deb package --- test/CMakeLists.txt | 5 ++--- test/gtest/CMakeLists.txt | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 52fd341f1b..745107e7d4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2287,6 +2287,5 @@ add_custom_test(test_regression_half_mi200 GFX900_DISABLED GFX906_DISABLED GFX90 ENVIRONMENT ${ENVS_FIND_ONLY_HIP_IGEMM_V4R4XDLOPS} COMMAND $ ${MIOPEN_TEST_FLOAT_ARG} --cmode conv --pmode default --input 120 64 75 75 --weights 128 64 1 1 --pads_strides_dilations 0 0 2 2 1 1 ${ARGS_ENABLE_FORWARD_ONLY} ) -#override if we need to install gtests -set(INSTALL_GTEST OFF) -add_subdirectory(gtest EXCLUDE_FROM_ALL) + +add_subdirectory(gtest) diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index 70ed14ca50..98d55f8137 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -35,7 +35,6 @@ foreach(TEST ${TESTS}) endforeach() - message("Adding miopen_gtest: " ${TESTS_CPP}) add_executable(miopen_gtest ${TESTS_CPP} ${SOURCES}) add_dependencies(tests miopen_gtest) @@ -52,3 +51,9 @@ if(NOT MIOPEN_EMBED_DB STREQUAL "") endif() # Enable CMake to discover the test binary gtest_discover_tests(miopen_gtest PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL}") + +if( NOT ENABLE_ASAN_PACKAGING ) + install(TARGETS miopen_gtest + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() From f529d952b211bdf6e41cfb6dba44cab0fb89062a Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Thu, 14 Dec 2023 20:42:19 +0000 Subject: [PATCH 12/25] tidy --- test/gtest/conv_test_base.hpp | 128 ++++++++++++++++------------------ 1 file changed, 59 insertions(+), 69 deletions(-) diff --git a/test/gtest/conv_test_base.hpp b/test/gtest/conv_test_base.hpp index 5649624c72..e68e346c19 100644 --- a/test/gtest/conv_test_base.hpp +++ b/test/gtest/conv_test_base.hpp @@ -127,84 +127,74 @@ template struct ConvFwdSolverTestBase { protected: - void SetUpImpl(ConvTestCaseBase conv_config, miopenTensorLayout_t tensor_layout); - - void TearDownConv(); - - void ThresholdChecks(); - - miopen::ConvolutionDescriptor conv_desc; - tensor input; - tensor weights; - tensor output; - tensor ref_out; - miopen::Allocator::ManageDataPtr in_dev; - miopen::Allocator::ManageDataPtr wei_dev; - miopen::Allocator::ManageDataPtr out_dev; -}; - -template -void ConvFwdSolverTestBase::SetUpImpl(ConvTestCaseBase conv_config, - miopenTensorLayout_t tensor_layout) -{ - input = tensor{tensor_layout, conv_config.GetInput()}; - weights = tensor{tensor_layout, conv_config.GetWeights()}; - input.generate(GenData{}); - weights.generate(GenWeights{}); + void SetUpImpl(ConvTestCaseBase conv_config, miopenTensorLayout_t tensor_layout) + { + input = tensor{tensor_layout, conv_config.GetInput()}; + weights = tensor{tensor_layout, conv_config.GetWeights()}; + input.generate(GenData{}); + weights.generate(GenWeights{}); - conv_desc = conv_config.GetConv(); + conv_desc = conv_config.GetConv(); - miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); + miopen::TensorDescriptor output_desc = + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); - output = tensor{tensor_layout, output_desc.GetLengths()}; - std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); + output = tensor{tensor_layout, output_desc.GetLengths()}; + std::fill(output.begin(), output.end(), std::numeric_limits::quiet_NaN()); - auto&& handle = get_handle(); - in_dev = handle.Write(input.data); - wei_dev = handle.Write(weights.data); - out_dev = handle.Write(output.data); -} + auto&& handle = get_handle(); + in_dev = handle.Write(input.data); + wei_dev = handle.Write(weights.data); + out_dev = handle.Write(output.data); + } -template -void ConvFwdSolverTestBase::TearDownConv() -{ - miopen::TensorDescriptor output_desc = - conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); - ref_out = tensor{output.desc.GetLayout_t(), output_desc.GetLengths()}; - if(use_cpu_ref) + void TearDownConv() { - cpu_convolution_forward(conv_desc.GetSpatialDimension(), - input, - weights, - ref_out, - conv_desc.GetConvPads(), - conv_desc.GetConvStrides(), - conv_desc.GetConvDilations(), - conv_desc.GetGroupCount()); + miopen::TensorDescriptor output_desc = + conv_desc.GetForwardOutputTensor(input.desc, weights.desc, miopen_type{}); + ref_out = tensor{output.desc.GetLayout_t(), output_desc.GetLengths()}; + if(use_cpu_ref) + { + cpu_convolution_forward(conv_desc.GetSpatialDimension(), + input, + weights, + ref_out, + conv_desc.GetConvPads(), + conv_desc.GetConvStrides(), + conv_desc.GetConvDilations(), + conv_desc.GetGroupCount()); + } + else + { + ref_out = ref_conv_fwd(input, weights, ref_out, conv_desc); + } } - else + + void ThresholdChecks() { - ref_out = ref_conv_fwd(input, weights, ref_out, conv_desc); - } -} + auto&& handle = get_handle(); + output.data = handle.Read(out_dev, output.data.size()); + EXPECT_FALSE(miopen::range_zero(ref_out)) << "Cpu data is all zeros"; + EXPECT_FALSE(miopen::range_zero(output)) << "Gpu data is all zeros"; + EXPECT_TRUE(miopen::range_distance(ref_out) == miopen::range_distance(output)); -template -void ConvFwdSolverTestBase::ThresholdChecks() -{ - auto&& handle = get_handle(); - output.data = handle.Read(out_dev, output.data.size()); - EXPECT_FALSE(miopen::range_zero(ref_out)) << "Cpu data is all zeros"; - EXPECT_FALSE(miopen::range_zero(output)) << "Gpu data is all zeros"; - EXPECT_TRUE(miopen::range_distance(ref_out) == miopen::range_distance(output)); + const double tolerance = 80; + double threshold = std::numeric_limits::epsilon() * tolerance; + auto error = miopen::rms_range(ref_out, output); - const double tolerance = 80; - double threshold = std::numeric_limits::epsilon() * tolerance; - auto error = miopen::rms_range(ref_out, output); + EXPECT_FALSE(miopen::find_idx(ref_out, miopen::not_finite) >= 0) + << "Non finite number found in the CPU data"; - EXPECT_FALSE(miopen::find_idx(ref_out, miopen::not_finite) >= 0) - << "Non finite number found in the CPU data"; + EXPECT_TRUE(error < threshold) + << "Error beyond tolerance Error:" << error << ", Threshold: " << threshold; + } - EXPECT_TRUE(error < threshold) - << "Error beyond tolerance Error:" << error << ", Threshold: " << threshold; -} + miopen::ConvolutionDescriptor conv_desc; + tensor input; + tensor weights; + tensor output; + tensor ref_out; + miopen::Allocator::ManageDataPtr in_dev; + miopen::Allocator::ManageDataPtr wei_dev; + miopen::Allocator::ManageDataPtr out_dev; +}; From c67f69ebeb6295d19de3036697fc0b7da8eebfb0 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Thu, 14 Dec 2023 23:08:04 +0000 Subject: [PATCH 13/25] move namespace for hip tidy to recognize gtest macro --- test/gtest/bad_fusion_plan.cpp | 8 +- test/gtest/cba_find2_infer.cpp | 4 +- test/gtest/cba_infer.cpp | 3 +- test/gtest/conv_embed_db.cpp | 79 +++++++-------- test/gtest/conv_f8_bwd.cpp | 4 +- test/gtest/conv_f8_fwd.cpp | 5 +- test/gtest/conv_f8_wrw.cpp | 3 +- test/gtest/conv_hip_igemm_xdlops.cpp | 47 ++++----- test/gtest/conv_igemm_dynamic.cpp | 31 +++--- test/gtest/conv_igemm_mlir.cpp | 132 +++++++++++++------------- test/gtest/conv_igemm_mlir_xdlops.cpp | 94 +++++++++--------- test/gtest/conv_trans.cpp | 31 +++--- test/gtest/group_conv3d_bwd.cpp | 5 +- test/gtest/group_conv3d_fwd.cpp | 5 +- test/gtest/group_conv3d_wrw.cpp | 5 +- test/gtest/layernorm.cpp | 5 +- test/gtest/sum.cpp | 5 +- 17 files changed, 244 insertions(+), 222 deletions(-) diff --git a/test/gtest/bad_fusion_plan.cpp b/test/gtest/bad_fusion_plan.cpp index 4f4c6e4df8..41bd9e7ed5 100644 --- a/test/gtest/bad_fusion_plan.cpp +++ b/test/gtest/bad_fusion_plan.cpp @@ -31,10 +31,11 @@ #include "get_handle.hpp" #include "conv_test_base.hpp" -namespace bad_fusion_plan { #if MIOPEN_BACKEND_HIP +namespace bad_fusion_plan { + void setEnvironmentVariable(const std::string& name, const std::string& value) { int ret = 0; @@ -166,6 +167,9 @@ class TestFusionPlan bool skip_test; }; +} // namespace bad_fusion_plan +using namespace bad_fusion_plan; + TEST(TestFusionPlan, GoodFusionPlan) { TestFusionPlan obj( @@ -257,5 +261,3 @@ TEST(TestFusionPlan, UnSupportedFusionPlanDuringSearchMode) } #endif - -} // namespace bad_fusion_plan diff --git a/test/gtest/cba_find2_infer.cpp b/test/gtest/cba_find2_infer.cpp index 7aaa96c0fc..030d4e3515 100644 --- a/test/gtest/cba_find2_infer.cpp +++ b/test/gtest/cba_find2_infer.cpp @@ -103,6 +103,9 @@ void RunTunableSolver(miopen::FusedProblem& problem, handle.Finish(); } +} // namespace cba_find2_infer +using namespace cba_find2_infer; + TEST_P(ConvBiasActivFind2InferTestFloat, ConvBiasActivAsm1x1UFind2Float) { RunTunableSolver( @@ -176,4 +179,3 @@ INSTANTIATE_TEST_SUITE_P(CBAFind2InferSolverTest, testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNHWC))); -} // namespace cba_find2_infer diff --git a/test/gtest/cba_infer.cpp b/test/gtest/cba_infer.cpp index f92bce732c..5a9a8009a0 100644 --- a/test/gtest/cba_infer.cpp +++ b/test/gtest/cba_infer.cpp @@ -110,6 +110,8 @@ void RunTunableSolver(miopen::FusionPlanDescriptor& fusePlanDesc, (invoker)(handle, *(plan_params.get())); handle.Finish(); } +} // namespace cba_infer +using namespace cba_infer; TEST_P(ConvBiasActivInferTestFloat, ConvBiasActivAsm1x1UFloat) { @@ -181,4 +183,3 @@ INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest, testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNHWC))); -} // namespace cba_infer diff --git a/test/gtest/conv_embed_db.cpp b/test/gtest/conv_embed_db.cpp index 57e82cea64..fe239cab09 100644 --- a/test/gtest/conv_embed_db.cpp +++ b/test/gtest/conv_embed_db.cpp @@ -111,6 +111,46 @@ bool IsTestSupportedForDevice(const miopen::Handle& handle) return false; } +std::vector GetTestCases(const std::string& precision) +{ + std::string flags = " --disable-validation --verbose "; + + // If precision env var is not set + if(!(IsTestRunWith("--float") || IsTestRunWith("--half") || IsTestRunWith("--int8") || + IsTestRunWith("--bfloat16"))) + flags.insert(0, precision); + + const std::vector test_cases = { + // clang-format off + {flags + "--input 128 128 28 28 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, + {flags + "--input 128 256 56 56 --weights 512 256 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, + {flags + "--input 128 3 230 230 --weights 64 3 7 7 --pads_strides_dilations 0 0 2 2 1 1"}, + {flags + "--input 128 64 56 56 --weights 64 64 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, + {flags + "--input 128 256 14 14 --weights 256 256 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, + {flags + "--input 128 512 7 7 --weights 512 512 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, + {flags + "--input 128 1024 14 14 --weights 512 1024 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, + {flags + "--input 128 1024 14 14 --weights 2048 1024 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, + {flags + "--input 128 256 14 14 --weights 1024 256 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + {flags + "--input 128 512 28 28 --weights 256 512 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, + {flags + "--input 128 1024 14 14 --weights 256 1024 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + {flags + "--input 128 64 56 56 --weights 256 64 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + {flags + "--input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + {flags + "--input 128 128 28 28 --weights 512 128 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + {flags + "--input 128 256 56 56 --weights 128 256 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, + {flags + "--input 128 256 56 56 --weights 64 256 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + {flags + "--input 128 512 28 28 --weights 1024 512 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, + {flags + "--input 128 512 28 28 --weights 128 512 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + {flags + "--input 128 512 7 7 --weights 2048 512 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + {flags + "--input 128 2048 7 7 --weights 512 2048 1 1 --pads_strides_dilations 0 0 1 1 1 1"} + // clang-format on + }; + + return test_cases; +} + +} // namespace conv_embed_db +using namespace conv_embed_db; + TEST_P(ConvEmbedConfigFloat, FloatTest) { #if MIOPEN_EMBED_DB @@ -187,43 +227,6 @@ TEST_P(ConvEmbedConfigBFloat16, BFloat16Test) #endif }; -std::vector GetTestCases(const std::string& precision) -{ - std::string flags = " --disable-validation --verbose "; - - // If precision env var is not set - if(!(IsTestRunWith("--float") || IsTestRunWith("--half") || IsTestRunWith("--int8") || - IsTestRunWith("--bfloat16"))) - flags.insert(0, precision); - - const std::vector test_cases = { - // clang-format off - {flags + "--input 128 128 28 28 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, - {flags + "--input 128 256 56 56 --weights 512 256 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, - {flags + "--input 128 3 230 230 --weights 64 3 7 7 --pads_strides_dilations 0 0 2 2 1 1"}, - {flags + "--input 128 64 56 56 --weights 64 64 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, - {flags + "--input 128 256 14 14 --weights 256 256 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, - {flags + "--input 128 512 7 7 --weights 512 512 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, - {flags + "--input 128 1024 14 14 --weights 512 1024 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, - {flags + "--input 128 1024 14 14 --weights 2048 1024 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, - {flags + "--input 128 256 14 14 --weights 1024 256 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - {flags + "--input 128 512 28 28 --weights 256 512 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, - {flags + "--input 128 1024 14 14 --weights 256 1024 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - {flags + "--input 128 64 56 56 --weights 256 64 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - {flags + "--input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - {flags + "--input 128 128 28 28 --weights 512 128 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - {flags + "--input 128 256 56 56 --weights 128 256 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, - {flags + "--input 128 256 56 56 --weights 64 256 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - {flags + "--input 128 512 28 28 --weights 1024 512 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, - {flags + "--input 128 512 28 28 --weights 128 512 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - {flags + "--input 128 512 7 7 --weights 2048 512 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - {flags + "--input 128 2048 7 7 --weights 512 2048 1 1 --pads_strides_dilations 0 0 1 1 1 1"} - // clang-format on - }; - - return test_cases; -} - INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConvEmbedConfigFloat, testing::Values(GetTestCases("--float"))); @@ -232,5 +235,3 @@ INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConvEmbedConfigInt8, testing::Values(GetTe INSTANTIATE_TEST_SUITE_P(ConvEmbedDB, ConvEmbedConfigBFloat16, testing::Values(GetTestCases("--bfloat16"))); - -} // namespace conv_embed_db diff --git a/test/gtest/conv_f8_bwd.cpp b/test/gtest/conv_f8_bwd.cpp index 9b48e01887..cf2765375b 100644 --- a/test/gtest/conv_f8_bwd.cpp +++ b/test/gtest/conv_f8_bwd.cpp @@ -176,6 +176,9 @@ void SolverBwd(const miopen::TensorDescriptor& inputDesc, handle.Finish(); } +} // namespace conv_f8_bwd +using namespace conv_f8_bwd; + TEST_P(ConvBwdSolverTestF8, CKConvF8Bwd) { SolverBwd(input.desc, @@ -195,4 +198,3 @@ INSTANTIATE_TEST_SUITE_P(ConvBwdTest, testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); -} // namespace conv_f8_bwd diff --git a/test/gtest/conv_f8_fwd.cpp b/test/gtest/conv_f8_fwd.cpp index 8432c2220c..766b8b3d51 100644 --- a/test/gtest/conv_f8_fwd.cpp +++ b/test/gtest/conv_f8_fwd.cpp @@ -175,6 +175,9 @@ void SolverFwd(const miopen::TensorDescriptor& inputDesc, handle.Finish(); } +} // namespace conv_f8_fwd +using namespace conv_f8_fwd; + TEST_P(ConvFwdSolverTestF8, CKConvF8Fwd) { SolverFwd(input.desc, @@ -193,5 +196,3 @@ INSTANTIATE_TEST_SUITE_P(ConvFwdTest, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); - -} // namespace conv_f8_fwd diff --git a/test/gtest/conv_f8_wrw.cpp b/test/gtest/conv_f8_wrw.cpp index ce0808ab64..2a06bd5d27 100644 --- a/test/gtest/conv_f8_wrw.cpp +++ b/test/gtest/conv_f8_wrw.cpp @@ -179,6 +179,8 @@ void SolverWrw(const miopen::TensorDescriptor& inputDesc, (invoker)(handle, invoke_params); handle.Finish(); } +} // namespace conv_f8_wrw +using namespace conv_f8_wrw; TEST_P(ConvWrwSolverTestF8, CKConvF8Wrw) { @@ -200,4 +202,3 @@ INSTANTIATE_TEST_SUITE_P( testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); -} // namespace conv_f8_wrw diff --git a/test/gtest/conv_hip_igemm_xdlops.cpp b/test/gtest/conv_hip_igemm_xdlops.cpp index ab746e2011..45ae7a99ca 100644 --- a/test/gtest/conv_hip_igemm_xdlops.cpp +++ b/test/gtest/conv_hip_igemm_xdlops.cpp @@ -36,7 +36,7 @@ MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_COMPOSABLEKERNEL) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) -namespace conv_hip_igem_xdlops { +namespace conv_hip_igemm_xdlops { static bool IsTestRunWith(const char* float_arg) { @@ -105,26 +105,6 @@ bool IsTestSupportedForDevice(const miopen::Handle& handle) return false; } -TEST_P(ConvHipIgemmXdlopsConfigInt8, Int8Test) -{ -#if MIOPEN_BACKEND_OPENCL - - GTEST_SKIP() << "MIOPEN_BACKEND_HIP needed for this test"; - -#else // MIOPEN_BACKEND_HIP, OCL_DISABLED - const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && miopen::IsEnabled(ENV(MIOPEN_TEST_COMPOSABLEKERNEL)) && - miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && IsTestRunWith("--int8")) - { - Run2dDriver(miopenInt8); - } - else - { - GTEST_SKIP(); - } -#endif -}; - std::vector GetTestCases(const std::string& precision) { std::string fwd = " --disable-backward-data --disable-backward-weights --verbose"; @@ -166,8 +146,29 @@ std::vector GetTestCases(const std::string& precision) return test_cases; } +} // namespace conv_hip_igemm_xdlops +using namespace conv_hip_igemm_xdlops; + +TEST_P(ConvHipIgemmXdlopsConfigInt8, Int8Test) +{ +#if MIOPEN_BACKEND_OPENCL + + GTEST_SKIP() << "MIOPEN_BACKEND_HIP needed for this test"; + +#else // MIOPEN_BACKEND_HIP, OCL_DISABLED + const auto& handle = get_handle(); + if(IsTestSupportedForDevice(handle) && miopen::IsEnabled(ENV(MIOPEN_TEST_COMPOSABLEKERNEL)) && + miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && IsTestRunWith("--int8")) + { + Run2dDriver(miopenInt8); + } + else + { + GTEST_SKIP(); + } +#endif +}; + INSTANTIATE_TEST_SUITE_P(ConvHipIgemmXdlops, ConvHipIgemmXdlopsConfigInt8, testing::Values(GetTestCases("--int8"))); - -} // namespace conv_hip_igem_xdlops diff --git a/test/gtest/conv_igemm_dynamic.cpp b/test/gtest/conv_igemm_dynamic.cpp index a5217e176a..0a5ace31a6 100644 --- a/test/gtest/conv_igemm_dynamic.cpp +++ b/test/gtest/conv_igemm_dynamic.cpp @@ -108,19 +108,6 @@ bool IsTestSupportedForDevice(const miopen::Handle& handle) return false; } -TEST_P(Conv2dFloat, FloatTest) -{ - const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) - { - Run2dDriver(miopenFloat); - } - else - { - GTEST_SKIP(); - } -}; - std::vector GetTestCases(const std::string& precision) { @@ -187,6 +174,20 @@ std::vector GetTestCases(const std::string& precision) return test_cases; } -INSTANTIATE_TEST_SUITE_P(ConvIgemmDynamic, Conv2dFloat, testing::Values(GetTestCases("--float"))); - } // namespace conv_igemm_dynamic +using namespace conv_igemm_dynamic; + +TEST_P(Conv2dFloat, FloatTest) +{ + const auto& handle = get_handle(); + if(IsTestSupportedForDevice(handle) && !SkipTest()) + { + Run2dDriver(miopenFloat); + } + else + { + GTEST_SKIP(); + } +}; + +INSTANTIATE_TEST_SUITE_P(ConvIgemmDynamic, Conv2dFloat, testing::Values(GetTestCases("--float"))); diff --git a/test/gtest/conv_igemm_mlir.cpp b/test/gtest/conv_igemm_mlir.cpp index 231c24f535..b2ac46ca0b 100644 --- a/test/gtest/conv_igemm_mlir.cpp +++ b/test/gtest/conv_igemm_mlir.cpp @@ -115,6 +115,73 @@ void Run2dDriver(miopenDataType_t prec) } }; +std::vector GetTestCases(const std::string& precision) +{ + std::vector igemm_fwd = {"MIOPEN_FIND_MODE=normal", + "MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvMlirIgemmFwd"}; + std::string flags_fwd = " --verbose --disable-backward-data --disable-backward-weights"; + std::string layout = " --in_layout NHWC --fil_layout NHWC --out_layout NHWC"; + std::string groupCount_4 = " --group-count 4"; + + // FWD test cases for precision == "--int8" + std::vector test_cases = { + // clang-format off + TestCase{igemm_fwd, precision + flags_fwd + " --input 256 1024 14 14 --weights 2048 1024 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, + TestCase{igemm_fwd, precision + flags_fwd + " --input 256 128 28 28 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, + TestCase{igemm_fwd, precision + flags_fwd + " --input 256 128 28 28 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1" + layout}, + TestCase{igemm_fwd, precision + flags_fwd + " --input 128 512 7 7 --weights 512 512 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, + TestCase{igemm_fwd, precision + flags_fwd + " --input 128 512 7 7 --weights 512 512 3 3 --pads_strides_dilations 1 1 1 1 1 1" + layout}, + TestCase{igemm_fwd, precision + flags_fwd + " --input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + TestCase{igemm_fwd, precision + flags_fwd + " --input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + layout}, + TestCase{igemm_fwd, precision + flags_fwd + " --input 256 256 56 56 --weights 256 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + groupCount_4} + // clang-format on + }; + + std::vector igemm_bwd = {"MIOPEN_FIND_MODE=normal", + "MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvMlirIgemmBwd"}; + std::vector igemm_wrw = {"MIOPEN_FIND_MODE=normal", + "MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvMlirIgemmWrW"}; + + std::string flags_bwd = " --verbose --disable-forward --disable-backward-weights"; + std::string flags_wrw = " --verbose --disable-forward --disable-backward-data"; + std::string groupCount_32 = " --group-count 32"; + + // BWD WRW test cases + const std::vector test_cases_bwd_wrw = { + // clang-format off + TestCase{igemm_bwd, precision + flags_bwd + " --input 256 1024 14 14 --weights 2048 1024 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, + TestCase{igemm_bwd, precision + flags_bwd + " --input 256 1024 14 14 --weights 2048 1024 1 1 --pads_strides_dilations 0 0 2 2 1 1" + layout}, + TestCase{igemm_bwd, precision + flags_bwd + " --input 256 128 28 28 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, + TestCase{igemm_bwd, precision + flags_bwd + " --input 256 128 28 28 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1" + layout}, + TestCase{igemm_bwd, precision + flags_bwd + " --input 128 512 7 7 --weights 512 512 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, + TestCase{igemm_bwd, precision + flags_bwd + " --input 128 512 7 7 --weights 512 512 3 3 --pads_strides_dilations 1 1 1 1 1 1" + layout}, + TestCase{igemm_bwd, precision + flags_bwd + " --input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + TestCase{igemm_bwd, precision + flags_bwd + " --input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + layout}, + + TestCase{igemm_wrw, precision + flags_wrw + " --input 64 1024 14 14 --weights 256 1024 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + TestCase{igemm_wrw, precision + flags_wrw + " --input 64 1024 14 14 --weights 256 1024 1 1 --pads_strides_dilations 0 0 1 1 1 1" + layout}, + TestCase{igemm_wrw, precision + flags_wrw + " --input 256 256 14 14 --weights 256 256 3 3 --pads_strides_dilations 0 0 2 2 1 1"}, + TestCase{igemm_wrw, precision + flags_wrw + " --input 256 256 14 14 --weights 256 256 3 3 --pads_strides_dilations 0 0 2 2 1 1" + layout}, + TestCase{igemm_wrw, precision + flags_wrw + " --input 128 2048 7 7 --weights 512 2048 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, + TestCase{igemm_wrw, precision + flags_wrw + " --input 128 2048 7 7 --weights 512 2048 1 1 --pads_strides_dilations 0 0 1 1 1 1" + layout}, + TestCase{igemm_wrw, precision + flags_wrw + " --input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + layout}, + TestCase{igemm_wrw, precision + flags_wrw + " --input 256 1024 14 14 --weights 1024 32 1 1 --pads_strides_dilations 0 0 1 1 1 1" + groupCount_32} + // clang-format on + }; + + // FWD BWD WRW cases in test_cases + if(precision == "--float" || precision == "--half") + { + test_cases.reserve(test_cases_bwd_wrw.size()); + test_cases.insert(test_cases.end(), test_cases_bwd_wrw.begin(), test_cases_bwd_wrw.end()); + } + + return test_cases; +} + +} // namespace conv_igemm_mlir +using namespace conv_igemm_mlir; + TEST_P(ConvIgemmMlirConfigFloat, FloatTest) { #if MIOPEN_USE_MLIR @@ -181,69 +248,6 @@ TEST_P(ConvIgemmMlirConfigInt8, Int8Test) #endif }; -std::vector GetTestCases(const std::string& precision) -{ - std::vector igemm_fwd = {"MIOPEN_FIND_MODE=normal", - "MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvMlirIgemmFwd"}; - std::string flags_fwd = " --verbose --disable-backward-data --disable-backward-weights"; - std::string layout = " --in_layout NHWC --fil_layout NHWC --out_layout NHWC"; - std::string groupCount_4 = " --group-count 4"; - - // FWD test cases for precision == "--int8" - std::vector test_cases = { - // clang-format off - TestCase{igemm_fwd, precision + flags_fwd + " --input 256 1024 14 14 --weights 2048 1024 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, - TestCase{igemm_fwd, precision + flags_fwd + " --input 256 128 28 28 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, - TestCase{igemm_fwd, precision + flags_fwd + " --input 256 128 28 28 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1" + layout}, - TestCase{igemm_fwd, precision + flags_fwd + " --input 128 512 7 7 --weights 512 512 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, - TestCase{igemm_fwd, precision + flags_fwd + " --input 128 512 7 7 --weights 512 512 3 3 --pads_strides_dilations 1 1 1 1 1 1" + layout}, - TestCase{igemm_fwd, precision + flags_fwd + " --input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - TestCase{igemm_fwd, precision + flags_fwd + " --input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + layout}, - TestCase{igemm_fwd, precision + flags_fwd + " --input 256 256 56 56 --weights 256 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + groupCount_4} - // clang-format on - }; - - std::vector igemm_bwd = {"MIOPEN_FIND_MODE=normal", - "MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvMlirIgemmBwd"}; - std::vector igemm_wrw = {"MIOPEN_FIND_MODE=normal", - "MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvMlirIgemmWrW"}; - - std::string flags_bwd = " --verbose --disable-forward --disable-backward-weights"; - std::string flags_wrw = " --verbose --disable-forward --disable-backward-data"; - std::string groupCount_32 = " --group-count 32"; - - // BWD WRW test cases - const std::vector test_cases_bwd_wrw = { - // clang-format off - TestCase{igemm_bwd, precision + flags_bwd + " --input 256 1024 14 14 --weights 2048 1024 1 1 --pads_strides_dilations 0 0 2 2 1 1"}, - TestCase{igemm_bwd, precision + flags_bwd + " --input 256 1024 14 14 --weights 2048 1024 1 1 --pads_strides_dilations 0 0 2 2 1 1" + layout}, - TestCase{igemm_bwd, precision + flags_bwd + " --input 256 128 28 28 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, - TestCase{igemm_bwd, precision + flags_bwd + " --input 256 128 28 28 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1" + layout}, - TestCase{igemm_bwd, precision + flags_bwd + " --input 128 512 7 7 --weights 512 512 3 3 --pads_strides_dilations 1 1 1 1 1 1"}, - TestCase{igemm_bwd, precision + flags_bwd + " --input 128 512 7 7 --weights 512 512 3 3 --pads_strides_dilations 1 1 1 1 1 1" + layout}, - TestCase{igemm_bwd, precision + flags_bwd + " --input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - TestCase{igemm_bwd, precision + flags_bwd + " --input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + layout}, - - TestCase{igemm_wrw, precision + flags_wrw + " --input 64 1024 14 14 --weights 256 1024 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - TestCase{igemm_wrw, precision + flags_wrw + " --input 64 1024 14 14 --weights 256 1024 1 1 --pads_strides_dilations 0 0 1 1 1 1" + layout}, - TestCase{igemm_wrw, precision + flags_wrw + " --input 256 256 14 14 --weights 256 256 3 3 --pads_strides_dilations 0 0 2 2 1 1"}, - TestCase{igemm_wrw, precision + flags_wrw + " --input 256 256 14 14 --weights 256 256 3 3 --pads_strides_dilations 0 0 2 2 1 1" + layout}, - TestCase{igemm_wrw, precision + flags_wrw + " --input 128 2048 7 7 --weights 512 2048 1 1 --pads_strides_dilations 0 0 1 1 1 1"}, - TestCase{igemm_wrw, precision + flags_wrw + " --input 128 2048 7 7 --weights 512 2048 1 1 --pads_strides_dilations 0 0 1 1 1 1" + layout}, - TestCase{igemm_wrw, precision + flags_wrw + " --input 128 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + layout}, - TestCase{igemm_wrw, precision + flags_wrw + " --input 256 1024 14 14 --weights 1024 32 1 1 --pads_strides_dilations 0 0 1 1 1 1" + groupCount_32} - // clang-format on - }; - - // FWD BWD WRW cases in test_cases - if(precision == "--float" || precision == "--half") - { - test_cases.reserve(test_cases_bwd_wrw.size()); - test_cases.insert(test_cases.end(), test_cases_bwd_wrw.begin(), test_cases_bwd_wrw.end()); - } - - return test_cases; -} // Float for FWD, BWD, WRW INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConvIgemmMlirConfigFloat, @@ -256,5 +260,3 @@ INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, INSTANTIATE_TEST_SUITE_P(ConvIgemmMlir, ConvIgemmMlirConfigInt8, testing::Values(GetTestCases("--int8"))); - -} // namespace conv_igemm_mlir diff --git a/test/gtest/conv_igemm_mlir_xdlops.cpp b/test/gtest/conv_igemm_mlir_xdlops.cpp index 4117f3c761..b3b4826abb 100644 --- a/test/gtest/conv_igemm_mlir_xdlops.cpp +++ b/test/gtest/conv_igemm_mlir_xdlops.cpp @@ -88,50 +88,6 @@ void Run2dDriver(miopenDataType_t prec) } }; -TEST_P(ConvIgemmMlirXdlopsConfigHalf, HalfTest) -{ -#if MIOPEN_USE_MLIR - - const auto& handle = get_handle(); - if((miopen::StartsWith(handle.GetDeviceName(), "gfx908") || - miopen::StartsWith(handle.GetDeviceName(), "gfx90a")) && - miopen::IsEnabled(ENV(MIOPEN_TEST_MLIR)) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && - GetFloatArg() == "--half") - { - Run2dDriver(miopenHalf); - } - else - { - GTEST_SKIP(); - } - -#else - GTEST_SKIP(); -#endif -}; - -TEST_P(ConvIgemmMlirXdlopsConfigInt8, Int8Test) -{ -#if MIOPEN_USE_MLIR - - const auto& handle = get_handle(); - if((miopen::StartsWith(handle.GetDeviceName(), "gfx908") || - miopen::StartsWith(handle.GetDeviceName(), "gfx90a")) && - miopen::IsEnabled(ENV(MIOPEN_TEST_MLIR)) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && - GetFloatArg() == "--int8") - { - Run2dDriver(miopenInt8); - } - else - { - GTEST_SKIP(); - } - -#else - GTEST_SKIP(); -#endif -}; - std::vector GetTestCases(const std::string& precision) { std::vector fwd = {"MIOPEN_FIND_MODE=normal", @@ -196,6 +152,54 @@ std::vector GetTestCases(const std::string& precision) return test_cases; } + +} // namespace conv_igemm_mlir_xdlops +using namespace conv_igemm_mlir_xdlops; + +TEST_P(ConvIgemmMlirXdlopsConfigHalf, HalfTest) +{ +#if MIOPEN_USE_MLIR + + const auto& handle = get_handle(); + if((miopen::StartsWith(handle.GetDeviceName(), "gfx908") || + miopen::StartsWith(handle.GetDeviceName(), "gfx90a")) && + miopen::IsEnabled(ENV(MIOPEN_TEST_MLIR)) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && + GetFloatArg() == "--half") + { + Run2dDriver(miopenHalf); + } + else + { + GTEST_SKIP(); + } + +#else + GTEST_SKIP(); +#endif +}; + +TEST_P(ConvIgemmMlirXdlopsConfigInt8, Int8Test) +{ +#if MIOPEN_USE_MLIR + + const auto& handle = get_handle(); + if((miopen::StartsWith(handle.GetDeviceName(), "gfx908") || + miopen::StartsWith(handle.GetDeviceName(), "gfx90a")) && + miopen::IsEnabled(ENV(MIOPEN_TEST_MLIR)) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && + GetFloatArg() == "--int8") + { + Run2dDriver(miopenInt8); + } + else + { + GTEST_SKIP(); + } + +#else + GTEST_SKIP(); +#endif +}; + // Half for FWD, BWD, WRW INSTANTIATE_TEST_SUITE_P(ConvIgemmMlirXdlops, ConvIgemmMlirXdlopsConfigHalf, @@ -204,5 +208,3 @@ INSTANTIATE_TEST_SUITE_P(ConvIgemmMlirXdlops, INSTANTIATE_TEST_SUITE_P(ConvIgemmMlirXdlops, ConvIgemmMlirXdlopsConfigInt8, testing::Values(GetTestCases("--int8"))); - -} // namespace conv_igemm_mlir_xdlops diff --git a/test/gtest/conv_trans.cpp b/test/gtest/conv_trans.cpp index 2aa1dd825c..31a6f9cb92 100644 --- a/test/gtest/conv_trans.cpp +++ b/test/gtest/conv_trans.cpp @@ -96,19 +96,6 @@ bool IsTestSupportedForDevice(const miopen::Handle& handle) return false; } -TEST_P(ConfigWithFloat, FloatTest) -{ - const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL))) - { - Run2dDriver(miopenFloat); - } - else - { - GTEST_SKIP(); - } -}; - std::vector GetTestCases(void) { std::string flags = " --verbose "; @@ -152,6 +139,20 @@ std::vector GetTestCases(void) return test_cases; } -INSTANTIATE_TEST_SUITE_P(ConvTrans, ConfigWithFloat, testing::Values(GetTestCases())); - } // namespace conv_trans +using namespace conv_trans; + +TEST_P(ConfigWithFloat, FloatTest) +{ + const auto& handle = get_handle(); + if(IsTestSupportedForDevice(handle) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL))) + { + Run2dDriver(miopenFloat); + } + else + { + GTEST_SKIP(); + } +}; + +INSTANTIATE_TEST_SUITE_P(ConvTrans, ConfigWithFloat, testing::Values(GetTestCases())); diff --git a/test/gtest/group_conv3d_bwd.cpp b/test/gtest/group_conv3d_bwd.cpp index a427a1a907..a74be630ad 100644 --- a/test/gtest/group_conv3d_bwd.cpp +++ b/test/gtest/group_conv3d_bwd.cpp @@ -91,6 +91,9 @@ void SolverBwd(const miopen::TensorDescriptor& inputDesc, handle.Finish(); } +} // namespace group_conv3d_bwd +using namespace group_conv3d_bwd; + TEST_P(ConvBwdSolverTest3D, CKGroupConvBwd3D) { SolverBwd(input.desc, @@ -109,5 +112,3 @@ INSTANTIATE_TEST_SUITE_P(ConvBwdTest, testing::Combine(testing::Values(miopenConvolutionBwdDataAlgoImplicitGEMM), testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); - -} // namespace group_conv3d_bwd diff --git a/test/gtest/group_conv3d_fwd.cpp b/test/gtest/group_conv3d_fwd.cpp index de8001e722..879ed24b18 100644 --- a/test/gtest/group_conv3d_fwd.cpp +++ b/test/gtest/group_conv3d_fwd.cpp @@ -97,6 +97,9 @@ void SolverFwd(const miopen::TensorDescriptor& inputDesc, handle.Finish(); } +} // namespace group_conv3d_fwd +using namespace group_conv3d_fwd; + TEST_P(ConvGroupFwdSolverTest3D, CKGroupConvFwd3D) { SolverFwd(input.desc, @@ -115,5 +118,3 @@ INSTANTIATE_TEST_SUITE_P(ConvFwdTest, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); - -} // namespace group_conv3d_fwd diff --git a/test/gtest/group_conv3d_wrw.cpp b/test/gtest/group_conv3d_wrw.cpp index 7ba2ba2b60..e43b3fcc04 100644 --- a/test/gtest/group_conv3d_wrw.cpp +++ b/test/gtest/group_conv3d_wrw.cpp @@ -93,6 +93,9 @@ void SolverWrw(const miopen::TensorDescriptor& inputDesc, handle.Finish(); } +} // namespace group_conv3d_wrw +using namespace group_conv3d_wrw; + TEST_P(ConvWrwSolverTest3D, CKGroupConvWrw3D) { SolverWrw(input.desc, @@ -112,5 +115,3 @@ INSTANTIATE_TEST_SUITE_P( testing::Combine(testing::Values(miopenConvolutionBwdWeightsAlgoImplicitGEMM), testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); - -} // namespace group_conv3d_wrw diff --git a/test/gtest/layernorm.cpp b/test/gtest/layernorm.cpp index 7bb3a8f94f..257802fc53 100644 --- a/test/gtest/layernorm.cpp +++ b/test/gtest/layernorm.cpp @@ -45,6 +45,9 @@ struct LayerNormTestFloat : LayerNormTest { }; +} // namespace layernorm +using namespace layernorm; + TEST_P(LayerNormTestFloat, LayerNormTestFw) { const auto& handle = get_handle(); @@ -65,5 +68,3 @@ TEST_P(LayerNormTestFloat, LayerNormTestFw) INSTANTIATE_TEST_SUITE_P(LayerNormTestSet, LayerNormTestFloat, testing::ValuesIn(LayerNormTestConfigs())); - -} // namespace layernorm diff --git a/test/gtest/sum.cpp b/test/gtest/sum.cpp index d847d5550b..b18fc0a89e 100644 --- a/test/gtest/sum.cpp +++ b/test/gtest/sum.cpp @@ -45,6 +45,9 @@ struct SumTestFloat : SumTest { }; +} // namespace sum +using namespace sum; + TEST_P(SumTestFloat, SumTestFw) { if(miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && (GetFloatArg() == "--float")) @@ -59,5 +62,3 @@ TEST_P(SumTestFloat, SumTestFw) }; INSTANTIATE_TEST_SUITE_P(SumTestSet, SumTestFloat, testing::ValuesIn(SumTestConfigs())); - -} // namespace sum From 8ac0916ec96bd12c90c4f8c6d675930f448a6092 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Fri, 15 Dec 2023 15:56:21 +0000 Subject: [PATCH 14/25] format --- test/gtest/bad_fusion_plan.cpp | 1 - test/gtest/cba_find2_infer.cpp | 1 - test/gtest/cba_infer.cpp | 1 - test/gtest/conv_f8_bwd.cpp | 1 - test/gtest/conv_f8_wrw.cpp | 1 - 5 files changed, 5 deletions(-) diff --git a/test/gtest/bad_fusion_plan.cpp b/test/gtest/bad_fusion_plan.cpp index 41bd9e7ed5..26958c3269 100644 --- a/test/gtest/bad_fusion_plan.cpp +++ b/test/gtest/bad_fusion_plan.cpp @@ -31,7 +31,6 @@ #include "get_handle.hpp" #include "conv_test_base.hpp" - #if MIOPEN_BACKEND_HIP namespace bad_fusion_plan { diff --git a/test/gtest/cba_find2_infer.cpp b/test/gtest/cba_find2_infer.cpp index 030d4e3515..0472688a50 100644 --- a/test/gtest/cba_find2_infer.cpp +++ b/test/gtest/cba_find2_infer.cpp @@ -178,4 +178,3 @@ INSTANTIATE_TEST_SUITE_P(CBAFind2InferSolverTest, testing::Combine(testing::Values(miopenActivationRELU), testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNHWC))); - diff --git a/test/gtest/cba_infer.cpp b/test/gtest/cba_infer.cpp index 5a9a8009a0..e02dd31ec8 100644 --- a/test/gtest/cba_infer.cpp +++ b/test/gtest/cba_infer.cpp @@ -182,4 +182,3 @@ INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest, testing::Combine(testing::Values(miopenActivationRELU), testing::ValuesIn(GetNetwork1()), testing::Values(miopenTensorNHWC))); - diff --git a/test/gtest/conv_f8_bwd.cpp b/test/gtest/conv_f8_bwd.cpp index cf2765375b..e18779b718 100644 --- a/test/gtest/conv_f8_bwd.cpp +++ b/test/gtest/conv_f8_bwd.cpp @@ -197,4 +197,3 @@ INSTANTIATE_TEST_SUITE_P(ConvBwdTest, testing::Combine(testing::Values(miopenConvolutionBwdDataAlgoImplicitGEMM), testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); - diff --git a/test/gtest/conv_f8_wrw.cpp b/test/gtest/conv_f8_wrw.cpp index 2a06bd5d27..07851d4878 100644 --- a/test/gtest/conv_f8_wrw.cpp +++ b/test/gtest/conv_f8_wrw.cpp @@ -201,4 +201,3 @@ INSTANTIATE_TEST_SUITE_P( testing::Combine(testing::Values(miopenConvolutionBwdWeightsAlgoImplicitGEMM), testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); - From f68938d5737517cb62759f28f3c63aeb167ad5f5 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Fri, 15 Dec 2023 17:51:49 +0000 Subject: [PATCH 15/25] add flag for discrete gtest --- test/gtest/CMakeLists.txt | 78 ++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index e946b114c8..3e4d91b15a 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -10,8 +10,35 @@ if(MIOPEN_BACKEND_OPENCL) set(SKIP_TESTS dumpTensorTest.cpp) endif() +function(add_gtest TEST_NAME TEST_CPP) + #message("Adding Test: " ${TEST_NAME} " : " ${TEST_CPP}) + add_executable(${TEST_NAME} ${TEST_CPP} ${SOURCES}) + if(WIN32) + target_compile_definitions(${TEST_NAME} PRIVATE NOMINMAX) + endif() + add_dependencies(tests ${TEST_NAME}) + add_dependencies(check ${TEST_NAME}) + target_compile_options(${TEST_NAME} PRIVATE -Wno-global-constructors -Wno-undef) + target_include_directories(${TEST_NAME} PRIVATE ../ ../../src/kernels) + if(MIOPEN_ENABLE_AI_KERNEL_TUNING) + target_link_libraries(${TEST_NAME} frugally-deep::fdeep Eigen3::Eigen) + endif() + target_link_libraries(${TEST_NAME} GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $) + if(NOT MIOPEN_EMBED_DB STREQUAL "") + target_link_libraries(${TEST_NAME} $) + endif() + if(NOT WIN32) # TODO: cannot run on Windows due to missing DLL dependencies + # Enable CMake to discover the test binary + gtest_discover_tests(${TEST_NAME} PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL}") + endif() + + if(WIN32) + # Refer to https://en.cppreference.com/w/cpp/language/types for details. + target_compile_options(${TEST_NAME} PRIVATE $:-U__LP64__>>) + endif() +endfunction() + file(GLOB TESTS *.cpp) -file(GLOB HEADERS *.hpp) # Remove files that do not contain tests foreach(SOURCE ${SOURCES}) list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}) @@ -21,42 +48,25 @@ foreach(SOURCE ${SKIP_TESTS}) list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}) endforeach() -message("Test files: " ${TESTS}) -foreach(TEST ${TESTS}) - get_filename_component(BASE_NAME ${TEST} NAME) - list(APPEND TESTS_CPP ${BASE_NAME}) -endforeach() +if( DISCRETE_GTEST ) + foreach(TEST ${TESTS}) + get_filename_component(BASE_NAME ${TEST} NAME_WE) + add_gtest(test_${BASE_NAME} ${BASE_NAME}.cpp) + endforeach() +else() + foreach(TEST ${TESTS}) + get_filename_component(BASE_NAME ${TEST} NAME) + list(APPEND TESTS_CPP ${BASE_NAME}) + endforeach() -message("Adding miopen_gtest: " ${TESTS_CPP}) -add_executable(miopen_gtest ${TESTS_CPP} ${SOURCES}) -if(WIN32) - target_compile_definitions(miopen_gtest PRIVATE NOMINMAX) -endif() -add_dependencies(tests miopen_gtest) -add_dependencies(check miopen_gtest) -target_compile_options(miopen_gtest PRIVATE -Wno-global-constructors -Wno-undef) -target_include_directories(miopen_gtest PRIVATE ../ ../../src/kernels) -if(MIOPEN_ENABLE_AI_KERNEL_TUNING) - target_link_libraries(miopen_gtest frugally-deep::fdeep Eigen3::Eigen) -endif() -target_link_libraries(miopen_gtest GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $) -if(NOT MIOPEN_EMBED_DB STREQUAL "") - target_link_libraries(miopen_gtest $) -endif() + add_gtest(miopen_gtest "${TESTS_CPP}") -if(NOT WIN32) # TODO: cannot run on Windows due to missing DLL dependencies - # Enable CMake to discover the test binary - gtest_discover_tests(miopen_gtest PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL}") + if( NOT ENABLE_ASAN_PACKAGING ) + install(TARGETS miopen_gtest + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() endif() -if(WIN32) - # Refer to https://en.cppreference.com/w/cpp/language/types for details. - target_compile_options(miopen_gtest PRIVATE $:-U__LP64__>>) -endif() -if( NOT ENABLE_ASAN_PACKAGING ) - install(TARGETS miopen_gtest - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - DESTINATION ${CMAKE_INSTALL_BINDIR}) -endif() From 77118956b660aa716db1bb448c1d091fb2bc5346 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Fri, 15 Dec 2023 17:56:27 +0000 Subject: [PATCH 16/25] fix ci call to test_db_sync --- Jenkinsfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7e07d3deba..1fe6dff53b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -922,9 +922,9 @@ pipeline { } agent{ label rocmnode("gfx908") } environment{ - setup_flags="-DMIOPEN_TEST_DBSYNC=1" - config_targets='test_db_sync' - execute_cmd='./bin/test_db_sync' + setup_flags="-DDISCRETE_GTEST=1 -DMIOPEN_TEST_DBSYNC=1" + config_targets='test_db_sync' + execute_cmd='./bin/test_db_sync' } steps{ buildHipClangJobAndReboot(lfs_pull: true, setup_flags: setup_flags, config_targets: config_targets, execute_cmd: execute_cmd, @@ -941,9 +941,9 @@ pipeline { } agent{ label rocmnode("gfx90a") } environment{ - setup_flags="-DMIOPEN_TEST_DBSYNC=1" - config_targets='test_db_sync' - execute_cmd='./bin/test_db_sync' + setup_flags="-DDISCRETE_GTEST=1 -DMIOPEN_TEST_DBSYNC=1" + config_targets='test_db_sync' + execute_cmd='./bin/test_db_sync' } steps{ buildHipClangJobAndReboot(lfs_pull: true, setup_flags: setup_flags, config_targets: config_targets, execute_cmd: execute_cmd, From ce6a22c1634396a2f40087f640dff3125d80f28a Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Mon, 18 Dec 2023 16:53:03 +0000 Subject: [PATCH 17/25] add unique names for tests --- test/gtest/conv3d_codecov.cpp | 8 ++++---- test/gtest/conv_embed_db.cpp | 8 ++++---- test/gtest/conv_igemm_dynamic.cpp | 2 +- test/gtest/conv_igemm_mlir.cpp | 6 +++--- test/gtest/conv_igemm_mlir_xdlops.cpp | 4 ++-- test/gtest/conv_trans.cpp | 2 +- test/gtest/immed_conv2d_codecov.cpp | 8 ++++---- test/gtest/immed_conv3d_codecov.cpp | 8 ++++---- test/gtest/pooling2d_asymmetric.cpp | 4 ++-- test/gtest/pooling2d_codecov.cpp | 4 ++-- test/gtest/pooling2d_wide.cpp | 4 ++-- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/test/gtest/conv3d_codecov.cpp b/test/gtest/conv3d_codecov.cpp index f85b072722..a27de9e4bb 100644 --- a/test/gtest/conv3d_codecov.cpp +++ b/test/gtest/conv3d_codecov.cpp @@ -98,7 +98,7 @@ void Run3dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } -TEST_P(Conv3dFloat, FloatTest) +TEST_P(Conv3dFloat, FloatTest_conv3d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -111,7 +111,7 @@ TEST_P(Conv3dFloat, FloatTest) } }; -TEST_P(Conv3dHalf, HalfTest) +TEST_P(Conv3dHalf, HalfTest_conv3d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -124,7 +124,7 @@ TEST_P(Conv3dHalf, HalfTest) } }; -TEST_P(Conv3dBFloat16, BFloat16Test) +TEST_P(Conv3dBFloat16, BFloat16Test_conv3d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -137,7 +137,7 @@ TEST_P(Conv3dBFloat16, BFloat16Test) } }; -TEST_P(Conv3dInt8, Int8Test) +TEST_P(Conv3dInt8, Int8Test_conv3d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) diff --git a/test/gtest/conv_embed_db.cpp b/test/gtest/conv_embed_db.cpp index fe239cab09..61374c95b0 100644 --- a/test/gtest/conv_embed_db.cpp +++ b/test/gtest/conv_embed_db.cpp @@ -151,7 +151,7 @@ std::vector GetTestCases(const std::string& precision) } // namespace conv_embed_db using namespace conv_embed_db; -TEST_P(ConvEmbedConfigFloat, FloatTest) +TEST_P(ConvEmbedConfigFloat, FloatTest_conv_embed_db) { #if MIOPEN_EMBED_DB @@ -170,7 +170,7 @@ TEST_P(ConvEmbedConfigFloat, FloatTest) #endif }; -TEST_P(ConvEmbedConfigHalf, HalfTest) +TEST_P(ConvEmbedConfigHalf, HalfTest_conv_embed_db) { #if MIOPEN_EMBED_DB @@ -189,7 +189,7 @@ TEST_P(ConvEmbedConfigHalf, HalfTest) #endif }; -TEST_P(ConvEmbedConfigInt8, Int8Test) +TEST_P(ConvEmbedConfigInt8, Int8Test_conv_embed_db) { #if MIOPEN_EMBED_DB @@ -208,7 +208,7 @@ TEST_P(ConvEmbedConfigInt8, Int8Test) #endif }; -TEST_P(ConvEmbedConfigBFloat16, BFloat16Test) +TEST_P(ConvEmbedConfigBFloat16, BFloat16Test_conv_embed_db) { #if MIOPEN_EMBED_DB diff --git a/test/gtest/conv_igemm_dynamic.cpp b/test/gtest/conv_igemm_dynamic.cpp index 0a5ace31a6..ff98e464f0 100644 --- a/test/gtest/conv_igemm_dynamic.cpp +++ b/test/gtest/conv_igemm_dynamic.cpp @@ -177,7 +177,7 @@ std::vector GetTestCases(const std::string& precision) } // namespace conv_igemm_dynamic using namespace conv_igemm_dynamic; -TEST_P(Conv2dFloat, FloatTest) +TEST_P(Conv2dFloat, FloatTest_conv_igemm_dynamic) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) diff --git a/test/gtest/conv_igemm_mlir.cpp b/test/gtest/conv_igemm_mlir.cpp index b2ac46ca0b..72e4a9add1 100644 --- a/test/gtest/conv_igemm_mlir.cpp +++ b/test/gtest/conv_igemm_mlir.cpp @@ -182,7 +182,7 @@ std::vector GetTestCases(const std::string& precision) } // namespace conv_igemm_mlir using namespace conv_igemm_mlir; -TEST_P(ConvIgemmMlirConfigFloat, FloatTest) +TEST_P(ConvIgemmMlirConfigFloat, FloatTest_conv_igemm_mlir) { #if MIOPEN_USE_MLIR @@ -204,7 +204,7 @@ TEST_P(ConvIgemmMlirConfigFloat, FloatTest) #endif }; -TEST_P(ConvIgemmMlirConfigHalf, HalfTest) +TEST_P(ConvIgemmMlirConfigHalf, HalfTest_conv_igemm_mlir) { #if MIOPEN_USE_MLIR @@ -226,7 +226,7 @@ TEST_P(ConvIgemmMlirConfigHalf, HalfTest) #endif }; -TEST_P(ConvIgemmMlirConfigInt8, Int8Test) +TEST_P(ConvIgemmMlirConfigInt8, Int8Test_conv_igemm_mlir) { #if MIOPEN_USE_MLIR diff --git a/test/gtest/conv_igemm_mlir_xdlops.cpp b/test/gtest/conv_igemm_mlir_xdlops.cpp index 7bde20ded9..feda46ad60 100644 --- a/test/gtest/conv_igemm_mlir_xdlops.cpp +++ b/test/gtest/conv_igemm_mlir_xdlops.cpp @@ -156,7 +156,7 @@ std::vector GetTestCases(const std::string& precision) } // namespace conv_igemm_mlir_xdlops using namespace conv_igemm_mlir_xdlops; -TEST_P(ConvIgemmMlirXdlopsConfigHalf, HalfTest) +TEST_P(ConvIgemmMlirXdlopsConfigHalf, HalfTest_conv_igemm_mlir_xdlops) { #if MIOPEN_USE_MLIR @@ -178,7 +178,7 @@ TEST_P(ConvIgemmMlirXdlopsConfigHalf, HalfTest) #endif }; -TEST_P(ConvIgemmMlirXdlopsConfigInt8, Int8Test) +TEST_P(ConvIgemmMlirXdlopsConfigInt8, Int8Test_conv_igemm_mlir_xdlops) { #if MIOPEN_USE_MLIR diff --git a/test/gtest/conv_trans.cpp b/test/gtest/conv_trans.cpp index 31a6f9cb92..9a715e8c6d 100644 --- a/test/gtest/conv_trans.cpp +++ b/test/gtest/conv_trans.cpp @@ -142,7 +142,7 @@ std::vector GetTestCases(void) } // namespace conv_trans using namespace conv_trans; -TEST_P(ConfigWithFloat, FloatTest) +TEST_P(ConfigWithFloat, FloatTest_conv_trans) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL))) diff --git a/test/gtest/immed_conv2d_codecov.cpp b/test/gtest/immed_conv2d_codecov.cpp index ba2a9de09c..185e8ef2c5 100644 --- a/test/gtest/immed_conv2d_codecov.cpp +++ b/test/gtest/immed_conv2d_codecov.cpp @@ -132,7 +132,7 @@ void Run2dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } -TEST_P(Conv2dFloat, FloatTest) +TEST_P(Conv2dFloat, FloatTest_immed_conv2d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -145,7 +145,7 @@ TEST_P(Conv2dFloat, FloatTest) } }; -TEST_P(Conv2dHalf, HalfTest) +TEST_P(Conv2dHalf, HalfTest_immed_conv2d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -158,7 +158,7 @@ TEST_P(Conv2dHalf, HalfTest) } }; -TEST_P(Conv2dBFloat16, BFloat16Test) +TEST_P(Conv2dBFloat16, BFloat16Test_immed_conv2d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -171,7 +171,7 @@ TEST_P(Conv2dBFloat16, BFloat16Test) } }; -TEST_P(Conv2dInt8, Int8Test) +TEST_P(Conv2dInt8, Int8Test_immed_conv2d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) diff --git a/test/gtest/immed_conv3d_codecov.cpp b/test/gtest/immed_conv3d_codecov.cpp index 3f22479d91..cb30c2ce0d 100644 --- a/test/gtest/immed_conv3d_codecov.cpp +++ b/test/gtest/immed_conv3d_codecov.cpp @@ -132,7 +132,7 @@ void Run3dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } -TEST_P(Conv3dFloat, FloatTest) +TEST_P(Conv3dFloat, FloatTest_immed_conv3d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -145,7 +145,7 @@ TEST_P(Conv3dFloat, FloatTest) } }; -TEST_P(Conv3dHalf, HalfTest) +TEST_P(Conv3dHalf, HalfTest_immed_conv3d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -158,7 +158,7 @@ TEST_P(Conv3dHalf, HalfTest) } }; -TEST_P(Conv3dBFloat16, BFloat16Test) +TEST_P(Conv3dBFloat16, BFloat16Test_immed_conv3d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -171,7 +171,7 @@ TEST_P(Conv3dBFloat16, BFloat16Test) } }; -TEST_P(Conv3dInt8, Int8Test) +TEST_P(Conv3dInt8, Int8Test_immed_conv3d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) diff --git a/test/gtest/pooling2d_asymmetric.cpp b/test/gtest/pooling2d_asymmetric.cpp index 894210b813..d9d2213f36 100644 --- a/test/gtest/pooling2d_asymmetric.cpp +++ b/test/gtest/pooling2d_asymmetric.cpp @@ -92,7 +92,7 @@ void Run2dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } -TEST_P(Pooling2dFloat, FloatTest) +TEST_P(Pooling2dFloat, FloatTest_pooling2d_asymmetric) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -105,7 +105,7 @@ TEST_P(Pooling2dFloat, FloatTest) } }; -TEST_P(Pooling2dHalf, HalfTest) +TEST_P(Pooling2dHalf, HalfTest_pooling2d_asymmetric) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) diff --git a/test/gtest/pooling2d_codecov.cpp b/test/gtest/pooling2d_codecov.cpp index 52daa50f3f..365c03d272 100644 --- a/test/gtest/pooling2d_codecov.cpp +++ b/test/gtest/pooling2d_codecov.cpp @@ -92,7 +92,7 @@ void Run2dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } -TEST_P(Pooling2dFloat, FloatTest) +TEST_P(Pooling2dFloat, FloatTest_pooling2d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -105,7 +105,7 @@ TEST_P(Pooling2dFloat, FloatTest) } }; -TEST_P(Pooling2dHalf, HalfTest) +TEST_P(Pooling2dHalf, HalfTest_pooling2d_codecov) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) diff --git a/test/gtest/pooling2d_wide.cpp b/test/gtest/pooling2d_wide.cpp index 159da6f608..cb4233ae0c 100644 --- a/test/gtest/pooling2d_wide.cpp +++ b/test/gtest/pooling2d_wide.cpp @@ -92,7 +92,7 @@ void Run2dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } -TEST_P(Pooling2dFloat, FloatTest) +TEST_P(Pooling2dFloat, FloatTest_pooling2d_wide) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -105,7 +105,7 @@ TEST_P(Pooling2dFloat, FloatTest) } }; -TEST_P(Pooling2dHalf, HalfTest) +TEST_P(Pooling2dHalf, HalfTest_pooling2d_wide) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) From aeaa83fb114145c4fef36457c40af9036c163773 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Mon, 18 Dec 2023 19:08:51 +0000 Subject: [PATCH 18/25] resolve build conflicts --- test/conv3d.hpp | 17 +++++++++ test/gtest/conv3d_codecov.cpp | 54 ++++++++++++----------------- test/gtest/conv_igemm_dynamic.cpp | 12 ++++--- test/gtest/immed_conv2d_codecov.cpp | 31 ++++++++++------- test/gtest/immed_conv3d_codecov.cpp | 54 ++++++++++++----------------- test/gtest/pooling2d_asymmetric.cpp | 46 ++++++++++++------------ test/gtest/pooling2d_codecov.cpp | 46 ++++++++++++------------ test/gtest/pooling2d_wide.cpp | 46 ++++++++++++------------ test/pooling2d.hpp | 9 +++++ 9 files changed, 161 insertions(+), 154 deletions(-) diff --git a/test/conv3d.hpp b/test/conv3d.hpp index 2b49c0f10e..8cb7940ca2 100644 --- a/test/conv3d.hpp +++ b/test/conv3d.hpp @@ -23,6 +23,7 @@ * SOFTWARE. * *******************************************************************************/ +#include #include "conv_common.hpp" template @@ -58,3 +59,19 @@ struct conv3d_driver : conv_driver this->add(this->out_layout, "out_layout", this->generate_data({"NCDHW"})); } }; + +class Conv3dFloat : public testing::TestWithParam> +{ +}; + +class Conv3dHalf : public testing::TestWithParam> +{ +}; + +class Conv3dBFloat16 : public testing::TestWithParam> +{ +}; + +class Conv3dInt8 : public testing::TestWithParam> +{ +}; diff --git a/test/gtest/conv3d_codecov.cpp b/test/gtest/conv3d_codecov.cpp index a27de9e4bb..d1b7e9a888 100644 --- a/test/gtest/conv3d_codecov.cpp +++ b/test/gtest/conv3d_codecov.cpp @@ -23,14 +23,17 @@ * SOFTWARE. * *******************************************************************************/ -#include "conv3d.hpp" -#include "get_handle.hpp" -#include #include +#include +#include "get_handle.hpp" + +#include "conv3d.hpp" MIOPEN_DECLARE_ENV_VAR_BOOL(CODECOV_TEST) MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLAGS_ARGS) +namespace conv3d_codecov { + static bool SkipTest(void) { return !miopen::IsEnabled(ENV(CODECOV_TEST)); } void GetArgs(const std::string& param, std::vector& tokens) @@ -42,22 +45,6 @@ void GetArgs(const std::string& param, std::vector& tokens) tokens.push_back(*begin++); } -class Conv3dFloat : public testing::TestWithParam> -{ -}; - -class Conv3dHalf : public testing::TestWithParam> -{ -}; - -class Conv3dBFloat16 : public testing::TestWithParam> -{ -}; - -class Conv3dInt8 : public testing::TestWithParam> -{ -}; - void Run3dDriver(miopenDataType_t prec) { @@ -98,6 +85,22 @@ void Run3dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } +std::vector GetTestCases(const std::string& precision) +{ + const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); + + const std::vector test_cases = { + // clang-format off + {"test_conv3d " + precision + " --input 2 4 4 4 4 --weights 2 4 1 1 1 --pads_strides_dilations 0 0 0 1 1 1 1 1 1 "+flag_arg} + // clang-format on + }; + + return test_cases; +} + +} // namespace conv3d_codecov +using namespace conv3d_codecov; + TEST_P(Conv3dFloat, FloatTest_conv3d_codecov) { const auto& handle = get_handle(); @@ -150,19 +153,6 @@ TEST_P(Conv3dInt8, Int8Test_conv3d_codecov) } }; -std::vector GetTestCases(const std::string& precision) -{ - const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); - - const std::vector test_cases = { - // clang-format off - {"test_conv3d " + precision + " --input 2 4 4 4 4 --weights 2 4 1 1 1 --pads_strides_dilations 0 0 0 1 1 1 1 1 1 "+flag_arg} - // clang-format on - }; - - return test_cases; -} - INSTANTIATE_TEST_SUITE_P(Conv3D, Conv3dFloat, testing::Values(GetTestCases("--float"))); INSTANTIATE_TEST_SUITE_P(Conv3D, Conv3dHalf, testing::Values(GetTestCases("--half"))); diff --git a/test/gtest/conv_igemm_dynamic.cpp b/test/gtest/conv_igemm_dynamic.cpp index ff98e464f0..916fa71612 100644 --- a/test/gtest/conv_igemm_dynamic.cpp +++ b/test/gtest/conv_igemm_dynamic.cpp @@ -56,7 +56,7 @@ void GetArgs(const TestCase& param, std::vector& tokens) tokens.push_back(*begin++); } -class Conv2dFloat : public testing::TestWithParam> +class Conv2dFloatDynamic : public testing::TestWithParam> { }; @@ -66,7 +66,7 @@ void Run2dDriver(miopenDataType_t prec) std::vector params; switch(prec) { - case miopenFloat: params = Conv2dFloat::GetParam(); break; + case miopenFloat: params = Conv2dFloatDynamic::GetParam(); break; case miopenHalf: case miopenInt8: case miopenBFloat16: @@ -78,7 +78,7 @@ void Run2dDriver(miopenDataType_t prec) "miopenDouble, miopenFloat8, miopenBFloat8 " "data type not supported by conv_igemm_dynamic test"; - default: params = Conv2dFloat::GetParam(); + default: params = Conv2dFloatDynamic::GetParam(); } for(const auto& test_value : params) @@ -177,7 +177,7 @@ std::vector GetTestCases(const std::string& precision) } // namespace conv_igemm_dynamic using namespace conv_igemm_dynamic; -TEST_P(Conv2dFloat, FloatTest_conv_igemm_dynamic) +TEST_P(Conv2dFloatDynamic, FloatTest_conv_igemm_dynamic) { const auto& handle = get_handle(); if(IsTestSupportedForDevice(handle) && !SkipTest()) @@ -190,4 +190,6 @@ TEST_P(Conv2dFloat, FloatTest_conv_igemm_dynamic) } }; -INSTANTIATE_TEST_SUITE_P(ConvIgemmDynamic, Conv2dFloat, testing::Values(GetTestCases("--float"))); +INSTANTIATE_TEST_SUITE_P(ConvIgemmDynamic, + Conv2dFloatDynamic, + testing::Values(GetTestCases("--float"))); diff --git a/test/gtest/immed_conv2d_codecov.cpp b/test/gtest/immed_conv2d_codecov.cpp index 185e8ef2c5..32b71ed0f7 100644 --- a/test/gtest/immed_conv2d_codecov.cpp +++ b/test/gtest/immed_conv2d_codecov.cpp @@ -31,6 +31,8 @@ MIOPEN_DECLARE_ENV_VAR_BOOL(CODECOV_TEST) MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLAGS_ARGS) +namespace immed_conv2d_codecov { + template struct conv2d_driver : conv_driver { @@ -132,6 +134,22 @@ void Run2dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } +std::vector GetTestCases(const std::string& precision) +{ + const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); + + const std::vector test_cases = { + // clang-format off + {"test_immed_conv2d " + precision + " --input 2 2 14 14 --weights 8 2 3 3 --pads_strides_dilations 0 0 1 1 1 1 "+flag_arg} + // clang-format on + }; + + return test_cases; +} + +} // namespace immed_conv2d_codecov +using namespace immed_conv2d_codecov; + TEST_P(Conv2dFloat, FloatTest_immed_conv2d_codecov) { const auto& handle = get_handle(); @@ -184,19 +202,6 @@ TEST_P(Conv2dInt8, Int8Test_immed_conv2d_codecov) } }; -std::vector GetTestCases(const std::string& precision) -{ - const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); - - const std::vector test_cases = { - // clang-format off - {"test_immed_conv2d " + precision + " --input 2 2 14 14 --weights 8 2 3 3 --pads_strides_dilations 0 0 1 1 1 1 "+flag_arg} - // clang-format on - }; - - return test_cases; -} - INSTANTIATE_TEST_SUITE_P(ImmedConv2D, Conv2dFloat, testing::Values(GetTestCases("--float"))); INSTANTIATE_TEST_SUITE_P(ImmedConv2D, Conv2dHalf, testing::Values(GetTestCases("--half"))); diff --git a/test/gtest/immed_conv3d_codecov.cpp b/test/gtest/immed_conv3d_codecov.cpp index cb30c2ce0d..1e98ad7a61 100644 --- a/test/gtest/immed_conv3d_codecov.cpp +++ b/test/gtest/immed_conv3d_codecov.cpp @@ -23,14 +23,17 @@ * SOFTWARE. * *******************************************************************************/ -#include "conv_common.hpp" -#include "get_handle.hpp" -#include #include +#include +#include "get_handle.hpp" + +#include "conv3d.hpp" MIOPEN_DECLARE_ENV_VAR_BOOL(CODECOV_TEST) MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLAGS_ARGS) +namespace immed_conv3d_codecov { + template struct conv3d_driver : conv_driver { @@ -76,22 +79,6 @@ void GetArgs(const std::string& param, std::vector& tokens) tokens.push_back(*begin++); } -class Conv3dFloat : public testing::TestWithParam> -{ -}; - -class Conv3dHalf : public testing::TestWithParam> -{ -}; - -class Conv3dBFloat16 : public testing::TestWithParam> -{ -}; - -class Conv3dInt8 : public testing::TestWithParam> -{ -}; - void Run3dDriver(miopenDataType_t prec) { @@ -132,6 +119,22 @@ void Run3dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } +std::vector GetTestCases(const std::string& precision) +{ + const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); + + const std::vector test_cases = { + // clang-format off + {"test_immed_conv3d " + precision + " --input 1 4 4 4 4 --weights 2 4 3 3 3 --pads_strides_dilations 0 0 0 1 1 1 1 1 1 "+flag_arg} + // clang-format on + }; + + return test_cases; +} + +} // namespace immed_conv3d_codecov +using namespace immed_conv3d_codecov; + TEST_P(Conv3dFloat, FloatTest_immed_conv3d_codecov) { const auto& handle = get_handle(); @@ -184,19 +187,6 @@ TEST_P(Conv3dInt8, Int8Test_immed_conv3d_codecov) } }; -std::vector GetTestCases(const std::string& precision) -{ - const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); - - const std::vector test_cases = { - // clang-format off - {"test_immed_conv3d " + precision + " --input 1 4 4 4 4 --weights 2 4 3 3 3 --pads_strides_dilations 0 0 0 1 1 1 1 1 1 "+flag_arg} - // clang-format on - }; - - return test_cases; -} - INSTANTIATE_TEST_SUITE_P(ImmedConv3D, Conv3dFloat, testing::Values(GetTestCases("--float"))); INSTANTIATE_TEST_SUITE_P(ImmedConv3D, Conv3dHalf, testing::Values(GetTestCases("--half"))); diff --git a/test/gtest/pooling2d_asymmetric.cpp b/test/gtest/pooling2d_asymmetric.cpp index d9d2213f36..4b7fb06d12 100644 --- a/test/gtest/pooling2d_asymmetric.cpp +++ b/test/gtest/pooling2d_asymmetric.cpp @@ -24,14 +24,17 @@ * *******************************************************************************/ -#include "pooling2d.hpp" -#include "get_handle.hpp" -#include #include +#include +#include "get_handle.hpp" + +#include "pooling2d.hpp" MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLAGS_ARGS) +namespace pooling2d_asymmetric { + static bool SkipTest(void) { return miopen::IsDisabled(ENV(MIOPEN_TEST_ALL)); } void GetArgs(const std::string& param, std::vector& tokens) @@ -43,14 +46,6 @@ void GetArgs(const std::string& param, std::vector& tokens) tokens.push_back(*begin++); } -class Pooling2dFloat : public testing::TestWithParam> -{ -}; - -class Pooling2dHalf : public testing::TestWithParam> -{ -}; - void Run2dDriver(miopenDataType_t prec) { @@ -92,6 +87,22 @@ void Run2dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } +std::vector GetTestCases(const std::string& precision) +{ + const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); + + const std::vector test_cases = { + // clang-format off + {"test_pooling2d " + precision + " --all --dataset 1 --limit 0 "+flag_arg} + // clang-format on + }; + + return test_cases; +} + +} // namespace pooling2d_asymmetric +using namespace pooling2d_asymmetric; + TEST_P(Pooling2dFloat, FloatTest_pooling2d_asymmetric) { const auto& handle = get_handle(); @@ -118,19 +129,6 @@ TEST_P(Pooling2dHalf, HalfTest_pooling2d_asymmetric) } }; -std::vector GetTestCases(const std::string& precision) -{ - const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); - - const std::vector test_cases = { - // clang-format off - {"test_pooling2d " + precision + " --all --dataset 1 --limit 0 "+flag_arg} - // clang-format on - }; - - return test_cases; -} - INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dFloat, testing::Values(GetTestCases("--float"))); INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dHalf, testing::Values(GetTestCases("--half"))); diff --git a/test/gtest/pooling2d_codecov.cpp b/test/gtest/pooling2d_codecov.cpp index 365c03d272..e56aec5f4c 100644 --- a/test/gtest/pooling2d_codecov.cpp +++ b/test/gtest/pooling2d_codecov.cpp @@ -24,14 +24,17 @@ * *******************************************************************************/ -#include "pooling2d.hpp" -#include "get_handle.hpp" -#include #include +#include +#include "get_handle.hpp" + +#include "pooling2d.hpp" MIOPEN_DECLARE_ENV_VAR_BOOL(CODECOV_TEST) MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLAGS_ARGS) +namespace pooling2d_codecov { + static bool SkipTest(void) { return !miopen::IsEnabled(ENV(CODECOV_TEST)); } void GetArgs(const std::string& param, std::vector& tokens) @@ -43,14 +46,6 @@ void GetArgs(const std::string& param, std::vector& tokens) tokens.push_back(*begin++); } -class Pooling2dFloat : public testing::TestWithParam> -{ -}; - -class Pooling2dHalf : public testing::TestWithParam> -{ -}; - void Run2dDriver(miopenDataType_t prec) { @@ -92,6 +87,22 @@ void Run2dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } +std::vector GetTestCases(const std::string& precision) +{ + const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); + + const std::vector test_cases = { + // clang-format off + {"test_pooling2d " + precision + "--input 1, 192, 28, 28 --lens 2 2 --strides 2 2 --pads 0 0 "+flag_arg} + // clang-format on + }; + + return test_cases; +} + +} // namespace pooling2d_codecov +using namespace pooling2d_codecov; + TEST_P(Pooling2dFloat, FloatTest_pooling2d_codecov) { const auto& handle = get_handle(); @@ -118,19 +129,6 @@ TEST_P(Pooling2dHalf, HalfTest_pooling2d_codecov) } }; -std::vector GetTestCases(const std::string& precision) -{ - const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); - - const std::vector test_cases = { - // clang-format off - {"test_pooling2d " + precision + "--input 1, 192, 28, 28 --lens 2 2 --strides 2 2 --pads 0 0 "+flag_arg} - // clang-format on - }; - - return test_cases; -} - INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dFloat, testing::Values(GetTestCases("--float"))); INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dHalf, testing::Values(GetTestCases("--half"))); diff --git a/test/gtest/pooling2d_wide.cpp b/test/gtest/pooling2d_wide.cpp index cb4233ae0c..b9b80a6fbc 100644 --- a/test/gtest/pooling2d_wide.cpp +++ b/test/gtest/pooling2d_wide.cpp @@ -24,14 +24,17 @@ * *******************************************************************************/ -#include "pooling2d.hpp" -#include "get_handle.hpp" -#include #include +#include +#include "get_handle.hpp" + +#include "pooling2d.hpp" MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLAGS_ARGS) +namespace pooling2d_wide { + static bool SkipTest(void) { return miopen::IsDisabled(ENV(MIOPEN_TEST_ALL)); } void GetArgs(const std::string& param, std::vector& tokens) @@ -43,14 +46,6 @@ void GetArgs(const std::string& param, std::vector& tokens) tokens.push_back(*begin++); } -class Pooling2dFloat : public testing::TestWithParam> -{ -}; - -class Pooling2dHalf : public testing::TestWithParam> -{ -}; - void Run2dDriver(miopenDataType_t prec) { @@ -92,6 +87,22 @@ void Run2dDriver(miopenDataType_t prec) bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } +std::vector GetTestCases(const std::string precision) +{ + const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); + + const std::vector test_cases = { + // clang-format off + {"test_pooling2d " + precision + " --all --dataset 2 --limit 0 "+flag_arg} + // clang-format on + }; + + return test_cases; +} + +} // namespace pooling2d_wide +using namespace pooling2d_wide; + TEST_P(Pooling2dFloat, FloatTest_pooling2d_wide) { const auto& handle = get_handle(); @@ -118,19 +129,6 @@ TEST_P(Pooling2dHalf, HalfTest_pooling2d_wide) } }; -std::vector GetTestCases(const std::string precision) -{ - const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); - - const std::vector test_cases = { - // clang-format off - {"test_pooling2d " + precision + " --all --dataset 2 --limit 0 "+flag_arg} - // clang-format on - }; - - return test_cases; -} - INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dFloat, testing::Values(GetTestCases("--float"))); INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dHalf, testing::Values(GetTestCases("--half"))); diff --git a/test/pooling2d.hpp b/test/pooling2d.hpp index 128e81cce2..e6e107678a 100644 --- a/test/pooling2d.hpp +++ b/test/pooling2d.hpp @@ -24,6 +24,7 @@ * *******************************************************************************/ +#include #include "pooling_common.hpp" #define WORKAROUND_ISSUE_1670 1 @@ -105,3 +106,11 @@ struct pooling2d_driver : pooling_driver this->add(this->wsidx, "wsidx", this->generate_data({0, 1})); } }; + +class Pooling2dFloat : public testing::TestWithParam> +{ +}; + +class Pooling2dHalf : public testing::TestWithParam> +{ +}; From 9b8cfa43796864070675cf7e71b65d1a329b2c12 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Mon, 18 Dec 2023 21:32:50 +0000 Subject: [PATCH 19/25] add gtest precision checks, disable gtest pooling float --- test/gtest/conv3d_codecov.cpp | 9 ++++--- test/gtest/conv_embed_db.cpp | 11 ++------ test/gtest/conv_hip_igemm_xdlops.cpp | 12 +++------ test/gtest/conv_igemm_dynamic.cpp | 6 +++-- test/gtest/conv_igemm_mlir.cpp | 21 +++++---------- test/gtest/conv_igemm_mlir_xdlops.cpp | 19 ++++---------- test/gtest/immed_conv2d_codecov.cpp | 9 ++++--- test/gtest/immed_conv3d_codecov.cpp | 9 ++++--- test/gtest/pooling2d_asymmetric.cpp | 9 ++++--- test/gtest/pooling2d_codecov.cpp | 5 ++-- test/gtest/pooling2d_wide.cpp | 9 ++++--- test/test_env.hpp | 38 +++++++++++++++++++++++++++ 12 files changed, 88 insertions(+), 69 deletions(-) create mode 100644 test/test_env.hpp diff --git a/test/gtest/conv3d_codecov.cpp b/test/gtest/conv3d_codecov.cpp index d1b7e9a888..fe7b2f6987 100644 --- a/test/gtest/conv3d_codecov.cpp +++ b/test/gtest/conv3d_codecov.cpp @@ -26,6 +26,7 @@ #include #include #include "get_handle.hpp" +#include "test_env.hpp" #include "conv3d.hpp" @@ -104,7 +105,7 @@ using namespace conv3d_codecov; TEST_P(Conv3dFloat, FloatTest_conv3d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--float")) { Run3dDriver(miopenFloat); } @@ -117,7 +118,7 @@ TEST_P(Conv3dFloat, FloatTest_conv3d_codecov) TEST_P(Conv3dHalf, HalfTest_conv3d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--half")) { Run3dDriver(miopenHalf); } @@ -130,7 +131,7 @@ TEST_P(Conv3dHalf, HalfTest_conv3d_codecov) TEST_P(Conv3dBFloat16, BFloat16Test_conv3d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--bfloat16")) { Run3dDriver(miopenBFloat16); } @@ -143,7 +144,7 @@ TEST_P(Conv3dBFloat16, BFloat16Test_conv3d_codecov) TEST_P(Conv3dInt8, Int8Test_conv3d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--int8")) { Run3dDriver(miopenInt8); } diff --git a/test/gtest/conv_embed_db.cpp b/test/gtest/conv_embed_db.cpp index 61374c95b0..e752cea630 100644 --- a/test/gtest/conv_embed_db.cpp +++ b/test/gtest/conv_embed_db.cpp @@ -29,20 +29,13 @@ #include #include #include -#include "../conv2d.hpp" #include "get_handle.hpp" +#include "test_env.hpp" -MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) +#include "../conv2d.hpp" namespace conv_embed_db { -static bool IsTestRunWith(const char* float_arg) -{ - assert(float_arg != nullptr); - const auto& s_envVar = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLOAT_ARG)); - return (s_envVar.compare(float_arg) == 0); -} - void GetArgs(const std::string& param, std::vector& tokens) { std::stringstream ss(param); diff --git a/test/gtest/conv_hip_igemm_xdlops.cpp b/test/gtest/conv_hip_igemm_xdlops.cpp index 45ae7a99ca..fa2d25aad7 100644 --- a/test/gtest/conv_hip_igemm_xdlops.cpp +++ b/test/gtest/conv_hip_igemm_xdlops.cpp @@ -29,22 +29,16 @@ #include #include #include -#include "../conv2d.hpp" #include "get_handle.hpp" +#include "test_env.hpp" + +#include "../conv2d.hpp" -MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_COMPOSABLEKERNEL) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) namespace conv_hip_igemm_xdlops { -static bool IsTestRunWith(const char* float_arg) -{ - assert(float_arg != nullptr); - const auto& s_envVar = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLOAT_ARG)); - return (!s_envVar.empty() && std::strcmp(s_envVar.c_str(), float_arg) == 0); -} - void GetArgs(const std::string& param, std::vector& tokens) { std::stringstream ss(param); diff --git a/test/gtest/conv_igemm_dynamic.cpp b/test/gtest/conv_igemm_dynamic.cpp index 916fa71612..676ce1c352 100644 --- a/test/gtest/conv_igemm_dynamic.cpp +++ b/test/gtest/conv_igemm_dynamic.cpp @@ -28,8 +28,10 @@ #include #include #include -#include "../conv2d.hpp" #include "get_handle.hpp" +#include "test_env.hpp" + +#include "../conv2d.hpp" using TestCase = std::tuple, std::string>; @@ -180,7 +182,7 @@ using namespace conv_igemm_dynamic; TEST_P(Conv2dFloatDynamic, FloatTest_conv_igemm_dynamic) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--float")) { Run2dDriver(miopenFloat); } diff --git a/test/gtest/conv_igemm_mlir.cpp b/test/gtest/conv_igemm_mlir.cpp index 72e4a9add1..3b846d6e6c 100644 --- a/test/gtest/conv_igemm_mlir.cpp +++ b/test/gtest/conv_igemm_mlir.cpp @@ -29,10 +29,11 @@ #include #include #include -#include "../conv2d.hpp" #include "get_handle.hpp" +#include "test_env.hpp" + +#include "../conv2d.hpp" -MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_MLIR) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) @@ -40,16 +41,6 @@ namespace conv_igemm_mlir { using TestCase = std::tuple, std::string>; -std::string GetFloatArg() -{ - const auto& tmp = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLOAT_ARG)); - if(tmp.empty()) - { - return ""; - } - return tmp; -}; - void GetArgs(const TestCase& param, std::vector& tokens) { auto env_vars = std::get<0>(param); @@ -190,7 +181,7 @@ TEST_P(ConvIgemmMlirConfigFloat, FloatTest_conv_igemm_mlir) if((miopen::StartsWith(handle.GetDeviceName(), "gfx103") || miopen::StartsWith(handle.GetDeviceName(), "gfx906")) && miopen::IsEnabled(ENV(MIOPEN_TEST_MLIR)) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && - GetFloatArg() == "--float") + IsTestRunWith("--float")) { Run2dDriver(miopenFloat); } @@ -212,7 +203,7 @@ TEST_P(ConvIgemmMlirConfigHalf, HalfTest_conv_igemm_mlir) if((miopen::StartsWith(handle.GetDeviceName(), "gfx103") || miopen::StartsWith(handle.GetDeviceName(), "gfx906")) && miopen::IsEnabled(ENV(MIOPEN_TEST_MLIR)) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && - GetFloatArg() == "--half") + IsTestRunWith("--half")) { Run2dDriver(miopenHalf); } @@ -234,7 +225,7 @@ TEST_P(ConvIgemmMlirConfigInt8, Int8Test_conv_igemm_mlir) if((miopen::StartsWith(handle.GetDeviceName(), "gfx103") || miopen::StartsWith(handle.GetDeviceName(), "gfx906")) && miopen::IsEnabled(ENV(MIOPEN_TEST_MLIR)) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && - GetFloatArg() == "--int8") + IsTestRunWith("--int8")) { Run2dDriver(miopenInt8); } diff --git a/test/gtest/conv_igemm_mlir_xdlops.cpp b/test/gtest/conv_igemm_mlir_xdlops.cpp index feda46ad60..ff43a91896 100644 --- a/test/gtest/conv_igemm_mlir_xdlops.cpp +++ b/test/gtest/conv_igemm_mlir_xdlops.cpp @@ -4,10 +4,11 @@ #include #include #include -#include "conv2d.hpp" #include "get_handle.hpp" +#include "test_env.hpp" + +#include "conv2d.hpp" -MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_MLIR) MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) @@ -15,16 +16,6 @@ namespace conv_igemm_mlir_xdlops { using TestCase = std::tuple, std::string>; -std::string GetFloatArg() -{ - const auto& tmp = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLOAT_ARG)); - if(tmp.empty()) - { - return ""; - } - return tmp; -}; - void GetArgs(const TestCase& param, std::vector& tokens) { auto env_vars = std::get<0>(param); @@ -164,7 +155,7 @@ TEST_P(ConvIgemmMlirXdlopsConfigHalf, HalfTest_conv_igemm_mlir_xdlops) if((miopen::StartsWith(handle.GetDeviceName(), "gfx908") || miopen::StartsWith(handle.GetDeviceName(), "gfx90a")) && miopen::IsEnabled(ENV(MIOPEN_TEST_MLIR)) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && - GetFloatArg() == "--half") + IsTestRunWith("--half")) { Run2dDriver(miopenHalf); } @@ -186,7 +177,7 @@ TEST_P(ConvIgemmMlirXdlopsConfigInt8, Int8Test_conv_igemm_mlir_xdlops) if((miopen::StartsWith(handle.GetDeviceName(), "gfx908") || miopen::StartsWith(handle.GetDeviceName(), "gfx90a")) && miopen::IsEnabled(ENV(MIOPEN_TEST_MLIR)) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && - GetFloatArg() == "--int8") + IsTestRunWith("--int8")) { Run2dDriver(miopenInt8); } diff --git a/test/gtest/immed_conv2d_codecov.cpp b/test/gtest/immed_conv2d_codecov.cpp index 32b71ed0f7..5d4153bc53 100644 --- a/test/gtest/immed_conv2d_codecov.cpp +++ b/test/gtest/immed_conv2d_codecov.cpp @@ -27,6 +27,7 @@ #include "get_handle.hpp" #include #include +#include "test_env.hpp" MIOPEN_DECLARE_ENV_VAR_BOOL(CODECOV_TEST) MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLAGS_ARGS) @@ -153,7 +154,7 @@ using namespace immed_conv2d_codecov; TEST_P(Conv2dFloat, FloatTest_immed_conv2d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--float")) { Run2dDriver(miopenFloat); } @@ -166,7 +167,7 @@ TEST_P(Conv2dFloat, FloatTest_immed_conv2d_codecov) TEST_P(Conv2dHalf, HalfTest_immed_conv2d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--half")) { Run2dDriver(miopenHalf); } @@ -179,7 +180,7 @@ TEST_P(Conv2dHalf, HalfTest_immed_conv2d_codecov) TEST_P(Conv2dBFloat16, BFloat16Test_immed_conv2d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--bfloat16")) { Run2dDriver(miopenBFloat16); } @@ -192,7 +193,7 @@ TEST_P(Conv2dBFloat16, BFloat16Test_immed_conv2d_codecov) TEST_P(Conv2dInt8, Int8Test_immed_conv2d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--int8")) { Run2dDriver(miopenInt8); } diff --git a/test/gtest/immed_conv3d_codecov.cpp b/test/gtest/immed_conv3d_codecov.cpp index 1e98ad7a61..e1223906c9 100644 --- a/test/gtest/immed_conv3d_codecov.cpp +++ b/test/gtest/immed_conv3d_codecov.cpp @@ -26,6 +26,7 @@ #include #include #include "get_handle.hpp" +#include "test_env.hpp" #include "conv3d.hpp" @@ -138,7 +139,7 @@ using namespace immed_conv3d_codecov; TEST_P(Conv3dFloat, FloatTest_immed_conv3d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--float")) { Run3dDriver(miopenFloat); } @@ -151,7 +152,7 @@ TEST_P(Conv3dFloat, FloatTest_immed_conv3d_codecov) TEST_P(Conv3dHalf, HalfTest_immed_conv3d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--half")) { Run3dDriver(miopenHalf); } @@ -164,7 +165,7 @@ TEST_P(Conv3dHalf, HalfTest_immed_conv3d_codecov) TEST_P(Conv3dBFloat16, BFloat16Test_immed_conv3d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--bfloat16")) { Run3dDriver(miopenBFloat16); } @@ -177,7 +178,7 @@ TEST_P(Conv3dBFloat16, BFloat16Test_immed_conv3d_codecov) TEST_P(Conv3dInt8, Int8Test_immed_conv3d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--int8")) { Run3dDriver(miopenInt8); } diff --git a/test/gtest/pooling2d_asymmetric.cpp b/test/gtest/pooling2d_asymmetric.cpp index 4b7fb06d12..13cd49051a 100644 --- a/test/gtest/pooling2d_asymmetric.cpp +++ b/test/gtest/pooling2d_asymmetric.cpp @@ -27,6 +27,7 @@ #include #include #include "get_handle.hpp" +#include "test_env.hpp" #include "pooling2d.hpp" @@ -103,10 +104,11 @@ std::vector GetTestCases(const std::string& precision) } // namespace pooling2d_asymmetric using namespace pooling2d_asymmetric; +/* TEST_P(Pooling2dFloat, FloatTest_pooling2d_asymmetric) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--float")) { Run2dDriver(miopenFloat); } @@ -115,11 +117,12 @@ TEST_P(Pooling2dFloat, FloatTest_pooling2d_asymmetric) GTEST_SKIP(); } }; +*/ TEST_P(Pooling2dHalf, HalfTest_pooling2d_asymmetric) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--half")) { Run2dDriver(miopenHalf); } @@ -129,6 +132,6 @@ TEST_P(Pooling2dHalf, HalfTest_pooling2d_asymmetric) } }; -INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dFloat, testing::Values(GetTestCases("--float"))); +// INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dFloat, testing::Values(GetTestCases("--float"))); INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dHalf, testing::Values(GetTestCases("--half"))); diff --git a/test/gtest/pooling2d_codecov.cpp b/test/gtest/pooling2d_codecov.cpp index e56aec5f4c..f17b0ee25e 100644 --- a/test/gtest/pooling2d_codecov.cpp +++ b/test/gtest/pooling2d_codecov.cpp @@ -27,6 +27,7 @@ #include #include #include "get_handle.hpp" +#include "test_env.hpp" #include "pooling2d.hpp" @@ -106,7 +107,7 @@ using namespace pooling2d_codecov; TEST_P(Pooling2dFloat, FloatTest_pooling2d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--float")) { Run2dDriver(miopenFloat); } @@ -119,7 +120,7 @@ TEST_P(Pooling2dFloat, FloatTest_pooling2d_codecov) TEST_P(Pooling2dHalf, HalfTest_pooling2d_codecov) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--half")) { Run2dDriver(miopenHalf); } diff --git a/test/gtest/pooling2d_wide.cpp b/test/gtest/pooling2d_wide.cpp index b9b80a6fbc..f6c7da0148 100644 --- a/test/gtest/pooling2d_wide.cpp +++ b/test/gtest/pooling2d_wide.cpp @@ -27,6 +27,7 @@ #include #include #include "get_handle.hpp" +#include "test_env.hpp" #include "pooling2d.hpp" @@ -103,10 +104,11 @@ std::vector GetTestCases(const std::string precision) } // namespace pooling2d_wide using namespace pooling2d_wide; +/* TEST_P(Pooling2dFloat, FloatTest_pooling2d_wide) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--float")) { Run2dDriver(miopenFloat); } @@ -115,11 +117,12 @@ TEST_P(Pooling2dFloat, FloatTest_pooling2d_wide) GTEST_SKIP(); } }; +*/ TEST_P(Pooling2dHalf, HalfTest_pooling2d_wide) { const auto& handle = get_handle(); - if(IsTestSupportedForDevice(handle) && !SkipTest()) + if(IsTestSupportedForDevice(handle) && !SkipTest() && IsTestRunWith("--half")) { Run2dDriver(miopenHalf); } @@ -129,6 +132,6 @@ TEST_P(Pooling2dHalf, HalfTest_pooling2d_wide) } }; -INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dFloat, testing::Values(GetTestCases("--float"))); +// INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dFloat, testing::Values(GetTestCases("--float"))); INSTANTIATE_TEST_SUITE_P(Pooling2D, Pooling2dHalf, testing::Values(GetTestCases("--half"))); diff --git a/test/test_env.hpp b/test/test_env.hpp new file mode 100644 index 0000000000..f0c3ec9b4a --- /dev/null +++ b/test/test_env.hpp @@ -0,0 +1,38 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ + +#pragma once + +#include + +MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) + +inline bool IsTestRunWith(const char* float_arg) +{ + assert(float_arg != nullptr); + const auto& s_envVar = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLOAT_ARG)); + return (s_envVar.compare(float_arg) == 0); +} From eb3812c8c5ac9191ab57141fe20564bcce95e35e Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Mon, 18 Dec 2023 16:27:50 -0600 Subject: [PATCH 20/25] default smoketest true, suspend nightly action --- Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1fe6dff53b..544316d4ae 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -436,15 +436,15 @@ pipeline { description: "") booleanParam( name: "BUILD_SMOKE_FP32", - defaultValue: env.BRANCH_NAME == env.NIGHTLY_BRANCH ? true : false, + defaultValue: true, //env.BRANCH_NAME == env.NIGHTLY_BRANCH ? true : false, description: "") booleanParam( name: "BUILD_SMOKE_AUX1", - defaultValue: env.BRANCH_NAME == env.NIGHTLY_BRANCH ? true : false, + defaultValue: true, //env.BRANCH_NAME == env.NIGHTLY_BRANCH ? true : false, description: "") booleanParam( name: "BUILD_SMOKE_FP16_BF16_INT8", - defaultValue: env.BRANCH_NAME == env.NIGHTLY_BRANCH ? true : false, + defaultValue: true, //env.BRANCH_NAME == env.NIGHTLY_BRANCH ? true : false, description: "") booleanParam( name: "BUILD_FULL_TESTS", @@ -535,10 +535,10 @@ pipeline { Smoke_targets = "check MIOpenDriver" NOCOMGR_flags = " -DMIOPEN_USE_COMGR=Off" } - triggers{ - - cron(env.BRANCH_NAME == env.NIGHTLY_BRANCH ? env.NIGHTLY_SCHEDULE : '') - } + //triggers{ + // + // cron(env.BRANCH_NAME == env.NIGHTLY_BRANCH ? env.NIGHTLY_SCHEDULE : '') + //} stages{ stage('Build Docker'){ when { From 1e7c6fc77c61809460555dc0f977db467eccbd03 Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Tue, 19 Dec 2023 03:37:27 +0000 Subject: [PATCH 21/25] test name + scope correction --- test/gtest/CMakeLists.txt | 2 +- test/gtest/db_sync.cpp | 28 ++++++++++++++++++---------- test/gtest/group_conv3d_bwd.hpp | 2 +- test/gtest/group_conv3d_fwd.hpp | 2 +- test/gtest/group_conv3d_wrw.hpp | 4 +++- test/gtest/group_solver.hpp | 2 +- test/gtest/layernorm.hpp | 3 ++- test/gtest/nonpack_conv3d_fwd.cpp | 6 +++--- test/gtest/nonpack_conv3d_fwd.hpp | 2 +- test/gtest/sum.hpp | 2 +- 10 files changed, 32 insertions(+), 21 deletions(-) diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index f792ff36a5..f3d92a610a 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -29,7 +29,7 @@ function(add_gtest TEST_NAME TEST_CPP) endif() if(NOT WIN32) # TODO: cannot run on Windows due to missing DLL dependencies # Enable CMake to discover the test binary - gtest_discover_tests(${TEST_NAME} PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL};CODECOV_TEST=${CODECOV_TEST}") + gtest_discover_tests(${TEST_NAME} PROPERTIES ENVIRONMENT "MIOPEN_USER_DB_PATH=${CMAKE_CURRENT_BINARY_DIR};MIOPEN_TEST_FLOAT_ARG=${MIOPEN_TEST_FLOAT_ARG};MIOPEN_TEST_ALL=${MIOPEN_TEST_ALL};MIOPEN_TEST_MLIR=${MIOPEN_TEST_MLIR};MIOPEN_TEST_COMPOSABLEKERNEL=${MIOPEN_TEST_COMPOSABLEKERNEL};CODECOV_TEST=${CODECOV_TEST};MIOPEN_TEST_DBSYNC=${MIOPEN_TEST_DBSYNC}") endif() if(WIN32) diff --git a/test/gtest/db_sync.cpp b/test/gtest/db_sync.cpp index aed0bdaed0..93ac329f40 100644 --- a/test/gtest/db_sync.cpp +++ b/test/gtest/db_sync.cpp @@ -50,6 +50,8 @@ #define SKIP_KDB_PDB_TESTING 0 // Allows testing FDB on gfx1030. #define SKIP_CONVOCLDIRECTFWDFUSED 0 // Allows testing FDB on gfx1030 (legacy fdb). +MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_DBSYNC) + struct KDBKey { std::string program_file; @@ -438,14 +440,17 @@ void SetupPaths(boost::filesystem::path& fdb_file_path, TEST(DBSync, KDBTargetID) { - boost::filesystem::path fdb_file_path, pdb_file_path, kdb_file_path; + if(miopen::IsEnabled(ENV(MIOPEN_TEST_DBSYNC))) + { + boost::filesystem::path fdb_file_path, pdb_file_path, kdb_file_path; #if WORKAROUND_ISSUE_2493 - SetEnvironmentVariable("MIOPEN_DEBUG_WORKAROUND_ISSUE_2493", "0"); + SetEnvironmentVariable("MIOPEN_DEBUG_WORKAROUND_ISSUE_2493", "0"); #endif - SetupPaths(fdb_file_path, pdb_file_path, kdb_file_path, get_handle()); - std::ignore = fdb_file_path; - std::ignore = pdb_file_path; - EXPECT_FALSE(!SKIP_KDB_PDB_TESTING && miopen::CheckKDBForTargetID(kdb_file_path)); + SetupPaths(fdb_file_path, pdb_file_path, kdb_file_path, get_handle()); + std::ignore = fdb_file_path; + std::ignore = pdb_file_path; + EXPECT_FALSE(!SKIP_KDB_PDB_TESTING && miopen::CheckKDBForTargetID(kdb_file_path)); + } } bool LogBuildMessage() @@ -820,10 +825,13 @@ struct DBSync : testing::TestWithParam> TEST_P(DBSync, StaticFDBSync) { - std::string arch; - size_t num_cu; - std::tie(arch, num_cu) = GetParam(); - StaticFDBSync(arch, num_cu); + if(miopen::IsEnabled(ENV(MIOPEN_TEST_DBSYNC))) + { + std::string arch; + size_t num_cu; + std::tie(arch, num_cu) = GetParam(); + StaticFDBSync(arch, num_cu); + } } INSTANTIATE_TEST_SUITE_P(DBSyncSuite, diff --git a/test/gtest/group_conv3d_bwd.hpp b/test/gtest/group_conv3d_bwd.hpp index 41241b605a..0299e3f420 100644 --- a/test/gtest/group_conv3d_bwd.hpp +++ b/test/gtest/group_conv3d_bwd.hpp @@ -27,7 +27,7 @@ #include "conv3d_test_case.hpp" -inline int SetTensorLayout(miopen::TensorDescriptor& desc) +static int SetTensorLayout(miopen::TensorDescriptor& desc) { // get layout string names std::string layout_str = desc.GetLayout_str(); diff --git a/test/gtest/group_conv3d_fwd.hpp b/test/gtest/group_conv3d_fwd.hpp index 49a2261537..3cdb370fc0 100644 --- a/test/gtest/group_conv3d_fwd.hpp +++ b/test/gtest/group_conv3d_fwd.hpp @@ -27,7 +27,7 @@ #include "conv3d_test_case.hpp" -inline int SetTensorLayout(miopen::TensorDescriptor& desc) +static int SetTensorLayout(miopen::TensorDescriptor& desc) { // get layout string names std::string layout_str = desc.GetLayout_str(); diff --git a/test/gtest/group_conv3d_wrw.hpp b/test/gtest/group_conv3d_wrw.hpp index 492d332892..55ea4c51e7 100644 --- a/test/gtest/group_conv3d_wrw.hpp +++ b/test/gtest/group_conv3d_wrw.hpp @@ -27,7 +27,8 @@ #include "conv3d_test_case.hpp" -inline int SetTensorLayout(miopen::TensorDescriptor& desc) +/* +static int SetTensorLayout(miopen::TensorDescriptor& desc) { // get layout string names std::string layout_str = desc.GetLayout_str(); @@ -38,6 +39,7 @@ inline int SetTensorLayout(miopen::TensorDescriptor& desc) // set the strides for the tensor return SetTensorNd(&desc, int_lens, layout_str, desc.GetType()); } +*/ template struct ConvWrwSolverTest diff --git a/test/gtest/group_solver.hpp b/test/gtest/group_solver.hpp index ee03f880d5..3d50fd05c5 100644 --- a/test/gtest/group_solver.hpp +++ b/test/gtest/group_solver.hpp @@ -92,7 +92,7 @@ inline std::vector ConvTestConfigs() {32, 256, 1024, 28, 28, 2048, 3, 3, 1, 1, 1, 1, 1, 1, miopenConvolution}}; } -inline int SetTensorLayout(miopen::TensorDescriptor& desc) +static int SetTensorLayout(miopen::TensorDescriptor& desc) { // get layout string names std::string layout_str = desc.GetLayout_str(); diff --git a/test/gtest/layernorm.hpp b/test/gtest/layernorm.hpp index 63158ef134..f93071c915 100644 --- a/test/gtest/layernorm.hpp +++ b/test/gtest/layernorm.hpp @@ -151,7 +151,7 @@ std::vector LayerNormTestConfigs() // clang-format on } -inline int32_t SetTensorLayout(miopen::TensorDescriptor& desc) +static int32_t SetTensorLayout(miopen::TensorDescriptor& desc) { std::vector lens = desc.GetLengths(); std::vector int32_t_lens(lens.begin(), lens.end()); @@ -168,6 +168,7 @@ struct LayerNormTest : public ::testing::TestWithParam { auto&& handle = get_handle(); layernorm_config = GetParam(); + std::mt19937 gen(0); std::uniform_real_distribution<> d{-3, 3}; auto gen_value = [&](auto...) { return d(gen); }; diff --git a/test/gtest/nonpack_conv3d_fwd.cpp b/test/gtest/nonpack_conv3d_fwd.cpp index 6b00e43eb2..64a6ef5eb8 100644 --- a/test/gtest/nonpack_conv3d_fwd.cpp +++ b/test/gtest/nonpack_conv3d_fwd.cpp @@ -32,7 +32,7 @@ #include "get_handle.hpp" #include "nonpack_conv3d_fwd.hpp" -struct ConvNonpackFwdSolverTest3D : ConvFwdSolverTest +struct ConvNonpackFwdSolverTest3DHalf : ConvNonpackFwdSolverTest3D { }; @@ -78,7 +78,7 @@ void SolverFwd(const miopen::TensorDescriptor& inputDesc, handle.Finish(); } -TEST_P(ConvNonpackFwdSolverTest3D, CKNonPackConvFwd3D) +TEST_P(ConvNonpackFwdSolverTest3DHalf, CKNonPackConvFwd3D) { SolverFwd(input.desc, in_dev.get(), @@ -92,7 +92,7 @@ TEST_P(ConvNonpackFwdSolverTest3D, CKNonPackConvFwd3D) } INSTANTIATE_TEST_SUITE_P(ConvFwdTest, - ConvNonpackFwdSolverTest3D, + ConvNonpackFwdSolverTest3DHalf, testing::Combine(testing::Values(miopenConvolutionFwdAlgoImplicitGEMM), testing::ValuesIn(ConvTestConfigs()), testing::Values(miopenTensorNDHWC))); diff --git a/test/gtest/nonpack_conv3d_fwd.hpp b/test/gtest/nonpack_conv3d_fwd.hpp index b69ba977cc..9cba761211 100644 --- a/test/gtest/nonpack_conv3d_fwd.hpp +++ b/test/gtest/nonpack_conv3d_fwd.hpp @@ -87,7 +87,7 @@ std::vector ConvTestConfigs() } template -struct ConvFwdSolverTest +struct ConvNonpackFwdSolverTest3D : public ::testing::TestWithParam< std::tuple> { diff --git a/test/gtest/sum.hpp b/test/gtest/sum.hpp index f38da15f96..80105780ec 100644 --- a/test/gtest/sum.hpp +++ b/test/gtest/sum.hpp @@ -99,7 +99,7 @@ std::vector SumTestConfigs() // clang-format on } -inline int32_t SetTensorLayout(miopen::TensorDescriptor& desc) +static int32_t SetTensorLayout(miopen::TensorDescriptor& desc) { std::vector lens = desc.GetLengths(); std::vector int32_t_lens(lens.begin(), lens.end()); From 5c88612105cec3fd7722579ef637871df705ecfc Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Tue, 19 Dec 2023 15:50:42 +0000 Subject: [PATCH 22/25] fix jenkins db_sync call --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 544316d4ae..9f0b7066df 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -924,7 +924,7 @@ pipeline { environment{ setup_flags="-DDISCRETE_GTEST=1 -DMIOPEN_TEST_DBSYNC=1" config_targets='test_db_sync' - execute_cmd='./bin/test_db_sync' + execute_cmd='MIOPEN_TEST_DBSYNC=1 ./bin/test_db_sync' } steps{ buildHipClangJobAndReboot(lfs_pull: true, setup_flags: setup_flags, config_targets: config_targets, execute_cmd: execute_cmd, @@ -943,7 +943,7 @@ pipeline { environment{ setup_flags="-DDISCRETE_GTEST=1 -DMIOPEN_TEST_DBSYNC=1" config_targets='test_db_sync' - execute_cmd='./bin/test_db_sync' + execute_cmd='MIOPEN_TEST_DBSYNC=1 ./bin/test_db_sync' } steps{ buildHipClangJobAndReboot(lfs_pull: true, setup_flags: setup_flags, config_targets: config_targets, execute_cmd: execute_cmd, From ed002f5877789f135883dcf13c935fa29de22f4c Mon Sep 17 00:00:00 2001 From: Christopher Erb Date: Tue, 19 Dec 2023 10:26:27 -0600 Subject: [PATCH 23/25] Revert "[HotFix] revert #2580 and re-enable smoke tests (#2616)" This reverts commit c567b2e964c01c576a6e670ee85a1ca3920ef4ce. --- .github/workflows/update_develop_nightly.yml | 20 ++ Jenkinsfile | 6 +- test/CMakeLists.txt | 22 -- test/{immed_conv3d.cpp => conv3d.hpp} | 12 +- test/driver.hpp | 7 +- test/gtest/CMakeLists.txt | 2 +- test/gtest/conv3d_codecov.cpp | 172 ++++++++++++++++ test/gtest/conv_2d.hpp | 66 ------ test/gtest/conv_igemm_mlir_xdlops.cpp | 2 +- test/gtest/immed_conv2d_codecov.cpp | 206 +++++++++++++++++++ test/gtest/immed_conv3d_codecov.cpp | 206 +++++++++++++++++++ test/gtest/pooling2d_asymmetric.cpp | 136 ++++++++++++ test/gtest/pooling2d_codecov.cpp | 136 ++++++++++++ test/gtest/pooling2d_wide.cpp | 136 ++++++++++++ test/immed_conv2d.cpp | 62 ------ test/{pooling2d.cpp => pooling2d.hpp} | 2 - 16 files changed, 1028 insertions(+), 165 deletions(-) create mode 100644 .github/workflows/update_develop_nightly.yml rename test/{immed_conv3d.cpp => conv3d.hpp} (91%) create mode 100644 test/gtest/conv3d_codecov.cpp delete mode 100644 test/gtest/conv_2d.hpp create mode 100644 test/gtest/immed_conv2d_codecov.cpp create mode 100644 test/gtest/immed_conv3d_codecov.cpp create mode 100644 test/gtest/pooling2d_asymmetric.cpp create mode 100644 test/gtest/pooling2d_codecov.cpp create mode 100644 test/gtest/pooling2d_wide.cpp delete mode 100644 test/immed_conv2d.cpp rename test/{pooling2d.cpp => pooling2d.hpp} (98%) diff --git a/.github/workflows/update_develop_nightly.yml b/.github/workflows/update_develop_nightly.yml new file mode 100644 index 0000000000..a8b5aabdb9 --- /dev/null +++ b/.github/workflows/update_develop_nightly.yml @@ -0,0 +1,20 @@ +name: Sync branch + +on: + pull_request: + workflow_dispatch: + push: + branches: + - develop +jobs: + sync-branch: + name: Update nightly branch + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@main + - uses: connor-baer/action-sync-branch@main + with: + branch: develop_nightly + token: ${{ secrets.GITHUB_TOKEN }} + force: false \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index a103509f23..7e07d3deba 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -436,15 +436,15 @@ pipeline { description: "") booleanParam( name: "BUILD_SMOKE_FP32", - defaultValue: true, + defaultValue: env.BRANCH_NAME == env.NIGHTLY_BRANCH ? true : false, description: "") booleanParam( name: "BUILD_SMOKE_AUX1", - defaultValue: true, + defaultValue: env.BRANCH_NAME == env.NIGHTLY_BRANCH ? true : false, description: "") booleanParam( name: "BUILD_SMOKE_FP16_BF16_INT8", - defaultValue: true, + defaultValue: env.BRANCH_NAME == env.NIGHTLY_BRANCH ? true : false, description: "") booleanParam( name: "BUILD_FULL_TESTS", diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d35ed0c43f..ffaeb93228 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -673,20 +673,6 @@ function(add_custom_test NAME) set_tests_properties(${NAME} PROPERTIES DISABLED On) endif() endfunction() -if(${CODECOV_TEST}) - add_custom_test(test_conv3d_codecov - COMMAND $ ${MIOPEN_TEST_FLOAT_ARG} --input 2 4 4 4 4 --weights 2 4 1 1 1 --pads_strides_dilations 0 0 0 1 1 1 1 1 1 ${MIOPEN_TEST_FLAGS_ARGS} - ) - add_custom_test(test_immed_conv2d_codecov - COMMAND $ ${MIOPEN_TEST_FLOAT_ARG} --input 2 2 14 14 --weights 8 2 3 3 --pads_strides_dilations 0 0 1 1 1 1 ${MIOPEN_TEST_FLAGS_ARGS} - ) - add_custom_test(test_immed_conv3d_codecov - COMMAND $ ${MIOPEN_TEST_FLOAT_ARG} --input 1 4 4 4 4 --weights 2 4 3 3 3 --pads_strides_dilations 0 0 0 1 1 1 1 1 1 ${MIOPEN_TEST_FLAGS_ARGS} - ) - add_custom_test(test_pooling2d_codecov - COMMAND $ ${MIOPEN_TEST_FLOAT_ARG} --input 1, 192, 28, 28 --lens 2 2 --strides 2 2 --pads 0 0 ${MIOPEN_TEST_FLAGS_ARGS} - ) -endif() if(${MIOPEN_TEST_WITH_MIOPENDRIVER}) add_custom_test(test_miopendriver_regression_issue_1576 SKIP_UNLESS_ALL GFX94X_ENABLED GFX103X_ENABLED GFX110X_ENABLED FLOAT_DISABLED HALF_ENABLED @@ -776,14 +762,6 @@ set(TEST_CONV_VERBOSE_F ${MIOPEN_TEST_FLOAT_ARG} --verbose --disable-backward-da set(TEST_CONV_VERBOSE_B ${MIOPEN_TEST_FLOAT_ARG} --verbose --disable-forward --disable-backward-weights) set(TEST_CONV_VERBOSE_W ${MIOPEN_TEST_FLOAT_ARG} --verbose --disable-forward --disable-backward-data) -add_custom_test(test_pooling2d_asymmetric SKIP_UNLESS_ALL HALF_ENABLED GFX94X_ENABLED GFX103X_ENABLED GFX110X_ENABLED - COMMAND $ ${MIOPEN_TEST_FLOAT_ARG} --all --dataset 1 --limit 0 ${MIOPEN_TEST_FLAGS_ARGS} -) - -add_custom_test(test_pooling2d_wide SKIP_UNLESS_ALL HALF_ENABLED GFX94X_ENABLED GFX103X_ENABLED GFX110X_ENABLED - COMMAND $ ${MIOPEN_TEST_FLOAT_ARG} --all --dataset 2 --limit 0 ${MIOPEN_TEST_FLAGS_ARGS} -) - set(IMPLICITGEMM_MLIR_ENV_F_XDLOPS ${IMPLICITGEMM_MLIR_ENV_BASE} MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvMlirIgemmFwdXdlops) set(IMPLICITGEMM_MLIR_ENV_B_XDLOPS ${IMPLICITGEMM_MLIR_ENV_BASE} MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvMlirIgemmBwdXdlops) set(IMPLICITGEMM_MLIR_ENV_W_XDLOPS ${IMPLICITGEMM_MLIR_ENV_BASE} MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvMlirIgemmWrWXdlops) diff --git a/test/immed_conv3d.cpp b/test/conv3d.hpp similarity index 91% rename from test/immed_conv3d.cpp rename to test/conv3d.hpp index a968cd6100..2b49c0f10e 100644 --- a/test/immed_conv3d.cpp +++ b/test/conv3d.hpp @@ -26,9 +26,9 @@ #include "conv_common.hpp" template -struct conv3d_driver : conv_driver +struct conv3d_driver : conv_driver { - conv3d_driver() : conv_driver() + conv3d_driver() : conv_driver() { this->add(this->input_dims, "input"); this->add(this->weight_tensor_dims, "weights"); @@ -37,16 +37,16 @@ struct conv3d_driver : conv_driver this->generate_data_limited(this->get_batch_sizes(), 1, {8})); this->add(this->input_channels, "input_channels", - this->generate_data_limited(this->get_input_channels(), 1, {2})); + this->generate_data_limited(this->get_input_channels(), 1, {32})); this->add(this->output_channels, "output_channels", - this->generate_data_limited(this->get_output_channels(), 1, {16})); + this->generate_data_limited(this->get_output_channels(), 1, {32})); this->add(this->spatial_dim_elements, "spatial_dim_elements", this->generate_data_limited(this->get_3d_spatial_dims(), 1, {16, 16, 16})); this->add(this->filter_dims, "filter_dims", - this->generate_data_limited(this->get_3d_filter_dims(), 2, {5, 5, 5})); + this->generate_data_limited(this->get_3d_filter_dims(), 2, {3, 3, 3})); this->add(this->pads_strides_dilations, "pads_strides_dilations", this->generate_data_limited(this->get_3d_pads_strides_dilations(), 2)); @@ -58,5 +58,3 @@ struct conv3d_driver : conv_driver this->add(this->out_layout, "out_layout", this->generate_data({"NCDHW"})); } }; - -int main(int argc, const char* argv[]) { test_drive(argc, argv); } diff --git a/test/driver.hpp b/test/driver.hpp index 825a0d4511..97896d6c5d 100644 --- a/test/driver.hpp +++ b/test/driver.hpp @@ -1242,6 +1242,11 @@ void test_drive_impl_1(std::string program_name, std::vector as) Driver d{}; d.program_name = program_name; + std::cout << program_name << " "; + for(const auto& str : as) + std::cout << str << " "; + std::cout << std::endl; + std::set keywords{ "--help", "-h", "--half", "--float", "--double", "--int8", "--bfloat16"}; d.parse(keyword_set{keywords}); @@ -1381,7 +1386,7 @@ template