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] conversion for lstm #2545

Merged
merged 122 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
9a41dde
WIP: updatable env vars, first draft
amberhassaan Nov 7, 2023
1e63ea6
update env var declarations
cderb Nov 7, 2023
0222ee6
draw out env string definitions
cderb Nov 7, 2023
cd035e4
compilation fixes
cderb Nov 8, 2023
de4766e
Merge remote-tracking branch 'origin/develop' into cderb/env-var-update
cderb Nov 8, 2023
79446a4
fix
cderb Nov 8, 2023
9d4d4f5
fix
cderb Nov 8, 2023
541eea5
update driver envs
cderb Nov 8, 2023
5e59daf
env for test folder
cderb Nov 8, 2023
438aa34
compilation fixes
cderb Nov 8, 2023
fb292b3
format
cderb Nov 8, 2023
44a174f
tidy
cderb Nov 8, 2023
473b17c
quality improvements for env.h
cderb Nov 8, 2023
d33b9a9
convert to const string reference
cderb Nov 8, 2023
694a079
fix
cderb Nov 8, 2023
9c12c2f
fix string definition
cderb Nov 9, 2023
a3605ab
formatting
cderb Nov 9, 2023
688919c
fix
cderb Nov 9, 2023
5ea88a6
use std::string::compare
cderb Nov 9, 2023
434f154
rename IsDefault to IsUnset, check unset in disabled/enabled check
cderb Nov 9, 2023
708b472
Merge branch 'cderb/env-var-update' of https://github.com/ROCmSoftwar…
cderb Nov 9, 2023
55dfe4d
macro for bool + string envs
cderb Nov 9, 2023
c1a257a
fix macros
cderb Nov 9, 2023
e21d7da
relabel uint64 envs
cderb Nov 9, 2023
f037fe9
typo fix + format
cderb Nov 9, 2023
051538c
tidy
cderb Nov 10, 2023
fbc8558
Update src/include/miopen/env.hpp
cderb Nov 10, 2023
9074f83
update tests with env syntax
cderb Nov 10, 2023
dd38c5f
Merge branch 'cderb/env-var-update' of https://github.com/ROCmSoftwar…
cderb Nov 10, 2023
42893a9
Merge branch 'develop' into cderb/env-var-update
cderb Nov 10, 2023
57a80f5
format
cderb Nov 10, 2023
86c61c7
string references
cderb Nov 13, 2023
2d50b1d
Merge branch 'develop' into cderb/env-var-update
cderb Nov 13, 2023
4da821c
Merge branch 'develop' into cderb/env-var-update
cderb Nov 13, 2023
312a321
move generic_search env defaults into header
cderb Nov 13, 2023
34a21ca
Merge branch 'develop' into cderb/env-var-update
xinlipn Nov 14, 2023
9f85fae
Merge branch 'develop' into cderb/env-var-update
xinlipn Nov 15, 2023
cae82dc
mergefix
cderb Nov 15, 2023
2692bb8
mergefix
cderb Nov 16, 2023
4f46583
lstm gtest
cderb Nov 16, 2023
3cfee15
missing include
cderb Nov 16, 2023
65f0f89
string fix
cderb Nov 16, 2023
f8afcc8
fixup lstm gtest
cderb Nov 16, 2023
8024a5e
Merge remote-tracking branch 'origin/cderb/env-var-update' into cderb…
cderb Nov 16, 2023
9a66976
tidy
cderb Nov 17, 2023
b422b57
tidy
cderb Nov 17, 2023
3a42c21
remove commented lines
cderb Nov 17, 2023
61de002
Merge remote-tracking branch 'origin/develop' into cderb/env-var-update
cderb Nov 17, 2023
479d97e
mergefix
cderb Nov 17, 2023
92c8374
Merge remote-tracking branch 'origin/cderb/env-var-update' into cderb…
cderb Nov 17, 2023
f775ff1
Merge branch 'develop' into cderb/env-var-update
xinlipn Nov 20, 2023
6665114
address comments
cderb Nov 20, 2023
6be69d4
small performance remedy for find controls, remove log pollutants
cderb Nov 20, 2023
18cc17a
clang format
cderb Nov 20, 2023
a7b4344
revert find_controls changes
cderb Nov 20, 2023
a06e464
env namespace
cderb Nov 21, 2023
88bd707
fix
cderb Nov 21, 2023
9ac26bb
Merge remote-tracking branch 'origin/cderb/env-var-update' into cderb…
cderb Nov 21, 2023
dec1532
env mergefix
cderb Nov 21, 2023
eb46c35
fix
cderb Nov 21, 2023
a44b0d5
Merge remote-tracking branch 'origin/develop' into cderb/env-var-update
cderb Nov 21, 2023
30ab419
Merge branch 'cderb/env-var-update' into cderb/gtest
cderb Nov 21, 2023
263917e
mergefix
cderb Nov 22, 2023
d986103
Merge branch 'cderb/env-var-update' into cderb/gtest
cderb Nov 22, 2023
2be776c
add Unset method for env, update assert string
cderb Nov 22, 2023
b597b81
fix
cderb Nov 22, 2023
707ce2d
Merge branch 'develop' into cderb/env-var-update
cderb Nov 22, 2023
c1c8336
Merge branch 'develop' into cderb/env-var-update
cderb Nov 22, 2023
4dc46ef
Merge branch 'develop' into cderb/env-var-update
xinlipn Nov 26, 2023
64c53e1
Merge branch 'develop' into cderb/env-var-update
cderb Nov 27, 2023
1aea239
Merge remote-tracking branch 'origin/develop' into cderb/env-var-update
cderb Nov 28, 2023
11c11b2
Merge branch 'develop' into cderb/env-var-update
cderb Nov 28, 2023
589b8d1
Merge branch 'develop' into cderb/env-var-update
xinlipn Nov 30, 2023
47458e8
Merge remote-tracking branch 'origin/cderb/env-var-update' into cderb…
cderb Nov 30, 2023
58e5750
Merge remote-tracking branch 'origin/develop' into cderb/gtest
cderb Nov 30, 2023
79cdd94
Merge remote-tracking branch 'origin/develop' into cderb/gtest
cderb Dec 4, 2023
ecb6fbe
add restructuring for lstm gtest
cderb Dec 4, 2023
6b5d1f9
convert lstm gtest format
cderb Dec 4, 2023
ab8f2c8
update lstm_extra skip condition
cderb Dec 4, 2023
91e7bda
clang format
cderb Dec 4, 2023
cc8e11c
Merge branch 'develop' into cderb/gtest
cderb Dec 5, 2023
a448547
Merge branch 'develop' into cderb/gtest
xinlipn Dec 11, 2023
af956d4
Merge branch 'develop' into cderb/gtest
cderb Dec 11, 2023
f1b6df2
rm unused header
cderb Dec 11, 2023
e6f57fd
rename lstm tests, add half test, add test flags
cderb Dec 11, 2023
5c1552c
restore lstm.cpp main
cderb Dec 11, 2023
86c90e1
cleanup, pass ENV to gtest
cderb Dec 13, 2023
6c44486
Merge branch 'develop' into cderb/gtest
cderb Dec 13, 2023
80c6bff
cderb/gtest : fix merge conflict
bghimireamd Dec 14, 2023
6147d1e
cderb/gtest: fix clang format
bghimireamd Dec 14, 2023
2582815
cderb/gtest : fix compilation error
bghimireamd Dec 14, 2023
301b3d2
Merge branch 'develop' into cderb/gtest
cderb Dec 14, 2023
b7e949c
cderb/gtest : set environment variable
bghimireamd Dec 18, 2023
586d237
cderb/gtest : fixed merge conflict
bghimireamd Dec 18, 2023
1054497
cderb/gtest : add missing env var and add namespace around test
bghimireamd Dec 18, 2023
2de7073
cderb/gtest : fix gtest name, fixed merge conflict
bghimireamd Dec 19, 2023
e937886
Merge branch 'develop' into cderb/gtest
cderb Dec 19, 2023
0efa608
Merge branch 'develop' into cderb/gtest
junliume Dec 24, 2023
1ccc296
Merge branch 'develop' into cderb/gtest
cderb Jan 4, 2024
95f8faf
redress lstm test environs
cderb Jan 4, 2024
22e633e
clang format
cderb Jan 4, 2024
4142ff0
Merge branch 'develop' into cderb/gtest
cderb Jan 5, 2024
29269c3
reenable device support check
cderb Jan 5, 2024
7ca4d31
Merge branch 'develop' into cderb/gtest
cderb Jan 5, 2024
418be36
Merge branch 'develop' into cderb/gtest
cderb Jan 8, 2024
4b05c35
Merge branch 'develop' into cderb/gtest
cderb Jan 11, 2024
3a32d79
Merge branch 'develop' into cderb/gtest
cderb Jan 15, 2024
34093b3
Remove half precision and not needed code
xinlipn Jan 23, 2024
799793d
Remove unneeded code
xinlipn Jan 29, 2024
45c16ce
Merge branch 'develop' into cderb/gtest
xinlipn Jan 31, 2024
8ba8342
Merge branch 'develop' into cderb/gtest
xinlipn Feb 5, 2024
51e15f1
Fix build
xinlipn Feb 5, 2024
fd3f0ec
Run test when standalone run OR full tests enabled with "--float"
xinlipn Feb 6, 2024
0616af1
Merge branch 'develop' into cderb/gtest
xinlipn Feb 6, 2024
6def350
Fix make error
xinlipn Feb 7, 2024
3f4c6bf
Merge branch 'develop' into cderb/gtest
xinlipn Feb 7, 2024
dd38bfa
Merge branch 'develop' into cderb/gtest
xinlipn Feb 8, 2024
2ac057e
Merge branch 'develop' into cderb/gtest
junliume Feb 11, 2024
dca7ae7
Revert class name from ConfigWithFloat_conv_trans to ConfigWithFloat
xinlipn Feb 12, 2024
5f37e02
Revert class name from ConfigWithFloat_* to ConfigWithFloat
xinlipn Feb 12, 2024
ea4477d
Merge branch 'develop' into cderb/gtest
xinlipn Feb 12, 2024
ca67a88
Change test suite name from ConfigWithFloat to ConfigWithFloat_*
xinlipn Feb 12, 2024
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
3 changes: 1 addition & 2 deletions test/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +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
# Extend GTest DISCOVERY_TIMEOUT to 5 mins
gtest_discover_tests(${TEST_NAME} DISCOVERY_TIMEOUT 300 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};MIOPEN_TEST_DEEPBENCH=${MIOPEN_TEST_DEEPBENCH};MIOPEN_TEST_FLOAT=${MIOPEN_TEST_FLOAT};MIOPEN_TEST_HALF=${MIOPEN_TEST_HALF}")
gtest_discover_tests(${TEST_NAME} DISCOVERY_TIMEOUT 300 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};MIOPEN_TEST_CONV=${MIOPEN_TEST_CONV};MIOPEN_TEST_DEEPBENCH=${MIOPEN_TEST_DEEPBENCH};MIOPEN_DEBUG_TUNING_ITERATIONS_MAX=${MIOPEN_DEBUG_TUNING_ITERATIONS_MAX}")
endif()
target_link_libraries(${TEST_NAME} BZip2::BZip2)
if(WIN32)
Expand Down
10 changes: 5 additions & 5 deletions test/gtest/conv_trans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void GetArgs(const std::string& param, std::vector<std::string>& tokens)
tokens.push_back(*begin++);
}

