Commit Graph

294 Commits

Author SHA1 Message Date
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
TUNG LEDUC 53ab014a1d [MLIR] Canonicalization pattern for eliminating identity ops (#377)
* Canonicalization pattern for eliminating identity ops

* Add a test for the identity elimination rule

* Remove frontend from test

* Use CHECK-NEXT instead of CHECK
2019-12-21 00:47:22 -05:00
GHEORGHE-TEOD BERCEA bee32e2041 Fix rebase errors. (#378) 2019-12-21 00:46:29 -05:00
Tian Jin 6c7ff180f9 Update type parser (#376) 2019-12-21 00:43:33 -05:00
TUNG LEDUC 0c36057404 [MLIR] Add a constraint for the rewriting rule of add_matmult to fullgemm (#374)
* Add a constraint for the rewriting rule of matmul_add to fullgemm

* Edit comments
2019-12-21 00:42:19 -05:00
Tian Jin 701c7d7508 clean up 2019-12-21 00:41:40 -05:00
TONG CHEN 3f68c5420d [MLIR] generate op from onnx document (#366)
* generate op from onnx document

* Restore FullGemm

* update the op attribute for shape inference and canonicalizer

* Update onnx_canonicalization.mlir
2019-12-21 00:40:40 -05:00
Tian Jin d01ac7732f [MLIR] compartmentalize build script (#369)
* compartmentalize build script, temporarily remove dependency of onnf_opt on helper.cpp

* fix test includes

* fix op directory include

* compiler -> op

* compiler test depends on boost system

* fix function name

* specify libcompiler dependencies

* let cmake take care of transitive dependencies

* remove unnecessary includes

* use ONNF_SRC_ROOT and ONNF_BIN_ROOT

* allow whole-archive linked libraries to be appended

* [MLIR] Support filecheck (#371)

* support lit+FileCheck

* add lit into build script

* format MLIR.cmake

* format cmake

* [MLIR] Remove input/output ops (#372)

* remove input/output ops

* get output tensor type from symbol table
2019-12-21 00:34:51 -05:00
GHEORGHE-TEOD BERCEA dc36fd416b [MLIR] Fix shape inference and enable ONNF to read in MLIR files. (#367)
* Fix inference. Enable ONNF to read in MLIR files.

* Fix input of onnx or mlir models.

* Address comments.
2019-12-21 00:12:27 -05:00
TUNG LEDUC 0d644fab92 [MLIR] Legalize output tensors' names (#368)
* [MLIR] legalize output tensor's name

* Update frontend_dialect_transformer.cpp
2019-12-21 00:08:02 -05:00
GHEORGHE-TEOD BERCEA 63596e723f [MLIR] Add optimization based on TableGen pattern (#363)
* Define pattern.

* Fix file names.

* Add canonicalizer optimization based on TableGen pattern.

* Remove custom builders.

* Enable canonicalization in ONNF and ONNF-OPT.
2019-12-21 00:04:51 -05:00
Tian Jin 780e6f0aa0 [MLIR] Krnl Dialect Definition (#357)
* a complete, roud-trippable Krnl dialect operation definition

* remove old dialect definition files, edit build files

* register dialect

* check in src for onnf_opt and dimension handler types

* re-trigger jenkins

* fix build

* clarify operation semantics

* add verifier for krnl.iterate

* refactor to make things clear

* do not hard code types

* nit and add comments

* fix rebase

* update op implementation

* fix merge

* update kernel dialect definition

* more comment on how to use the builder for krnl.iterate operation

* ammend the comment

* can parse krnl.iterate

* can parse and print if bounds are not SSA values

* address comments

* better error handling

* Update CMakeLists.txt

* update comment

* reflow comments
2019-12-20 11:37:09 -05:00
GHEORGHE-TEOD BERCEA 03be41f7df [MLIR] Add shape inference pass (#361)
* Add shape inference pass.

* Format code.

* Enable shape inference pass.

* Rename new files to use ONNF convention.

* Use include path from src folder.

* Replace guards with pragma once.

* Format variable names. Shuffle headers.

* Fix comment.

* Fix comments.
2019-12-19 20:14:07 -05:00
Doru Bercea a6cca3cbb7 Code clean-up. 2019-12-19 19:51:01 -05:00
GHEORGHE-TEOD BERCEA a9960f6e44 [MLIR] Add conversion to MLIR types. (#360)
* Add conversion of tensor proto types to MLIR types.

* Fix integer type conversion. Use new type conversion for ouput type.
2019-12-19 19:48:31 -05:00
Doru Bercea 626552f4a0 Remove files. 2019-12-19 19:35:19 -05:00
Tian Jin 02e1e8720f [MLIR] Add onnf-opt Support (#359)
* support onnf-opt, register standard dialect

* use onnf native assertions

* fix build

* nit
2019-12-19 19:31:48 -05:00
GHEORGHE-TEOD BERCEA 958a2fbffc ONNX Dialect creation and registration with MLIR (#358)
* Create and register ONNX Dialect with one Add operation.

* Fix file formatting.

* Change name from ONNX to SGIR.

* Use ONNX dialect. Change SGIR to frontend placeholder dialect.

* Add comments.

* Type clean-up.
2019-12-19 16:56:30 -05:00
GHEORGHE-TEOD BERCEA 45a5a8499c Fix MLIR-enabled build. (#354)
* Add new build paths. Add Ranker or Unracked tensor types.

* Remove path to LLVM root folder, it is not needed anymore.

* Code clean-up.

* Clean-up code.

* update LLVM_PROJECT_SRC

* Update p9.sh

* Update MLIR.cmake
2019-12-19 16:16:06 -05:00
Tian Jin 00aee2e0b6 Use TableGen (#347)
* use table gen

* fix name of the dialect

* add old compilation path

* add some doc

* fix bug, sgir importer imports every op twice

* knl.visit -> knl.iterate
2019-12-19 15:18:35 -05:00
Tian Jin cc39a92802 fix code format (#348) 2019-12-19 14:53:18 -05:00
Doru Bercea e1f6ae1336 Fix name legalization. 2019-12-19 14:46:18 -05:00
TONG CHEN 50ac6e7bce emit SGIR based on onnx model, following the toy/Ch2 example (#345)
* emit SGIR based on onnx model, following the toy/Ch2 example

* fix 1) code style 2) multiple output of a node

* Update sgir.cpp
2019-12-19 14:37:20 -05:00
Doru Bercea 63427030ca Enable building of first commit. 2019-12-19 14:24:37 -05:00
Doru Bercea b6a2a50dd8 Add header. Clean-up file. Add CMake file. 2019-12-18 16:45:05 -05:00
TONG CHEN f3207be963 add MLIR: compile/link/run (#342)
* add MLIR: compile/link/run

* change LLVMPROJECT to LLVM_PROJECT and do not allow linking with system LLVM libraries
2019-12-18 15:43:35 -05:00