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

Call symint::sizes() instead of sizes() on convolution error messages. #89549

Closed
wants to merge 1 commit into from

Conversation

ysiraichi
Copy link
Collaborator

@ysiraichi ysiraichi commented Nov 23, 2022

This PR fixes convolution when using torchdynamo with dynamic shapes.

Problem: there are some tensor.sizes() calls in a few error messages. As a result, an uninformative error message was being displayed.

@torch._dynamo.optimize("eager")
def foo(inp, w):
    return F.conv2d(inp, w)

inp = torch.rand((1, 1, 32, 32))
w = torch.rand((1, 2, 3, 3))
#                  |
#                  |--------- incorrect shape!

foo(inp, w)

Before this PR:

Traceback (most recent call last):
  File "torch/_dynamo/utils.py", line 1076, in run_node
    return node.target(*args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 867, in __torch_dispatch__
    op_impl_out = op_impl(self, func, *args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 445, in conv
    conv_backend = torch._C._select_conv_backend(**kwargs)
RuntimeError: Cannot call sizes() on tensor with symbolic sizes/strides

After this PR:

Traceback (most recent call last):
  File "torch/_dynamo/utils.py", line 1076, in run_node
    return node.target(*args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 867, in __torch_dispatch__
    op_impl_out = op_impl(self, func, *args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 445, in conv
    conv_backend = torch._C._select_conv_backend(**kwargs)
RuntimeError: Given groups=1, weight of size [1, s1, s2, s2], expected input[1, 1, s0, s0] to have s1 channels, but got 1 channels instead

cc @VitalyFedyunin @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 23, 2022

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/89549

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 43239b8:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions github-actions bot added the module: cpu CPU specific problem (e.g., perf, algorithm) label Nov 23, 2022
@ezyang
Copy link
Contributor

ezyang commented Nov 23, 2022

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 23, 2022
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Dec 10, 2022
…ages. (pytorch#89549)

This PR fixes convolution when using `torchdynamo` with dynamic shapes.

**Problem:** there are some `tensor.sizes()` calls in a few error messages. As a result, an uninformative error message was being displayed.

```python
@torch._dynamo.optimize("eager")
def foo(inp, w):
    return F.conv2d(inp, w)

inp = torch.rand((1, 1, 32, 32))
w = torch.rand((1, 2, 3, 3))
#                  |
#                  |--------- incorrect shape!

foo(inp, w)
```

-----
**Before this PR:**
```python
Traceback (most recent call last):
  File "torch/_dynamo/utils.py", line 1076, in run_node
    return node.target(*args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 867, in __torch_dispatch__
    op_impl_out = op_impl(self, func, *args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 445, in conv
    conv_backend = torch._C._select_conv_backend(**kwargs)
RuntimeError: Cannot call sizes() on tensor with symbolic sizes/strides
```

**After this PR:**
```python
Traceback (most recent call last):
  File "torch/_dynamo/utils.py", line 1076, in run_node
    return node.target(*args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 867, in __torch_dispatch__
    op_impl_out = op_impl(self, func, *args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 445, in conv
    conv_backend = torch._C._select_conv_backend(**kwargs)
RuntimeError: Given groups=1, weight of size [1, s1, s2, s2], expected input[1, 1, s0, s0] to have s1 channels, but got 1 channels instead
```

Pull Request resolved: pytorch#89549
Approved by: https://github.com/ezyang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged module: cpu CPU specific problem (e.g., perf, algorithm) open source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants