Skip to content

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.

3 participants