Commit Graph

46 Commits

Author SHA1 Message Date
NathanielMcVicar 3491b90b1e
Support LLVM as of 7dcd0042 (#309)
* Update to support LLVM as of 7dcd0042

Fixes for upstream changes to mlir.

- New pass registration method from https://reviews.llvm.org/D85622
- Integer attributes are now C types when possible https://reviews.llvm.org/D86739

Signed-off-by: Nathaniel McVicar <namcvica@microsoft.com>

* Fix for checkclang

* Windows incremental build fix from @max-ku

* Remove MLIRShapeToSCF lib

* Missed a getSExtValue on now c type

* Rebuild prereq docker.

* Bump CircleCI cache version.

* Update hash for Windows build

Signed-off-by: Nathaniel McVicar <namcvica@microsoft.com>

* Bump CircieCI cache version again.

* Rebuild prereq docker.

* Update README.md

* Update README.md

* Undo edits to ONNXOps.td.inc.

* Undo changes to ONNXOps.td.inc.

* Fix cast op TableGen.

* Tweak tablegen definition of Cast.

* Use explicitly signed integer as attributes.

* Move all signless attribute to explicitly signed attribute.

* Import ONNX int attribute as SI64 attribute.

* Make Conv.group attr use SI64 attr.

* Fix conv test.

* Fix DocCheck complaint.

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-09-22 23:42:50 +07:00
chentong319 fa04c32a0c
ShapeInference for SizeOp (#299)
* add shape inference

* Revert "add shape inference"

This reverts commit f9d42f39e68e14b5648abccfc8617fff00244d16.

* shape inference

* test case

* format
2020-09-11 12:47:11 -05:00
Aman LaChapelle 24d0a2ac71
Add shape inference and names (#266)
* Add shape inference and names

 - Add shape inference for PRelu
 - Fix shape inference for group conv
   for ConvTranspose
 - Add input and output names for
   graphs (functions)
 - Add support for (u)int8 tensor
   attributes

* Fix format issues

* Revert formatting for gen_onnx_mlir.py

* Pads can have ArrayAttr and DenseElementsAttr so support both

* NumInputs is the number of graph inputs that don't have initializers

* Add test for 2D batchnorm

* Fix typo in define_loops in new 2d BN test

* Change 'name' to 'onnx_node_name'

* Fix Batchnorm for 2D I/O and add lowering test

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-08-27 15:46:27 -04:00
Anh Leu 00299910f3
OneHotEncoder Shape Inference (#265)
* move scalerop to decompose

* change clang format

* change clang format

* add shape inference for scaler op

* fixing generated onnxop

* generate onnx.md

* redo get onnx.md and onnxop.td.inc using onnx 1.6

* Add shape inference for scaler op

* add benefit for scaler decompose and simplify scaler shape inference

* add scaler decompose benefit num and simplify shape inference

* add cast builder

* cast rewrite only for float

* add cast op same type rewrite rule

* working on cast lowering

* cast lowering working

* add cast lowering

* fix format

* Delete OpBuildTable.inc

* complete requested changes

Co-authored-by: chentong319 <chentong@us.ibm.com>
2020-08-14 16:13:31 -04:00
albertomagni-ms e1386b0689
Add shape inference for Ops used by BERT (#249)
* Add shape inference for Ops used by BERT

* Erf
* Pow
* ReduceMean
* Dropout
* Expand
  https://github.com/onnx/onnx/blob/master/docs/Operators.md#expand
  Deduce the value of the shape operand by looking at the producer
  of the operand.
  Currently supported producers are: onnx.Constant and onnx.Shape.

* Add corresponding tests for each op.

* Sort the list of ops with shape inference in gen_onnx_mlir.py
in alphabetic order for clarity.

* Restart CI

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-08-07 13:08:00 +08:00
Anh Leu c9e3ba2d64
Add shape inference for ScalerOp (#228)
* move scalerop to decompose

* change clang format

* change clang format

* add shape inference for scaler op

* fixing generated onnxop

* generate onnx.md

* Add shape inference for scaler op

* add benefit for scaler decompose and simplify scaler shape inference
2020-07-23 13:05:19 -04:00
Tung D. Le 034f98c00c
Shape inference for some ops in RNN models (#207)
* Shape inference for ShapeOp

* Shape inference for TileOp

* Fix check-doc

* Fix onnx-mlir-doc

* Shape inference for GatherOp

* Check validity of GatherOp's indices tensor

* Shape inference for Slice

* Tests for SliceOp

* Fix importing none inputs

* Type inference for constantofshape

* Empty tensor in case of ConstantOfShape

* Remove unrelated changes

Co-authored-by: chentong319 <chentong@us.ibm.com>
2020-07-22 10:15:56 -04:00
Tung D. Le 2c8f5701bd
Lower SqueezeOp to Krnl dialect (#164)
* Lower Squeeze op to Krnl dialect

* Emit tensor size as a single constant; add a lit test for unknown dimensions

* Code style

* Speical case where the input is only used by this squeeze op

* Remove squeeze-in-place optimization

* Update ConvertONNXToKrnl.cpp

Twek to re-run tests.

* Trigger buildbot re-run.

* Re-run CI

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-07-03 16:26:41 +08:00
chentong319 2e08b2112c
String type (Ready for Review) (#182)
* string type from tensorflow

* simplify type

* parser and print

* gen StringType for tablegen

* onnx to onnx-mlir type

* add namespace

* allow all integer type

* dialect document

* add test case

* format

* more precise type for ONNXOp

* format

* enable the failed test

* update comment

* update onnx.md

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-06-25 16:34:37 -04:00
Alexandre Eichenberger 82d2caa542
constant folding for transpose of constant tensors (#171)
* added constant folding for transpose of constant tensors

* format

* responding to reviews
2020-06-17 10:42:06 -04:00
Aman LaChapelle ca185002f2
Add shape inference for several ops (#163)
* 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>
2020-06-09 14:55:49 +08:00
chentong319 23bea50404
Implement PadOp based on attribute promotion (#71)
* 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>
2020-05-15 13:19:28 +08:00
Tung D. Le 24343177b8
Lower LSTMOp to Krnl dialect (#73)
* 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>
2020-05-13 21:08:06 +08:00
Tung D. Le 9a874007ce
Implement shape inference for SplitOp (#95)
* 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>
2020-05-13 18:07:27 +08:00
Tung D. Le e32f531546
Add the split marker to test files (#90)
Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-04-16 15:17:27 +08:00
Alexandre Eichenberger fa8962753c
Concat lower (#82)
* 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>
2020-04-13 11:40:39 -04:00
Alexandre Eichenberger f5bed72e13
implement shape inference for concat (#74)
* implement shape inference for concat

* better checking of axis being concatenated: constant values only
2020-04-07 16:13:41 -04:00
Alexandre Eichenberger 653fa69102
Unify Conv implementation (#54)
* fixed readme for new git repo

* conv with bias as an optional input
2020-03-26 11:03:19 -04:00
Gheorghe-Teodor Bercea 1622b9f161
[NFC] Change ONNF based names to ONNX-MLIR (#32)
* Rename onnf to onnx-mlir.

* Change workspace name.
2020-03-17 09:16:33 -04:00
Tung D. Le d86591d61a
Import all initialized tensors as dense constants (#30)
* Import initialized tensor as dense attribute

* Import all initialize tensors as dense constants

* Remove unintentional code

* Fix value attribute format in shape inference tests of reshape

* Readd rank check for reshape's shape inference

* Remove a redundant variable

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-03-16 11:17:28 -04:00
Gheorghe-Teodor Bercea c46880d5c6
Fix reshape output shape inference when a single dynamic shape is given (#22)
* 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.
2020-03-13 17:18:46 -04:00
chentong319 6137fc7c17
Fix issues #15 and #16 (#29)
* fix issue #15 and #16

* fix format

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-03-13 10:19:27 -04:00
Tung D. Le 362491553c
Shape inference for ONNXAveragePool (#21)
* Shape inference for ONNXAveragePool

* Edit comments and puts helper function on top of the file

* Fix template
2020-03-13 09:59:16 -04:00
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
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
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
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
chentong c3041bfb43 shape inference for pad with constant pads 2020-02-13 19:56:05 -05:00
Tung D. Le f3047943a1
Handle 1-D MATMUL N-D (#56) 2020-01-29 10:35:05 -05:00
Gheorghe-Teodor Bercea 3f5c543782
Merge branch 'master' into matmul-shape 2020-01-27 11:37:40 -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
Doru Bercea 07d28769d3 Merge remote-tracking branch 'origin/master' into matmul-shape 2020-01-23 11:53:53 -05:00
Doru Bercea 7dda698e7e Add test with dilations and auto padding set to SAME_UPPER. 2020-01-22 16:40:33 -05:00
Doru Bercea 68efd21064 Fix dilation formula in the code. 2020-01-22 16:34:59 -05:00
Doru Bercea 050d7d277d Fix test. 2020-01-22 16:12:09 -05:00
Doru Bercea 0bc07ef661 Merge remote-tracking branch 'origin/master' into matmul-shape 2020-01-22 15:29:09 -05:00
Doru Bercea ea45cbcca9 Add support for dilations attribute and add tests. 2020-01-22 14:40:10 -05:00
Doru Bercea f0b484c0bc Add test for transpose with permutation. 2020-01-20 14:54:40 -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 642f77abed Add additional dynamic dimension. 2020-01-14 10:47:24 -05:00
Doru Bercea 95ebf3e23a Add test for multypling stacks of matrices. 2020-01-14 10:47:24 -05:00
Doru Bercea ae966cdee9 Add tests for matrices and stack of matrices combinations. 2020-01-14 10:47:24 -05:00
Doru Bercea a5f1d39c20 Add tests for matrices and stack of matrices combinations. 2020-01-14 10:47:24 -05:00
Doru Bercea 6478c88cdc Add test for all one dimensional case. 2020-01-14 10:47:24 -05:00
Doru Bercea 151f4f8c44 Add the default shape inference for the transposition operation. 2020-01-09 13:50:38 -05:00