Commit Graph

48 Commits

Author SHA1 Message Date
Tung D. Le 6bd9471262
Lower ReduceMean op to Krnl dialect (#318)
* Improve support for krnl.dim (#317)

* Reorganize main function.

* Follow review comments.

* Emit constants are globals in Krnl and LLVM dialects.

* Make krnl dim more robust.

* Format.

* Update comments.

* Change pass name.

Signed-off-by: Tung D. Le <tung@jp.ibm.com>

* Initial Location info support (#302)

* NFC: Attribute cleanup (remove references of attributes)  (#286)

* Define krnl.permute op.

* Support krnl.permute operation.

* Properly remove loop references.

* Re-push, Github was down.

* Need to debug interpretOp error.

* Fix lowering bug by erasing ops after full krnl IR interpretation is done, and clean up & comment code.

* Introduce permute, unroll operations.

* More debug.

* Remove std::set.

* krnl.terminate fails to be converted.

* Pass all tests, need to add legal ops as well as part of the conversion target.

* Change test format to new permute spec.

* Bug fix for nested iterate op lowering.

* Simplify error reporting.

* Fix compilation error.

* Increase comments coverage.

* Remove unnecessary imports.

* Re-trigger Jenkins

* Add permute/unroll tests.

* Retrigger Jenkins

* remove & (ref) for Attributes

Co-authored-by: Tian Jin <tjingrant@gmail.com>
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* Syntax highlighting for mlir code in README (#276)

* Syntax highlighting for mlir code in README

* Restart Jenkins

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* use print not dump

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* add semicolon

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* syntax

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* add code to preserve locations

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* format

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* Emit the dynamic memory pool (#290)

* Reorganize main function.

* Follow review comments.

* Emit constants are globals in Krnl and LLVM dialects.

* Add support for bundling dynamic memory pools.

* Add dynamic bundling.

* Clean-up code.

* Clean-up file.

* Add test for bundling dynamic memory pool.

* Fixes. Simplify data structure. Add mixed test.

* Remove unused import.

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* Fix wrong type for llvm::loadop (#293)

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* Update llvm commit ID to 1d01fc1 (#292)

* Fix for LLVM revision D85495

* Fix for LLVM revision DD86121

* Fix for LLVM revision D85622 (f9dc2b7)
TODO: Change preloadDialectsInContext to false

Memo for previous fixes: D86121 (250f43d), D85495 (575b22b)

* clang-format

* Update llvm commit ID of README and clone-mlir.sh

* Updated llvm commit ID of README.md

* Fix for passing backend tests

* Removed the commented code

* Empty commit for triggering rebuild

* Test multi-stage travis build

* Specify stage order.

* Empty commit for triggering rebuild

* Update prereq.s390x.Dockerfile

Make it possible to execute s390x prereq docker multiple times.

* Build prereq for each arch

* Fix multi-arch prereq build.

* timeout at 40m

* Update .travis.yml

* add ppc64le prereq builder

* Run ppc docker prereq build multiple times

* Do not test branch update unless it's mater.

* Fix dockerfile.

* Fix typo in travis.yml.

* Fix ppc64 docker file

* Update .travis.yml

* turn off metacopy on ppc64le

* Update .travis.yml

* Turn off metacopy.

* Turn off metacopy inside Dockerfile in ppc64.

* No sudo in Docker.

* Remove metacopy config from Dockerfile.

* Change base image to be bionic.

* Using newer linux distro for ppc64.

* Turn off metacopy in before_install.

* Fix sudo permission issue.

* Run docker info.

* Allow amd64 docker file to be built multiple times

* Support building amd64 prereq.

* Fix amd64 docker file typo.

* fix ppc64le dockerfile typo.

* timeout from 40m -> 30m

* 40m->30m

* 40m->30m

* fix bug preventing incremental build.

* fix bug preventing incremental build.

* Bump CircleCI cache version.

* Push to production prereq container repository and condition prereq docker rebuild on commit message.

* Rebuild prereq docker.

* Move default script to top-level.

* Python not properly installed.

* amd64 -> x86

* Rebuild prereq docker.

* Rebuild prereq docker.

* Rebuild prereq docker.

* Restart all CI.

* Disallow cache on Jenkins docker build.

* Restart zJenkins.

* Restart zJenkins.

Co-authored-by: Haruki Imai <imaihal@jp.ibm.com>
Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com>
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* Using onnx-mlir through incremental stages (#257)

* Add lowering of Vector dialect for lower-all-llvm pass

* Fix generating CallOp instructions when return type is void

* Fix lowering of memref

* Reformat using clang-format

* Record more context.

* Reflow comments.

Co-authored-by: Tian Jin <tjingrant@gmail.com>
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* Dropout elimination & Conv Bugfix (#297)

* Dropout elimination.

* Test VGG19.

* Add shufflenet.

* Fix grouped convolution bug.

* Fix lit test failure.

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* Rewrite shape and size OP  (#285)

* add shape inference

* Revert "add shape inference"

This reverts commit f9d42f39e68e14b5648abccfc8617fff00244d16.

* add rewrite rules

* test cases

* format

* add constraint

* response to review

* response to review

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* initial code for handling custom ops (#288)

* initial code for handling custom ops

* format

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* ShapeInference for SizeOp (#299)

* add shape inference

* Revert "add shape inference"

This reverts commit f9d42f39e68e14b5648abccfc8617fff00244d16.

* shape inference

* test case

* format

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* Gather ONNX to Kernel Lowering (#294)

* Define krnl.permute op.

* Support krnl.permute operation.

* Properly remove loop references.

* Re-push, Github was down.

* Need to debug interpretOp error.

* Fix lowering bug by erasing ops after full krnl IR interpretation is done, and clean up & comment code.

* Introduce permute, unroll operations.

* More debug.

* Remove std::set.

* krnl.terminate fails to be converted.

* Pass all tests, need to add legal ops as well as part of the conversion target.

* Change test format to new permute spec.

* Bug fix for nested iterate op lowering.

* Simplify error reporting.

* Fix compilation error.

* Increase comments coverage.

* Remove unnecessary imports.

* Re-trigger Jenkins

* Add permute/unroll tests.

* Retrigger Jenkins

* initial implementation of gather

* added tests

* format

* remove affine load for second load, as it uses an indirection

* changes suggested by reviewers

* remove backend tests until I can verify them locally

Co-authored-by: Tian Jin <tjingrant@gmail.com>
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* add lit test
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* fix option spelling
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* braces in wrong place
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* add lit test
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* remove duplicate code from lit test Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* Simplify lit test Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* remove attributes from lit test Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* add onnx-mlir-opt to tool names
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* add printIR to second RUN
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* redo adding printIR
Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* fix bug

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* format

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

* fix typo in test

Signed-off-by: Kevin O'Brien <caomhin@us.ibm.com>

Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
Co-authored-by: Tung D. Le <tung@jp.ibm.com>
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
Co-authored-by: Haruki Imai <imaihal@jp.ibm.com>
Co-authored-by: Kevin Wu <6334443+kwu91@users.noreply.github.com>
Co-authored-by: chentong319 <chentong@us.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>

* Support ReduceMean

Signed-off-by: Tung D. Le <tung@jp.ibm.com>

* Add lit tests

Signed-off-by: Tung D. Le <tung@jp.ibm.com>

* Fix unknown dimensions for type f32

Signed-off-by: Tung D. Le <tung@jp.ibm.com>

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
Co-authored-by: Kevin O'Brien <caomhin@us.ibm.com>
Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
Co-authored-by: Haruki Imai <imaihal@jp.ibm.com>
Co-authored-by: Kevin Wu <6334443+kwu91@users.noreply.github.com>
Co-authored-by: chentong319 <chentong@us.ibm.com>
2020-10-10 22:09:42 -04:00
gongsu832 81c774ba5b
Cleanup rtmemref api (#238)
* Detect llvm-project commit change in utils/clone-mlir.sh and rebuild llvm-project
for zLinux Jenkins build bot

* Cleanup RtMemRef API

-  use forward declaration to hide private data fields
-  RtMemRef.h: external user header, C/C++
- _RtMemRef.h: internal user header, C++ only
-  RtMemRef.hpp and RtMemRef.cpp: implementation header and file
-  add external APIs
       OrderedRtMemRefDict *ormrd_create(RtMemRef **rmrs, int n)
       RtMemRef **ormrd_getRmrs(OrderedRtMemRefDict *ormrd)
       int ormrd_getNumOfRmrs(OrderedRtMemRefDict *ormrd)
   for creating and querying OrderedRtMemRefDict with RtMemRef arrays
-  data buffer installed by rmr_setData() will be managed by user
-  unique_ptr<RtMemRef> must use custom deleter <RtMemRef,decltype(&rmr_destroy)>

* See if I have write access.

* Remove test CMake code.

* Use new API.

* Format code.

* Format code & rename variables for readability.

* Remove used API spec.

* Rename OrderedRtMemRefDict -> RtMemRefList, _dataMalloc -> _owningData.

* OrderedRtMemRefDict -> RtMemRefList

* Update KrnlToLLVM.cpp

* Trigger Jenkins

* Restart Jenkins

* OrderedRtMemRefDict -> RtRmrRefList

* More OrderedRtMemRefDict -> RtMemRefList.

* Format jni wrapper.

* Rename API functions to maintain stylistic consistency.

* Bug fix.

* Bug fix.

* Format code.

* Fix RtMemRefUtils.

* Format code.

* Using llvm function naming scheme.

* Rename runtime api file name to project name (onnx-mlir) as per convention.

* Include the new runtime header file.

* Reflect api header file name change in build script.

* Bug fix.

* Remove C++ code.

* Revert "Remove C++ code."

This reverts commit b217dfabae99e42db30721600cb5507866d4dc98.

* Clarify memory management responsibility.

* Add constructor to specify name & data ownership.

* Include stdbool.

* Remove dictionary semantics from RtMemRefList

* Bug fix.

* Format code.

* Format code.

* Use macro to define database of metadata.

* Prevent formatter from acting on metadata decl.

* Nit.

* Restore backend unit tests.

* Use spaces instead of tabs for better formatting.

* Use explicit template instantiation.

* Update RtMemRef struct doc.

* Make runtime compilable both in c and c++ mode.
Build two versions of the runtime library, one c version as the user-facing c runtime, and one c++ version as the one used inside this project.

* Bug fix, avoid stack allocation for output rmr list.

* Change _dyn_entry_point_main_graph -> run_main_graph for better memorability.

* Write a complete introductory tutorial on c99 Runtime and a test for it.

* Add onnx installation as dependency.

* Use target_include_directory to avoid installation.

* Format code.

* Fix cmake target_include_directories.

* Address compiler warning.

* First pass of RtMemRef->OMTensor.

* Second pass of RtMemRef -> OMTensor.

* nit, omtList -> omTensorList.

* omt -> omTensor for clarity.

* Rename OnnxMlirInternal.h -> OnnxMlirRuntime.hpp because there's no internal/external API, only C/C++ API.

* Format code.

* Restructure Runtime source code and move header -> /include and test -> /test/unit.

* Bugfix.

* Format code.

* Add unit test for OMTensor ctor.

* Update JNI CMake include directory.

* Bugfix.

* No need to re-declare ONNX types.

* Disable runtime doc test on non-x86 platforms.

* Rename OMTensor fields to be more sensible.

* Fix data type mismatch.

* size_t -> int64_t, prefer fixed width integers.

* Use consistent header guard style.

* Further tweak OMTensor API.

* Bugfix.

* Bugfix.

* Format code.

* Add doxygen config file.

* Tweak OMTensor API.

* Tweak API doc, hide OMTensorList implementation.

* Format code.

* Add new documentation item for Runtime API.

* Hide internal use only API declarations, move their comments to their implementations.

* Clarify ownership semantics in relevant API documentations.

* Fix PyRuntime.

* Remove alignment concerns from public API and include explaination of alignment issue in struct OMTensor definition.

* Print out unsupported numpy dtype.

* Use preferred way of type comparison in pybind11.

* Debug s390x issue.

* Remove debug code.

* Clarify semantics of strides/shape setter/getter, use \brief to include short description of API function.

* Improve documentation.

* Single out unpolished C++ API declarations.

* Clarify OMTensorList API.

* Bugfix.

* Bugfix.

* Assert after malloc.

* Handle malloc failures.

* Nit.

* Tweak legal notices.

* Format code.

* Remove doxygen generated files.

* Tweak legal notice format.

* Upgrade Cython

Numpy installation depends on Cython.

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-10-10 10:32:09 -04:00
chentong319 931127c7e9
Lower tile to Krnl (#308)
* alloc for unknown shape

* determine affine

* format

* test for unknown input

* Update test.py

* fix the expression

Signed-off-by: chentong <chentong@us.ibm.com>

* fix test lit

Signed-off-by: chentong <chentong@us.ibm.com>

* remove affine load

Signed-off-by: chentong <chentong@us.ibm.com>

* format

Signed-off-by: chentong <chentong@us.ibm.com>

* fix test

Signed-off-by: chentong <chentong@us.ibm.com>

* fix Affineload

Signed-off-by: chentong <chentong@us.ibm.com>

* affine for alternative

Signed-off-by: chentong <chentong@us.ibm.com>

* use DimOp

Signed-off-by: chentong <chentong@us.ibm.com>

* change test case

Signed-off-by: chentong <chentong@us.ibm.com>

* fix test

Signed-off-by: chentong <chentong@us.ibm.com>

* use more auto type

Signed-off-by: chentong <chentong@us.ibm.com>

* fix affine load

Signed-off-by: chentong <chentong@us.ibm.com>

* small fix

Signed-off-by: chentong <chentong@us.ibm.com>

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-10-05 00:50:59 -04:00
Alexandre Eichenberger f0c5b99229
Gather: fix for negative indices (#313)
* Define krnl.permute op.

* Support krnl.permute operation.

* Properly remove loop references.

* Re-push, Github was down.

* Need to debug interpretOp error.

* Fix lowering bug by erasing ops after full krnl IR interpretation is done, and clean up & comment code.

* Introduce permute, unroll operations.

* More debug.

* Remove std::set.

* krnl.terminate fails to be converted.

* Pass all tests, need to add legal ops as well as part of the conversion target.

* Change test format to new permute spec.

* Bug fix for nested iterate op lowering.

* Simplify error reporting.

* Fix compilation error.

* Increase comments coverage.

* Remove unnecessary imports.

* Re-trigger Jenkins

* Add permute/unroll tests.

* Retrigger Jenkins

* changes to support negative indices

Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com>

* use krnl.dim now

Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com>

* move comment

Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com>

* updated test for krnl-dim pattern

Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com>

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-09-24 14:02:49 -04:00
Prashant Kumar 4cc16aceb7
[MLIR] Add SizeOp conversion from ONNX dialect to Krnl dialect (#295)
* [MLIR] Add SizeOp conversion from ONNX dialect to Krnl dialect

Added ONNXSizeOp conversion from ONNX dialect to Krnl dialect. This op is added as a part of --convert-onnx-to-krnl pass.

Signed-off-by: Prashant Kumar <pk5561@gmail.com>

* Add unit tests for Size op.

* Remove unit tests.

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-09-21 16:55:21 +07:00
Tung D. Le 66074da3ac
Lower ONNXConstantOfShapeOp to Krnl dialect (#296)
* Lower ONNXConstantOfShapeOp to Krnl dialect

* Change a variable name

* Add comments to lit tests

Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com>
2020-09-19 12:47:39 -04:00
Alexandre Eichenberger 3a5aa7ee31
Gather ONNX to Kernel Lowering (#294)
* Define krnl.permute op.

* Support krnl.permute operation.

* Properly remove loop references.

* Re-push, Github was down.

* Need to debug interpretOp error.

* Fix lowering bug by erasing ops after full krnl IR interpretation is done, and clean up & comment code.

* Introduce permute, unroll operations.

* More debug.

* Remove std::set.

* krnl.terminate fails to be converted.

* Pass all tests, need to add legal ops as well as part of the conversion target.

* Change test format to new permute spec.

* Bug fix for nested iterate op lowering.

* Simplify error reporting.

* Fix compilation error.

* Increase comments coverage.

* Remove unnecessary imports.

* Re-trigger Jenkins

* Add permute/unroll tests.

* Retrigger Jenkins

* initial implementation of gather

* added tests

* format

* remove affine load for second load, as it uses an indirection

* changes suggested by reviewers

* remove backend tests until I can verify them locally

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-09-11 15:36:23 -04:00
Tian Jin 5e11429d77
Dropout elimination & Conv Bugfix (#297)
* Dropout elimination.

* Test VGG19.

* Add shufflenet.

* Fix grouped convolution bug.

* Fix lit test failure.
2020-09-10 14:47:30 +08: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
Tian Jin e0ae583da0
Compiling Models with Large Constant Arrays (#146)
* PoC works.

* MNist works.

* Clean up.

* Fix test.

* Make Linux work.

* Use consistent symbol name.

* Fix variable name.

* Fix array addr access.

* Bug fix.

* Bug fix.

* install before running e2e tests.

* Fix build config.

* Use sudo when installing.

* Make embeddedDataLoader position independent.

* Enable ResNet50.

* Format code.

* Format MainUtil.

* Try not using sudo to install.

* Supply runtime dir via environment variable.

* Dump problematic operation.

* Dump entire function.

* Debug.

* Dump input.

* Dump constant op.

* Debug.

* Debug.

* Debug.

* Print to stderr.

* take care of endianness.

* Use endianness-aware execution session.

* Fix ZLinux error.

* Include warning when desired output endianness can't be deduced.

* Remove debug code.

* Remove debug code in shape inference.

* Support binary-decoder for testing constants packing.

* Support filename, move-to-file, elision-threshold configurations in constant packing pass for easy testing.

* Add lit test, fix lit test type mismatch.

* Add more consts packing tests.

* Ensure intermediate files are properly cleaned up.

* No need for constant elimination.

* Link with threading libraries.

* Remove debug code.

* Format code.

* More tests.

* test nit.

* Remove debug code.

* Reduce hard-coded constants.

* Use temporary and unique working directory for hosting model parameters.

* Test if it works.

* Try to find objcopy.

* Rename symbols using objcopy.

* Move sanitized name to linux section.

* Use verbose mode for debugging.

* Disambiguate pass constructor.

* Fix symbol name.

* Use Command API to build and execute commands.

* Move linux to use Command API.

* Fix reset args.

* Execute redefine sym.

* Format code.

* Do not use verbose mode for CircleCI.

* Remove debug code.

* Prettify code, add comments.

* getSegmentData -> getEmbeddedConstPool

* vector -> std::vector.

* Make sure we properly clean up intermediate files.

* Fix test cases.

* Add runtime directory.

* Trigger rebuild.

* [Merge with master] fix debug script.

* Diable affine fusion pass for now.

* Support generic fallback const packing mechanism.

* Remove debug code.

* Handle the case where objcopy is not available.

* Fix Windows missing types.

* Support int64.

* Copy packed constant to a local directory for non-Linux/Mac platforms.

* Nit: remove debug code, refactor const pack preprocessing out as a separate function.

* Cannot make preprocessConstPack a standalone function because file removers are stack-allocated, and they are deallocated prematurely when function stack gets popped, deleteing intermediate files too early.

* Don't require executable filename.

* Import ONNX data types directly.

* Fix LIT test.

* Bug fix, use moved string value.

* Remove redundant filenames.

* Fix CMake script.

* Embed endianness information as a symbol, and check during runtime.

* More comments, update lit tests.

* Fix lit test on BE machine.

* Copyright notices.
2020-06-12 10:27:05 +08:00
Tung D. Le 8c4d527eea
Lower SplitOp to Krnl dialect (#155)
* Fix importing variadic output

* Lower splitop

* Support unknown dimension and add lit tests

Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-06-11 10:57:20 +08:00
Tian Jin cde1157d62
Rapid check test (#141)
* 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.
2020-06-08 10:18:55 +08:00
Tian Jin 4cdc0873ca
Call llc, ld from within onnx-mlir. (#127)
* Call llc, ld from within onnx-mlir.

* Rename EmitLLVMBC -> EmitLib., reorder header files

* Edit comment.

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-05-19 10:15:48 +08:00
Tian Jin adc08fb93e
Specify in linking stage, where runtime shared library is located. (#120)
* Specify in linking stage, where runtime shared library is located.

* Cite & make comment a full sentence.

* Fix error communicating runtime dir to ld.
2020-05-14 09:04:16 +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
Gheorghe-Teodor Bercea f5f336db08
Fix running backend tests triggered by preloading cruntime dynamic library (#104)
* 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.
2020-05-04 08:37:58 -04:00
Tian Jin fad2ad7d03
Make onnx-mlir work with latest mlir. (#93)
* 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.
2020-04-27 17:03:56 +08:00
Gheorghe-Teodor Bercea 137ce767e6
Rework output to improve readability of intermediate MLIR code. (#87)
* 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.
2020-04-24 16:15:36 -04:00
Tung D. Le eac2297624
Lower MaxPooling and AveragePool to Krnl dialect using AffineMap (#38)
* 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>
2020-04-19 21:39:34 +08:00
gongsu832 72de6eb004
Fix check-onnx-backend build on x86 Linux. (#91) 2020-04-16 14:38:52 +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
Tung D. Le f4fefcf713
Re-add tanh lowering (#75)
* Re-add tanh lowering

* Make the emission deterministic
2020-04-09 14:22:36 +08:00
Alexandre Eichenberger 844dcd8b1f
Name change for tests, to be check-onnx-(lit | backend) (#62) 2020-03-31 10:06:14 -04:00
Tung D. Le 2814ea3898
Support dilations and enable the remaining e2e tests for MaxPoolSingleOut (#31)
* 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>
2020-03-18 09:55:50 -04:00
Tung D. Le 4763e8a8bc
Lower ONNXAbsOp to Krnl dialect and enable e2e tests for ONNXReduceL1 (#18)
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-03-17 11:12:45 -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
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 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 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
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
Tung D. Le e5677bba1f
Add e2e tests related to Reduction Ops (#79) 2020-02-12 16:40:32 +08: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
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
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 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
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 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
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
Tian Jin ff0e25fdc9 Re-enable Reciprocal tests. 2020-01-21 19:41:22 -07: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
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