Commit Graph

275 Commits

Author SHA1 Message Date
Tung D. Le a65820940c
Lower ConstantOp (#28)
* Lower ConstantOp

* Refactor the code

* Edit error messages

* Check whether attribute is sparse or dense during shape inference
2020-03-12 10:58:42 -04:00
Tung D. Le 162ac1bc32
Pad value for MaxPool must be negative infinity instead of zero (#20)
Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com>
2020-03-12 09:30:02 -04:00
Alexandre Eichenberger 811b63e031
Inter common pad (#26)
* common pad handling in shape inference for conv and maxpool

* common pads

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-03-11 18:36:02 -04:00
chentong319 391f565a66
Lower constant padding operation to KRNL dialect (#27) 2020-03-11 16:54:07 -04:00
Gheorghe-Teodor Bercea e8a0b47e10
Fix case for upper and lower padding when strides are present. (#11)
* Fix case for upper and lower padding when strides are present.

* Address comments.

* Code clean-up.

* Fix tests.
2020-03-10 16:58:05 -04:00
Gheorghe-Teodor Bercea fe3279e721
Initialize operation arguments with ONNX model constants (#8)
* Save current state.

* Include constant arguments in source.

* Emit constants for Reshape second argument.

* Clean-up code.

* Add changes to gen_doc.py file.

* Propagate constant tensor to Reshape second arg to infer shape.

* Update documentation.

* Eliminate constant tensor operations when lowering to KRNL dialect.

* Replace ConstantTensorOp with ConstantOp.

* Add comment to remove temporary Constant lowering code.

* Remove unused shape inference for Constant.

* Remove comment.

* Remove explicit constant elimination.

* Refactor code.
2020-03-10 14:46:35 -04:00
Gheorghe-Teodor Bercea ba02b90e0b
Enable inference for arbitrary number of instructions (#12)
* Fix shape inference.

* Remove comment.

* Remove worklist since it is not needed.
2020-03-10 14:16:03 -04:00
Tung D. Le 1882059ac9
Support Pads for MaxPoolSingleOut (#14)
* 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
2020-03-09 20:15:58 -04:00
Gheorghe-Teodor Bercea 8a992b619f
Create some helper functions to emit constant op for a specific type (#7)
* emitConstantOp with a given type

* Helper functions to create infinity constants

* Use new constant helper functions for MaxPoolSingleOut

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-03-05 14:21:00 -05:00
Gheorghe-Teodor Bercea 8e1b30e133
Check channel dimension mismatch only for known dimensions (#2)
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-03-04 14:34:08 -05:00
Gheorghe-Teodor Bercea e4c23da4fd
Lower MaxPoolSingleOutOp to Krnl dialect (#1)
* 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>
2020-03-04 14:27:21 -05:00
Tung D. Le e97df0b343
Add a pass to decompose ONNX operations (#9) 2020-03-04 10:53:59 -05:00
Tung D. Le 5357fc1421
Use SqrtOp in Standard dialect (#108)
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-02-26 12:03:24 -05:00
Tung D. Le 0c4a010283
Remove rank constraints in gemm fusion (#101)
* 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>
2020-02-26 11:40:52 -05:00
Tung D. Le 24d89625e3
Remove redundant lower_frontend_to_krnl since we reorganized it (#99)
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-02-26 16:32:06 +08:00
chentong 3abbf1c0e9 put the common code into a helper function 2020-02-25 17:43:49 -05:00
chentong 4079ee1f26 Merge remote-tracking branch 'upstream/master' into shapeinference-pad 2020-02-25 15:54:18 -05:00
Alexandre Eichenberger 3a88361b17
use input/output operation names, use helper for attribute function and int values (#106) 2020-02-25 15:46:11 -05:00
Alexandre Eichenberger 3b1c29c078
Using attribute setters for maxpool (#105)
* using attribute setters for maxpool

* fix typos, added handling of storage order, simplified code
2020-02-25 14:33:48 -05:00
Gheorghe-Teodor Bercea ee3e140ddb
[NFC] Change structure of conversion folder. (#96)
* Change structure of conversion folder.

* Fix comments.

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-02-25 10:38:08 -05:00
Gheorghe-Teodor Bercea 32f08bcf0c
Clean-up code. (#98) 2020-02-25 09:54:29 -05:00
Gheorghe-Teodor Bercea 0d307d1183
Set flag to true when definition is emitted. (#97) 2020-02-25 09:47:42 -05:00
Tung D. Le a720f9a7b2
Remove special GemmNoBias since we can handle it using NoneType bias (#100)
* Remove special GemmNoBias since we can handle it using NoneType bias

* Remove GemmNoBias from onnx.md

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-02-25 13:20:43 +08:00
Tian Jin 732317cd5a
Transition to ONNX-1.6.0. (#95)
* Transition to ONNX-1.6.0.

* Use the version of ONNX inside ONNF when running backend tests.

* Install quietly and with sudo previledge.
2020-02-25 13:04:15 +08:00
Alexandre Eichenberger fcb5f35993
Introduce helper class to generate KRNL code and apply it to Convolution (#93)
* helper to gen krnl code, applied to conv

* suggested changes, name, removed set insertion point

* format

* suggested changes

* added comments and made a small name change
2020-02-24 17:20:15 -05:00
Tian Jin 9c398c0121
Support Optional Inputs (#94)
* 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.
2020-02-24 23:46:48 +08:00
chentong b3df3c64b5 Merge branch 'master' of github.com:clang-ykt/ONNF into shapeinference-pad 2020-02-24 09:26:45 -05:00
chentong 2281cc060f Merge branch 'master' of github.com:clang-ykt/ONNF into shapeinference-pad
Conflicts:
	src/pass/shape_inference_pass.cpp
2020-02-21 09:30:40 -05:00
Tung D. Le 479dd5e35a
Add result type inference to op definition (#87)
* Add result type inference to op definition

* Edit MLIR tests

* Fix result type for Mul

* Format comments

* Return UnrankedTensorType as result type

* Just for testing -split-input-file

* Undo: Just for testing -split-input-file

* Extract a function, get_operand_ins, that gets operand types; rewrite gen_attr_ins function

* Generate custom builders

* Call existing build methods

* Add comments

* Minor changes

* Generate build methods with attributes

* Add support of variadic type

* Do not generate custom build methods for ops having only attributes

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-02-21 22:28:24 +08:00
Tung D. Le aea6479ad3
Lower BatchNormalization (test mode) to Krnl dialect (#70)
* 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>
2020-02-20 11:45:40 -05:00
Tung D. Le f1d20e368f
Add support of GemmNoBias (#91)
* Add support of GemmNoBias

* Fix a wrong indentation
2020-02-20 10:55:24 -05:00
Tung D. Le a3f042220e
Get MemRefType for result types (#69)
* Get memreftype for result types

* Revise

* Replace convertToMemRefType

* Use convertToMemRefType in ONNXConvNoBiasOpLowering

* Merge with the master branch

* Reverse an unintentional change

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-02-20 21:44:01 +08:00
Gheorghe-Teodor Bercea b28c6906b4
Fix building ONNF with latest LLVM/MLIR (#89)
* Fix build and link errors.

* Fix end to end tests.

* Fix indentation.

* Fix type conversion.

* Use newest LLVM version.

* Use newest LLVM version.
2020-02-19 18:15:02 -05:00
Gheorghe-Teodor Bercea da037ffc7d
Merge branch 'master' into shapeinference-pad 2020-02-19 13:46:00 -05:00
Tung D. Le b9f2f25b56
[NFC] Categorize ONNX ops lowering (#80)
* Create two categories: elementwise and tensor

* typos

* Create directories for categories

* Edit comments

* Extract a function that creates a KrnlIterateOp

* Add comments

* Extract some common parts

* Revise softmax

* Add reduction.inc

* Move lower-frontend to lib/conversion

* Move  directory to  directory

* Change file/directory names

* Comment format

* Add matmul.inc
2020-02-19 15:17:48 +08:00
chentong ec43fadc3b Merge remote-tracking branch 'upstream/master' into shapeinference-pad 2020-02-17 08:27:43 -05:00
Gheorghe-Teodor Bercea 3c505ae31d
Split convolution into explicit padding and unpaded convolution. (#82)
* Split convolution into explicit padding and unpaded convolution.

* Refactor code. Add test.
2020-02-14 16:06:38 -05:00
chentong bbdf4e3b4d Merge remote-tracking branch 'upstream/master' into shapeinference-pad
Conflicts:
	test/mlir/onnx/onnx_shape_inference.mlir
2020-02-14 15:35:47 -05:00
Gheorghe-Teodor Bercea 17d84901b7
Allow 1-D convolutions. (#86)
* Fix check.

* Fix comment.
2020-02-14 10:54:08 -05:00
Tung D. Le b521719587
Lower Matmul operation to Krnl dialect (#57)
* 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>
2020-02-14 10:43:17 -05:00
chentong c3041bfb43 shape inference for pad with constant pads 2020-02-13 19:56:05 -05:00
Tian Jin 937bbec265
Fix scalar entry point parameter lowering issue. (#78)
* 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>
2020-02-13 13:50:05 +08:00
chentong319 49dae74eab
Create constant pad (#75)
* 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
2020-02-11 15:32:01 -05:00
Gheorghe-Teodor Bercea 094be4f37a
Add support for strides when emitting convolution loop nest. (#76)
* Add support for strides when emitting convolution loop nest.

* Only emit stride multiplication if strides is greater than one.

* Add test.
2020-02-11 11:53:13 -05:00
Tung D. Le adad9e24bd
Add support of negative dimensions (#66)
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-02-11 10:37:47 -05:00
Tian Jin 181803ebf4
Using Tablegen to Generate Op Documentation (#74)
* Add dialect documentation.

* Add a step in our CI to ensure documentation is up-to-date.

* Add dialect documentation.

* Fix config file mistake, using multi-line commands.

* Fix a bug in DocCheck.
2020-02-10 14:18:54 -05:00
Tung D. Le 2c7046ff5f
Lowering ReductionMax, ReductionMin, ReductionProd and ReductionSum (#31)
* 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
2020-02-10 21:38:19 +08:00
Gheorghe-Teodor Bercea 0272451521
Lower convolution to KRNL dialect. (#65)
* 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.
2020-02-07 16:51:32 -05:00
Tung D. Le 0564c0eaef
Add constraints for matmul-add fusion (#67)
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-02-07 13:51:44 -05:00
Tung D. Le 0bfb660d02
Import 2-argument Gemm as GemmNoBias (#68)
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-02-07 13:45:37 -05:00
chentong319 60ac8f081f
Op def output (#73)
* fix name of operator output in onnxop.inc and Operator.md

* remove Operators.md
2020-02-08 00:10:35 +08:00
Gheorghe-Teodor Bercea ae297f14ee
Revert "fix name of operator output in onnxop.inc and Operator.md (#62)" (#72)
This reverts commit c45655413d.
2020-02-06 10:52:57 -05:00
chentong319 c45655413d
fix name of operator output in onnxop.inc and Operator.md (#62)
* fix name of operator output in onnxop.inc and Operator.md

* Update directive.py

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-02-06 20:54:03 +08:00
Haruki Imai 477227a0ec
Added lowering of SignOp (#21)
* 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
2020-02-04 22:27:17 +08:00
Gheorghe-Teodor Bercea 87aa72764f
Fix dependencies for onnf-opt (#51)
* Ensure onnf-opt is being rebuilt.

* Remove additional dependencies.
2020-01-31 10:51:43 -05:00
Tung D. Le 2b56c09454
Rewrite ReduceL1, ReduceL2, ReduceLogSum, ReduceLogSumExp, ReduceSumSquare in the ONNX dialect (#38)
* 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>
2020-01-31 19:00:39 +08:00
Alexandre Eichenberger 0d77840969
Inference maxpool (#48)
* 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>
2020-01-30 14:30:28 -05:00
Gheorghe-Teodor Bercea 9fb826ae7e
Lower transpose operation to KRNL dialect (#54)
* Lower transpose operation.

* Fix IndetityOp.

* Add tests.

* Add backend tests.

* Clean-up code.

* Move transpose code and improve comment.
2020-01-30 11:44:56 -05:00
chentong319 6959cf4586
clean up gen_doc.py (#59)
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-01-29 13:54:46 -05:00
Tung D. Le 400676e371
Lowering Gemm (#19)
* 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>
2020-01-29 11:11:49 -05:00
Tung D. Le 9e82d388f0
Add support for Unsqueeze (#50)
* 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>
2020-01-29 10:46:02 -05:00
Tung D. Le 5b44169aaa
Support dimension zero in reshape (#55)
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-01-29 10:41:09 -05:00
Tung D. Le f3047943a1
Handle 1-D MATMUL N-D (#56) 2020-01-29 10:35:05 -05:00
Tung D. Le 195bf9d15d Add KrnlSqrtOp (#22)
* 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>
2020-01-28 11:10:47 -05:00
Gheorghe-Teodor Bercea f00206cecf
Fix reshape op. (#53) 2020-01-28 10:21:08 -05:00
Tung D. Le 7c889548a7 Allow importing variadic inputs/outputs of onnx operators (#16)
* Allow importing variadic inputs/outputs of onnx operators

* Enable testcases for variadic ops

* Modify gen_doc.py
2020-01-28 21:48:11 +08:00
Doru Bercea b450a763d1 Change variable names to use rank. Add aditional check for scalars. 2020-01-27 12:08:23 -05:00
Gheorghe-Teodor Bercea 3f5c543782
Merge branch 'master' into matmul-shape 2020-01-27 11:37:40 -05:00
Gheorghe-Teodor Bercea 95cf939c5c
Fix end-to-end tests. (#52)
* Fix end-to-end tests.

* Use dyn_cast.
2020-01-27 11:35:45 -05:00
chentong319 c74f814f64 Add attributes as operation parameters (#45)
* 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
2020-01-27 10:09:14 -05:00
Gheorghe-Teodor Bercea 696da50d2a
Merge branch 'master' into matmul-shape 2020-01-24 15:53:02 -05:00
Yasushi Negishi 383a5c31ac Support Softplus and Softsign operations (#17)
* 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>
2020-01-23 21:18:38 -07:00
Doru Bercea 07d28769d3 Merge remote-tracking branch 'origin/master' into matmul-shape 2020-01-23 11:53:53 -05:00
Doru Bercea 68efd21064 Fix dilation formula in the code. 2020-01-22 16:34:59 -05:00
Doru Bercea 1784ec2314 Fix reference error. 2020-01-22 16:09:19 -05:00
Doru Bercea 0bc07ef661 Merge remote-tracking branch 'origin/master' into matmul-shape 2020-01-22 15:29:09 -05:00
Doru Bercea 94391a3cde Add comment. 2020-01-22 15:05:56 -05:00
Doru Bercea ea45cbcca9 Add support for dilations attribute and add tests. 2020-01-22 14:40:10 -05:00
Doru Bercea de77758faf Fix kernel dimensions. 2020-01-22 10:11:36 -05:00
Doru Bercea 169236a8fc Handle SAME_LOWER and SAME_UPPER. 2020-01-22 10:11:36 -05:00
Doru Bercea ec9e023f04 Add shape inference method. 2020-01-22 10:11:36 -05:00
Doru Bercea 3fe0f2e735 Fix operand type access. 2020-01-22 10:11:36 -05:00
Doru Bercea ab8e2f9a1b Add verifier to check for required attributes. 2020-01-22 10:11:34 -05:00
Tian Jin 51b0f4c9dd
Chentong319 attribute with variant (#25)
* 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>
2020-01-21 19:36:21 -07:00
Tian Jin 0231bb83a2
Properly link with ZLIB. (#40) 2020-01-21 11:08:16 -05:00
Tung D. Le e89e51699b Lowering softmax (#14)
* 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>
2020-01-20 21:57:32 -05:00
Doru Bercea 6b55bb43c7 Fix operand type access. 2020-01-20 15:48:16 -05:00
Doru Bercea bd44d8402e Add verifier function for checking negative perms. 2020-01-20 14:54:40 -05:00
Doru Bercea 9d1078540d Transpose using perm attribute. 2020-01-20 14:54:40 -05:00
Tian Jin 8665ecd998
Enable e2e tests (#29)
* Sync with latest MLIR.

* Enable ONNX backend tests as a means to test ONNF lowering end-to-end.

* Install ONNX using quiet mode.

* Remove debug comments.

* Install ONNX from third_party/onnx.

* Check python version and fix pip command for installing ONNX.

* Using --user install option to prevent permission denied.

* Remove unused imports.

* Try using stock ONNX pip package as there are more tests in them.

* Pip got stuck building wheels, try sudo.

* Use verbose install to debug.

* Invalidate cache to build LLVM tools.

* Fix mlir installation script location.

* Debug to locate ONNF.

* Sanity check.

* Check out ONNF code first.

* Use verbose LIT output.

* 1. Update documentation to always use verbose LIT.
2. Update krnl ops to reflect new affine map attribute syntax.

* See if conda exists

* Install ONNX by manually cloning the repo.

* Install cmake first.

* Using sudo priviledge when installing.

* Limit build parallelism.

* Limit parallelism.

* Larger memory.

* Install onnx package with pip.

* Build MLIR tools.

* Invalidate cache.

* Compile model.so with -fPIC.

* Remove module dump to get concise debug output.

* Print command before executing.

* Use quiet install mode to reduce logging.

* Use -relocation-model=pic to generate position independent code.

* 1. Remove MAKEFLAGS because now buildbot has enough memory.
2. Run DocCheck as a last step.

* 1. Add verbose mode for backtend test.

* When dumping to LLVM bitcode, do not dump module IR, but print a message indicating that bitcode has been written to disk.

* Do not pass MakeFlags to CMake.

* Add more explaination for posible reasons of failing to identify tests.
2020-01-20 12:30:08 -05:00
Gheorghe-Teodor Bercea a87f01747a
Merge branch 'master' into matmul-shape 2020-01-15 18:03:03 -05:00
Gheorghe-Teodor Bercea d895670656
Merge branch 'master' into fix-conv 2020-01-15 17:56:57 -05:00
Gheorghe-Teodor Bercea deb7a7c4bb
Merge branch 'master' into matmul-shape 2020-01-15 17:51:13 -05:00
Gheorghe-Teodor Bercea 969459ddcb
Merge branch 'master' into fix-conv 2020-01-15 17:50:36 -05:00
Gheorghe-Teodor Bercea 514cbcb1dc
Merge branch 'master' into fix-gemm 2020-01-15 17:50:15 -05:00
Doru Bercea a1b44905e2 Add documentation for handling optional arguments. 2020-01-15 17:06:14 -05:00
Doru Bercea 3f6efdf4a4 Fix MaxPool translation to ONNX dialect. 2020-01-15 15:16:45 -05:00
Doru Bercea d2a90e2923 Remove references to FullGemm. 2020-01-15 14:27:21 -05:00
Doru Bercea a42fdd08f3 Fix Gemm translation to ONNX dialect. 2020-01-15 14:11:32 -05:00
Doru Bercea 67ec9e9009 Fix convolution translation to MLIR. 2020-01-15 13:26:50 -05:00
Doru Bercea fc352745e0 Make last argument of conv variadic. 2020-01-14 11:17:52 -05:00
Doru Bercea 36475ac509 Code clean-up. 2020-01-14 10:47:24 -05:00
Doru Bercea e091825896 Add check for matrix size match for 1 and 2 dimenisional cases. 2020-01-14 10:47:24 -05:00
Doru Bercea da0e9b01b1 Fix 1 and 2 dimensional cases. Add test for 1 and 2 dimensional combinations. 2020-01-14 10:47:24 -05:00
Doru Bercea 96551ef71e Fix conditions. 2020-01-14 10:47:24 -05:00
Doru Bercea a3995b61e7 Add support for shape broadcast. 2020-01-14 10:47:24 -05:00
Doru Bercea 38bffee619 Add support for broadcasting left matrix. 2020-01-14 10:47:24 -05:00
Doru Bercea d176b84506 Add support for broadcasting right matrix. 2020-01-14 10:47:24 -05:00
Doru Bercea 170296b7c6 Add special case for 1-D matrix multiplication. 2020-01-14 10:47:22 -05:00
Tian Jin 22a6bdc574
Sync with latest MLIR. (#26) 2020-01-13 12:21:29 -05:00
Doru Bercea 151f4f8c44 Add the default shape inference for the transposition operation. 2020-01-09 13:50:38 -05:00
Tung D. Le edcd506dde
Merge branch 'master' into tanh_cos_log 2020-01-08 13:39:24 +09:00
Tung D. Le 3d4ad52011 Rewrite tanh using TanhOp, add log, cos 2020-01-08 12:11:21 +09:00
Tung D. Le becb2add4a Do not get float attributes with fixed precision 2020-01-07 17:39:34 +09:00
Tian Jin 0582846864 Transition to value-typed Value, rename Value* -> Value, in accordance with upstream MLIR style change. 2019-12-30 22:42:13 -05:00
Tian Jin eadf33d816 explicit ordering among operands 2019-12-24 03:36:33 -05:00
Tian Jin 4eb95b2373 fix onnf build 2019-12-24 03:00:54 -05:00
Tian Jin 58c2f6de00 fix link 2019-12-24 02:46:14 -05:00
Tian Jin c55020f6b6 fix build script 2019-12-24 02:29:28 -05:00
Tian Jin 1188b765c9 comment out test tanh 2019-12-24 02:19:46 -05:00
Tian Jin 95de5b7ac9 revert changes to lower-to-krnl 2019-12-24 02:07:21 -05:00
Tian Jin 8815f12ad0 final -> override 2019-12-24 01:09:54 -05:00
Tian Jin 50ea6bed03 fix build 2019-12-23 02:09:11 -05:00
Tian Jin 238c937f1b rewrite cli description 2019-12-23 01:14:35 -05:00
Tian Jin 0c41a204e4 fix include path 2019-12-23 00:22:11 -05:00
Tian Jin da4527c961 flatten src directory structure 2019-12-23 00:13:52 -05:00
Tian Jin 82d513096e a commandline interface for onnf 2019-12-22 23:52:49 -05:00
Tian Jin 911cc2ad92
Merge pull request #1 from doru1004/remove-boost
clean up, remove dependency for boost
2019-12-22 23:15:46 -05:00
Tian Jin 685bf23b40 Enable ONNX Backend Test (#1)
* wip, commit before merging with upstream

* organize API, return wrapped output

* enable onnx backend test

* undo unintentional commit

* fix krnl ops tablegen

* format krnl ops

* reorder fillDynMemRefWithMemRef to be after fillPtrToMemRefWithDynMemRef, better comments

* more onnx backend tests

* ensure that test names refer to existing tests

* improve code readability by shortening type names

* nit

* restore unintentional changes

* more nits

* fix ; -> :

* split runtime implementation into header and body file, add support for data types

* comment on the onnx backend test

* make the comments read better

* do not dump when lowering
2019-12-22 23:14:57 -05:00
Tian Jin 2cb054324d clean up, remove dependency for boost 2019-12-22 20:49:29 -05:00
Tian Jin 5573cb39fe clean up, remove dependency for boost 2019-12-22 20:33:33 -05:00
Tian Jin a6a40cf989 Format Key Files using LLVM Style (#403)
* format using llvm style

* merge and format
2019-12-21 02:11:49 -05:00
TUNG LEDUC 06a968d4a1 [MLIR] Add broadcasting support for element wise operations (#398)
* 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
2019-12-21 02:08:27 -05:00
GHEORGHE-TEOD BERCEA 0a8af69e94 Add inference for Identity operation. (#400) 2019-12-21 02:08:13 -05:00
Haruki Imai 7e3f96e642 [MLIR] Add support for Reciprocal (#397)
* Added support for Reciprocal

* Fixed format
2019-12-21 02:07:44 -05:00
Tian Jin 3e7b8465e9 clean up 2019-12-21 02:07:24 -05:00
GHEORGHE-TEOD BERCEA e81a7654f9 [MLIR] Add support for reshape (#390)
* 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.
2019-12-21 02:06:14 -05:00
TUNG LEDUC 5ed79083d5 [MLIR] Add support for Max, Min, Sum, Elu, Selu, LeakyRelu, HardSigmoid (#395)
* 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
2019-12-21 02:02:09 -05:00
TONG CHEN c8d591fb28 [MLIR] import attribute of onnx node (#383)
* add attributes as NamedAttribute

* support list value for attribute

* use std::tie to avoid c++17 feature
2019-12-21 02:00:58 -05:00
TUNG LEDUC 45608282e0 [MLIR] Add support for Relu (#392)
* Add support for Relu

* Add comments
2019-12-21 01:38:16 -05:00
Tian Jin 82f5bfec9f Update lower_frontend_to_krnl.cpp (#391) 2019-12-21 01:37:50 -05:00
TUNG LEDUC 1c3176bf9f [MLIR] Lower ONNX element-wise unary ops: Exp, Tanh, Sinh, Cosh, Sigmoid (#389)
* Lower ExpOp

* Lower ONNXTanhOp

* Lower Exp Tanh, Sinh, and Cosh

* Lower ONNX Sigmoid op

* Merge

* Specialize template lowerScalarOp

* Unify ONNXEWUnaryOpLowering and ONNXEWBinaryOpLowering

* Support multiple types

* Reformat the code

* Add test cases

* Reformat the code

* Change names

* Apply clang-format

* Update variable names
2019-12-21 01:37:29 -05:00
TUNG LEDUC c3ef1d93ae [MLIR] Lower ONNX element-wise binary ops: Mul, Div, Sub, And, Or, Xor (#388)
* Lower ONNX element-wise binary ops: Mul, Div, Sub, And, Or, Xor

* Edit gen_doc.py to avoid changes about AnyTypeOf<[AnyMemRef, AnyTensor]>

* Miss a space

* Add tests

* Shorten ONNXElementWiseBinaryOpLowering into ONNXEWBinaryOpLowering

* Move lowering patterns into runOnModule()

* Redundant space
2019-12-21 01:35:31 -05:00
TUNG LEDUC 05e16dafae Use template to support lowering all binary onnx ops to kernel ir (#387) 2019-12-21 01:35:17 -05:00
GHEORGHE-TEOD BERCEA 7fb2f80dce [MLIR] Add support for dealloc insertion (#386)
* Add support for dealloc op.

* Check dealloc for returned result not present.
2019-12-21 01:34:48 -05:00
Tian Jin b2a1103915 [MLIR] Refactor Krnl Dialect and Krnl Dialect Lowering (#375)
* Store bounds as affine map attributes & check in test cases with generic printer

* Upgrading MLIR

MLIR is outdated on Buildbot, rebuilding a newer version.

* work with new version of mlir

* check-in parser tests

* custom printer

* nit

* bug fix

* enable custom asm printer test

* enable custom asm printer test

* more consistent variable naming

* test max/min

* variable naming scheme change to MLIR style

* can lower krnl to llvm

* kernel -> llvm

* comments

* bug fix

* try fixing ci

* fix ci

* deactivate model test

* fix lit test

* nit

* fix z buildbot
2019-12-21 01:34:14 -05:00
GHEORGHE-TEOD BERCEA 652ce4b7d4 Add test for checking lowering of Add op to KRNL IR (#385)
* Add test for checking lowering of Add op to KRNL IR.

* Add test file.
2019-12-21 01:20:36 -05:00
Tian Jin b46f965715 clean up 2019-12-21 01:13:50 -05:00
GHEORGHE-TEOD BERCEA b02652dd76 [MLIR] Lowering of frontend dialect to KRNL dialect (#382)
* Partial support for lowering operations to KRNL dialect.

* Attempt to lower to KRNL IR.

* Update file.

* Add lowering.

* Address comments. Fix alloc dynamic dimensions. Correctly link StandardOps.

* Temporarily remove deallocation of locally allocated tensors.
2019-12-21 01:11:14 -05:00
Tian Jin 8ea7e34a60 clean up 2019-12-21 00:51:05 -05:00