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] RNN scripting (#57564) #58691

Closed
wants to merge 3 commits into from
Closed

Conversation

BowenBao
Copy link
Collaborator

@BowenBao BowenBao commented May 20, 2021

Stack from ghstack:

Note the first commit in this PR has its own pull request here since it seemed self-contained:
#57082

  • [ONNX] simplify batch_first logic in RNN tests

  • [ONNX] support GRU with packed input in scripting mode

This required two changes:

  • Add as_tensor to symbolic_opset9.py
  • Change torch::jit::pushPackingPastRnn to recognize and properly
    replace another use of the batch_sizes output of prim::PackPadded.
    Previously the code assumed that the first use was as input to the
    RNN operator. However in some cases, it is also used to compute
    max_batch_size. For example in this code:
    https://github.com/pytorch/pytorch/blob/febff45/torch/nn/modules/rnn.py#L815-L815

With these changes the GRU tests now pass in scripting mode for opset
version >= 11.

Co-authored-by: Gary Miguel garymiguel@microsoft.com

Differential Revision: D28714805

Note the first commit in this PR has its own pull request here since it seemed self-contained:
#57082

* [ONNX] simplify batch_first logic in RNN tests

* [ONNX] support GRU with packed input in scripting mode

This required two changes:
* Add as_tensor to symbolic_opset9.py
* Change torch::jit::pushPackingPastRnn to recognize and properly
  replace another use of the batch_sizes output of prim::PackPadded.
  Previously the code assumed that the first use was as input to the
  RNN operator. However in some cases, it is also used to compute
  max_batch_size. For example in this code:
  https://github.com/pytorch/pytorch/blob/febff45/torch/nn/modules/rnn.py#L815-L815

With these changes the GRU tests now pass in scripting mode for opset
version >= 11.

Co-authored-by: Gary Miguel <garymiguel@microsoft.com>

[ghstack-poisoned]
@facebook-github-bot facebook-github-bot added cla signed oncall: jit Add this issue/PR to JIT oncall triage queue labels May 20, 2021
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented May 20, 2021

💊 CI failures summary and remediations

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


  • 7/7 failures possibly* introduced in this PR
    • 1/7 non-scanned failure(s)

6 failures not recognized by patterns:

Job Step Action
GitHub Actions Lint / mypy Run autogen 🔁 rerun
GitHub Actions Linux CI (pytorch-linux-xenial-py3.6-gcc5.4) / calculate-docker-image Checkout PyTorch 🔁 rerun
GitHub Actions Windows CI (pytorch-win-vs2019-cpu-py3) / test Setup Python3 🔁 rerun
GitHub Actions clang-format / clang-format Post Fetch PyTorch 🔁 rerun
GitHub Actions Windows CI (pytorch-win-vs2019-cpu-py3) / render_test_results Download PyTorch Test Reports 🔁 rerun
GitHub Actions Lint / quick-checks C++ docs check 🔁 rerun

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

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

Click here to manually regenerate this comment.

Note the first commit in this PR has its own pull request here since it seemed self-contained:
#57082

* [ONNX] simplify batch_first logic in RNN tests

* [ONNX] support GRU with packed input in scripting mode

This required two changes:
* Add as_tensor to symbolic_opset9.py
* Change torch::jit::pushPackingPastRnn to recognize and properly
  replace another use of the batch_sizes output of prim::PackPadded.
  Previously the code assumed that the first use was as input to the
  RNN operator. However in some cases, it is also used to compute
  max_batch_size. For example in this code:
  https://github.com/pytorch/pytorch/blob/febff45/torch/nn/modules/rnn.py#L815-L815

With these changes the GRU tests now pass in scripting mode for opset
version >= 11.

Co-authored-by: Gary Miguel <garymiguel@microsoft.com>

[ghstack-poisoned]
@SplitInfinity
Copy link

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

@SplitInfinity
Copy link

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

Note the first commit in this PR has its own pull request here since it seemed self-contained:
#57082

* [ONNX] simplify batch_first logic in RNN tests

* [ONNX] support GRU with packed input in scripting mode

This required two changes:
* Add as_tensor to symbolic_opset9.py
* Change torch::jit::pushPackingPastRnn to recognize and properly
  replace another use of the batch_sizes output of prim::PackPadded.
  Previously the code assumed that the first use was as input to the
  RNN operator. However in some cases, it is also used to compute
  max_batch_size. For example in this code:
  https://github.com/pytorch/pytorch/blob/febff45/torch/nn/modules/rnn.py#L815-L815

With these changes the GRU tests now pass in scripting mode for opset
version >= 11.

Co-authored-by: Gary Miguel <garymiguel@microsoft.com>

Differential Revision: [D28714805](https://our.internmc.facebook.com/intern/diff/D28714805)

[ghstack-poisoned]
@SplitInfinity
Copy link

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

@facebook-github-bot
Copy link
Contributor

@SplitInfinity merged this pull request in d101816.

@facebook-github-bot facebook-github-bot deleted the gh/BowenBao/73/head branch May 31, 2021 14:17
deniskokarev pushed a commit to deniskokarev/pytorch that referenced this pull request Jun 9, 2021
Summary:
Pull Request resolved: pytorch#58691

Note the first commit in this PR has its own pull request here since it seemed self-contained:
pytorch#57082

* [ONNX] simplify batch_first logic in RNN tests

* [ONNX] support GRU with packed input in scripting mode

This required two changes:
* Add as_tensor to symbolic_opset9.py
* Change torch::jit::pushPackingPastRnn to recognize and properly
  replace another use of the batch_sizes output of prim::PackPadded.
  Previously the code assumed that the first use was as input to the
  RNN operator. However in some cases, it is also used to compute
  max_batch_size. For example in this code:
  https://github.com/pytorch/pytorch/blob/febff45/torch/nn/modules/rnn.py#L815-L815

With these changes the GRU tests now pass in scripting mode for opset
version >= 11.

Test Plan: Imported from OSS

Reviewed By: driazati

Differential Revision: D28714805

Pulled By: SplitInfinity

fbshipit-source-id: f19647a04533d9ec76399a8793b3f712ea0337d2

Co-authored-by: Gary Miguel <garymiguel@microsoft.com>
titaiwangms added a commit that referenced this pull request Jan 27, 2023
From PR: #58691, Replacing the second input of `Gather` 0 to 1 affects other innocent Nodes. In Issue #91526 onnx::range starts from 0, the 0 is changed by this mechanism, as it's shared by onnx::Gather. This PR intends to create a whole independent Constant 0 for replacement.

TODO: test

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Jan 30, 2023
…ole"


From PR: #58691, Replacing the second input of `Gather` 0 to 1 affects other innocent Nodes. In Issue #91526 onnx::range starts from 0, the 0 is changed by this mechanism, as it's shared by onnx::Gather. This PR intends to create a whole independent Constant 0 for replacement. NOTE: The PR passes all existing RNN tests locally in case CI doesn't include RNN test.

TODO: test

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Jan 30, 2023
From PR: #58691, Replacing the second input of `Gather` 0 to 1 affects other innocent Nodes. In Issue #91526 onnx::range starts from 0, the 0 is changed by this mechanism, as it's shared by onnx::Gather. This PR intends to create a whole independent Constant 0 for replacement. NOTE: The PR passes all existing RNN tests locally in case CI doesn't include RNN test.

TODO: test

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Jan 31, 2023
…ole"


From PR: #58691, Replacing the second input of `Gather` 0 to 1 affects other innocent Nodes. In Issue #91526 onnx::range starts from 0, the 0 is changed by this mechanism, as it's shared by onnx::Gather. This PR intends to create a whole independent Constant 0 for replacement. NOTE: The PR passes all existing RNN tests locally in case CI doesn't include RNN test.

TODO: test

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Jan 31, 2023
From PR: #58691, Replacing the second input of `Gather` 0 to 1 affects other innocent Nodes. In Issue #91526 onnx::range starts from 0, the 0 is changed by this mechanism, as it's shared by onnx::Gather. This PR intends to create a whole independent Constant 0 for replacement. NOTE: The PR passes all existing RNN tests locally in case CI doesn't include RNN test.

TODO: test

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Jan 31, 2023
…ole"


From PR: #58691, Replacing the second input of `Gather` 0 to 1 affects other innocent Nodes. In Issue #91526 onnx::range starts from 0, the 0 is changed by this mechanism, as it's shared by onnx::Gather. This PR intends to create a whole independent Constant 0 for replacement. NOTE: The PR passes all existing RNN tests locally in case CI doesn't include RNN test.

TODO: test

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Jan 31, 2023
From PR: #58691, Replacing the second input of `Gather` 0 to 1 affects other innocent Nodes. In Issue #91526 onnx::range starts from 0, the 0 is changed by this mechanism, as it's shared by onnx::Gather. This PR intends to create a whole independent Constant 0 for replacement. NOTE: The PR passes all existing RNN tests locally in case CI doesn't include RNN test.

TODO: test

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Feb 1, 2023
…ole"


From PR: #58691, Replacing the second input of `Gather` 0 to 1 affects other innocent Nodes. In Issue #91526 onnx::range starts from 0, the 0 is changed by this mechanism, as it's shared with onnx::Gather. This PR intends to create a whole independent Constant 0 for replacement. NOTE: The PR passes all existing RNN tests locally in case CI doesn't include RNN test.

~~TODO: test~~

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Feb 1, 2023
From PR: #58691, Replacing the second input of `Gather` 0 to 1 affects other innocent Nodes. In Issue #91526 onnx::range starts from 0, the 0 is changed by this mechanism, as it's shared with onnx::Gather. This PR intends to create a whole independent Constant 0 for replacement. NOTE: The PR passes all existing RNN tests locally in case CI doesn't include RNN test.

~~TODO: test~~

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Feb 1, 2023
From PR: #58691, Replacing the second input of `Gather` 0 to 1 affects other innocent Nodes. In Issue #91526 onnx::range starts from 0, the 0 is changed by this mechanism, as it's shared with onnx::Gather. This PR intends to create a whole independent Constant 0 for replacement. NOTE: The PR passes all existing RNN tests locally in case CI doesn't include RNN test.

~~TODO: test~~
Pull Request resolved: #93120
Approved by: https://github.com/BowenBao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged oncall: jit Add this issue/PR to JIT oncall triage queue open source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants