Skip to content

Commit

Permalink
chore: adding additional logging to the converter registry system (#3199
Browse files Browse the repository at this point in the history
)
  • Loading branch information
narendasan authored Dec 19, 2024
1 parent f17fd5f commit 4972fe0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 13 additions & 4 deletions py/torch_tensorrt/dynamo/conversion/_ConverterRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
cast,
)

import tensorrt as trt
import torch
from torch import SymBool, SymFloat, SymInt
from torch._ops import OpOverloadPacket
Expand All @@ -27,6 +26,8 @@
from torch_tensorrt.dynamo.conversion._ConversionContext import ConversionContext
from torch_tensorrt.fx.converter_registry import CONVERTERS as FX_CONVERTERS

import tensorrt as trt

logger = logging.getLogger(__name__)

LegacyConverterImplSignature = Callable[
Expand Down Expand Up @@ -440,25 +441,33 @@ def __getitem__(
):
if key in registry:
converters = registry[key]

if isinstance(converters, (list, tuple)):
for candidate in converters:
logger.debug(f"Converter options for {key}: {len(converters)}")
for i, candidate in enumerate(converters):
# We enable the converter under 4 conditions
# 1) capability validator is True
# 2) Assume dynamic_shape support is True
# 3) Node only has static shaped inputs
# 4) Node has dynamic inputs and the converter has supports_dynamic_shapes=True
if candidate.capability_validator(
if is_valid := candidate.capability_validator(
node, self.compilation_settings
) and (
assume_dynamic_shape_support
or not node_has_dynamic_shapes(node)
or candidate.supports_dynamic_shapes
):
logger.debug(
f"Selecting converter option {i} for converting {key}"
)
return (
candidate.converter_implementation,
calling_convention,
)
else:
logger.debug(
f"Skipping option {i} for {key}: (validator: {is_valid}, supports dynamic shapes: {candidate.supports_dynamic_shapes})"
)
continue
else:
# Assuming FX converters don't have dynamic shapes supported
if not node_has_dynamic_shapes(node):
Expand Down
4 changes: 1 addition & 3 deletions py/torch_tensorrt/dynamo/conversion/impl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from torch_tensorrt.fx.converters.impl import convolution

from . import (
from torch_tensorrt.dynamo.conversion.impl import (
activation,
addmm,
arange,
Expand Down

0 comments on commit 4972fe0

Please sign in to comment.