Skip to content

Conversation

@ZolotukhinM
Copy link

@ZolotukhinM ZolotukhinM commented Nov 15, 2019

Stack from ghstack:

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.
This change also makes torchscript stacktraces look like python ones.

Example:

@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))

Output before:

Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE

Output after:

Traceback (most recent call last):
  File "fail.py", line 41, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter.
Traceback (most recent call last):
  File "fail.py", line 33
@torch.jit.script
def bar(c, b):
    return foo(c, b)
           ~~~ <--- HERE
  File "fail.py", line 29, in foo
@torch.jit.script
def foo(c, b):
    return baz(c, b)
           ~~~ <--- HERE
  File "fail.py", line 25, in baz
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE

Output of non-scripted python code:

Traceback (most recent call last):
  File "fail.py", line 36, in <module>
    bar(torch.rand(10), torch.rand(9))
  File "fail.py", line 21, in bar
    return foo(c, b)
  File "fail.py", line 18, in foo
    return baz(c, b)
  File "fail.py", line 15, in baz
    return c + b
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0

Differential Revision: D18532812

…lined.

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.

Example:
```
@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))
```

Output before:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output after:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
1. at fail.py:23:11
@torch.jit.script
def bar(c, b):
    return foo(c, b)
           ~~~ <--- HERE
2. at fail.py:19:11
@torch.jit.script
def foo(c, b):
    return baz(c, b)
           ~~~ <--- HERE
3. at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

[ghstack-poisoned]
if (i > 0) {
out << "during call ";
}
int idx = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you format the error trace to more closely match python format. e.g. call it a Traceback have the string "(most recent call last)".
I think it should also mention the function name being called in addition to the source range.

