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

fix: Update floor division schema replacement in lowering #1464

Merged
merged 1 commit into from
Nov 21, 2022

Conversation

gs-olive
Copy link
Collaborator

@gs-olive gs-olive commented Nov 19, 2022

Description

  • Lowering can occasionally replace the aten::floor_divide inputs with integers or floats, for which the correct function name is aten::floordiv, which ultimately throws an unknown schema error
  • Fix RemoveSingleUse0DTensors lowering pass to repair schema when replacing intermediate operation including an aten::floor_divide call
  • Add test cases to ensure that the resulting graph is schematically correct, but also numerically accurate

Error thrown:

RuntimeError: 
Schema not found for node. File a bug report.
Node: %25626 : int = aten::floor_divide(%22918, %25625)

Input types:int, int
candidates were:
  aten::floor_divide(Tensor self, Tensor other) -> Tensor
  aten::floor_divide.Scalar(Tensor self, Scalar other) -> Tensor
  aten::floor_divide.out(Tensor self, Tensor other, *, Tensor(a!) out) -> Tensor(a!)

Preceding Lowering Optimizations:

GRAPH: [Torch-TensorRT - Debug Build] - Found a 0D Tensor: 234
GRAPH: [Torch-TensorRT - Debug Build] - Number of uses: 1
GRAPH: [Torch-TensorRT - Debug Build] - Downstream user is aten::Int/aten::Float
GRAPH: [Torch-TensorRT - Debug Build] - Input 0 is a Tensor
GRAPH: [Torch-TensorRT - Debug Build] - Found a prim::NumToTensor / aten::[Int/Float] pair with an intermediate operation:
    %234 : Tensor = prim::Constant[value={8}]()
   %22919 : Tensor = prim::NumToTensor(%22918)
   %22920 : Tensor = aten::floor_divide(%22919, %234)
   %22921 : int = aten::Int(%22920)

GRAPH: [Torch-TensorRT - Debug Build] - Deleting 0-dim Tensor: %234 : Tensor = prim::Constant[value={8}]()
GRAPH: [Torch-TensorRT - Debug Build] - New constant: %25625 : int = prim::Constant[value=8]()
GRAPH: [Torch-TensorRT - Debug Build] - Deleting NumToTensor: %22919 : Tensor = prim::NumToTensor(%22918) 
GRAPH: [Torch-TensorRT - Debug Build] - aten::floor_divide(Tensor self, Tensor other) -> Tensor
GRAPH: [Torch-TensorRT - Debug Build] - New intermediate operation: %25626 : int = aten::floor_divide(%22918, %25625)

Fixes #1462

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • [ x ] My code follows the style guidelines of this project (You can use the linters)
  • [ x ] I have performed a self-review of my own code
  • [ x ] I have commented my code, particularly in hard-to-understand areas and hacks
  • [ x ] I have made corresponding changes to the documentation
  • [ x ] I have added tests to verify my fix or my feature
  • [ x ] New and existing unit tests pass locally with my changes
  • [ x ] I have added the relevant labels to my PR in so that relevant reviewers are notified

- Lowering can occasionally replace the `aten::floor_divide` inputs with
integers or floats, for which the correct function name is
`aten::floordiv`, which ultimately throws an unknown schema error
- Fix `RemoveSingleUse0DTensors` lowering pass to repair schema when
replacing intermediate operation including an `aten::floor_divide` call
- Add test cases to ensure that the resulting graph is schematically
correct, but also numerically accurate
@gs-olive gs-olive self-assigned this Nov 19, 2022
@github-actions github-actions bot added component: core Issues re: The core compiler component: lowering Issues re: The lowering / preprocessing passes component: tests Issues re: Tests labels Nov 19, 2022
Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

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

LGTM

@narendasan narendasan merged commit cd1bda3 into pytorch:master Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: core Issues re: The core compiler component: lowering Issues re: The lowering / preprocessing passes component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug] Error encountered when compiling Waveglow model
3 participants