class ConfigWithFloat : public testing::TestWithParam<std::vector<std::string>>
class ConfigWithFloat_conv_trans : public testing::TestWithParam<std::vector<std::string>>
Copy link
Contributor

@atamazov atamazov Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question] Why we need ConfigWithFloat_conv_trans? We are within the conv_trans namespace already. Ditto other similar places. Or maybe this is somehow related to GTest?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xinlipn What about

Ditto other similar places.

e.g. ConfigWithFloat_deepbench_lstm, ConfigWithFloat_lstm_extra?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atamazov , thanks for picking them up. ConfigWithFloat would pass locally, but I recall CI complained about duplicated names, thus the change.

First reverted back to ConfigWithFloat in conv_trans.cpp for test. Now reverted ConfigWithFloat in all files.

{
};

Expand All @@ -53,7 +53,7 @@ void Run2dDriver(miopenDataType_t prec)
std::vector<std::string> params;
switch(prec)
{
case miopenFloat: params = ConfigWithFloat::GetParam(); break;
case miopenFloat: params = ConfigWithFloat_conv_trans::GetParam(); break;
case miopenHalf:
case miopenFloat8:
case miopenBFloat8:
Expand All @@ -65,7 +65,7 @@ void Run2dDriver(miopenDataType_t prec)
"data type not supported by "
"conv_trans test";

default: params = ConfigWithFloat::GetParam();
default: params = ConfigWithFloat_conv_trans::GetParam();
}

