-
Notifications
You must be signed in to change notification settings - Fork 350
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: Improve input handling in aten bmm lowering pass #1821
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import torch | ||
import torch.nn as nn | ||
from parameterized import parameterized | ||
from torch.testing._internal.common_utils import run_tests, TestCase | ||
from torch_tensorrt.fx.tracer.dispatch_tracer.aten_tracer import trace | ||
from torch_tensorrt.fx.passes.lower_basic_pass_aten import compose_bmm | ||
|
||
|
||
class TestComposeBMM(TestCase): | ||
@parameterized.expand( | ||
[ | ||
("3_dim", (2, 3, 4), (2, 4, 3)), | ||
("3_dim_same_shape", (4, 4, 4), (4, 4, 4)), | ||
] | ||
) | ||
def test_compose_bmm(self, test_name, x_shape, y_shape): | ||
class BMM(nn.Module): | ||
def forward(self, x, y): | ||
return torch.bmm(x, y) | ||
|
||
inputs = [torch.randn(x_shape), torch.randn(y_shape)] | ||
fx_model, _ = trace(BMM(), inputs) | ||
composed_module = compose_bmm(fx_model) | ||
out = composed_module.graph_module(*inputs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test is not complete yet. Could you pls add the converter and complete the test as other test? |
||
|
||
|
||
if __name__ == "__main__": | ||
run_tests() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
do we have such case which has no inputs to the bmm?
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.
Yes, the case in #1789, which uses this model, has
len(input_n.all_input_nodes) == 0
:The test case shows this behavior too.
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.
I did an experiment. 1) Looks like
bmm
is not decomposed anymore. 2) bmm's all_input_nodes is not 0There 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.
@frank-wei I see, thanks for the additional details. The reason I included that test case was for the case where we take the model in question and apply the
compose_bmm
lowering pass to it, in which case we see the failure. Specifically, in the above example, add the following lines:When doing so, the following error is elicited: