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

Support per-test tolerances for ONNX tests #11775

Merged
merged 18 commits into from
Jun 14, 2022
Merged

Conversation

garymm
Copy link
Contributor

@garymm garymm commented Jun 7, 2022

Prior to this every test shared the same global tolerances. This meant
that if an ONNX test failed due to a small but acceptable difference in
output, the only alternative was to disable the test entirely.

In op set 17, the DFT operator is being added. Without this change, the
tests for that operator fail because the output is off by about 5e-5.
It's better to keep test coverage for this new op rather than disable
the test entirely.

Also prior to this change, the global tolerances were not shared between
JavaScript, Python and C++ tests. Now they are.

Also update the JSON submodule, which is needed to get it to build with
exceptions disabled.

Unblocks #11640.

Prior to this every test shared the same global tolerances. This meant
that if an ONNX test failed due to a small but acceptable difference in
output, the only alternative was to disable the test entirely.

In op set 17, the DFT operator is being added. Without this change, the
tests for that operator fail because the output is off by about 5e-5.
It's better to keep test coverage for this new op rather than disable
the test entirely.

Also prior to this change, the global tolerances were not shared between
JavaScript and Python tests. Now they are.

Unblocks microsoft#11640.
@garymm garymm mentioned this pull request Jun 7, 2022

import onnxruntime.backend as c2
from onnxruntime import backend
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why this is causing this check to fail.

@garymm garymm marked this pull request as ready for review June 9, 2022 00:15
@garymm garymm requested review from fs-eire, jcwchen and snnn June 9, 2022 00:15
Copy link
Contributor

@jcwchen jcwchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for proposing per-test tolerances! The document improvement looks good to me. It would be better to get other experts' approvals about the Python/JavaScript part. Going forward with this PR, perhaps in the future we can go through the whole skip list for ONNX node tests and enable some of them with specific tolerances if reasonable.

js/node/test/test-utils.ts Show resolved Hide resolved
@fs-eire
Copy link
Contributor

fs-eire commented Jun 9, 2022

please fix the build errors of code formatting and ESLint by running the following commands under <ORT_ROOT>/js/ :

npm ci
npm run format
npm run lint

@lgtm-com
Copy link

lgtm-com bot commented Jun 9, 2022

This pull request introduces 107 alerts when merging bec5a0d into 5ecfaef - view on LGTM.com

new alerts:

  • 98 for Commented-out code
  • 4 for Long switch case
  • 2 for Use of goto
  • 1 for For loop variable changed in body
  • 1 for Block with too many statements
  • 1 for No trivial switch statements

@lgtm-com
Copy link

lgtm-com bot commented Jun 10, 2022

This pull request introduces 129 alerts when merging 5d4b8f6 into 5562b47 - view on LGTM.com

new alerts:

  • 119 for Commented-out code
  • 4 for Long switch case
  • 2 for Use of goto
  • 1 for For loop variable changed in body
  • 1 for Block with too many statements
  • 1 for Sizeof with side effects
  • 1 for No trivial switch statements

@lgtm-com
Copy link

lgtm-com bot commented Jun 11, 2022

This pull request introduces 129 alerts when merging ccafd94 into 0869f4f - view on LGTM.com

new alerts:

  • 119 for Commented-out code
  • 4 for Long switch case
  • 2 for Use of goto
  • 1 for For loop variable changed in body
  • 1 for Block with too many statements
  • 1 for Sizeof with side effects
  • 1 for No trivial switch statements

@lgtm-com
Copy link

lgtm-com bot commented Jun 13, 2022

This pull request introduces 129 alerts when merging bc78ae7 into a93ebd2 - view on LGTM.com

new alerts:

  • 119 for Commented-out code
  • 4 for Long switch case
  • 2 for Use of goto
  • 1 for For loop variable changed in body
  • 1 for Block with too many statements
  • 1 for Sizeof with side effects
  • 1 for No trivial switch statements

@garymm
Copy link
Contributor Author

garymm commented Jun 13, 2022

@fs-eire @jcwchen could you please review?

