-
Notifications
You must be signed in to change notification settings - Fork 364
feat: Add _to_copy
, operator.get
and clone
ATen converters
#2161
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
61e716e
feat: Add `_to_copy`, `operator.get` and `clone`
gs-olive 31c1cfd
fix: Add temporary workaround for precisions
gs-olive 26d1051
fix: Increase block size to reduce compile time BERT
gs-olive 2e902db
fix: Add generic evaluator function
gs-olive File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.