Adding Custom Operator under torch.compile


I want to introduce custom operators in Pytorch 2.0. The goal is to make my custom operator fusable with other existing operators when running it using torch.compile. I know I probably would have to make some modification to TorchInductor/TorchDynamo and introduce new Aten ops but I am not sure what is the best way to do this. Can someone tell me which file I should modify/take a look at in order to achieve this? Pointer to URL/github commit would also be useful. Step-by-step tutorial is even more appreciated.

Thank you!

You can follow this thread for updates, I believe this doesnt work quite yet custom_op API follow-ups · Issue #101191 · pytorch/pytorch · GitHub