Skip to content

feat: support bmm converter in dynamo #2248

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

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions py/torch_tensorrt/dynamo/conversion/aten_ops_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def aten_ops_hard_sigmoid(
@dynamo_tensorrt_converter(torch.ops.aten.matmul) # type: ignore[misc]
@dynamo_tensorrt_converter(torch.ops.aten.mm.default) # type: ignore[misc]
@dynamo_tensorrt_converter(torch.ops.aten.mv.default) # type: ignore[misc]
@dynamo_tensorrt_converter(torch.ops.aten.bmm.default) # type: ignore[misc]
def aten_ops_matmul(
network: TRTNetwork,
target: Target,
Expand Down
36 changes: 36 additions & 0 deletions tests/py/dynamo/conversion/test_bmm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import torch
import torch.nn as nn
from parameterized import parameterized
from torch.testing._internal.common_utils import run_tests

from .harness import DispatchTestCase


class TestBmmConverter(DispatchTestCase):
@parameterized.expand(
Copy link
Collaborator

Choose a reason for hiding this comment

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

As such everything looks good. But can more test cases be added with varying dimensions?

[
("10_3_5", (10, 3, 4), (10, 4, 5)),
("1_10_1", (1, 10, 1), (1, 1, 1)),
("1_1_1", (1, 1, 1), (1, 1, 1)),
]
)
def test_bmm(self, _, input_shape, mat2_shape):
class BMM(nn.Module):
def __init__(self):
super().__init__()

def forward(self, input, mat2):
return torch.bmm(input, mat2)

inputs = [torch.randn(*input_shape), torch.randn(*mat2_shape)]

self.run_test(
BMM(),
inputs,
disable_passes=True,
expected_ops={torch.ops.aten.bmm.default},
)


if __name__ == "__main__":
run_tests()