1; // make sure we report the call node, not the node after it
Node* node = frame.function->instructions_source_[pc];
if (i > 0) {
out << "during call ";
Copy link
Contributor

Choose a reason for hiding this comment

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

"during call" formatting here is going to cause the formatting to be different depending of if things have been inlined. I think we should have a test that runs the model with/without inlining and checks the stack trace appears byte-for-byte the same.

with self.assertRaises(RuntimeError) as cm:
bar(torch.rand(10), torch.rand(9))
FileCheck().check("The above operation failed in interpreter, with the following stack trace").check("bar").check("foo").check("baz").run(str(cm.exception))

Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a test that includes an interface call (see test_interface) to exercise the combined inlined/not-inlined case.

@kostmo
Copy link
Member

kostmo commented Nov 15, 2019

CircleCI build failures summary

As of commit a7a5854:

  • 9/9 failures introduced in this PR
  • 0/9 recognized as flaky

Here are the reasons each build failed:

Job Step Log excerpt
pytorch_linux_backward_compatibility_check_test Test The PR is introducing backward incompatible changes
pytorch_linux_xenial_py3_6_gcc5_4_ge_config_simple_test Test RuntimeError: test_jit_simple failed!
pytorch_linux_xenial_py3_6_gcc5_4_ge_config_legacy_test Test RuntimeError: test_jit_legacy failed!
pytorch_linux_xenial_py3_6_gcc5_4_test Test main()\':\n/tmp/torch_extensions/test_compilation_error_formatting/main.cpp:2:23: error:
pytorch_linux_xenial_py2_7_9_test Test main()\':\n/tmp/torch_extensions/test_compilation_error_formatting/main.cpp:2:23: error:
pytorch_linux_xenial_cuda9_cudnn7_py3_nogpu_test Test main()\':\n/tmp/torch_extensions/test_compilation_error_formatting/main.cpp:2:23: error:
pytorch_linux_xenial_cuda9_cudnn7_py3_NO_AVX_NO_AVX2_test Test main()\':\n/tmp/torch_extensions/test_compilation_error_formatting/main.cpp:2:23: error:
pytorch_linux_xenial_cuda9_cudnn7_py3_test Test main()\':\n/tmp/torch_extensions/test_compilation_error_formatting/main.cpp:2:23: error:
pytorch_linux_xenial_cuda9_cudnn7_py3_NO_AVX2_test Test main()\':\n/tmp/torch_extensions/test_compilation_error_formatting/main.cpp:2:23: error:

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

Please report bugs/suggestions on the GitHub issue tracker.

This comment has been revised 5 time(s).

…lls were inlined."

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.

Example:
```
@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))
```

Output before:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output after:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
1. at fail.py:23:11
@torch.jit.script
def bar(c, b):
    return foo(c, b)
           ~~~ <--- HERE
2. at fail.py:19:11
@torch.jit.script
def foo(c, b):
    return baz(c, b)
           ~~~ <--- HERE
3. at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

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

[ghstack-poisoned]
…lls were inlined."

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.
This change also makes torchscript stacktraces look like python ones.

Example:
```
@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))
```

Output before:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output after:
```
Traceback (most recent call last):
  File "fail.py", line 41, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter.
Traceback (most recent call last):
  File "fail.py", line 33
    return foo(c, b)
  File "fail.py", line 29, in foo
    return baz(c, b)
  File "fail.py", line 25, in baz
    return c + b
```

Output of non-scripted python code:
```
Traceback (most recent call last):
  File "fail.py", line 36, in <module>
    bar(torch.rand(10), torch.rand(9))
  File "fail.py", line 21, in bar
    return foo(c, b)
  File "fail.py", line 18, in foo
    return baz(c, b)
  File "fail.py", line 15, in baz
    return c + b
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
```

Make torchscript stack traces look like python ones.

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

[ghstack-poisoned]
@ZolotukhinM
Copy link
Author

@zdevito could you please take another look?
Now the stacktraces look as close as possible to python ones. We cannot make them exactly the same, but it's close (see example in commit message). I also added a test with an interface call.

@ZolotukhinM ZolotukhinM requested a review from zdevito November 16, 2019 01:00
Mikhail Zolotukhin added 3 commits November 15, 2019 19:48
…lls were inlined."

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.
This change also makes torchscript stacktraces look like python ones.

Example:
```
@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))
```

Output before:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output after:
```
Traceback (most recent call last):
  File "fail.py", line 41, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter.
Traceback (most recent call last):
  File "fail.py", line 33
    return foo(c, b)
  File "fail.py", line 29, in foo
    return baz(c, b)
  File "fail.py", line 25, in baz
    return c + b
```

Output of non-scripted python code:
```
Traceback (most recent call last):
  File "fail.py", line 36, in <module>
    bar(torch.rand(10), torch.rand(9))
  File "fail.py", line 21, in bar
    return foo(c, b)
  File "fail.py", line 18, in foo
    return baz(c, b)
  File "fail.py", line 15, in baz
    return c + b
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
```

Make torchscript stack traces look like python ones.

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

[ghstack-poisoned]
…lls were inlined."

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.
This change also makes torchscript stacktraces look like python ones.

Example:
```
@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))
```

Output before:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output after:
```
Traceback (most recent call last):
  File "fail.py", line 41, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter.
Traceback (most recent call last):
  File "fail.py", line 33
    return foo(c, b)
  File "fail.py", line 29, in foo
    return baz(c, b)
  File "fail.py", line 25, in baz
    return c + b
```

Output of non-scripted python code:
```
Traceback (most recent call last):
  File "fail.py", line 36, in <module>
    bar(torch.rand(10), torch.rand(9))
  File "fail.py", line 21, in bar
    return foo(c, b)
  File "fail.py", line 18, in foo
    return baz(c, b)
  File "fail.py", line 15, in baz
    return c + b
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
```

Make torchscript stack traces look like python ones.

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

[ghstack-poisoned]
…lls were inlined."

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.
This change also makes torchscript stacktraces look like python ones.

Example:
```
@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))
```

Output before:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output after:
```
Traceback (most recent call last):
  File "fail.py", line 41, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter.
Traceback (most recent call last):
  File "fail.py", line 33
    return foo(c, b)
  File "fail.py", line 29, in foo
    return baz(c, b)
  File "fail.py", line 25, in baz
    return c + b
```

Output of non-scripted python code:
```
Traceback (most recent call last):
  File "fail.py", line 36, in <module>
    bar(torch.rand(10), torch.rand(9))
  File "fail.py", line 21, in bar
    return foo(c, b)
  File "fail.py", line 18, in foo
    return baz(c, b)
  File "fail.py", line 15, in baz
    return c + b
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
```

Make torchscript stack traces look like python ones.

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

[ghstack-poisoned]
Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

Nice! Looks good now.

out << "during call ";
if (node->callstack()) {
for (const auto& p : (*node->callstack())->vec()) {
p.second.print_with_context(
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that Python doesn't add more context by default, but I think we should do it anyway. For instance, python notebooks will print more of the context in stack traces. My previous comments were mostly about the wording differences for the stuff around the highlighting. I also think we should keep the highlighting on, since it makes it easier to read which part of the line we are talking about.

Mikhail Zolotukhin added 3 commits November 18, 2019 20:46
…lls were inlined."

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.
This change also makes torchscript stacktraces look like python ones.

Example:
```
@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))
```

Output before:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output after:
```
Traceback (most recent call last):
  File "fail.py", line 41, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter.
Traceback (most recent call last):
  File "fail.py", line 33
@torch.jit.script
def bar(c, b):
    return foo(c, b)
           ~~~ <--- HERE
  File "fail.py", line 29, in foo
@torch.jit.script
def foo(c, b):
    return baz(c, b)
           ~~~ <--- HERE
  File "fail.py", line 25, in baz
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output of non-scripted python code:
```
Traceback (most recent call last):
  File "fail.py", line 36, in <module>
    bar(torch.rand(10), torch.rand(9))
  File "fail.py", line 21, in bar
    return foo(c, b)
  File "fail.py", line 18, in foo
    return baz(c, b)
  File "fail.py", line 15, in baz
    return c + b
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
```

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

[ghstack-poisoned]
…lls were inlined."

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.
This change also makes torchscript stacktraces look like python ones.

Example:
```
@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))
```

Output before:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output after:
```
Traceback (most recent call last):
  File "fail.py", line 41, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter.
Traceback (most recent call last):
  File "fail.py", line 33
@torch.jit.script
def bar(c, b):
    return foo(c, b)
           ~~~ <--- HERE
  File "fail.py", line 29, in foo
@torch.jit.script
def foo(c, b):
    return baz(c, b)
           ~~~ <--- HERE
  File "fail.py", line 25, in baz
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output of non-scripted python code:
```
Traceback (most recent call last):
  File "fail.py", line 36, in <module>
    bar(torch.rand(10), torch.rand(9))
  File "fail.py", line 21, in bar
    return foo(c, b)
  File "fail.py", line 18, in foo
    return baz(c, b)
  File "fail.py", line 15, in baz
    return c + b
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
```

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

[ghstack-poisoned]
…lls were inlined."

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.
This change also makes torchscript stacktraces look like python ones.

Example:
```
@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))
```

Output before:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output after:
```
Traceback (most recent call last):
  File "fail.py", line 41, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter.
Traceback (most recent call last):
  File "fail.py", line 33
@torch.jit.script
def bar(c, b):
    return foo(c, b)
           ~~~ <--- HERE
  File "fail.py", line 29, in foo
@torch.jit.script
def foo(c, b):
    return baz(c, b)
           ~~~ <--- HERE
  File "fail.py", line 25, in baz
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output of non-scripted python code:
```
Traceback (most recent call last):
  File "fail.py", line 36, in <module>
    bar(torch.rand(10), torch.rand(9))
  File "fail.py", line 21, in bar
    return foo(c, b)
  File "fail.py", line 18, in foo
    return baz(c, b)
  File "fail.py", line 15, in baz
    return c + b
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
```

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

[ghstack-poisoned]
@ZolotukhinM
Copy link
Author

It's already committed.

@facebook-github-bot facebook-github-bot deleted the gh/ZolotukhinM/145/head branch December 23, 2019 15:20
xxtEchjovs44 pushed a commit to xxtEchjovs44/pytorch that referenced this pull request Jan 29, 2020
…lined.

Summary:
This uses newly added InlinedCallStack to print the original call stack
even if the real call stack is shallower because of inlining.
This change also makes torchscript stacktraces look like python ones.

Example:
```
@torch.jit.script
def baz(c, b):
    return c + b

@torch.jit.script
def foo(c, b):
    return baz(c, b)

@torch.jit.script
def bar(c, b):
    return foo(c, b)

bar(torch.rand(10), torch.rand(9))
```

Output before:
```
Traceback (most recent call last):
  File "fail.py", line 25, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter, with the following stack trace:
at fail.py:15:11
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output after:
```
Traceback (most recent call last):
  File "fail.py", line 41, in <module>
    bar(torch.rand(10), torch.rand(9))
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
The above operation failed in interpreter.
Traceback (most recent call last):
  File "fail.py", line 33
@torch.jit.script
def bar(c, b):
    return foo(c, b)
           ~~~ <--- HERE
  File "fail.py", line 29, in foo
@torch.jit.script
def foo(c, b):
    return baz(c, b)
           ~~~ <--- HERE
  File "fail.py", line 25, in baz
@torch.jit.script
def baz(c, b):
    return c + b
           ~~~~~ <--- HERE
```

Output of non-scripted python code:
```
Traceback (most recent call last):
  File "fail.py", line 36, in <module>
    bar(torch.rand(10), torch.rand(9))
  File "fail.py", line 21, in bar
    return foo(c, b)
  File "fail.py", line 18, in foo
    return baz(c, b)
  File "fail.py", line 15, in baz
    return c + b
RuntimeError: The size of tensor a (10) must match the size of tensor b (9) at non-singleton dimension 0
```

ghstack-source-id: ba40b19
Pull Request resolved: pytorch/pytorch#29911
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants