Navigation Menu

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

Patch convert nodes op to allow for ops with private variable names #1593

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dncnbuck
Copy link

@dncnbuck dncnbuck commented Sep 3, 2022

This PR addresses an issue with the convert_nodes method that arises for ops with privately named variables such as __and__

Convert_nodes assumes that ops ending in _ are in place ops and removes the trailing _ before op lookup.

op_lookup = node.kind
if op_lookup.endswith("_"):
    # This is an "in place" op.
    # Look up the standard op instead by removing underscore.
    op_lookup = op_lookup[:-1]
add_op = _TORCH_OPS_REGISTRY.get(op_lookup, None)

the patch below fixes this

add_op = _TORCH_OPS_REGISTRY.get(op_lookup, None)
if add_op is None and op_lookup.endswith("_"):
    # This is an "in place" op.
    # Look up the standard op instead by removing underscore.
    op_lookup = op_lookup[:-1]
    add_op = _TORCH_OPS_REGISTRY.get(op_lookup, None)

I mentioned this previously here #1509 (comment)

@TobyRoseman
Copy link
Collaborator

@dncnbuck - could you please add a unit test which fails without your fix but passes with the fix?

Hphu2004

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants