Skip to content
Open
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
5 changes: 5 additions & 0 deletions backends/nvidia/tensorrt/converters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
Expand All @@ -8,3 +8,8 @@

# Import converters to trigger registration via @converter decorator
from executorch.backends.nvidia.tensorrt.converters import add # noqa: F401
from executorch.backends.nvidia.tensorrt.converters import div # noqa: F401
from executorch.backends.nvidia.tensorrt.converters import mm # noqa: F401
from executorch.backends.nvidia.tensorrt.converters import mul # noqa: F401
from executorch.backends.nvidia.tensorrt.converters import relu # noqa: F401
from executorch.backends.nvidia.tensorrt.converters import sub # noqa: F401
5 changes: 5 additions & 0 deletions backends/nvidia/tensorrt/converters/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def define_common_targets():
srcs = [
"__init__.py",
"add.py",
"div.py",
"mm.py",
"mul.py",
"relu.py",
"sub.py",
],
visibility = ["PUBLIC"],
deps = [
Expand Down
24 changes: 20 additions & 4 deletions backends/nvidia/tensorrt/partitioner/operator_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@ class TensorRTOperatorSupport(OperatorSupportBase):
3. Its output dtype is in SUPPORTED_DTYPES
"""

# Operations that have TensorRT converters.
# Format: "op_name.overload" (e.g., "add.Tensor")
# Operations that have TensorRT converters (sorted alphabetically).
SUPPORTED_OPS: Set[str] = {
"add.Tensor",
"add_.Tensor",
"div.Tensor",
"div.Tensor_mode",
"mm.default",
"mul.Scalar",
"mul.Tensor",
"mul_.Tensor",
"relu.default",
"relu_.default",
"sub.Tensor",
}

# Glue operations that don't compute but are needed to keep partitions connected.
Expand Down Expand Up @@ -86,8 +95,15 @@ def _get_op_name(self, node: torch.fx.Node) -> str:
if hasattr(target, "_schema"):
schema = target._schema
base_name = schema.name.replace("::", ".")
if hasattr(schema, "overload_name") and schema.overload_name:
return f"{base_name}.{schema.overload_name}"
# Note: For the "default" overload, overload_name is an empty string "",
# so we need to check for that and use "default" as the overload name.
if hasattr(schema, "overload_name"):
overload_name = schema.overload_name
if overload_name:
return f"{base_name}.{overload_name}"
else:
# Empty overload_name means "default" overload
return f"{base_name}.default"
return base_name

# Callable with module info (e.g., operator.getitem)
Expand Down
1 change: 1 addition & 0 deletions examples/nvidia/tensorrt/export.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
Expand Down Expand Up @@ -36,6 +36,7 @@
"add",
"add_mul",
"mul",
"softmax",
}


Expand Down
3 changes: 3 additions & 0 deletions examples/nvidia/tensorrt/tests/test_export.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
Expand All @@ -16,7 +16,7 @@
import shutil
import unittest

import torch

Check warning on line 19 in examples/nvidia/tensorrt/tests/test_export.py

View workflow job for this annotation

GitHub Actions / lintrunner

FLAKE8 F401

'torch' imported but unused See https://www.flake8rules.com/rules/F401.html.

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -85,7 +85,7 @@
from executorch.examples.models import MODEL_NAME_TO_MODEL
from executorch.examples.models.model_factory import EagerModelFactory
from executorch.exir import to_edge_transform_and_lower
import torch

Check warning on line 88 in examples/nvidia/tensorrt/tests/test_export.py

View workflow job for this annotation

GitHub Actions / lintrunner

FLAKE8 F811

redefinition of unused 'torch' from line 19 See https://www.flake8rules.com/rules/F811.html.

Check warning on line 88 in examples/nvidia/tensorrt/tests/test_export.py

View workflow job for this annotation

GitHub Actions / lintrunner

FLAKE8 F401

'torch' imported but unused See https://www.flake8rules.com/rules/F401.html.
from torch.export import export
model, example_inputs, _, _ = EagerModelFactory.create_model(*MODEL_NAME_TO_MODEL["add"])
model = model.eval()
Expand All @@ -95,3 +95,6 @@
exec_prog = edge.to_executorch()
self.assertIsNotNone(exec_prog)
logger.info("PASS: add model exported with BF16 precision")

def test_softmax(self) -> None:
_export_and_verify("softmax")
Loading