-
Notifications
You must be signed in to change notification settings - Fork 230
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 code coverage tests #2580
Merged
Merged
Changes from all commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
9a41dde
WIP: updatable env vars, first draft
amberhassaan 1e63ea6
update env var declarations
cderb 0222ee6
draw out env string definitions
cderb cd035e4
compilation fixes
cderb de4766e
Merge remote-tracking branch 'origin/develop' into cderb/env-var-update
cderb 79446a4
fix
cderb 9d4d4f5
fix
cderb 541eea5
update driver envs
cderb 5e59daf
env for test folder
cderb 438aa34
compilation fixes
cderb fb292b3
format
cderb 44a174f
tidy
cderb 473b17c
quality improvements for env.h
cderb d33b9a9
convert to const string reference
cderb 694a079
fix
cderb 9c12c2f
fix string definition
cderb a3605ab
formatting
cderb 688919c
fix
cderb 5ea88a6
use std::string::compare
cderb 434f154
rename IsDefault to IsUnset, check unset in disabled/enabled check
cderb 708b472
Merge branch 'cderb/env-var-update' of https://github.com/ROCmSoftwar…
cderb 55dfe4d
macro for bool + string envs
cderb c1a257a
fix macros
cderb e21d7da
relabel uint64 envs
cderb f037fe9
typo fix + format
cderb 051538c
tidy
cderb fbc8558
Update src/include/miopen/env.hpp
cderb 9074f83
update tests with env syntax
cderb dd38c5f
Merge branch 'cderb/env-var-update' of https://github.com/ROCmSoftwar…
cderb 42893a9
Merge branch 'develop' into cderb/env-var-update
cderb 57a80f5
format
cderb 86c61c7
string references
cderb 2d50b1d
Merge branch 'develop' into cderb/env-var-update
cderb 4da821c
Merge branch 'develop' into cderb/env-var-update
cderb 312a321
move generic_search env defaults into header
cderb 34a21ca
Merge branch 'develop' into cderb/env-var-update
xinlipn 9f85fae
Merge branch 'develop' into cderb/env-var-update
xinlipn cae82dc
mergefix
cderb 2692bb8
mergefix
cderb 3cfee15
missing include
cderb 65f0f89
string fix
cderb 61de002
Merge remote-tracking branch 'origin/develop' into cderb/env-var-update
cderb 479d97e
mergefix
cderb f775ff1
Merge branch 'develop' into cderb/env-var-update
xinlipn 6665114
address comments
cderb 6be69d4
small performance remedy for find controls, remove log pollutants
cderb 18cc17a
clang format
cderb a7b4344
revert find_controls changes
cderb a06e464
env namespace
cderb 88bd707
fix
cderb eb46c35
fix
cderb a44b0d5
Merge remote-tracking branch 'origin/develop' into cderb/env-var-update
cderb 263917e
mergefix
cderb 2be776c
add Unset method for env, update assert string
cderb b597b81
fix
cderb 5046fa5
immed_conv2d test update
cderb 707ce2d
Merge branch 'develop' into cderb/env-var-update
cderb c1c8336
Merge branch 'develop' into cderb/env-var-update
cderb 4dc46ef
Merge branch 'develop' into cderb/env-var-update
xinlipn 64c53e1
Merge branch 'develop' into cderb/env-var-update
cderb 1aea239
Merge remote-tracking branch 'origin/develop' into cderb/env-var-update
cderb 11c11b2
Merge branch 'develop' into cderb/env-var-update
cderb 589b8d1
Merge branch 'develop' into cderb/env-var-update
xinlipn 66b8988
Merge remote-tracking branch 'origin/cderb/env-var-update' into cderb…
cderb 9ca70e3
Merge remote-tracking branch 'origin/develop' into cderb/gtest_immed_…
cderb 4da4d95
Merge remote-tracking branch 'origin/develop' into cderb/gtest_immed_…
cderb db4413e
update immed_conv2d gtest
cderb 8deca20
format
cderb 2fa7707
convert code coverage tests
cderb 4bd3f1d
Merge branch 'develop' into cderb/gtest_immed_conv2d
cderb f4403d5
Reformat code
xinlipn b90ea4a
update const str ref
cderb 42c1acf
move precision flags
cderb 0bef850
Merge branch 'develop' into cderb/gtest_immed_conv2d
junliume fdb8c97
Merge remote-tracking branch 'origin/develop' into cderb/gtest_immed_…
cderb bf90c84
Merge branch 'develop' into cderb/gtest_immed_conv2d
cderb 0fd9d59
re-enable long tests
cderb 66b1234
Merge remote-tracking branch 'origin/develop' into cderb/gtest_immed_…
cderb 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This must be reverted too due to the same reason. |
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 |
---|---|---|
|
@@ -1242,6 +1242,11 @@ void test_drive_impl_1(std::string program_name, std::vector<std::string> as) | |
Driver d{}; | ||
d.program_name = program_name; | ||
|
||
std::cout << program_name << " "; | ||
for(const auto& str : as) | ||
std::cout << str << " "; | ||
std::cout << std::endl; | ||
|
||
std::set<std::string> keywords{ | ||
"--help", "-h", "--half", "--float", "--double", "--int8", "--bfloat16"}; | ||
d.parse(keyword_set{keywords}); | ||
|
@@ -1381,7 +1386,7 @@ template <template <class...> class Driver> | |
void test_drive(int argc, const char* argv[]) | ||
{ | ||
std::vector<std::string> as(argv + 1, argv + argc); | ||
as.emplace_back("--float"); | ||
// as.emplace_back("--float"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this is necessary? |
||
for(auto&& arg : as) | ||
{ | ||
if(arg == "--half") | ||
|
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,172 @@ | ||
/******************************************************************************* | ||
* | ||
* 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 "conv3d.hpp" | ||
#include "get_handle.hpp" | ||
#include <miopen/env.hpp> | ||
#include <gtest/gtest.h> | ||
|
||
MIOPEN_DECLARE_ENV_VAR_BOOL(CODECOV_TEST) | ||
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLAGS_ARGS) | ||
|
||
static bool SkipTest(void) { return !miopen::IsEnabled(ENV(CODECOV_TEST)); } | ||
|
||
void GetArgs(const std::string& param, std::vector<std::string>& tokens) | ||
{ | ||
std::stringstream ss(param); | ||
std::istream_iterator<std::string> begin(ss); | ||
std::istream_iterator<std::string> end; | ||
while(begin != end) | ||
tokens.push_back(*begin++); | ||
} | ||
|
||
class Conv3dFloat : public testing::TestWithParam<std::vector<std::string>> | ||
{ | ||
}; | ||
|
||
class Conv3dHalf : public testing::TestWithParam<std::vector<std::string>> | ||
{ | ||
}; | ||
|
||
class Conv3dBFloat16 : public testing::TestWithParam<std::vector<std::string>> | ||
{ | ||
}; | ||
|
||
class Conv3dInt8 : public testing::TestWithParam<std::vector<std::string>> | ||
{ | ||
}; | ||
|
||
void Run3dDriver(miopenDataType_t prec) | ||
{ | ||
|
||
std::vector<std::string> params; | ||
switch(prec) | ||
{ | ||
case miopenHalf: params = Conv3dHalf::GetParam(); break; | ||
case miopenBFloat16: params = Conv3dBFloat16::GetParam(); break; | ||
case miopenFloat: params = Conv3dFloat::GetParam(); break; | ||
case miopenInt8: params = Conv3dInt8::GetParam(); break; | ||
case miopenFloat8: | ||
case miopenBFloat8: | ||
case miopenInt32: | ||
case miopenDouble: | ||
FAIL() << "miopenInt32, miopenDouble, miopenFloat8, miopenBFloat8 " | ||
"data type not supported by " | ||
"conv3d_codecov test"; | ||
|
||
default: params = Conv3dFloat::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 auto& str) { | ||
return str.data(); | ||
}); | ||
|
||
testing::internal::CaptureStderr(); | ||
test_drive<conv3d_driver>(ptrs.size(), ptrs.data()); | ||
auto capture = testing::internal::GetCapturedStderr(); | ||
std::cout << capture; | ||
} | ||
}; | ||
|
||
bool IsTestSupportedForDevice(const miopen::Handle& handle) { return true; } | ||
|
||
TEST_P(Conv3dFloat, FloatTest) | ||
{ | ||
const auto& handle = get_handle(); | ||
if(IsTestSupportedForDevice(handle) && !SkipTest()) | ||
{ | ||
Run3dDriver(miopenFloat); | ||
} | ||
else | ||
{ | ||
GTEST_SKIP(); | ||
} | ||
}; | ||
|
||
TEST_P(Conv3dHalf, HalfTest) | ||
{ | ||
const auto& handle = get_handle(); | ||
if(IsTestSupportedForDevice(handle) && !SkipTest()) | ||
{ | ||
Run3dDriver(miopenHalf); | ||
} | ||
else | ||
{ | ||
GTEST_SKIP(); | ||
} | ||
}; | ||
|
||
TEST_P(Conv3dBFloat16, BFloat16Test) | ||
{ | ||
const auto& handle = get_handle(); | ||
if(IsTestSupportedForDevice(handle) && !SkipTest()) | ||
{ | ||
Run3dDriver(miopenBFloat16); | ||
} | ||
else | ||
{ | ||
GTEST_SKIP(); | ||
} | ||
}; | ||
|
||
TEST_P(Conv3dInt8, Int8Test) | ||
{ | ||
const auto& handle = get_handle(); | ||
if(IsTestSupportedForDevice(handle) && !SkipTest()) | ||
{ | ||
Run3dDriver(miopenInt8); | ||
} | ||
else | ||
{ | ||
GTEST_SKIP(); | ||
} | ||
}; | ||
|
||
std::vector<std::string> GetTestCases(const std::string& precision) | ||
{ | ||
const auto& flag_arg = miopen::GetStringEnv(ENV(MIOPEN_TEST_FLAGS_ARGS)); | ||
|
||
const std::vector<std::string> test_cases = { | ||
// clang-format off | ||
{"test_conv3d " + precision + " --input 2 4 4 4 4 --weights 2 4 1 1 1 --pads_strides_dilations 0 0 0 1 1 1 1 1 1 "+flag_arg} | ||
// clang-format on | ||
}; | ||
|
||
return test_cases; | ||
} | ||
|
||
INSTANTIATE_TEST_SUITE_P(Conv3D, Conv3dFloat, testing::Values(GetTestCases("--float"))); | ||
|
||
INSTANTIATE_TEST_SUITE_P(Conv3D, Conv3dHalf, testing::Values(GetTestCases("--half"))); | ||
|
||
INSTANTIATE_TEST_SUITE_P(Conv3D, Conv3dBFloat16, testing::Values(GetTestCases("--bfloat16"))); | ||
|
||
INSTANTIATE_TEST_SUITE_P(Conv3D, Conv3dInt8, testing::Values(GetTestCases("--int8"))); |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
Oops, something went wrong.
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.
[Recommendation] This is not a code coverage test. The title of PR should be changed.