* enable promote attr for pad
* use optional arguments for pad
* shape infereance for pad
* Lowering Pad
* format file
* use DenseTensor for the attribute
* use Pad in ONNXRewrite
* fix the merge conflict
* fix the attr given to constantOp
* handle ONNXConstantOp in attribute promotion
* Fix bug when AttributePromotion is called more than once
* update ONNXOps.td.inc with correct version of onnx
* update onnx.md
* responses to review
* fix the build error
* change the implementation of Pad
* delete commented out code
* clang format
Co-authored-by: Tian Jin <tjingrant@gmail.com>
* Use AffineMap
* Shared AffineMap
* AffineMap for Conv/Pooling
* Create helper files
* Remove changes for Relu
* Remove redundant includes
* Use AffineMap for AveragePool's shape inference
* Add MLIR tests for unknown dimension case
* Extract a method AffineMapIntConstant
* Comment stylist and include path
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Specialize the op lowering logic for elementwise operations
* Fix clang-format error.
* Update tests for LSTM since LSTM uses element-wise ops
Co-authored-by: Tian Jin <tjingrant@gmail.com>
* Support dilations and enable e2e tests
* Fix allocating memory for dynamic shape
* Edit comments
* Do dilation by computing an offset from kernel index
* Correct dilation formula, add an example of out-of-bound, and add a test for dilation
* Import optional outputs as NoneType
* Shape inference for ONNXLSTM
* Edit ONNXLSTM::inferShape()
* Shape inference for ONNXLSTMOp
* Create a common function for inferring shape for RNN ops
* CheckInsertDeallocation for a specific result
* Allocate memory for LSTM
* First round of lowering
* Allocate memory for hidden and cell states
* Test with custom Tanh
* Fix an error in Ct's formula
* Add E2E tests
* Return outputs
* Refactor the code
* Enable E2E tests
* Support reverse and bidirectional directions
* Minor revision
* Return all intermediate hidden states
* Call existing activation functions
* Structs for activation functions
* Call existing activations in ONNX
* Minor revision
* Compare strings ignoring case
* Use memreftype of rank 0 for calling activation functions
* Fix getActivationPack()
* Revise the code
* Add one MLIR test
* Add MLIR tests for reverse and bidirectional modes
* Make the order of emiting instructions deterministic
* Use OperandAdaptor instead of directly use an operand index
* Use literal assignments
* Change some variable names
* Use literal assignments
* Use literal assignments
* Format the code
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Implement shape inference for SplitOp
* Change spitOpt to SplitAttribute and check the axis range before updating the axis attribute
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Reorganize main function.
* Follow review comments.
* Emit constants are globals in Krnl and LLVM dialects.
* Output of non-value constants. Write full source to file.
* Fix e2e tests.
* Output constant free and full code in separate files.
* Emit separate files.
* Move file output management to utils.
* Elide the values of glotbal krnl constants.
* Add dual file output for Basic flag.
* Add tests.
* Add passes to cmake file.
* Create a template for pooling and add support for AveragePool
* Edit MLIR tests for MaxPool according to the new lowering template for pooling
* Dealloc temporary variables
* Support count_include_pad for AveragePool
* Add MLIR tests for AveragePool lowering
* Make changes according to Tian's comments
* Push AffineMap as upper bound for KrnlIterateOp
* Test AffineMap to use in Pooling
* Replace the old implementaion by a new one using AffineMap
* Fix the computation when dilations are non-unit
* Clean up the old code
* Remove AveragePool from Canonicalization pass
* Fix computing the end indices of a filter window
* Refactor the code for pooling
* Revise pushAffineMapBound
* Add MLIR tests
* Remove unused functions
* Fix check-onnx-backend build on x86 Linux. (#91)
* Add the split marker to test files (#90)
Co-authored-by: Tian Jin <tjingrant@gmail.com>
Co-authored-by: gongsu832 <gong_su@hotmail.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
* implement shape inference for concat
* better checking of axis being concatenated: constant values only
* lowering of Concat with lit and backend tests
* fixes
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Support dilations and enable e2e tests
* Fix allocating memory for dynamic shape
* Edit comments
* Do dilation by computing an offset from kernel index
* Correct dilation formula, add an example of out-of-bound, and add a test for dilation
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Fix reshape when a dynamic shape is given.
* Fix default attributes for ConvNoBias.
* Fix comment.
* Resolve comment.
* Improve checks.
* Handle zero dim case.
* Add helper to fetch constants. Add test for dynamic reshape.
* Add test for zero.
* Use shortcut method for size.
* Support Pads for MaxPoolSingleOut
* Regenerate onnx.md to include the new op
* Edit comments
* Undo redundant parts that were unintentionally changed
* Move declarative rewriting rules into canonicalize to avoid creating a new op
* Reformat the rewriting rule pattern of MaxPoolSingleOut
* Put ONNXPadConstantValuePadOp's build method into a .cpp file instead of a tablegen file
* Use the same helper function as the one in inferShape for the ONNXPadConstantValuePadOp's build method
* Change function names and fix padding for the spatial dimensions
* Call shape-inference again after canonicalization to infer shape for newly added ops during canonicalization.
* Fix typos
* Lower MaxPoolSingleOutOp to Krnl dialect
* Edit comments
* Update changes according to the new folder structure
* Add MLIR tests
* Support ceil_mode
* Merge the first two krnl loops into one krnl loop; remove attribute checks
* Dynamically allocate memory for the result if the result has unknown dimensions
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Remove rank constraints in gemm fusion
* Add an MLIR test
Co-authored-by: Tian Jin <tjingrant@gmail.com>
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* 1. Combine variadicIn/Out with expectedNumOperands/Results to simplify import function arguments.
2. Generic improvements to code readability in gen_doc.py.
* Update ONNX Dialect doc.
* Remove redundant code in ImportNode.
* Prettify op_build_table.inc.
* 1. Remove irrelevant code in gen_doc.py
* Refactor code to be more readable.
* Further refactoring for readability improvements.
* Allow gemm to have an optional operand (bias term), and include an example of declarative optimization pattern targeting gemm with bias term ommitted.
* Make shape inference/lowering of gemm op compatible with optional operand declaration.
* Apply canonicalization again after lowering from onnx -> std dialects.
* Make hasBias compatible with the situation of GemmNoBias op.
* Update doc.
* Add a canonicalization test.
* Remove special handler for importing Gemm op, as it's redundant now.
* Add ONNXBatchNormalizationTestModeOp and its shape inference
* Lower batchnormalization test mode
* re-use scale, bias, mean, and variance
* Add MLIR tests
* Add e2e tests
* fix typos
* Fix a bug in MLIR tests
* Change type from int to int64_t for indices
* Uncomment e2e tests due to segmentation fault
* Uncomment e2e tests due to segmentation fault
* Revise the code
* [Tian] Fix segmentation fault in e2e tests
* Re-generate onnx.md to include BatchNormalizationTestModeOp
* Reverse an unintentional change
* Fix some typos in comments
* Use convertToMemRefType from the master branch
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Allocate memory for matmul's result
* Group cases
* Add support of N-D x N-D, N>=2
* Revise createIterateOperandPack
* Add 1-D x 1-D
* Add 1-D x N-D
* Add MLIR tests
* Change variable names
* Change type from int to int64_t for indices
* Change variable names
* Change int64_t back to int
* Change int64_t back to int
* Change int64_t back to int
* Use decltype
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
* handle pad op which does not have the optional third argment
* rewrite PadConstantValue with constant pad into PadConstantValuePad
* add test for PadConstantValuePad
* update onnx.md
* Shape inference for reduction
* Lower ReduceSum
* Support list-like attributes
* Add ReduceMax, ReduceMin, ReduceProd
* Add tests
* Emit errors for unsupported types
* Typos
* Add backend test
* Fix axis computation
* Update the use of attributes
* Use SmallVector
* Address stylistic comments
* Change type from int to int64_t for indices
* Change type from int to int64_t for indices
* Ensure data shape is at least 4.
* First version of convolution.
* Simplify code for KRNL lowering.
* Add test without padding or strides.
* Refactor code for lowering frontend operations to KRNL dialect.
* Add test for conv with no bias and no padding.
* Add test with group greater than one.
* Address comment.
* Support lowering of SignOp
* Fixed test code for signop of integer input
* Inserted Sigh and Reciprocal in SharingWork.md (Reciprocal is for past commit 7e3f96e)
* Added test for Sign Op
* Fixed minus_one -> minusOne
* Fixed test for signop
* Rewrite ReduceSumSquare
* Edit gen_doc.py
* Revise the code
* Do shape inference after canonicalization so that there is no need to implement shape inference of rewritten ops
* Rewrite ReduceL2
* Add onnx_rewrite.cpp for all rewriting for ONNX ops
* Rewrite ReduceL1, ReduceLogSum, ReduceLogSumExp
* Edit comments
* Change the use of -> to .
* Checkout gen_doc.py from the master branch
* Use emplace_back instead of push_back
* Revise the code
* Edit comments
Co-authored-by: Tian Jin <tjingrant@gmail.com>
* first steps for shape inference of maxpool
* setps forward
* ongoing
* working version
* first steps for shape inference of maxpool
* setps forward
* ongoing
* working version
* fix errors introduced by github merge
* changes suggested by Doru
* updates
* requested fixes
* reqested changes
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Initial implementation
* Support transposing inputs
* Revise unidirectional broadcasting and unknown dimensions
* Revise gemm
* Add testcase
* Rename some variables
* Update SharingWork.md
* Change from the use of Value* to Value
* Insert deallocation
* Initilize the output matrix and fix wrong computation
* Add end-to-end testcases
* Edit lowering tests
* Change attribute names
* Use emplace_push for SmallVector
* Use the new way of getting attributes
* Revise the use of attributes
* Check the bias's shape
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Infer shape for Unsqueeze
* Lower Unsqueeze
* Revise
* Turn off backend tests
* Compute tensorSize for static shape
* Compute tensorSize with unknown dims
* Edit tests
* Update the use of attributes
* Add e2e tests
* Use SmallVector
* Remove return
* Check whether the operand is ranked or not
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Initial lowering of KrnlSqrtOp
* Fix errors and add a testcase
* typos
* Add the MLIR example
* Restore doc/doc_check/CMakeLists.txt
* Clean the code
* Edit comments
* Remove redundant parts
* Chang the use of -> to .
* Add a test for f64
* Support ONNXSqrtOp
* Fix indentation
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* add attributes of Op into parameters
* fix rewrite rule for GemmOp with attributes
* use I64Attr instead of I32Attr and modify test cases for the changes in attributes
* add output name (prefixed with o_) to Op definition
* update shape inference for the new attributes
* Support Softplus and Softsign operations
* Add the default shape inference for the transposition operation.
* Fix conflict with master
* Fix conflict with master branch
* Add test for softplus and softsign in test/backend/test.py
* Re-enable Reciprocal tests.
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
* change the read-in of attribute, using variant
* Use backported variant.
* Reduce code duplication.
* 1. Make array attribute parsing more clear.
2. int -> int64_t.
* 1. Fix how array attributes are imported.
* 1. Fix clang-tidy warnings.
* 1. Nit: fix clang-tidy warnings.
* Fix MaxPool node construction.
* Fix call to MaxPool.
* Comment out backend tests that fail.
* Add path to variant submodule to enable include file detection.
* Allow unused argument to avoid special casing generator.
* Address attribute related e2e test failures for Hard sigmoid,Elu,LeakyRelu,Selu,Softmax
Co-authored-by: chentong319 <chentong@us.ibm.com>
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Rebase
* Use max normalization
* Handle axis
* Add tests
* Update SharingWork.md
* Remove redundant spaces
* Format code
* Rebase
* Change from the use of Value* to Value
* Add end-to-end tests
Co-authored-by: Tian Jin <tjingrant@gmail.com>
* Add broadcasting support for elementwise operations
* Remove MLIRDialect from MLIRWholeArchiveLibs
* Rewrite getLoopIVsForBroadcasting
* Compute dimensions for allocating result memory
* Compute dimensions for allocating result memory (revised)
* Use static dimension for element-wise operation testcases
* Add a test for addition with broadcasting
* Missed Traits.h when merging
* Revise
* Update SharedWork.md
* Broadcasting for variadic operations
* Edit comments
* Update SharedWork.md
* Reorganize the code
* Add CHECK-LABEL for test_add_with_broadcasting
* Add reshape op handling.
* Lower reshape to KRNL dialect.
* Add comments.
* Propagate reshape to KRNL IR.
* Lower KRNL reshape to affine and standard ops level dialects.
* Add lowering of reshape operation to Krnl and LLVM Dialects.
* Add test for LLVM IR dialect output for reshape.
* Fix rebase.
* Fix test variable.
* Emit errors during reshape shape inference. Address other reviewer comments.
* Lower ONNXSumOp
* Add inferShapes() and test cases
* Load the first operand to the result
* Update SharingWork.md
* Update SharingWork.md
* Update SharingWork.md
* Add support for Max, Min
* Pass operation instead of location to mapToLowerScalarOp
* Add support for Elu, Selu, LeakyRelu, HardSigmoid
* Add test cases
* Update SharingWork.md
* Rewrite the part of lowering variadic ops and use it for binary ops
* Use two diffenrent templates for Unary and Variadic Ops
* Revise the code
* Canonicalization pattern for eliminating identity ops
* Add a test for the identity elimination rule
* Remove frontend from test
* Use CHECK-NEXT instead of CHECK