Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gtest] Combine gtests into single binary. #2599

Merged
merged 40 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
faac072
draft changes for combining gtest binaries
cderb Dec 11, 2023
ad3e487
more linking fixes
cderb Dec 12, 2023
645e289
add inline to avoid duplicate definition error
amberhassaan Dec 12, 2023
f094cc9
replace GetDataType with miopen_type
cderb Dec 12, 2023
85e64f8
Merge branch 'cderb/gtest_package' of https://github.com/ROCmSoftware…
cderb Dec 12, 2023
47ee6e0
fix template body missing error
amberhassaan Dec 12, 2023
457d265
fix linking issues
cderb Dec 12, 2023
3dc71ef
resolve compile errors
cderb Dec 12, 2023
c3229b8
Merge remote-tracking branch 'origin/develop' into cderb/gtest_package
cderb Dec 12, 2023
532c75f
reset hip_f8_impl
cderb Dec 12, 2023
3e9d843
resolve warnings, cleanup
cderb Dec 12, 2023
9c45745
remove if block from cmake
cderb Dec 13, 2023
1f87519
Merge branch 'develop' into cderb/gtest_package
cderb Dec 13, 2023
89f4782
add gtest binary to deb package
cderb Dec 14, 2023
b0d705d
Merge branch 'cderb/gtest_package' of https://github.com/ROCmSoftware…
cderb Dec 14, 2023
f529d95
tidy
cderb Dec 14, 2023
0f54296
Merge remote-tracking branch 'origin/develop' into cderb/gtest_package
cderb Dec 14, 2023
a6cbc3b
Merge remote-tracking branch 'origin/develop' into cderb/gtest_package
cderb Dec 14, 2023
c67f69e
move namespace for hip tidy to recognize gtest macro
cderb Dec 14, 2023
8ac0916
format
cderb Dec 15, 2023
f68938d
add flag for discrete gtest
cderb Dec 15, 2023
d912f17
Merge branch 'develop' into cderb/gtest_package
cderb Dec 15, 2023
7711895
fix ci call to test_db_sync
cderb Dec 15, 2023
d13348e
Merge branch 'cderb/gtest_package' of https://github.com/ROCmSoftware…
cderb Dec 15, 2023
48a16ba
Merge remote-tracking branch 'origin/develop' into cderb/gtest_package
cderb Dec 18, 2023
ce6a22c
add unique names for tests
cderb Dec 18, 2023
aeaa83f
resolve build conflicts
cderb Dec 18, 2023
9b8cfa4
add gtest precision checks, disable gtest pooling float
cderb Dec 18, 2023
eb3812c
default smoketest true, suspend nightly action
cderb Dec 18, 2023
1e7c6fc
test name + scope correction
cderb Dec 19, 2023
6d4e0e5
Merge branch 'cderb/gtest_package' of https://github.com/ROCmSoftware…
cderb Dec 19, 2023
5c88612
fix jenkins db_sync call
cderb Dec 19, 2023
ed002f5
Revert "[HotFix] revert #2580 and re-enable smoke tests (#2616)"
cderb Dec 19, 2023
7132297
Merge branch 'cderb/2580_revertx2' into cderb/gtest_package
cderb Dec 19, 2023
a13243f
Merge branch 'develop' into cderb/gtest_package
cderb Dec 19, 2023
fed0b7c
Merge remote-tracking branch 'origin/develop' into cderb/gtest_package
CAHEK7 Dec 20, 2023
b2eeb23
Merge branch 'develop' into cderb/gtest_package
junliume Dec 21, 2023
a719d15
Build discrete tests by default,
JehandadKhan Dec 21, 2023
cfdd95c
revert nightly workflow change
JehandadKhan Dec 21, 2023
996e342
Merge branch 'develop' into cderb/gtest_package
junliume Dec 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions test/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,45 @@ 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 $<BUILD_INTERFACE:${FDEEP_INCLUDE_DIR}>)
target_include_directories(test_${TEST_NAME} SYSTEM PRIVATE $<BUILD_INTERFACE:${EIGEN_INCLUDE_DIR}/eigen3>)
endif()
target_link_libraries(test_${TEST_NAME} GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $<BUILD_INTERFACE:roc::rocblas>)
if(NOT MIOPEN_EMBED_DB STREQUAL "")
target_link_libraries(test_${TEST_NAME} $<BUILD_INTERFACE:miopen_data>)
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()



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 $<BUILD_INTERFACE:${FDEEP_INCLUDE_DIR}>)
target_include_directories(miopen_gtest SYSTEM PRIVATE $<BUILD_INTERFACE:${EIGEN_INCLUDE_DIR}/eigen3>)
endif()
target_link_libraries(miopen_gtest GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $<BUILD_INTERFACE:roc::rocblas>)
if(NOT MIOPEN_EMBED_DB STREQUAL "")
target_link_libraries(miopen_gtest $<BUILD_INTERFACE:miopen_data>)
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()
2 changes: 1 addition & 1 deletion test/gtest/ai_heuristics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

