-
Notifications
You must be signed in to change notification settings - Fork 364
fix/feat: Add and repair multiple converters for SD + other models #2353
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ def sum( | |
): | ||
input_val = cast_trt_tensor(ctx, input_val, trt.float32, name) | ||
|
||
if dim is None: | ||
if dim is None or (isinstance(dim, (tuple, list)) and len(dim) == 0): | ||
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. Should we consider 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. I thought that 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. This is the behavior in |
||
dim = tuple(range(len(input_val.shape))) | ||
layer = ctx.net.add_reduce( | ||
input_val, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import logging | ||
from typing import Dict, Sequence, Tuple, Union | ||
|
||
import torch | ||
from torch.fx.node import Argument, Target | ||
from torch_tensorrt.dynamo._SourceIR import SourceIR | ||
from torch_tensorrt.dynamo.conversion import impl | ||
from torch_tensorrt.dynamo.conversion._ConversionContext import ConversionContext | ||
from torch_tensorrt.fx.types import TRTTensor | ||
|
||
from .converter_registry import dynamo_tensorrt_converter | ||
|
||
_LOGGER: logging.Logger = logging.getLogger(__name__) | ||
|
||
|
||
# TODO: expand the scope of this converter with aten.expand implementation | ||
def broadcast_checker(broadcast_node: torch.fx.Node) -> bool: | ||
# The current implementation of broadcast_in_dim can only handle unsqueeze | ||
return all( | ||
broadcast_node.args[1][i] == 1 | ||
for i in range(len(broadcast_node.args[1])) | ||
if i not in broadcast_node.args[2] | ||
) | ||
|
||
|
||
@dynamo_tensorrt_converter( | ||
torch.ops.prims.broadcast_in_dim.default, capability_validator=broadcast_checker | ||
) # type: ignore[misc] | ||
def aten_ops_broadcast_in_dim( | ||
ctx: ConversionContext, | ||
target: Target, | ||
args: Tuple[Argument, ...], | ||
kwargs: Dict[str, Argument], | ||
name: str, | ||
) -> Union[TRTTensor, Sequence[TRTTensor]]: | ||
return impl.unsqueeze.broadcast_in_dim( | ||
ctx, | ||
target, | ||
SourceIR.PRIM, | ||
name, | ||
args[0], | ||
args[1], | ||
args[2], | ||
) |
Uh oh!
There was an error while loading. Please reload this page.