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] handle aten::_set_item on Dict in convertInplaceOpsAndTrackAlias (#58317) #58581

Closed
wants to merge 1 commit into from

Conversation

BowenBao
Copy link
Collaborator

@BowenBao BowenBao commented May 19, 2021

Stack from ghstack:

It seems the JIT produces an output for aten::_set_item on lists but
not on dicts. Previously the code would crash because it assumed it
was operating on a list.

The different behavior can be seen with the following test:

class DictModule(torch.nn.Module):
    def forward(self, x_in: torch.Tensor) -> typing.Dict[str, torch.Tensor]:
        x_out = {}
        x_out["test_key_out"] = x_in
        return x_out

x_in = torch.tensor(1)
dms = torch.jit.script(DictModule())
torch.onnx.export(dms, (x_in,), "/dev/null", example_outputs=(dms(x_in),))

Before this change:
RuntimeError: outputs_.size() == 1INTERNAL ASSERT FAILED at "../torch/csrc/jit/ir/ir.h":452, please report a bug to PyTorch.

After this change:
RuntimeError: Exporting the operator prim_DictConstruct to ONNX opset version 9 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub.

This is a more useful error message.

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

…as (#58317)

It seems the JIT produces an output for aten::_set_item on lists but
not on dicts. Previously the code would crash because it assumed it
was operating on a list.

The different behavior can be seen with the following test:

```python
class DictModule(torch.nn.Module):
    def forward(self, x_in: torch.Tensor) -> typing.Dict[str, torch.Tensor]:
        x_out = {}
        x_out["test_key_out"] = x_in
        return x_out

x_in = torch.tensor(1)
dms = torch.jit.script(DictModule())
torch.onnx.export(dms, (x_in,), "/dev/null", example_outputs=(dms(x_in),))
```

Before this change:
`RuntimeError: outputs_.size() == 1INTERNAL ASSERT FAILED at "../torch/csrc/jit/ir/ir.h":452, please report a bug to PyTorch.`

After this change:
`RuntimeError: Exporting the operator prim_DictConstruct to ONNX opset version 9 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub.`

This is a more useful error message.

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

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented May 19, 2021

💊 CI failures summary and remediations

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


  • 1/3 failures introduced in this PR
  • 2/3 broken upstream at merge base b9cc9f3 on May 19 from 8:24am to 2:23pm

🕵️ 1 new failure recognized by patterns

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

See CircleCI build pytorch_linux_xenial_py3_clang7_onnx_ort_test2 (1/1)

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

May 19 21:12:55 AssertionError:
May 19 21:12:55   File "/var/lib/jenkins/workspace/test/onnx/test_pytorch_onnx_onnxruntime.py", line 93, in ort_compare_with_pytorch
May 19 21:12:55     [np.testing.assert_allclose(out, ort_out, rtol=rtol, atol=atol) for out, ort_out in zip(outputs, ort_outs)]
May 19 21:12:55   File "/var/lib/jenkins/workspace/test/onnx/test_pytorch_onnx_onnxruntime.py", line 93, in <listcomp>
May 19 21:12:55     [np.testing.assert_allclose(out, ort_out, rtol=rtol, atol=atol) for out, ort_out in zip(outputs, ort_outs)]
May 19 21:12:55   File "/opt/conda/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 1533, in assert_allclose
May 19 21:12:55     verbose=verbose, header=header, equal_nan=equal_nan)
May 19 21:12:55   File "/opt/conda/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 770, in assert_array_compare
May 19 21:12:55     flagged = func_assert_same_pos(x, y, func=isnan, hasval='nan')
May 19 21:12:55   File "/opt/conda/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 746, in func_assert_same_pos
May 19 21:12:55     raise AssertionError(msg)
May 19 21:12:55 AssertionError: 
May 19 21:12:55 Not equal to tolerance rtol=0.001, atol=1e-07
May 19 21:12:55 
May 19 21:12:55 x and y nan location mismatch:
May 19 21:12:55  x: array([[[-6.568032e+09,          -inf,           nan,          -inf,
May 19 21:12:55                    inf],
May 19 21:12:55         [-2.531204e+09,           inf,           nan,           inf,...
May 19 21:12:55  y: array([[[-6.568032e+09,          -inf,           nan,          -inf,
May 19 21:12:55                    inf],
May 19 21:12:55         [-2.531204e+09,           inf,           nan,           inf,...
May 19 21:12:55 =============================== warnings summary ===============================

🚧 2 fixed upstream failures:

These were probably caused by upstream breakages that were already fixed.

Please rebase on the viable/strict branch (expand for instructions)

If your commit is older than viable/strict, run these commands:

git fetch https://github.com/pytorch/pytorch viable/strict
git rebase FETCH_HEAD

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.

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label May 19, 2021
@BowenBao BowenBao closed this May 20, 2021
@facebook-github-bot facebook-github-bot deleted the gh/BowenBao/70/head branch June 20, 2021 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed 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.

4 participants