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

Add interface for register custom ops in torch.ops.ppe #796

Merged
merged 9 commits into from
Dec 7, 2023

Conversation

emcastillo
Copy link
Contributor

@emcastillo emcastillo commented Dec 5, 2023

Used to avoid decomposition of ops in torch.fx.Graph when using aot_autograd backend, or add new operations with autograd support for new execution backends/devices

# FWD graph traced 
def forward(self, primals_1, primals_2):
    custom_op_fwd = torch.ops.my_custom_library.custom_op_fwd.default(primals_1, primals_1, primals_1, primals_2)
    return [custom_op_fwd, primals_1, primals_2]

# BWD graph traced (name is forward by some pytorch convention)
def forward(self, primals_1, primals_2, tangents_1):
    custom_op_bwd = torch.ops.my_custom_library.custom_op_bwd.default(primals_1, primals_1, primals_1, primals_2);  primals_1 = primals_2 = None
    getitem = custom_op_bwd[0];  custom_op_bwd = None
    return [getitem, None]

@emcastillo emcastillo changed the title [WIP] Add interface for register custom ops in torch.ops.ppe Add interface for register custom ops in torch.ops.ppe Dec 5, 2023
@emcastillo emcastillo force-pushed the custom_torch_ops branch 2 times, most recently from bceb2e5 to f25db7c Compare December 5, 2023 07:41
@xuzijian629
Copy link
Contributor

I found two small typos. Other code looks good to me!

Co-authored-by: Joe <joe@preferred.jp>
@xuzijian629
Copy link
Contributor

/test

Copy link
Contributor

@xuzijian629 xuzijian629 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@emcastillo emcastillo merged commit 8e6438c into pfnet:master Dec 7, 2023
17 checks passed
@emcastillo emcastillo deleted the custom_torch_ops branch December 7, 2023 01:57
@linshokaku linshokaku added this to the v0.7.5 milestone Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants