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

[GTests Refactoring] Removing MIOPEN_TEST_ALL and MIOPEN_TEST_FLOAT_ARG env variables. Part 2. #3276

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
24 changes: 1 addition & 23 deletions test/gtest/conv3d_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,12 @@
*******************************************************************************/
#include <tuple>
#include <miopen/miopen.h>
#include <miopen/env.hpp>
#include <gtest/gtest.h>
#include "../conv3d.hpp"
#include "get_handle.hpp"

MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG)
MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)

namespace conv3d_test {

static bool IsTestRunWith(const char* float_arg)
{
assert(float_arg != nullptr);
if(!MIOPEN_TEST_ALL)
return true; // standalone run
return env::enabled(MIOPEN_TEST_ALL) && env::value(MIOPEN_TEST_FLOAT_ARG) == float_arg;
}

void GetArgs(const std::string& param, std::vector<std::string>& tokens)
{
std::stringstream ss(param);
Expand Down Expand Up @@ -127,16 +115,6 @@ std::vector<std::string> GetTestCases(const std::string& precision)

using namespace conv3d_test;

TEST_P(GPU_Conv3d_Test_FP32, FloatTest_conv3d_test)
{
if(IsTestRunWith("--float"))
{
Run3dDriver(miopenFloat);
}
else
{
GTEST_SKIP();
}
};
TEST_P(GPU_Conv3d_Test_FP32, FloatTest_conv3d_test) { Run3dDriver(miopenFloat); };

INSTANTIATE_TEST_SUITE_P(Full, GPU_Conv3d_Test_FP32, testing::Values(GetTestCases("--float")));
14 changes: 1 addition & 13 deletions test/gtest/conv_igemm_dynamic_xdlops_half.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,11 @@
#include "../conv2d.hpp"
#include "get_handle.hpp"

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_FIND_MODE)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_DEBUG_FIND_ONLY_SOLVER)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG)

namespace conv_igemm_dynamic_xdlops_half {

static bool SkipTest(const std::string& float_arg)
{
if(!MIOPEN_TEST_ALL)
return false;
if(env::enabled(MIOPEN_TEST_ALL))
if(env::value(MIOPEN_TEST_FLOAT_ARG) == float_arg)
return false;
return true;
}

void SetupEnvVar()
{
env::update(MIOPEN_FIND_MODE, "normal");
Expand Down Expand Up @@ -151,7 +139,7 @@ using namespace conv_igemm_dynamic_xdlops_half;
TEST_P(GPU_Conv2dHalf_conv_igemm_dynamic_xdlops_FP16, HalfTest_conv_igemm_dynamic_xdlops_half)
{
const auto& handle = get_handle();
if(IsTestSupportedForDevice(handle) && !SkipTest("--half"))
if(IsTestSupportedForDevice(handle))
{
Run2dDriver(miopenHalf);
}
Expand Down
14 changes: 1 addition & 13 deletions test/gtest/conv_igemm_dynamic_xdlops_nhwc_bf16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,11 @@
#include "../conv2d.hpp"
#include "get_handle.hpp"

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_FIND_MODE)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_DEBUG_FIND_ONLY_SOLVER)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG)

namespace conv_igemm_dynamic_xdlops_nhwc_bf16 {

static bool SkipTest(const std::string& float_arg)
{
if(!MIOPEN_TEST_ALL)
return false;
if(env::enabled(MIOPEN_TEST_ALL))
if(env::value(MIOPEN_TEST_FLOAT_ARG) == float_arg)
return false;
return true;
}

void SetupEnvVar()
{
env::update(MIOPEN_FIND_MODE, "normal");
Expand Down Expand Up @@ -208,7 +196,7 @@ using namespace conv_igemm_dynamic_xdlops_nhwc_bf16;
TEST_P(GPU_Conv2d_BFP16, Bf16Test_conv_igemm_dynamic_xdlops_nhwc_bf16)
{
const auto& handle = get_handle();
if(IsTestSupportedForDevice(handle) && !SkipTest("--bfloat16"))
if(IsTestSupportedForDevice(handle))
{
Run2dDriver(miopenBFloat16);
}
Expand Down
16 changes: 2 additions & 14 deletions test/gtest/conv_igemm_dynamic_xdlops_nhwc_nchw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,13 @@
#include "../conv2d.hpp"
#include "get_handle.hpp"

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_FIND_MODE)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_DEBUG_FIND_ONLY_SOLVER)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG)

namespace env = miopen::env;

