-
Notifications
You must be signed in to change notification settings - Fork 242
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] convert test_conv_igemm_mlir_fwd to gTest #2291
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
89c8fe2
conv_2d_wrapper gtest
alexandraBara dc3b8b9
pulling in env vars
alexandraBara 6f1d5b0
sending tuple values
alexandraBara ba9cd2a
updates to env vars
alexandraBara 9f3fe10
stdout test capture to fail based in stderr stream
alexandraBara 251bb89
clang tidy
alexandraBara 61e49ec
MIOPEN_FLOAT_TEST_ARG assigments to all gtests
alexandraBara 17aedb8
added all precision based tests
alexandraBara 1b5e8c1
some rework
alexandraBara f5d3cf1
renamed file
alexandraBara c5cbb1a
code cleanup
alexandraBara 8a8176d
Merge branch 'develop' into alex_gtest
alexandraBara ae29c5d
addressed reviews
alexandraBara beb7fcb
Cleaned up test case creation, skip tests for gfx908 and gfx90a, addr…
xinlipn da3594e
Resolve test CMakeLists.txt conflicts
xinlipn 6ad1a8c
convert ctest to gtest conv_igemm_dynamic
xinlipn ae496bc
Merge branch 'develop' of https://github.com/ROCmSoftwarePlatform/MIO…
xinlipn 6b70bd0
Fix cannot create target test_conv_igemm_dynamic error
xinlipn 652b477
Merge branch 'develop' into sl/gtest_conv_igemm_mlir_fwd
xinlipn 0a2c134
Fix build for FAIL()
xinlipn aa42b33
Remove unrecognized character
xinlipn 42d43dc
Remove MIOPEN_TEST_FLOAT_ARG
xinlipn 3804033
Isolate coredump cases
xinlipn 17d811e
Merge branch 'develop' into sl/gtest_conv_igemm_mlir_fwd
xinlipn 5f99bfe
Update with correct solvers for Wrw and Bwd test cases
xinlipn a90c1a1
Fix coredump abort due to invalid input parameter
xinlipn 3e2bf70
Merge branch 'develop' of https://github.com/ROCmSoftwarePlatform/MIO…
xinlipn a9d5ce0
Merge branch 'develop' into sl/gtest_conv_igemm_mlir_fwd
xinlipn 819da95
fix tidy issue
junliume 72a3423
fix clang-format
junliume d6e8324
Replace raw for loop with std::transform
xinlipn 782b634
Merge branch 'develop' of https://github.com/ROCmSoftwarePlatform/MIO…
xinlipn b8756ee
Merge branch 'develop' into sl/gtest_conv_igemm_mlir_fwd
xinlipn cd0827c
Merge branch 'develop' of https://github.com/ROCmSoftwarePlatform/MIO…
xinlipn 4a58549
Merge branch 'develop' of https://github.com/ROCmSoftwarePlatform/MIO…
xinlipn e7b05ab
Merge branch 'develop' into sl/gtest_conv_igemm_mlir_fwd
xinlipn 33700e5
Merge branch 'develop' into sl/gtest_conv_igemm_mlir_fwd
xinlipn 985f0d8
Merge branch 'sl/gtest_conv_igemm_mlir_fwd' of https://github.com/ROC…
xinlipn dacf96b
Update with newly added miopenFloat8 miopenBFloat8 data type
xinlipn 2a7a922
Merge branch 'develop' into sl/gtest_conv_igemm_mlir_fwd
xinlipn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
/******************************************************************************* | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2023 Advanced Micro Devices, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*******************************************************************************/ | ||
#include <tuple> | ||
|
||
#include <miopen/miopen.h> | ||
#include <gtest/gtest.h> | ||
#include <miopen/miopen.h> | ||
#include "../conv2d.hpp" | ||
#include "get_handle.hpp" | ||
|
||
using TestCase = std::tuple<std::vector<std::string>, std::string>; | ||
|
||
MIOPEN_DECLARE_ENV_VAR(MIOPEN_TEST_GPU_XNACK_ENABLED) | ||
|
||
static bool SkipTest(void) { return miopen::IsEnabled(MIOPEN_TEST_GPU_XNACK_ENABLED{}); } | ||
|
||
void GetArgs(const TestCase& param, std::vector<std::string>& tokens) | ||
{ | ||
auto env_vars = std::get<0>(param); | ||
for(auto& elem : env_vars) | ||
{ | ||
putenv(elem.data()); | ||
} | ||
|
||
auto cmd = std::get<1>(param); | ||
|
||
std::stringstream ss(cmd); | ||
std::istream_iterator<std::string> begin(ss); | ||
std::istream_iterator<std::string> end; | ||
while(begin != end) | ||
tokens.push_back(*begin++); | ||
} | ||
|
||
class Conv2dFloat : public testing::TestWithParam<std::vector<TestCase>> | ||
{ | ||
}; | ||
|
||
void Run2dDriver(miopenDataType_t prec) | ||
{ | ||
|
||
std::vector<TestCase> params; | ||
switch(prec) | ||
{ | ||
case miopenFloat: params = Conv2dFloat::GetParam(); break; | ||
case miopenHalf: | ||
case miopenInt8: | ||
case miopenBFloat16: | ||
case miopenInt8x4: | ||
case miopenInt32: | ||
case miopenDouble: | ||
case miopenFloat8: | ||
case miopenBFloat8: | ||
FAIL() << "miopenHalf, miopenInt8, miopenBFloat16, miopenInt8x4, miopenInt32, " | ||
"miopenDouble, miopenFloat8, miopenBFloat8 " | ||
"data type not supported by conv_igemm_dynamic test"; | ||
|
||
default: params = Conv2dFloat::GetParam(); | ||
} | ||
|
||
for(const auto& test_value : params) | ||
{ | ||
std::vector<std::string> tokens; | ||
GetArgs(test_value, tokens); | ||
std::vector<const char*> ptrs; | ||
|
||
std::transform(tokens.begin(), | ||
tokens.end(), | ||
std::back_inserter(ptrs), | ||
[](const std::string& str) { return str.data(); }); | ||
|
||
testing::internal::CaptureStderr(); | ||
test_drive<conv2d_driver>(ptrs.size(), ptrs.data()); | ||
auto capture = testing::internal::GetCapturedStderr(); | ||
std::cout << capture; | ||
} | ||
}; | ||
|
||
bool IsTestSupportedForDevice(const miopen::Handle& handle) | ||
{ | ||
std::string devName = handle.GetDeviceName(); | ||
if(devName == "gfx900" || devName == "gfx906") | ||
return true; | ||
else | ||
return false; | ||
} | ||
|
||
TEST_P(Conv2dFloat, FloatTest) | ||
{ | ||
const auto& handle = get_handle(); | ||
if(IsTestSupportedForDevice(handle) && !SkipTest()) | ||
{ | ||
Run2dDriver(miopenFloat); | ||
} | ||
else | ||
{ | ||
GTEST_SKIP(); | ||
} | ||
}; | ||
|
||
std::vector<TestCase> GetTestCases(const std::string& precision) | ||
{ | ||
|
||
std::vector<std::string> env = { | ||
"MIOPEN_FIND_MODE=normal", | ||
"MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvAsmImplicitGemmV4R1DynamicFwd"}; | ||
std::vector<std::string> env_1x1 = { | ||
"MIOPEN_FIND_MODE=normal", | ||
"MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvAsmImplicitGemmV4R1DynamicFwd_1x1"}; | ||
std::vector<std::string> env_wrw = { | ||
"MIOPEN_FIND_MODE=normal", | ||
"MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvAsmImplicitGemmV4R1DynamicWrw"}; | ||
std::vector<std::string> env_bwd = { | ||
"MIOPEN_FIND_MODE=normal", | ||
"MIOPEN_DEBUG_FIND_ONLY_SOLVER=ConvAsmImplicitGemmV4R1DynamicBwd"}; | ||
|
||
std::string v = " --verbose"; | ||
std::string dis_bk_data = " --disable-backward-data"; | ||
std::string dis_bk_wei = " --disable-backward-weights"; | ||
std::string dis_fwd = " --disable-forward"; | ||
std::string dis_vali = " --disable-validation"; | ||
|
||
const std::vector<TestCase> test_cases = { | ||
// clang-format off | ||
#if CODECOV_TEST | ||
TestCase{env, precision + v + " --input 32 32 17 17 --weights 32 32 1 7 --pads_strides_dilations 0 3 1 1 1 1" + dis_bk_data + dis_bk_wei + dis_vali}, | ||
TestCase{env_wrw, precision + v + " --input 64 64 28 28 --weights 32 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_data + dis_vali}, | ||
TestCase{env_bwd, precision + v + " --input 64 64 28 28 --weights 16 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_wei + dis_vali}, | ||
#else | ||
TestCase{env, precision + v + " --input 16 16 56 56 --weights 64 16 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env, precision + v + " --input 16 64 34 34 --weights 64 64 3 3 --pads_strides_dilations 0 0 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env, precision + v + " --input 32 32 17 17 --weights 32 32 1 7 --pads_strides_dilations 0 3 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env_1x1, precision + v + " --input 16 384 8 8 --weights 64 384 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env_wrw, precision + v + " --input 64 64 28 28 --weights 32 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_data}, | ||
TestCase{env_wrw, precision + v + " --input 16 128 36 36 --weights 32 128 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_data}, | ||
TestCase{env_bwd, precision + v + " --input 64 64 28 28 --weights 16 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_wei}, | ||
TestCase{env_bwd, precision + v + " --input 16 128 36 36 --weights 32 128 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_wei}, | ||
#endif | ||
|
||
#if MIOPEN_TEST_ALL | ||
//SKIP_UNLESS_ALL | ||
TestCase{env, precision + v + " --input 64 64 56 56 --weights 256 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env, precision + v + " --input 64 256 34 34 --weights 256 256 3 3 --pads_strides_dilations 0 0 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env, precision + v + " --input 128 128 35 35 --weights 128 128 3 3 --pads_strides_dilations 0 0 2 2 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env, precision + v + " --input 64 1536 8 8 --weights 256 1536 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env, precision + v + " --input 128 48 7 7 --weights 128 48 5 5 --pads_strides_dilations 2 2 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env, precision + v + " --input 128 128 17 17 --weights 128 128 1 7 --pads_strides_dilations 0 3 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env_1x1, precision + v + " --input 128 256 28 28 --weights 128 256 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env_1x1, precision + v + " --input 64 1536 8 8 --weights 256 1536 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env_1x1, precision + v + " --input 128 768 17 17 --weights 128 768 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_bk_data + dis_bk_wei}, | ||
TestCase{env_wrw, precision + v + " --input 64 64 56 56 --weights 256 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_data}, | ||
TestCase{env_wrw, precision + v + " --input 32 128 34 34 --weights 64 128 3 3 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_data}, | ||
TestCase{env_wrw, precision + v + " --input 128 128 35 35 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1" + dis_fwd + dis_bk_data}, | ||
TestCase{env_wrw, precision + v + " --input 128 256 56 56 --weights 64 256 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_data}, | ||
TestCase{env_wrw, precision + v + " --input 64 512 28 28 --weights 256 512 1 1 --pads_strides_dilations 0 0 2 2 1 1" + dis_fwd + dis_bk_data}, | ||
TestCase{env_wrw, precision + v + " --input 64 512 14 14 --weights 256 512 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_data}, | ||
TestCase{env_bwd, precision + v + " --input 64 64 56 56 --weights 256 64 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_wei}, | ||
TestCase{env_bwd, precision + v + " --input 32 128 34 34 --weights 64 128 3 3 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_wei}, | ||
TestCase{env_bwd, precision + v + " --input 128 128 35 35 --weights 128 128 3 3 --pads_strides_dilations 1 1 1 1 1 1" + dis_fwd + dis_bk_wei}, | ||
TestCase{env_bwd, precision + v + " --input 128 256 56 56 --weights 64 256 1 1 --pads_strides_dilations 0 0 1 1 1 1" + dis_fwd + dis_bk_wei} | ||
#endif | ||
// clang-format on | ||
}; | ||
return test_cases; | ||
} | ||
|
||
INSTANTIATE_TEST_SUITE_P(ConvIgemmDynamic, Conv2dFloat, testing::Values(GetTestCases("--float"))); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
⚓