Update ImportONNXDefs.md according to new changes in file name (#45)
Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com>
This commit is contained in:
parent
653fa69102
commit
bab2241b20
|
@ -2,25 +2,31 @@
|
|||
The specifications of ONNX are defined under onnx/defs directory in ONNX projects.
|
||||
There is a python script onnx/defs/gen_doc.py that automatically generate documents about operations in ONNX (docs/Operations.md).
|
||||
ONNX MLIR modified this script to import ONNX specifications into ONNX MLIR. There are two files generated for ONNX MLIR with the modified gen_doc.py:
|
||||
1. src/dialect/onnx/onnxop.inc: Operation defintion for MLIR tablegen. Will be included in src/dialect/onnx/onnx.td
|
||||
2. src/builder/op_build_table.inc: c code for ONNX MLIR frontend to import operation nodes from ONNX model. Will be included in src/builder/frontend_dialect_transformer.cpp
|
||||
1. src/Dialect/ONNX/ONNXOps.td.inc: Operation defintion for MLIR tablegen. Will be included in src/Dialect/ONNX/ONNXOps.td
|
||||
2. src/Builder/OpBuildTable.inc: c code for ONNX MLIR frontend to import operation nodes from ONNX model. Will be included in src/Builder/FrontendDialectTransformer.cpp
|
||||
|
||||
## How to use the script
|
||||
1. Get ONNX. You can use onnx-mlir/third_party/onnx
|
||||
2. In your ONNX directory, copy the script docs/gen_doc.py in your ONNX MLIR to onnx/defs in ONNX
|
||||
3. Run the script: python onnx/defs/gen_doc.py
|
||||
4. Two files, onnxop.inc and op_buid_table.inc should be generated in current directory
|
||||
5. copy the two file into your ONNX MLIR: cp onnxop.inc your_onnx-mlir/src/dialect/onnx/onnxop.inc; cp op_build_table.inc your_onnx-mlir/src/builder
|
||||
6. go to your ONNX MLIR and build
|
||||
2. Perform the following steps (assume that we use onnx-mlir/third_party/onnx):
|
||||
```bash
|
||||
$ cd onnx-mlir
|
||||
$ cp doc/gen_doc.py third_party/onnx/onnx/defs/
|
||||
$ cd third_party/onnx
|
||||
$ python onnx/defs/gen_doc.py
|
||||
$ cd ../..
|
||||
$ cp third_party/onnx/onnx/defs/ONNXOps.td.inc src/Dialect/ONNX/
|
||||
$ cp third_party/onnx/onnx/defs/OpBuildTable.inc src/Builder/
|
||||
```
|
||||
|
||||
## Consistency
|
||||
The Operators.md generated by gen_doc.py is copied into doc. Please refer to this specification, not the one in onnx github, to make sure operators are consistent in version with onnxop.inc.
|
||||
The Operators.md generated by gen_doc.py is copied into doc. Please refer to this specification, not the one in onnx github, to make sure operators are consistent in version with ONNXOps.td.inc.
|
||||
|
||||
## Customization
|
||||
In addition to following the ONNX specification, the modified gen_doc.py provides some mechanism for you to customize the output.
|
||||
Several tables are defined at the beginning of the script:
|
||||
1. special_attr_defaults: gives attribute special default value.
|
||||
1. special_attr_defaults: gives attribute special default value.
|
||||
2. special_op_handler: creates special import function in frontend_dialect_transformer.cpp. Currently special handler is used for operations with oprational arguments
|
||||
3. ShapeInferenceList: list of operations which has shape inference defined
|
||||
4. CanonicalList : list of operations which has canonical form
|
||||
5. manual_code_in_op_def: provides a way to specify any code for an operation in its tablegen
|
||||
3. OpsWithShapeInference: list of operations which have shape inference defined
|
||||
4. OpsWithCanonicalizer: list of operations which have canonical form
|
||||
5. OpsWithPromotableConstOperands: list of operations which have operands that, if produced by constant operations, should be promoted to become an attribute (via attribute promotion)
|
||||
6. custom_builder_ops_list: list of operations which need custom build methods to deduce result types
|
||||
|
|
Loading…
Reference in New Issue