-
Notifications
You must be signed in to change notification settings - Fork 224
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
test_conv_embed_db (ctest -> gtest) #2168
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexandraBara Sorry if I am too soon but I hopt you'll find this useful.
This comment was marked as outdated.
This comment was marked as outdated.
@JehandadKhan Hmm... Do we really want to move |
@alexandraBara Please rename this PR. It moves |
@xinlipn BTW testing is not covered in the PR description. I means testing of the test itself, does it perform as expected. Have you run this test with MIOPEN_LOG_LEVEL=5 and checked if the log matches your expectations? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some final review comments.
test/gtest/conv_embed_db.cpp
Outdated
|
||
std::string GetFloatArg() | ||
{ | ||
static const auto tmp = miopen::GetEnv("MIOPEN_TEST_FLOAT_ARG"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reuse env.hpp from the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Resolved]
test/gtest/conv_embed_db.cpp
Outdated
#if MIOPEN_EMBED_DB | ||
|
||
const auto& handle = get_handle(); | ||
if((handle.GetDeviceName() == "gfx900" || handle.GetDeviceName() == "gfx906") && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factor out device checks to a function.
if((handle.GetDeviceName() == "gfx900" || handle.GetDeviceName() == "gfx906") && | |
if(IsTestSupportedForDevice(handle) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Resolved]
test/gtest/conv_embed_db.cpp
Outdated
case miopenInt8x4: | ||
case miopenInt32: | ||
case miopenDouble: | ||
MIOPEN_THROW(miopenStatusBadParm, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use MIOPEN_THROW in tests. This one is for library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just fail the test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Resolved]
test/gtest/conv_embed_db.cpp
Outdated
#if MIOPEN_EMBED_DB | ||
|
||
const auto& handle = get_handle(); | ||
const auto& envVar = miopen::GetEnv("MIOPEN_TEST_FLOAT_ARG"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use miopen::GetStringEnv() as it implements caching. Example:
MIOPEN_DECLARE_ENV_VAR(MIOPEN_TEST_FLOAT_ARG)
...
static std::string GetFloatArg()
{
const char* p = miopen::GetStringEnv(MIOPEN_TEST_FLOAT_ARG{});
if(p == nullptr)
{
// Fail the test (preferred) or return "--float" by default.
}
return {p};
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches the proven pattern that we use in MIOpen when we need to read a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Resolved]
@xinlipn
These were hidden as resolved which is not actually so. Due to that I had do duplicate some review comments. Let's hide review comments after they explicitly marked Please also provide an answer to #2168 (comment). Thank you! |
Will upload
@atamazov , CTest and gTest cover the same test cases, after having it reviewed by JD, there are a few issues, e.g. warning message that test_drive was called more than once. Have been working on them... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some refactoring is highly recommended.
test/gtest/conv_embed_db.cpp
Outdated
if(IsTestSupportedForDevice(handle) && | ||
(p_envVar != nullptr && std::strcmp(p_envVar, "--float") == 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[R] This can be factored out to a function, like this:
if(IsTestSupportedForDevice(handle) && | |
(p_envVar != nullptr && std::strcmp(p_envVar, "--float") == 0)) | |
if(IsTestSupportedForDevice(handle) && IsTestRunWith("--float")) |
And of course you do not need the following definition above
const char* const p_envVar = miopen::GetStringEnv(MIOPEN_TEST_FLOAT_ARG{});
Proposed function:
static bool IsTestRunWith(const char* float_arg)
{
assert(float_arg != nullptr);
const char* const p = miopen::GetStringEnv(MIOPEN_TEST_FLOAT_ARG{})
return p != nullptr && std::strcmp(p, float_arg) == 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, on a side note, google test Macro ASSERT_NE(float_arg, nullptr) can only be used in a void function, otherwise there will be a compile error
"cannot initialize return object of type 'bool' with an rvalue of type 'void'"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Resolved]
test/gtest/conv_embed_db.cpp
Outdated
const char* const p_envVar = miopen::GetStringEnv(MIOPEN_TEST_FLOAT_ARG{}); | ||
|
||
if(IsTestSupportedForDevice(handle) && | ||
(p_envVar != nullptr && std::strcmp(p_envVar, "--half") == 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[R] Ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Resolved]
test/gtest/conv_embed_db.cpp
Outdated
const char* const p_envVar = miopen::GetStringEnv(MIOPEN_TEST_FLOAT_ARG{}); | ||
|
||
if(IsTestSupportedForDevice(handle) && | ||
(p_envVar != nullptr && std::strcmp(p_envVar, "--int8") == 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[R] Ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Resolved]
test/gtest/conv_embed_db.cpp
Outdated
const char* const p_envVar = miopen::GetStringEnv(MIOPEN_TEST_FLOAT_ARG{}); | ||
|
||
if(IsTestSupportedForDevice(handle) && | ||
(p_envVar != nullptr && std::strcmp(p_envVar, "--bfloat16") == 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[R] Ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Resolved]
Almost done. Two things left:
|
@atamazov , there was some discrepancies in terms of initiated solvers for test coverage between develop branch and this branch, e.g. Forward convolution: ConvAsmImplicitGemmV4R1DynamicFwd_1x1 in Develop vs ConvHipImplicitGemmV4R1Fwd in current branch for Took some time to remove the discrepancies by updated cmake flags on Develop branch.
devleop_make_test_conv_embed_db_stdout.log
Please note MIOPEN_LOG_LEVEL=5 has been enabled, but it has affected the gtest serial spew. I have been working on this, which may need a separate ticket. |
Request re-review
Moving part of the conv_2d test to gtest.
Test is automatically picked up by gtest.