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

[Tests] split teardown to runtest and verify in layernorm gtest #2535

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 9 additions & 4 deletions test/gtest/layernorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ struct LayerNormTestFloat : LayerNormTest<float>
TEST_P(LayerNormTestFloat, LayerNormTestFw)
{
const auto& handle = get_handle();
if(!(miopen::IsEnvvarValueEnabled("MIOPEN_TEST_ALL") && (GetFloatArg() == "--float")) ||
!(miopen::StartsWith(handle.GetDeviceName(), "gfx908") ||
miopen::StartsWith(handle.GetDeviceName(), "gfx90a") ||
miopen::StartsWith(handle.GetDeviceName(), "gfx94")))
if((miopen::StartsWith(handle.GetDeviceName(), "gfx908") ||
miopen::StartsWith(handle.GetDeviceName(), "gfx90a") ||
miopen::StartsWith(handle.GetDeviceName(), "gfx94")) &&
miopen::IsEnvvarValueEnabled("MIOPEN_TEST_ALL") && (GetFloatArg() == "--float"))
{
RunTest();
Verify();
}
else
{
GTEST_SKIP();
}
Expand Down
5 changes: 4 additions & 1 deletion test/gtest/layernorm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ struct LayerNormTest : public ::testing::TestWithParam<LayerNormTestCase>
mean_dev = handle.Write(mean.data);
rstd_dev = handle.Write(rstd.data);
}
void TearDown() override
void RunTest()
{
auto&& handle = get_handle();

Expand Down Expand Up @@ -266,7 +266,10 @@ struct LayerNormTest : public ::testing::TestWithParam<LayerNormTestCase>
output.data = handle.Read<T>(output_dev, output.data.size());
mean.data = handle.Read<T>(mean_dev, mean.data.size());
rstd.data = handle.Read<T>(rstd_dev, rstd.data.size());
}

void Verify()
{
double threshold = std::numeric_limits<T>::epsilon();
auto error = miopen::rms_range(ref_output, output);

Expand Down