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

[ONNX] Add symbolic support for torch.nn.cosinesimilarity (#72128) #73283

Closed
wants to merge 2 commits into from

Conversation

BowenBao
Copy link
Collaborator

@BowenBao BowenBao commented Feb 23, 2022

Stack from ghstack:

Differential Revision: D34625650

* Add support for torch.nn.cosine_similarity

* Remove fallback logic

* Fix onnx test failures

* Fix opset version

* Modify rtol

* Add aten fallback mode

* fix mypy

* gate with caffe2 fallback

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 23, 2022

CI Flow Status

⚛️ CI Flow

Ruleset - Version: v1
Ruleset - File: https://github.com/pytorch/pytorch/blob/cbb07715dd673e35df54e432239431d400835ef6/.github/generated-ciflow-ruleset.json
PR ciflow labels: ciflow/default
Add ciflow labels to this PR to trigger more builds:

Workflows Labels (bold enabled) Status
Triggered Workflows
linux-binary-conda ciflow/binaries, ciflow/binaries_conda, ciflow/default ✅ triggered
linux-binary-libtorch-cxx11-abi ciflow/binaries, ciflow/binaries_libtorch, ciflow/default ✅ triggered
linux-binary-libtorch-pre-cxx11 ciflow/binaries, ciflow/binaries_libtorch, ciflow/default ✅ triggered
linux-binary-manywheel ciflow/binaries, ciflow/binaries_wheel, ciflow/default ✅ triggered
linux-bionic-py3.7-clang9 ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/noarch, ciflow/trunk ✅ triggered
linux-bionic-rocm4.5-py3.7 ciflow/all, ciflow/default, ciflow/linux, ciflow/rocm, ciflow/trunk ✅ triggered
linux-docs ciflow/all, ciflow/cpu, ciflow/default, ciflow/docs, ciflow/linux, ciflow/trunk ✅ triggered
linux-vulkan-bionic-py3.7-clang9 ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk, ciflow/vulkan ✅ triggered
linux-xenial-cuda11.3-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/default, ciflow/linux, ciflow/trunk ✅ triggered
linux-xenial-cuda11.3-py3.7-gcc7-bazel-test ciflow/all, ciflow/bazel, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk ✅ triggered
linux-xenial-py3-clang5-mobile-build ciflow/all, ciflow/default, ciflow/linux, ciflow/mobile, ciflow/trunk ✅ triggered
linux-xenial-py3-clang5-mobile-custom-build-static ciflow/all, ciflow/default, ciflow/linux, ciflow/mobile, ciflow/trunk ✅ triggered
linux-xenial-py3.7-clang7-asan ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/sanitizers, ciflow/trunk ✅ triggered
linux-xenial-py3.7-clang7-onnx ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/onnx, ciflow/trunk ✅ triggered
linux-xenial-py3.7-gcc5.4 ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk ✅ triggered
linux-xenial-py3.7-gcc7 ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk ✅ triggered
linux-xenial-py3.7-gcc7-no-ops ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk ✅ triggered
macos-arm64-binary-conda ciflow/binaries, ciflow/binaries_conda, ciflow/default ✅ triggered
macos-arm64-binary-wheel ciflow/binaries, ciflow/binaries_wheel, ciflow/default ✅ triggered
macos-binary-conda ciflow/binaries, ciflow/binaries_conda, ciflow/default ✅ triggered
macos-binary-libtorch-cxx11-abi ciflow/binaries, ciflow/binaries_libtorch, ciflow/default ✅ triggered
macos-binary-libtorch-pre-cxx11 ciflow/binaries, ciflow/binaries_libtorch, ciflow/default ✅ triggered
macos-binary-wheel ciflow/binaries, ciflow/binaries_wheel, ciflow/default ✅ triggered
pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single ciflow/all, ciflow/android, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk ✅ triggered
pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single-full-jit ciflow/all, ciflow/android, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk ✅ triggered
win-vs2019-cpu-py3 ciflow/all, ciflow/cpu, ciflow/default, ciflow/trunk, ciflow/win ✅ triggered
win-vs2019-cuda11.3-py3 ciflow/all, ciflow/cuda, ciflow/default, ciflow/trunk, ciflow/win ✅ triggered
windows-binary-libtorch-cxx11-abi ciflow/binaries, ciflow/binaries_libtorch, ciflow/default ✅ triggered
windows-binary-libtorch-pre-cxx11 ciflow/binaries, ciflow/binaries_libtorch, ciflow/default ✅ triggered
windows-binary-wheel ciflow/binaries, ciflow/binaries_wheel, ciflow/default ✅ triggered
Skipped Workflows
caffe2-linux-xenial-py3.7-gcc5.4 ciflow/all, ciflow/cpu, ciflow/linux, ciflow/trunk 🚫 skipped
docker-builds ciflow/all, ciflow/trunk 🚫 skipped
ios-12-5-1-arm64 ciflow/all, ciflow/ios, ciflow/macos, ciflow/scheduled 🚫 skipped
ios-12-5-1-arm64-coreml ciflow/all, ciflow/ios, ciflow/macos, ciflow/scheduled 🚫 skipped
ios-12-5-1-arm64-custom-ops ciflow/all, ciflow/ios, ciflow/macos, ciflow/scheduled 🚫 skipped
ios-12-5-1-arm64-metal ciflow/all, ciflow/ios, ciflow/macos, ciflow/scheduled 🚫 skipped
ios-12-5-1-x86-64 ciflow/all, ciflow/ios, ciflow/macos, ciflow/trunk 🚫 skipped
ios-12-5-1-x86-64-coreml ciflow/all, ciflow/ios, ciflow/macos, ciflow/trunk 🚫 skipped
libtorch-linux-xenial-cuda10.2-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/libtorch, ciflow/linux, ciflow/trunk 🚫 skipped
libtorch-linux-xenial-cuda11.3-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/libtorch, ciflow/linux, ciflow/trunk 🚫 skipped
linux-bionic-cuda10.2-py3.9-gcc7 ciflow/all, ciflow/cuda, ciflow/linux, ciflow/slow, ciflow/trunk 🚫 skipped
linux-docs-push ciflow/all, ciflow/cpu, ciflow/linux, ciflow/scheduled 🚫 skipped
linux-xenial-cuda11.3-py3.7-gcc7-no-ops ciflow/all, ciflow/cuda, ciflow/linux, ciflow/trunk 🚫 skipped
macos-10-15-py3-arm64 ciflow/all, ciflow/macos, ciflow/trunk 🚫 skipped
macos-10-15-py3-lite-interpreter-x86-64 ciflow/all, ciflow/macos, ciflow/trunk 🚫 skipped
macos-11-py3-x86-64 ciflow/all, ciflow/macos, ciflow/trunk 🚫 skipped
parallelnative-linux-xenial-py3.7-gcc5.4 ciflow/all, ciflow/cpu, ciflow/linux, ciflow/trunk 🚫 skipped
periodic-libtorch-linux-bionic-cuda11.5-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/libtorch, ciflow/linux, ciflow/scheduled 🚫 skipped
periodic-libtorch-linux-xenial-cuda11.1-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/libtorch, ciflow/linux, ciflow/scheduled 🚫 skipped
periodic-linux-bionic-cuda11.5-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/linux, ciflow/scheduled 🚫 skipped
periodic-linux-xenial-cuda10.2-py3-gcc7-slow-gradcheck ciflow/all, ciflow/cuda, ciflow/linux, ciflow/scheduled, ciflow/slow, ciflow/slow-gradcheck 🚫 skipped
periodic-linux-xenial-cuda11.1-py3.7-gcc7-debug ciflow/all, ciflow/cuda, ciflow/linux, ciflow/scheduled 🚫 skipped
periodic-win-vs2019-cuda11.1-py3 ciflow/all, ciflow/cuda, ciflow/scheduled, ciflow/win 🚫 skipped
periodic-win-vs2019-cuda11.5-py3 ciflow/all, ciflow/cuda, ciflow/scheduled, ciflow/win 🚫 skipped
pytorch-linux-xenial-py3-clang5-android-ndk-r19c-build ciflow/all, ciflow/android, ciflow/cpu, ciflow/linux, ciflow/trunk 🚫 skipped
pytorch-xla-linux-bionic-py3.7-clang8 ciflow/all, ciflow/cpu, ciflow/linux, ciflow/trunk, ciflow/xla 🚫 skipped

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Feb 23, 2022

🔗 Helpful links

💊 CI failures summary and remediations

As of commit 5495c62 (more details on the Dr. CI page):


  • 3/3 failures introduced in this PR

🕵️ 3 new failures recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See GitHub Actions build linux-xenial-cuda11.3-py3.7-gcc7 / test (default, 2, 2, linux.4xlarge.nvidia.gpu) (1/3)

Step: "Unknown" (full log | diagnosis details | 🔁 rerun)

2022-03-02T21:29:56.2587780Z test_add_done_ca...arg() takes 0 positional arguments but 1 was given
2022-03-02T21:29:56.2558714Z   /opt/conda/lib/python3.7/unittest/suite.py(122): run
2022-03-02T21:29:56.2559041Z   /opt/conda/lib/python3.7/unittest/suite.py(84): __call__
2022-03-02T21:29:56.2559488Z   /opt/conda/lib/python3.7/site-packages/xmlrunner/runner.py(67): run
2022-03-02T21:29:56.2559843Z   /opt/conda/lib/python3.7/unittest/main.py(271): runTests
2022-03-02T21:29:56.2560190Z   /opt/conda/lib/python3.7/unittest/main.py(101): __init__
2022-03-02T21:29:56.2560682Z   /opt/conda/lib/python3.7/site-packages/torch/testing/_internal/common_utils.py(655): run_tests
2022-03-02T21:29:56.2561027Z   test_futures.py(331): <module>
2022-03-02T21:29:56.2561199Z 
2022-03-02T21:29:56.2561298Z ok (1.523s)
2022-03-02T21:29:56.2581618Z   test_add_done_callback_maintains_callback_order (__main__.TestFuture) ... ok (0.003s)
2022-03-02T21:29:56.2587780Z   test_add_done_callback_no_arg_error_is_ignored (__main__.TestFuture) ... [E pybind_utils.h:201] Got the following error when running the callback: TypeError: no_arg() takes 0 positional arguments but 1 was given
2022-03-02T21:29:56.2589186Z ok (0.001s)
2022-03-02T21:29:56.2602633Z   test_add_done_callback_simple (__main__.TestFuture) ... ok (0.001s)
2022-03-02T21:29:56.2660891Z   test_chained_then (__main__.TestFuture) ... ok (0.006s)
2022-03-02T21:29:56.3683269Z   test_collect_all (__main__.TestFuture) ... ok (0.102s)
2022-03-02T21:29:56.3690968Z   test_done (__main__.TestFuture) ... ok (0.001s)
2022-03-02T21:29:56.3704986Z   test_done_exception (__main__.TestFuture) ... ok (0.001s)
2022-03-02T21:29:56.3725631Z   test_interleaving_then_and_add_done_callback_maintains_callback_order (__main__.TestFuture) ... ok (0.002s)
2022-03-02T21:29:56.3737099Z   test_interleaving_then_and_add_done_callback_propagates_error (__main__.TestFuture) ... [E pybind_utils.h:201] Got the following error when running the callback: ValueError: Expected error
2022-03-02T21:29:56.3737855Z 
2022-03-02T21:29:56.3737985Z At:

See GitHub Actions build linux-xenial-py3.7-gcc5.4 / test (backwards_compat, 1, 1, linux.2xlarge) (2/3)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-03-02T19:34:38.6992527Z The PR is introduc...m to confirm whether this change is wanted or not.
2022-03-02T19:34:38.6979577Z processing existing schema:  text(__torch__.torch.classes.profiling.SourceRef _0) -> (str _0)
2022-03-02T19:34:38.6981066Z processing existing schema:  count(__torch__.torch.classes.profiling.InstructionStats _0) -> (int _0)
2022-03-02T19:34:38.6981669Z processing existing schema:  duration_ns(__torch__.torch.classes.profiling.InstructionStats _0) -> (int _0)
2022-03-02T19:34:38.6983206Z processing existing schema:  source(__torch__.torch.classes.profiling.SourceStats _0) -> (__torch__.torch.classes.profiling.SourceRef _0)
2022-03-02T19:34:38.6984717Z processing existing schema:  line_map(__torch__.torch.classes.profiling.SourceStats _0) -> (Dict(int, __torch__.torch.classes.profiling.InstructionStats) _0)
2022-03-02T19:34:38.6986025Z processing existing schema:  __init__(__torch__.torch.classes.profiling._ScriptProfile _0) -> (NoneType _0)
2022-03-02T19:34:38.6986939Z processing existing schema:  enable(__torch__.torch.classes.profiling._ScriptProfile _0) -> (NoneType _0)
2022-03-02T19:34:38.6988893Z processing existing schema:  disable(__torch__.torch.classes.profiling._ScriptProfile _0) -> (NoneType _0)
2022-03-02T19:34:38.6990657Z processing existing schema:  _dump_stats(__torch__.torch.classes.profiling._ScriptProfile _0) -> (__torch__.torch.classes.profiling.SourceStats[] _0)
2022-03-02T19:34:38.6992085Z processing existing schema:  __init__(__torch__.torch.classes.dist_rpc.WorkerInfo _0, str _1, int _2) -> (NoneType _0)
2022-03-02T19:34:38.6992527Z The PR is introducing backward incompatible changes to the operator library. Please contact PyTorch team to confirm whether this change is wanted or not. 
2022-03-02T19:34:38.6992548Z 
2022-03-02T19:34:38.6992680Z Broken ops: [
2022-03-02T19:34:38.6993233Z 	quantized::conv2d_relu_cudnn(Tensor act, Tensor weight, Tensor? bias, int[] stride, int[] padding, int[] dilation, int groups, float output_scale, int output_zero_point) -> (Tensor)
2022-03-02T19:34:38.6993284Z ]
2022-03-02T19:34:38.7888802Z + cleanup
2022-03-02T19:34:38.7888929Z + retcode=1
2022-03-02T19:34:38.7889001Z + set +x
2022-03-02T19:34:38.7928498Z ##[error]Process completed with exit code 1.
2022-03-02T19:34:38.7960372Z ##[group]Run # Ensure the working directory gets chowned back to the current user
2022-03-02T19:34:38.7960560Z �[36;1m# Ensure the working directory gets chowned back to the current user�[0m

See GitHub Actions build win-vs2019-cuda11.3-py3 / test (default, 1, 2, windows.8xlarge.nvidia.gpu) (3/3)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-03-02T23:02:24.7521110Z RuntimeError: test_ops failed!
2022-03-02T23:02:09.0927302Z Generated XML report: test-reports\python-unittest\test_ops\TEST-TestGradientsCUDA-20220302212237.xml
2022-03-02T23:02:09.0928811Z Generated XML report: test-reports\python-unittest\test_ops\TEST-TestJitCPU-20220302212237.xml
2022-03-02T23:02:09.0930381Z Generated XML report: test-reports\python-unittest\test_ops\TEST-TestJitCUDA-20220302212237.xml
2022-03-02T23:02:09.0933149Z Generated XML report: test-reports\python-unittest\test_ops\TEST-TestMathBitsCPU-20220302212237.xml
2022-03-02T23:02:09.0934741Z Generated XML report: test-reports\python-unittest\test_ops\TEST-TestMathBitsCUDA-20220302212237.xml
2022-03-02T23:02:24.7517855Z Traceback (most recent call last):
2022-03-02T23:02:24.7518931Z   File "run_test.py", line 1106, in <module>
2022-03-02T23:02:24.7519385Z     main()
2022-03-02T23:02:24.7519989Z   File "run_test.py", line 1084, in main
2022-03-02T23:02:24.7520570Z     raise RuntimeError(err_message)
2022-03-02T23:02:24.7521110Z RuntimeError: test_ops failed!
2022-03-02T23:02:25.1284686Z 
2022-03-02T23:02:25.1285715Z (base) C:\actions-runner\_work\pytorch\pytorch\test>if ERRORLEVEL 1 goto fail 
2022-03-02T23:02:25.1288755Z 
2022-03-02T23:02:25.1289476Z (base) C:\actions-runner\_work\pytorch\pytorch\test>exit /b 1 
2022-03-02T23:02:25.1324049Z + cleanup
2022-03-02T23:02:25.1324653Z + retcode=1
2022-03-02T23:02:25.1324994Z + set +x
2022-03-02T23:02:25.1363870Z ##[error]Process completed with exit code 1.
2022-03-02T23:02:25.2152982Z ##[group]Run # -ir => recursive include all files in pattern
2022-03-02T23:02:25.2153841Z �[36;1m# -ir => recursive include all files in pattern�[0m

This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@BowenBao BowenBao added the onnx-needs-import This PR is related to ONNX, but touches files outside of merge rule patterns, and hence needs import label Feb 23, 2022
…72128)"

* Add support for torch.nn.cosine_similarity

* Remove fallback logic

* Fix onnx test failures

* Fix opset version

* Modify rtol

* Add aten fallback mode

* fix mypy

* gate with caffe2 fallback

[ghstack-poisoned]
@malfet
Copy link
Contributor

malfet commented Mar 3, 2022

@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit that referenced this pull request Mar 9, 2022
…73283)

Summary:
Pull Request resolved: #73283

* Add support for torch.nn.cosine_similarity

* Remove fallback logic

* Fix onnx test failures

* Fix opset version

* Modify rtol

* Add aten fallback mode

* fix mypy

* gate with caffe2 fallback

Test Plan: Imported from OSS

Reviewed By: jbschlosser

Differential Revision: D34625650

Pulled By: malfet

fbshipit-source-id: bf15d32b1d7055d0ca166d9941ba90b5c8e81cc2
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2022

Hey @BowenBao.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed onnx-needs-import This PR is related to ONNX, but touches files outside of merge rule patterns, and hence needs import open source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants