-
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.
feat: Add
_to_copy
, operator.get
and clone
- Add ATen converters for key operators in the pipeline of multiple models - Add robust testing and patch issues in interpreter - Add evaluator and casting utilities to the converter utils
- Loading branch information
Showing
10 changed files
with
328 additions
and
12 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
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,28 @@ | ||
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 ( | ||
TRTNetwork, | ||
TRTTensor, | ||
TRTDataType, | ||
) | ||
|
||
|
||
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 |
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,45 @@ | ||
import operator | ||
import logging | ||
from typing import Optional, Sequence | ||
from torch.fx.node import Target | ||
|
||
from torch_tensorrt.dynamo._SourceIR import SourceIR | ||
|
||
from torch_tensorrt.fx.types import ( | ||
TRTNetwork, | ||
TRTTensor, | ||
) | ||
|
||
|
||
LOGGER: logging.Logger = logging.getLogger(__name__) | ||
|
||
|
||
def getitem( | ||
network: TRTNetwork, | ||
target: Target, | ||
source_ir: Optional[SourceIR], | ||
name: str, | ||
input: Sequence[TRTTensor], | ||
index: int, | ||
) -> TRTTensor: | ||
LOGGER.debug(f"Evaluating getitem on object with name: {name}") | ||
|
||
# Directly index the input sequence and return the value | ||
return operator.getitem(input, index) | ||
|
||
|
||
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
Oops, something went wrong.