struct AIModelTestCase
{
struct ConvTestCase conv;
struct ConvTestCaseBase conv;
miopen::conv::Direction direction;
miopenDataType_t data_type;
miopenTensorLayout_t layout;
Expand Down
20 changes: 8 additions & 12 deletions test/gtest/bad_fusion_plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

#include "tensor_holder.hpp"
#include "get_handle.hpp"
#include "conv_test_base.hpp"

namespace bad_fusion_plan {

#if MIOPEN_BACKEND_HIP

Expand All @@ -45,16 +48,7 @@ void setEnvironmentVariable(const std::string& name, const std::string& value)
EXPECT_EQ(ret, 0);
}

template <typename T>
miopenDataType_t GetDataType();

template <>
miopenDataType_t GetDataType<half_float::half>()
{
return miopenHalf;
}

struct ConvTestCase
struct ConvTestCaseFusion
{
size_t N;
size_t C;
Expand All @@ -69,7 +63,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
Expand All @@ -88,7 +82,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 <typename Solver, typename T>
class TestFusionPlan
Expand Down Expand Up @@ -263,3 +257,5 @@ TEST(TestFusionPlan, UnSupportedFusionPlanDuringSearchMode)
}

#endif

} // namespace bad_fusion_plan
8 changes: 4 additions & 4 deletions test/gtest/bn_bwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<BNTestCase>()),
testing::Values(miopenTensorNHWC)));

INSTANTIATE_TEST_SUITE_P(BNBwdTestFloatNHWCSuite,
BNBwdTestFloat,
testing::Combine(testing::ValuesIn(Network1()),
testing::Combine(testing::ValuesIn(Network1<BNTestCase>()),
testing::Values(miopenTensorNHWC)));

INSTANTIATE_TEST_SUITE_P(BNBwdTestBFloat16NHWCSuite,
BNBwdTestBFloat16,
testing::Combine(testing::ValuesIn(Network1()),
testing::Combine(testing::ValuesIn(Network1<BNTestCase>()),
testing::Values(miopenTensorNHWC)));

INSTANTIATE_TEST_SUITE_P(BNBwdTestDoubleNHWCSuite,
BNBwdTestDouble,
testing::Combine(testing::ValuesIn(Network1()),
testing::Combine(testing::ValuesIn(Network1<BNTestCase>()),
testing::Values(miopenTensorNHWC)));
8 changes: 4 additions & 4 deletions test/gtest/bn_fwd_train.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<BNTestCase>()),
testing::Values(miopenTensorNHWC)));

INSTANTIATE_TEST_SUITE_P(BNFwdTrainTestFloatNHWCSuite,
BNFwdTrainTestFloat,
testing::Combine(testing::ValuesIn(Network1()),
testing::Combine(testing::ValuesIn(Network1<BNTestCase>()),
testing::Values(miopenTensorNHWC)));

INSTANTIATE_TEST_SUITE_P(BNFwdTrainTestFloatNHWCSuite,
BNFwdTrainTestDouble,
testing::Combine(testing::ValuesIn(Network1()),
testing::Combine(testing::ValuesIn(Network1<BNTestCase>()),
testing::Values(miopenTensorNHWC)));

INSTANTIATE_TEST_SUITE_P(BNFwdTrainTestFloatNHWCSuite,
BNFwdTrainTestBFloat16,
testing::Combine(testing::ValuesIn(Network1()),
testing::Combine(testing::ValuesIn(Network1<BNTestCase>()),
testing::Values(miopenTensorNHWC)));
8 changes: 4 additions & 4 deletions test/gtest/bn_infer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<BNTestCase>()),
testing::Values(miopenTensorNHWC)));

