-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[bugfix] [Relay] fix broadcast in PyTorch frontend #14885
Conversation
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment. Generated by tvm-bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a unit test?
@echuraev Thanks for your review. Test cases have been added. These test cases can cover the bugging line. However only when the PyTorch version < 1.8.0 in your environments, these test cases can trigger this crash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks
* fix broadcast_tensors * Update pytorch.py * Update test_forward.py * Update test_forward.py
broadcast_shapes
is a newly introduced operator after PyTorch 1.8.0. If you install PyTorch < 1.8.0, the usagetorch.broadcast_shapes
will lead to a crash and throw: AttributeError: module 'torch' has no attribute 'broadcast_shapes'.This PR replaces
broadcast_shapes
with an old operatorbroadcast_tensors
, which was introduced since PyTorch 1.0.0.Reference: PyTorch Documentation
Reproducible script
BTW, this bug can be triggered by existing test cases. Thus, we needn't add new test cases.
cc @echuraev @vvchernov @yongwww