namespace conv_igemm_dynamic_xdlops_nhwc_nchw {

static bool SkipTest(const std::string& float_arg)
{
if(!MIOPEN_TEST_ALL)
return false;
if(env::enabled(MIOPEN_TEST_ALL))
if(env::value(MIOPEN_TEST_FLOAT_ARG) == float_arg)
return false;
return true;
}

void SetupEnvVar()
{
env::update(MIOPEN_FIND_MODE, "normal");
Expand Down Expand Up @@ -295,7 +283,7 @@ TEST_P(GPU_Conv2d_conv_igemm_dynamic_xdlops_nhwc_nchw_FP32,
FloatTest_conv_igemm_dynamic_xdlops_nhwc_nchw)
{
const auto& handle = get_handle();
if(IsTestSupportedForDevice(handle) && !SkipTest("--float"))
if(IsTestSupportedForDevice(handle))
{
Run2dDriver(miopenFloat);
}
Expand All @@ -309,7 +297,7 @@ TEST_P(GPU_Conv2d_conv_igemm_dynamic_xdlops_nhwc_nchw_FP16,
HalfTest_conv_igemm_dynamic_xdlops_nhwc_nchw)
{
const auto& handle = get_handle();
if(IsTestSupportedForDevice(handle) && !SkipTest("--half"))
if(IsTestSupportedForDevice(handle))
{
Run2dDriver(miopenHalf);
}
Expand Down
3 changes: 1 addition & 2 deletions test/gtest/conv_igemm_mlir_bwd_wrw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "../conv2d.hpp"

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_MLIR)
MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)

namespace {

Expand Down Expand Up @@ -74,7 +73,7 @@ auto GetTestCases()

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

bool SkipTest() { return !env::enabled(MIOPEN_TEST_MLIR) || env::disabled(MIOPEN_TEST_ALL); }
bool SkipTest() { return !env::enabled(MIOPEN_TEST_MLIR); }

bool IsTestSupportedForDevice()
{
Expand Down
3 changes: 1 addition & 2 deletions test/gtest/conv_igemm_mlir_fwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "../conv2d.hpp"

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_MLIR)
MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)

namespace {

Expand Down Expand Up @@ -61,7 +60,7 @@ auto GetTestCases()

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

bool SkipTest() { return !env::enabled(MIOPEN_TEST_MLIR) || env::disabled(MIOPEN_TEST_ALL); }
bool SkipTest() { return !env::enabled(MIOPEN_TEST_MLIR); }

bool IsTestSupportedForDevice()
{
Expand Down
11 changes: 5 additions & 6 deletions test/gtest/conv_igemm_mlir_xdlops_bwd_wrw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "../conv2d.hpp"

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_MLIR)
MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)

namespace {

Expand Down Expand Up @@ -77,7 +76,7 @@ auto GetTestCases()

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

bool SkipTest() { return !env::enabled(MIOPEN_TEST_MLIR) || env::disabled(MIOPEN_TEST_ALL); }
bool SkipTest() { return !env::enabled(MIOPEN_TEST_MLIR); }

bool IsTestSupportedForDevice()
{
Expand All @@ -88,15 +87,15 @@ bool IsTestSupportedForDevice()

} // namespace

class GPU_Conv2dDefault_FP16 : public FloatTestCase<std::vector<TestCase>>
class GPU_Conv2dDefault_FP32 : public FloatTestCase<std::vector<TestCase>>
{
};

TEST_P(GPU_Conv2dDefault_FP16, HalfTest_conv_igemm_mlir_xdlops_bwd_wrw)
TEST_P(GPU_Conv2dDefault_FP32, FloatTest_conv_igemm_mlir_xdlops_bwd_wrw)
{
if(IsTestSupportedForDevice() && !SkipTest())
{
invoke_with_params<conv2d_driver, GPU_Conv2dDefault_FP16>(db_check);
invoke_with_params<conv2d_driver, GPU_Conv2dDefault_FP32>(db_check);
}
else
{
Expand All @@ -105,4 +104,4 @@ TEST_P(GPU_Conv2dDefault_FP16, HalfTest_conv_igemm_mlir_xdlops_bwd_wrw)
};

// Half for FWD, BWD, WRW
INSTANTIATE_TEST_SUITE_P(Full, GPU_Conv2dDefault_FP16, testing::Values(GetTestCases()));
INSTANTIATE_TEST_SUITE_P(Full, GPU_Conv2dDefault_FP32, testing::Values(GetTestCases()));
11 changes: 5 additions & 6 deletions test/gtest/conv_igemm_mlir_xdlops_fwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "../conv2d.hpp"

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_MLIR)
MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)

namespace {

Expand Down Expand Up @@ -62,7 +61,7 @@ auto GetTestCases()

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

bool SkipTest() { return !env::enabled(MIOPEN_TEST_MLIR) || env::disabled(MIOPEN_TEST_ALL); }
bool SkipTest() { return !env::enabled(MIOPEN_TEST_MLIR); }

bool IsTestSupportedForDevice()
{
Expand All @@ -73,19 +72,19 @@ bool IsTestSupportedForDevice()

} // namespace

class GPU_Conv2dDefault_FP16 : public FloatTestCase<std::vector<TestCase>>
class GPU_Conv2dDefault_FP32 : public FloatTestCase<std::vector<TestCase>>
{
};

class GPU_Conv2dDefault_I8 : public Int8TestCase<std::vector<TestCase>>
{
};

TEST_P(GPU_Conv2dDefault_FP16, HalfTest_conv_igemm_mlir_xdlops_fwd)
TEST_P(GPU_Conv2dDefault_FP32, FloatTest_conv_igemm_mlir_xdlops_fwd)
{
if(IsTestSupportedForDevice() && !SkipTest())
{
invoke_with_params<conv2d_driver, GPU_Conv2dDefault_FP16>(db_check);
invoke_with_params<conv2d_driver, GPU_Conv2dDefault_FP32>(db_check);
}
else
{
Expand All @@ -106,6 +105,6 @@ TEST_P(GPU_Conv2dDefault_I8, Int8Test_conv_igemm_mlir_xdlops_fwd)
};

// Half for FWD, BWD, WRW
INSTANTIATE_TEST_SUITE_P(Full, GPU_Conv2dDefault_FP16, testing::Values(GetTestCases()));
INSTANTIATE_TEST_SUITE_P(Full, GPU_Conv2dDefault_FP32, testing::Values(GetTestCases()));
// Int8 for FWD
INSTANTIATE_TEST_SUITE_P(Full, GPU_Conv2dDefault_I8, testing::Values(GetTestCases()));
5 changes: 1 addition & 4 deletions test/gtest/conv_trans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@
#include <miopen/miopen.h>
#include <gtest/gtest.h>
#include <miopen/miopen.h>
#include <miopen/env.hpp>
#include "../conv2d.hpp"
#include "get_handle.hpp"

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)

namespace env = miopen::env;

namespace conv_trans {
Expand Down Expand Up @@ -148,7 +145,7 @@ using namespace conv_trans;
TEST_P(GPU_conv_trans_FP32, FloatTest_conv_trans)
{
const auto& handle = get_handle();
if(IsTestSupportedForDevice(handle) && env::enabled(MIOPEN_TEST_ALL))
if(IsTestSupportedForDevice(handle))
{
Run2dDriver(miopenFloat);
}
Expand Down
2 changes: 0 additions & 2 deletions test/gtest/deepbench_rnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "get_handle.hpp"

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_DEEPBENCH)
MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)

namespace env = miopen::env;

Expand All @@ -52,7 +51,6 @@ class GPU_DeepBenchRNN_FP32 : public testing::TestWithParam<std::vector<std::str

void Run2dDriverFloat(void)
{

std::vector<std::string> params = GPU_DeepBenchRNN_FP32::GetParam();

for(const auto& test_value : params)
Expand Down
10 changes: 1 addition & 9 deletions test/gtest/fused_conv_bias_res_add_activ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,18 @@
#include <gtest/gtest.h>
#include <gtest/gtest_ck_common.hpp>
#include <miopen/miopen.h>
#include <miopen/env.hpp>

#include "tensor_util.hpp"
#include "get_handle.hpp"

#include "conv3d_test_case.hpp"

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL)
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG)

namespace conv_bias_act_res_add_fwd {

bool TestIsApplicable()
{
const auto float_arg = env::value(MIOPEN_TEST_FLOAT_ARG);
/// \todo Check against specific ASCIs.
return ::IsDeviceSupportedForCK() &&
(float_arg == "--half" // So far only test for fp16 is implemented.
|| float_arg.empty()) // Empty when gtest is run without parameters.
&& !env::disabled(MIOPEN_TEST_ALL); // Not disabled when gtest is run without parameters.
return ::IsDeviceSupportedForCK();
}

std::vector<Conv3DTestCase> ConvTestConfigs()
Expand Down