Skip to content

Commit

Permalink
fix build warning
Browse files Browse the repository at this point in the history
  • Loading branch information
tianleiwu committed Mar 6, 2024
1 parent d4e3551 commit 976faf4
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions onnxruntime/test/providers/checkers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ T get_tolerance(float absolute_tolerance, float relative_tolerance, T expected_v

template <typename T>
T get_tolerance(const ValidateOutputParams& params, T expected_value) {
constexpr float default_absolute_tolerance = 1e-5;
constexpr float default_relative_tolerance = 1e-4;
constexpr float default_absolute_tolerance = 1e-5f;
constexpr float default_relative_tolerance = 1e-4f;
float absolute_tolerance = (params.absolute_error.has_value() ? *(params.absolute_error) : default_absolute_tolerance);

Check warning on line 30 in onnxruntime/test/providers/checkers.cc

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Lines should be <= 120 characters long [whitespace/line_length] [2] Raw Output: onnxruntime/test/providers/checkers.cc:30: Lines should be <= 120 characters long [whitespace/line_length] [2]
float relative_tolerance = (params.relative_error.has_value() ? *(params.relative_error) : default_relative_tolerance);

Check warning on line 31 in onnxruntime/test/providers/checkers.cc

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Lines should be <= 120 characters long [whitespace/line_length] [2] Raw Output: onnxruntime/test/providers/checkers.cc:31: Lines should be <= 120 characters long [whitespace/line_length] [2]
return get_tolerance(absolute_tolerance, relative_tolerance, expected_value);
return get_tolerance<T>(absolute_tolerance, relative_tolerance, expected_value);
}

template <typename T>
Expand Down Expand Up @@ -85,7 +85,7 @@ struct TensorCheck {
cur_actual = actual.Data<T>();
}

for (int i = 0; i < size; ++i) {
for (int64_t i = 0; i < size; ++i) {
EXPECT_EQ(cur_expected[i], cur_actual[i]) << "i:" << i;
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ struct TensorCheck<uint8_t> {
double threshold = has_abs_err ? *(params.absolute_error)
: 0.0;

for (int i = 0; i < size; ++i) {
for (int64_t i = 0; i < size; ++i) {
if (has_rel_err) {
EXPECT_NEAR(cur_expected[i], cur_actual[i],
*(params.relative_error) * cur_expected[i]) // expected[i] is unsigned, can't be negative
Expand All @@ -139,7 +139,7 @@ struct TensorCheck<uint8_t> {
}
}
} else {
for (int i = 0; i < size; ++i) {
for (int64_t i = 0; i < size; ++i) {
EXPECT_EQ(cur_expected[i], cur_actual[i]) << "i:" << i;
}
}
Expand Down Expand Up @@ -175,11 +175,11 @@ struct TensorCheck<int8_t> {
if (has_abs_err) {
double threshold = *(params.absolute_error);

for (int i = 0; i < size; ++i) {
for (int64_t i = 0; i < size; ++i) {
EXPECT_NEAR(cur_expected[i], cur_actual[i], threshold) << "i:" << i;
}
} else {
for (int i = 0; i < size; ++i) {
for (int64_t i = 0; i < size; ++i) {
EXPECT_EQ(cur_expected[i], cur_actual[i]) << "i:" << i;
}
}
Expand Down Expand Up @@ -215,7 +215,7 @@ struct TensorCheck<double> {
threshold = 0.005;
#endif

for (int i = 0; i < size; ++i) {
for (int64_t i = 0; i < size; ++i) {
// NOTE: Check isnan first to work around MSVC linker bug when /LTCG:incremental is specified.
// If the isinf check is first the isnan check and branch gets omitted
if (std::isnan(cur_expected[i])) {
Expand Down Expand Up @@ -258,7 +258,7 @@ void InternalNumericalCheck(const Tensor& expected,
constexpr float threshold = 0.0001f;
#endif

for (int i = 0; i < size; ++i) {
for (int64_t i = 0; i < size; ++i) {
// NOTE: Check isnan first to work around MSVC linker bug when /LTCG:incremental is specified.
// If the isinf check is first the isnan check and branch gets omitted
if (std::isnan(cur_expected[i])) {
Expand Down Expand Up @@ -311,7 +311,7 @@ struct TensorCheck<MLFloat16> {
#elif defined(USE_DML)
threshold = 0.02f;
#endif
for (int i = 0; i < size; ++i) {
for (int64_t i = 0; i < size; ++i) {
if (std::isnan(f_expected[i])) {
EXPECT_TRUE(std::isnan(f_expected[i])) << "Expected NaN. i:" << i;
} else if (std::isinf(f_expected[i])) { // Test infinity for equality
Expand Down Expand Up @@ -353,7 +353,7 @@ struct TensorCheck<BFloat16> {
rel_threshold = 0.05f; // expect at least 95% close
#endif

for (int i = 0; i < size; ++i) {
for (int64_t i = 0; i < size; ++i) {
if (std::isnan(f_expected[i])) {
EXPECT_TRUE(std::isnan(f_expected[i])) << "Expected NaN. i:" << i;
} else if (std::isinf(f_expected[i])) { // Test infinity for equality
Expand Down

0 comments on commit 976faf4

Please sign in to comment.