for(const auto& test_value : params)
Expand Down Expand Up @@ -142,7 +142,7 @@ std::vector<std::string> GetTestCases(void)
} // namespace conv_trans
using namespace conv_trans;

TEST_P(ConfigWithFloat, FloatTest_conv_trans)
TEST_P(ConfigWithFloat_conv_trans, FloatTest_conv_trans)
{
const auto& handle = get_handle();
if(IsTestSupportedForDevice(handle) && miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)))
Expand All @@ -155,4 +155,4 @@ TEST_P(ConfigWithFloat, FloatTest_conv_trans)
}
};

INSTANTIATE_TEST_SUITE_P(ConvTrans, ConfigWithFloat, testing::Values(GetTestCases()));
INSTANTIATE_TEST_SUITE_P(ConvTrans, ConfigWithFloat_conv_trans, testing::Values(GetTestCases()));
74 changes: 15 additions & 59 deletions test/gtest/deepbench_lstm.cpp
junliume marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,6 @@ MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_DEEPBENCH)

namespace deepbench_lstm {

static bool Skip(miopenDataType_t prec)
{
switch(prec)
{
case miopenFloat: return !miopen::IsEnabled(ENV(MIOPEN_TEST_DEEPBENCH));
case miopenHalf:
case miopenFloat8:
case miopenBFloat8:
case miopenInt8:
case miopenBFloat16:
case miopenInt32:
case miopenDouble:
default: MIOPEN_THROW("Unsupported datatype");
}
return true;
}

void GetArgs(const std::string& param, std::vector<std::string>& tokens)
{
std::stringstream ss(param);
Expand Down Expand Up @@ -97,50 +80,13 @@ auto GetTestCases(std::string precision)

using TestCase = decltype(GetTestCases({}))::value_type;

class ConfigWithFloat : public testing::TestWithParam<std::vector<TestCase>>
class ConfigWithFloat_deepbench_lstm : public testing::TestWithParam<std::vector<TestCase>>
{
};

class ConfigWithHalf : public testing::TestWithParam<std::vector<TestCase>>
void Run2dDriverFloat(void)
{
};

static bool IsTestSupportedForDevice()
{
using namespace miopen::debug;
using e_mask = enabled<Gpu::gfx94X, Gpu::gfx103X, Gpu::gfx110X, Gpu::gfx908>;
using d_mask = disabled<Gpu::Default>;
return miopen::debug::IsTestSupportedForDevice<d_mask, e_mask>();
}

void Run2dDriver(miopenDataType_t prec)
{
if(!IsTestSupportedForDevice())
{
GTEST_SKIP();
}
if(Skip(prec))
{
GTEST_SKIP();
}
std::vector<std::string> params;
switch(prec)
{
case miopenFloat: params = ConfigWithFloat::GetParam(); break;
case miopenHalf: params = ConfigWithHalf::GetParam(); break;
case miopenFloat8:
case miopenBFloat8:
case miopenInt8:
case miopenBFloat16:
case miopenInt32:
case miopenDouble:
FAIL() << "miopenInt8, miopenBFloat16, miopenInt32, "
"miopenDouble, miopenFloat8, miopenBFloat8 "
"data types not supported by "
"deepbench_lstm test";

default: params = ConfigWithFloat::GetParam();
}
std::vector<std::string> params = ConfigWithFloat_deepbench_lstm::GetParam();

for(const auto& test_value : params)
{
Expand All @@ -161,6 +107,16 @@ void Run2dDriver(miopenDataType_t prec)

using namespace deepbench_lstm;

TEST_P(ConfigWithFloat, FloatTest_deepbench_lstm) { Run2dDriver(miopenFloat); };
TEST_P(ConfigWithFloat_deepbench_lstm, FloatTest_deepbench_lstm)
{
if(!miopen::IsEnabled(ENV(MIOPEN_TEST_DEEPBENCH)))
{
GTEST_SKIP();
}

Run2dDriverFloat();
};

INSTANTIATE_TEST_SUITE_P(DeepbenchLstm, ConfigWithFloat, testing::Values(GetTestCases("--float")));
INSTANTIATE_TEST_SUITE_P(DeepbenchLstm,
ConfigWithFloat_deepbench_lstm,
testing::Values(GetTestCases("--float")));
6 changes: 1 addition & 5 deletions test/gtest/gtest_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@

#include "../driver.hpp"

namespace miopen {
namespace debug {
void default_check(const std::string& err) { std::cout << err; }
inline void default_check(const std::string& err) { std::cout << err; }

inline void tuning_check(const std::string& err)
{
Expand Down Expand Up @@ -174,8 +172,6 @@ void invoke_with_params(Check&& check)
check(testing::internal::GetCapturedStderr());
}
}
} // namespace debug
} // namespace miopen

/// The types for env variables must be redefined, but
/// do not mess up with the types - those variables are decalred in the library
Expand Down
45 changes: 16 additions & 29 deletions test/gtest/lstm_extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include <gtest/gtest.h>
#include <boost/algorithm/string.hpp>

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG)

namespace lstm_extra {
void GetArgs(const std::string& param, std::vector<std::string>& tokens)
{
Expand Down Expand Up @@ -77,19 +80,15 @@ auto GetTestCases(std::string precision)
{flags + commonFlags + " -dir-mode 1 --no-hy --no-cy"},
{flags + commonFlags + " -dir-mode 1 --no-dcx"},
{flags + commonFlags + " -dir-mode 1 --no-cy --no-dcx"},
{flags + commonFlags + " -dir-mode 0 --no-hx --no-dhy --no-cx --no-dcy --no-hy --no-dhx --no-cy --no-dcx"},
{flags + commonFlags + " -dir-mode 1 --no-hx --no-dhy --no-cx --no-dcy --no-hy --no-dhx --no-cy --no-dcx"}
{flags + commonFlags + " -dir-mode 0 --no-hx --no-dhy --no-cx --no-dcy --no-hy --no-dhx --no-cy --no-dcx"},
{flags + commonFlags + " -dir-mode 1 --no-hx --no-dhy --no-cx --no-dcy --no-hy --no-dhx --no-cy --no-dcx"}
};
// clang-format on
}

using TestCase = decltype(GetTestCases({}))::value_type;

class ConfigWithFloat : public testing::TestWithParam<std::vector<TestCase>>
{
};

class ConfigWithHalf : public testing::TestWithParam<std::vector<TestCase>>
class ConfigWithFloat_lstm_extra : public testing::TestWithParam<std::vector<TestCase>>
{
};

Expand All @@ -98,33 +97,19 @@ bool IsTestSupportedForDevice()
using namespace miopen::debug;
using e_mask = enabled<Gpu::gfx94X, Gpu::gfx103X, Gpu::gfx110X>;
using d_mask = disabled<Gpu::Default>;
return miopen::debug::IsTestSupportedForDevice<d_mask, e_mask>();
return ::IsTestSupportedForDevMask<d_mask, e_mask>();
}

void Run2dDriver(miopenDataType_t prec)
{
if(!IsTestSupportedForDevice())
if(!(IsTestSupportedForDevice() //
&& (miopen::IsUnset(ENV(MIOPEN_TEST_ALL)) // standalone run
|| (miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) // or --float full tests enabled
&& miopen::GetStringEnv(ENV(MIOPEN_TEST_FLOAT_ARG)) == "--float"))))
{
GTEST_SKIP();
}
std::vector<std::string> params;
switch(prec)
{
case miopenFloat: params = ConfigWithFloat::GetParam(); break;
case miopenHalf:
case miopenFloat8:
case miopenBFloat8:
case miopenInt8:
case miopenBFloat16:
case miopenInt32:
case miopenDouble:
FAIL() << "miopenInt8, miopenBFloat16, miopenInt32, "
"miopenDouble, miopenFloat8, miopenBFloat8 "
"data types not supported by "
"lstm_extra test";

default: params = ConfigWithFloat::GetParam();
}
std::vector<std::string> params = ConfigWithFloat_lstm_extra::GetParam();

for(const auto& test_value : params)
{
Expand All @@ -145,6 +130,8 @@ void Run2dDriver(miopenDataType_t prec)
} // namespace lstm_extra
using namespace lstm_extra;

TEST_P(ConfigWithFloat, FloatTest_lstm_extra) { Run2dDriver(miopenFloat); };
TEST_P(ConfigWithFloat_lstm_extra, FloatTest_lstm_extra) { Run2dDriver(miopenFloat); };

INSTANTIATE_TEST_SUITE_P(LstmExtra, ConfigWithFloat, testing::Values(GetTestCases("--float")));
INSTANTIATE_TEST_SUITE_P(LstmExtra,
ConfigWithFloat_lstm_extra,
testing::Values(GetTestCases("--float")));