-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
352 additions
and
40 deletions.
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from ._TRTInterpreter import * # noqa: F403 | ||
from .aten_ops_converters import * # noqa: F403 | ||
from .conversion import * # noqa: F403 | ||
from .op_evaluators import * # noqa: F403 | ||
from .truncate_long_and_double import repair_long_or_double_inputs |
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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
from . import ( | ||
activation, | ||
cast, | ||
condition, | ||
elementwise, | ||
embedding, | ||
|
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,43 @@ | ||
import logging | ||
from typing import Optional | ||
|
||
from torch.fx.node import Target | ||
from torch_tensorrt.dynamo._SourceIR import SourceIR | ||
from torch_tensorrt.dynamo.conversion.converter_utils import cast_trt_tensor | ||
from torch_tensorrt.fx.types import TRTDataType, TRTNetwork, TRTTensor | ||
|
||
LOGGER: logging.Logger = logging.getLogger(__name__) | ||
|
||
|
||
def to_copy( | ||
network: TRTNetwork, | ||
target: Target, | ||
source_ir: Optional[SourceIR], | ||
name: str, | ||
input: TRTTensor, | ||
dtype: TRTDataType, | ||
) -> TRTTensor: | ||
if not isinstance(input, TRTTensor): | ||
raise RuntimeError( | ||
f"to_copy received input {input} that is not a TensorRT ITensor" | ||
) | ||
|
||
casted_tensor = cast_trt_tensor(network, input, dtype, name, target, source_ir) | ||
return casted_tensor | ||
|
||
|
||
def clone( | ||
network: TRTNetwork, | ||
target: Target, | ||
source_ir: Optional[SourceIR], | ||
name: str, | ||
input: TRTTensor, | ||
) -> TRTTensor: | ||
if not isinstance(input, TRTTensor): | ||
raise RuntimeError( | ||
f"clone received input {input} that is not a TensorRT ITensor" | ||
) | ||
|
||
LOGGER.debug(f"Evaluating clone on object with name: {name}") | ||
|
||
return input |
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,32 @@ | ||
import logging | ||
import operator | ||
from typing import Dict, Sequence, Tuple, Union | ||
|
||
from torch.fx.node import Argument, Node, Target | ||
from torch_tensorrt.fx.types import TRTNetwork, TRTTensor | ||
|
||
from .converter_registry import ConverterRegistry, dynamo_tensorrt_converter | ||
|
||
_LOGGER: logging.Logger = logging.getLogger(__name__) | ||
|
||
|
||
def getitem_validator(getitem_node: Node) -> bool: | ||
from torch_tensorrt.dynamo.conversion.converter_registry import DYNAMO_CONVERTERS | ||
|
||
# Getitem nodes can only be converted if their parent node also can | ||
return getitem_node.args[0] in DYNAMO_CONVERTERS | ||
|
||
|
||
# TODO: Subsequent evaluators should be registered here with their own validators | ||
@dynamo_tensorrt_converter(operator.getitem, capability_validator=getitem_validator) | ||
def generic_evaluator( | ||
network: TRTNetwork, | ||
target: Target, | ||
args: Tuple[Argument, ...], | ||
kwargs: Dict[str, Argument], | ||
name: str, | ||
) -> Union[TRTTensor, Sequence[TRTTensor]]: | ||
_LOGGER.debug( | ||
f"Evaluating {ConverterRegistry.qualified_name_or_str(target)} on object with name: {name}" | ||
) | ||
return target(*args) |
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
Oops, something went wrong.