INSTANTIATE_TEST_SUITE_P(BNInferTestFloatNHWCSuite,
BNInferTestFloat,
testing::Combine(testing::ValuesIn(Network1()),
testing::Combine(testing::ValuesIn(Network1<BNTestCase>()),
testing::Values(miopenTensorNHWC)));

INSTANTIATE_TEST_SUITE_P(BNInferTestFloatNHWCSuite,
BNInferTestDouble,
testing::Combine(testing::ValuesIn(Network1()),
testing::Combine(testing::ValuesIn(Network1<BNTestCase>()),
testing::Values(miopenTensorNHWC)));

INSTANTIATE_TEST_SUITE_P(BNInferTestFloatNHWCSuite,
BNInferTestBFloat16,
testing::Combine(testing::ValuesIn(Network1()),
testing::Combine(testing::ValuesIn(Network1<BNTestCase>()),
testing::Values(miopenTensorNHWC)));
6 changes: 5 additions & 1 deletion test/gtest/bn_test_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ struct BNTestCase
std::vector<size_t> GetInput() const { return {N, C, H, W}; }
};

std::vector<BNTestCase> Network1()
template <typename T>
std::vector<T> Network1();

template <>
inline std::vector<BNTestCase> Network1()
{
// pyt_mlperf_resnet50v1.5
return {
Expand Down
4 changes: 2 additions & 2 deletions test/gtest/cba.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
template <typename T = float>
struct ConvBiasActivInferTest
: public ::testing::TestWithParam<
std::tuple<miopenActivationMode_t, ConvTestCase, miopenTensorLayout_t>>,
std::tuple<miopenActivationMode_t, ConvTestCaseBase, miopenTensorLayout_t>>,
ConvFwdSolverTestBase<T>
{
protected:
Expand Down Expand Up @@ -90,7 +90,7 @@ struct ConvBiasActivInferTest
cfsb::ref_out.data);
cfsb::ThresholdChecks();
}
ConvTestCase conv_config;
ConvTestCaseBase conv_config;
miopen::ActivationDescriptor activ_desc;
tensor<T> bias;
miopen::Allocator::ManageDataPtr bias_dev;
Expand Down
4 changes: 2 additions & 2 deletions test/gtest/cba_find2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
template <typename T = float>
struct ConvBiasActivInferFind2Test
: public ::testing::TestWithParam<
std::tuple<miopenActivationMode_t, ConvTestCase, miopenTensorLayout_t>>,
std::tuple<miopenActivationMode_t, ConvTestCaseBase, miopenTensorLayout_t>>,
ConvFwdSolverTestBase<T>
{
protected:
ConvTestCase conv_config;
ConvTestCaseBase conv_config;
miopen::ActivationDescriptor activ_desc;
tensor<T> bias;
miopen::Allocator::ManageDataPtr bias_dev;
Expand Down
21 changes: 13 additions & 8 deletions test/gtest/cba_find2_infer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include "get_handle.hpp"
#include "cba_find2.hpp"

namespace cba_find2_infer {

struct ConvBiasActivFind2InferTestFloat : ConvBiasActivInferFind2Test<float>
{
};
Expand Down Expand Up @@ -78,7 +80,7 @@ void RunSolver(miopen::FusedProblem& problem,
template <typename Solver>
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();
Expand Down Expand Up @@ -153,22 +155,25 @@ 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<ConvTestCaseBase>()),
testing::Values(miopenTensorNCHW)));

#endif

INSTANTIATE_TEST_SUITE_P(CBAFind2InferSolverTest,
ConvBiasActivFind2InferTestFloat,
testing::Combine(testing::Values(miopenActivationRELU),
testing::ValuesIn(GetNetwork1()),
testing::ValuesIn(GetNetwork1<ConvTestCaseBase>()),
testing::Values(miopenTensorNCHW)));

INSTANTIATE_TEST_SUITE_P(CBAFind2InferSolverTest,
ConvBiasActivFind2InferTestHalf,
testing::Combine(testing::Values(miopenActivationRELU),
testing::ValuesIn(GetNetwork1()),
testing::ValuesIn(GetNetwork1<ConvTestCaseBase>()),
testing::Values(miopenTensorNHWC)));

} // namespace cba_find2_infer
21 changes: 13 additions & 8 deletions test/gtest/cba_infer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "get_handle.hpp"
#include "cba.hpp"

namespace cba_infer {

struct ConvBiasActivInferTestFloat : ConvBiasActivInferTest<float>
{
};
Expand Down Expand Up @@ -87,7 +89,7 @@ void RunSolver(miopen::FusionPlanDescriptor& fusePlanDesc,
template <typename Solver>
void RunTunableSolver(miopen::FusionPlanDescriptor& fusePlanDesc,
const std::unique_ptr<miopen::fusion::FusionInvokeParams>& plan_params,
const ConvTestCase& conv_config,
const ConvTestCaseBase& conv_config,
bool& test_skipped)
{
auto& handle = get_handle();
Expand Down Expand Up @@ -158,22 +160,25 @@ 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<ConvTestCaseBase>()),
testing::Values(miopenTensorNCHW)));

#endif

INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest,
ConvBiasActivInferTestFloat,
testing::Combine(testing::Values(miopenActivationRELU),
testing::ValuesIn(GetNetwork1()),
testing::ValuesIn(GetNetwork1<ConvTestCaseBase>()),
testing::Values(miopenTensorNCHW)));

INSTANTIATE_TEST_SUITE_P(CBAInferSolverTest,
ConvBiasActivInferTestHalf,
testing::Combine(testing::Values(miopenActivationRELU),
testing::ValuesIn(GetNetwork1()),
testing::ValuesIn(GetNetwork1<ConvTestCaseBase>()),
testing::Values(miopenTensorNHWC)));

} // namespace cba_infer
22 changes: 1 addition & 21 deletions test/gtest/conv3d_test_case.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,7 @@

#include "../driver/tensor_driver.hpp"
#include "conv_common.hpp"

template <typename T>
miopenDataType_t GetDataType();

template <>
miopenDataType_t GetDataType<float>()
{
return miopenFloat;
}

template <>
miopenDataType_t GetDataType<half_float::half>()
{
return miopenHalf;
}

template <>
miopenDataType_t GetDataType<int8_t>()
{
return miopenInt8;
}
#include "conv_test_base.hpp"

struct Conv3DTestCase
{
Expand Down
Loading
Loading