Add New Operator
The steps to add an Op are as follows:
- Add the implementation of the Op for the corresponding Backend (CPU).
- Add the enumeration of the Op types.
- Register the implemented Op for the corresponding Backend.
- Add the frontend representation of the Op.
Add the implementation of the Op for the corresponding Backend
CPU
- Add CPUAbc.hpp and CPUAbc.cpp to the CPU directory, or you can generate the two files by running new_op.py.
- Class declaration. Inherit from the base class Op and mainly implement methods like reshape() and execute().
- Implement CPUOpCreator.
Here is an example:
Add the enumeration of the Op types
Add the enumeration of the Op types in the OpDefined.hpp file.
Register the implemented Op for the corresponding Backend
- Include CPUAbc.hpp in the corresponding Backend.cpp file.
- Add the addCreator function in the corresponding Backend.cpp file.
Add the frontend representation of the Op
Implement the frontend representation of the Op in the file Layer.hpp.