Skip to content
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

↔ [Converter] Add support for Granular Op-Support Checks in Dynamo #2058

Closed
gs-olive opened this issue Jun 26, 2023 · 1 comment · Fixed by #2161
Closed

↔ [Converter] Add support for Granular Op-Support Checks in Dynamo #2058

gs-olive opened this issue Jun 26, 2023 · 1 comment · Fixed by #2161
Assignees
Labels
component: converters Issues re: Specific op converters feature request New feature or request Story: ATen Op Support

Comments

@gs-olive
Copy link
Collaborator

Add support for operator.get and torch.ops.aten._to_copy and torch.ops.aten.clone

For operator.get we need an evaluator-style implementation which simply dispatches the call out to the Python implementation. For torch.ops.aten._to_copy, the implementation will be a bit more challenging, since we can only support a subset of these operations. Currently, a simple way to perform the differentiation of which _to_copy ops we can handle is to modify the support logic to check if the to converter has a cast which can be performed in TRT. An example of an allowed cast might be torch.float -> torch.int, whereas torch.int ->torch.long is not allowed:

def is_node_supported(
self, submodules: Dict[str, torch.nn.Module], node: torch.fx.Node
) -> bool:
node_name = (
_get_qualified_name(node.target)
if not isinstance(node.target, str)
else node.target
)
if (
node.target in CONVERTERS.keys()
and node_name not in self.torch_executed_ops
):
# If node is a proper, supported computational node, store the operator
if not node.is_impure():
self.supported_operators.add(node_name)
return True
else:
if not node.is_impure():
self.unsupported_operators.add(node_name)
return False

Long Term Solution

A long term solution to this issue of selective conversion is to alter the CONVERSION dictionary to also store an auxiliary function in addition to its converter. This function will take an input node of the converter's type and return whether that node can be converted. For most converters, this function will be: lambda node: True. For _to_copy, however, it might be something like:

def converts_to_copy(node: torch.fx.Node):
    return "dtype" in kwargs and kwargs["dtype"] in APPROVED_CAST_DTYPES
@gs-olive gs-olive added feature request New feature or request component: converters Issues re: Specific op converters labels Jun 26, 2023
@gs-olive gs-olive self-assigned this Jun 26, 2023
@gs-olive
Copy link
Collaborator Author

See RFC #2065 for additional details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: converters Issues re: Specific op converters feature request New feature or request Story: ATen Op Support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants