Add docs tutorial for adding a new ATen operator (MLIR path)#206
Conversation
| @@ -0,0 +1,681 @@ | |||
| # How to add support for a new ATen Operator in PyTorchSim | |||
There was a problem hiding this comment.
I think the template keyword is required in this title
| ## Overview | ||
| PyTorchSim executes PyTorch programs by **lowering ATen operators into MLIR**, | ||
| followed by backend-specific code generation and simulation. | ||
| This wiki describes contributors through the process of adding support for **new |
There was a problem hiding this comment.
describes -> guides or helps?
| PyTorchSim executes PyTorch programs by **lowering ATen operators into MLIR**, | ||
| followed by backend-specific code generation and simulation. | ||
| This wiki describes contributors through the process of adding support for **new | ||
| ATen operators** by defining custom lowerings in PyTorchSim’s MLIR-based |
There was a problem hiding this comment.
I think template need to be mentioned here
|
|
||
|
|
||
| We use a dummy operator, `torch._foobar()`, as a minimal example. | ||
| Although `_foobar` has trivial semantics, it still exercises the full |
There was a problem hiding this comment.
It would be helpful to explicitly mention that foobar is an ATen operator. Plus, how about adding a ULR?
| ## Background | ||
|
|
||
| Before diving into the step-by-step implementation, it helps to understand | ||
| how an ATen operator flows through PyTorchSim’s MLIR-based pipeline. At a high level, supporting a new ATen operator means intercepting the |
There was a problem hiding this comment.
What about adding a figure of the compilation flow for the template kernel?
There was a problem hiding this comment.
intercepting sounds slightly awkward
There was a problem hiding this comment.
I think it would be good to mention the difference between the ordinary codegen path and the template codegen path
|
|
||
| ### Lowering stage (`mlir_lowering.py`) | ||
|
|
||
| During lowering, a custom function (e.g., `custom_<op>`) is invoked for |
There was a problem hiding this comment.
I think readers might be confused about what custom_function is and why it suddenly appears here.
Did you mean to explain that custom_function is called during the lowering process because it is registered in the lowering dictionary as {aten._foobar: custom_function}
| `aten.<op>`. | ||
|
|
||
| The lowering: | ||
| - materializes inputs in Inductor IR if necessary, |
|
|
||
| This is the key hook where new ATen operator support is introduced. | ||
|
|
||
| ### Scheduling stage (`mlir_scheduling.py`) |
No description provided.