js/node/test/test-utils.ts Outdated Show resolved Hide resolved
jcwchen
jcwchen previously approved these changes Jun 14, 2022
Copy link
Contributor

@jcwchen jcwchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. It would be great if this PR can get approvals from ORT Core team and ORT Web team respectively.

cmake/onnxruntime_unittests.cmake Show resolved Hide resolved
static const ORTCHAR_T* x86_disabled_tests[] = {ORT_TSTR("mlperf_ssd_resnet34_1200"), ORT_TSTR("mask_rcnn_keras"), ORT_TSTR("mask_rcnn"), ORT_TSTR("faster_rcnn"), ORT_TSTR("vgg19"), ORT_TSTR("coreml_VGG16_ImageNet")};
all_disabled_tests.insert(std::begin(x86_disabled_tests), std::end(x86_disabled_tests));
#endif

const TestTolerances tt = LoadTestTolerances(enable_cuda, enable_openvino);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tt

test_tolerances

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined it instead.

@@ -173,8 +173,6 @@ std::string GetTestDataPath() {
static std::vector<ITestCase*> GetAllTestCases() {
std::vector<ITestCase*> tests;
std::vector<std::basic_string<PATH_CHAR_TYPE>> whitelistedTestCases;
double perSampleTolerance = 1e-3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doubl

constexpr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm not sure what you're asking me to do. Could you please elaborate?

@yuslepukhin
Copy link
Member

LGTM. As soon as checks pass I can sign off.

Copy link
Contributor

@fs-eire fs-eire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed off for typescript files (/js/node/**)

@lgtm-com
Copy link

lgtm-com bot commented Jun 14, 2022

This pull request introduces 129 alerts when merging d498d52 into 52f6db1 - view on LGTM.com

new alerts:

  • 119 for Commented-out code
  • 4 for Long switch case
  • 2 for Use of goto
  • 1 for For loop variable changed in body
  • 1 for Block with too many statements
  • 1 for Sizeof with side effects
  • 1 for No trivial switch statements

@garymm
Copy link
Contributor Author

garymm commented Jun 14, 2022

@yuslepukhin all checks passed so I'll merge now. If there are any changes you'd like to see, feel free to comment and I'll open another PR.

@garymm garymm merged commit e8b0d24 into microsoft:master Jun 14, 2022
@garymm garymm deleted the tol-overrides branch June 14, 2022 22:12
xkszltl added a commit to xkszltl/onnxruntime that referenced this pull request Jul 30, 2022
This is required on CentOS 7 if using distro-provided json-devel 3.6.1.

Regression introduced in:
- microsoft#11775

Related upstream commit:
- nlohmann/json@74520d8

Fixed microsoft#12393
xkszltl added a commit to xkszltl/onnxruntime that referenced this pull request Aug 8, 2022
This is required on CentOS 7 if using distro-provided json-devel 3.6.1.

Regression introduced in:
- microsoft#11775

Related upstream commit:
- nlohmann/json@74520d8

Fixed microsoft#12393
skottmckay pushed a commit that referenced this pull request Jan 17, 2023
This is required on CentOS 7 if using distro-provided json-devel 3.6.1.

Regression introduced in:
- #11775

Related upstream commit:
-
nlohmann/json@74520d8

Fixed #12393
xkszltl added a commit to xkszltl/onnxruntime that referenced this pull request Feb 28, 2023
This is required on CentOS 7 if using distro-provided json-devel 3.6.1.

Regression introduced in:
- microsoft#11775

Related upstream commit:
- nlohmann/json@74520d8

Fixed microsoft#12393
siweic0 pushed a commit to siweic0/onnxruntime-web that referenced this pull request May 9, 2024
Prior to this every test shared the same tolerances. This meant
that if an ONNX test failed due to a small but acceptable difference in
output, the only alternative was to disable the test entirely.

In op set 17, the DFT operator is being added. Without this change, the
tests for that operator fail because the output is off by about 5e-5.
It's better to keep test coverage for this new op rather than disable
the test entirely.

Also prior to this change, the global tolerances were not shared between
C++, JavaScript, and Python tests. Now they are.

Also fix various minor issues raised by linters.

Unblocks microsoft#11640.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants