add onnx op fields and remove OpBuildTable.inc #2249
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added ONNXOperationTrait to every ONNX operations generated from the ONNX spec by gen_onnx_mlir.py. The trait makes it possible with
std::is_base_of_v<ONNXOperationTrait<OP>, OP>
to test if an operation type OP is generated from the spec, and it gives access to the onnx name, domain, and since_version. When there are multiple operation types for a single ONNX spec op type, like ONNXUnqueezeOp and ONNXUnsqueezeV11OP, they will have the same name and domain and different since_versions. (The implementation of ONNXOperationTrait is done via corresponding generated static fields onnxName, onnxDomain, onnxSinceVersion in the generated op. I might change change ONNXOperationTrait to an OpInterface and generate implementations of its declared methods instead of the static fields.)Removed OpBuilder.inc and instead FrontendDialectTransformer now runs through the tablegen operation types in the dialect by calling
foreachONNXOp()
with a generic lambda to which is called with a null operation of each type. Via ONNXOperationTrait it can query the op name, domain, and since_version to build the needed tables.Changed the custom import handler methods
ImportCategoryMapper()
,ImportScan()
, etc to template specializationsbuildOperation<ONNXCategoryMapperOp>()
,buildOperation<ONNXScanOp>()
, etc.