* Reorganize main function.
* Follow review comments.
* Emit constants are globals in Krnl and LLVM dialects.
* Replace internal malloc with memory pool and getref instruction.
* Lower krnl.getref to LLVM.
* Fix formatting issues.
* Add tests.
* Add missing dependency.
* Improve LLVM lowering.
* Add test to show getref is generic.
* 1. Add shape inference for the following ops:
- Atan
- Tan
- Sin
- Cast
- ConvTranspose
- Flatten
- DynamicQuantizeLinear
- QuantizeLinear
- DequantizeLinear
- ConvInteger
2. Import attributes for generic nodes
3. Fixes for cases where .cast<> should be .isa<> (ONNXConcat::inferShapes)
* Fix foormatting issues
* Address comments:
- SmallVector<> * -> SmallVectorImpl<> &
- switch-case -> helper function
- Inside helper function, preserve signed-ness
- add TODOs
* Can't use signed integers yet in convertONNXTypeToMLIRType, add TODO
Co-authored-by: Tian Jin <tjingrant@gmail.com>
* initial const prop attempt
* added support for broadcast ops
* adde all binary broadcast ops into custom builders with precise type
* added test example
* working
* format
* fixed suggestion by Tung, start woring on unary
* added subtraction and neg the right way, and added elementwise mul too
* formatting changes
* format
* format
* added instructions to add new optimizations
* Call llc, ld from within onnx-mlir.
* Rename EmitLLVMBC -> EmitLib., reorder header files
* Edit comment.
* Checkpoint, debug.py works.
* Automatically generate inputs in debug.py.
* Use float.
* initial support for rapidcheck tests.
* Convolution test case works.
* Format code.
* Link library with MainUtils.
* Fix CMake script error.
* Fast implementation of array assertion, more detailed error analysis.
* More utility for DynMemRef.
* Fix linking issue.
* Uncomment unit test.
* Refactor to separate C++/Python ExecutionSession, enable unit test.
* format code.
* Verbose build.
* Enable PIC option for ExecusionSession.
* Fix cmake error.
* Build all targets.
* Fix doc to build all targets.
* Clean up.
* Clean up, debug.
* Use type alias consistently.
* Move definitions to DynMemRef.cpp.
* include algorithm.
* pyruntime -> PyRuntime
* Format code.
* Free memory.
* Add comments.
* Copyright notice.
* Improve stylistic consistency.
* Add comment.
* Revert irrelevant changes.
* Disambiguate.
* Refator test case generator out from test case implementation, implement example exhaustive test driver.
* Add documentation for testing.
* 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>
* Specify in linking stage, where runtime shared library is located.
* Cite & make comment a full sentence.
* Fix error communicating runtime dir to ld.
* 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.
* Fix preloading of runtime shared library for backend tests.
* Update library name.
* Only add libstdc++ library if it exists.
* Make onnx-mlir work with latest mlir.
* Bump CircleCI cache version.
* Fix missing passes in onnx-mlir-opt.
* Fix backend test failure.
* Fix doc.
* Fix doc and exclude the generated _site directory from DocCheck.
* Remove debug code.
* Do not hard code target name, on Mac shared lib can end with .dylib.
* FunctionPass -> PassWrapper.
* 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.
* Move to more recent LLVM commit ID
* Update LLVM cache version from V9 to V10
* Update to latest LLVM commit id from master, roll back conditions in util scripts
* Update circlci LLVM cache tag to ensure ci updates builds with latest LLVM commit id
* Update README.md to have matching LLVM commit id
* Update doc/Dialtects/onnx.md
* Enable onnx-mlir for VS builds on Windows
* Update README to include lit
* Update build command for Windows to include config
* Update build instructions, add cmd files for windows, enable single source of truth for MLIR commit-id (clone-mlir.sh)
* Add Visual Studio workload info
* Update ONNX op definitions
* Revert onnx submodule back to previous commit, disable warnings in CMakeLists to work around build issues with MSVC
* Update environment for path to PDcurses on Windows
* Fix directory strings to be compatible with Windows or Linux style slashes
* Fix install-mlir.sh so it works when sourced
* Ensure README and cmd files match and have correct paths
* Properly quote ONNX_MLIR_SRC_DIR
* Address PR feedback: Use llvm_unreachable to indicate failure to convert attribute proto to name/value pair
Co-authored-by: Tian Jin <tjingrant@gmail.com>
* 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>
* Specify each lib only once; allow llvm build in shared libs mode.
* Remove debug code.
* For library targets, retain dependency information using add_dependencies, but do not link using taget_link_libraries.
* Do not set LD_PRELOAD by default.
Co-authored-by: Gong Su <gongsu@us.ibm.com>
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@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>
* Bug fix, ensure krnl.iterate can lower in the degenerate case.
* Fix parser issue with degenerate iterate op.
* Add a test case.
* Remove dead code.
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
* Support attribute promotion.
* Simplify op interface name.
* 1. Add more comments to Attribute Promotion Pass.
2. Move Promotable Const Operand Interface to src/interface, and link against it.
* Complete NFC change onnx -> onnx-mlir.
* Move attribute_promotion pass to src/transform.
* Nit: reword comment.
* Support Attribute Promotion in gen_doc.py.
* Add test.
* Update ONNX doc.
* Add negative test.
* Rename onnxop.inc -> onnx_ops.td.inc.
* Include onnx_ops.td.inc.
* Nit: better comments.
* Prettify CMake.
* Remove original attribute_promotion code, improve comments.
* Append '_op_interface' to op interface decl/defs.
* Namespace cmake targets using onnx_mlir_ prefix.
* Use updated header name.
* Use new body file name.
* Fix dependency.
* Use new CMake target name.
* Make attribute promotion self-contained by removing redundant constant operaions inside the pass execution.
* Remove canonicalization pass.
* Increase comments.
* Use stricter checks.
* Add one more test case.
* Remove %arg1 as it's never used.
* 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>
* Fix scalar entry point parameter lowering issue.
* Enable scalar bias test.
* Nit. Improve comments and remove debug code.
* Make helper function static, move to upfront position.
* Move helper function to top of the file.
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@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>