Commit graph

260 commits

Author SHA1 Message Date
Yufeng Li
4bb0e29d0e
initialize generated_value_names with graph input (#8085)
* initialize generated_value_names with graph input
* use set for following usage
2021-06-22 15:08:54 -07:00
Olivia Jain
b2247ece25
Make Perf Test Configurable (#7836)
- Allow anyone to kick off a perf test here. Customize: branch, eps, model selection, cuda version.
- Only run shape inference when required.
- Kill errored out memory processes.
- Remove warmup run.
- Clean up script.
- Standalone_TRT is it's own "EP" vs as an additional run with TRT EP
2021-06-18 11:11:19 -07:00
Guoyu Wang
f013b0c0eb
[NNAPI EP] Add support of Elu, merge in NNAPI updates for API level 30 (#8001)
* Add elu, integrate new Android NNAPI API changes

* add slice check

* update previous typo

* Move sdk level check to nnapi feature level check

* update readme
2021-06-09 12:39:02 -07:00
Ye Wang
d433aa2459
Add transformers tool test to pipeline (#7959)
* checkin transformers pipeline

* add docker requirements

* only trigger linux cpu

* temp remove tf instalation due to numpy version conflicts

* test numpy>=1.7

* revert numpy and disable transformers

* add coloredlogs

* enable shape_infer_helper and install transformers when needed

* pip3?

* testtest

* enable more tets

* line too long

* remove pytorch1.4 test and added back some onnx  files

* add tests

* copy dir

* disable 2 teests

* trim lines

* add missing onnx

* fix type

* fix  version conflicts

* install psutil

* change file path

* mfix path

* remove cached files

* add back attention fusion test

* labeled the shape infer test as slow

* fix

* enable tf2onnx test and enable pytest

* refactor path

* fix typo

* add cwd
2021-06-08 19:43:59 -07:00
Vincent Wang
f0f3012666
Add SoftmaxCrossEntropyLossInternal to Support Dynamic ignore_index Input (#7899)
* add SoftmaxCrossEntropyLossInternal

* bugfix and ut

* fix ut

* fix ut

* support torch1.8.1

* function body for nll_loss_internal
2021-06-09 10:29:46 +08:00
Yufeng Li
500f18badb
fix bug that bias can not be shared across Convs (#7982) 2021-06-08 14:01:06 -07:00
Vincent Wang
71c4f5ddb2
ATenOp Enhancement (#7725)
* config parser, default argument values

* ut

* win build

* maxpool2d

* fix win build

* fix build

* unfold atenop
2021-06-08 11:01:17 +08:00
pengwa
9e4dc08483
training with custom autograd Functions (#7513)
* Register Torch Custom autograd.Function

* Add flag to supress pybind11 warning

* Avoid unnecessary include in cmake

* Add missing reference

* Add getter for registerred functions

* Format for making subsquent changes cleaner

* Fix interop feature build failure

* Forward pass, run PyOP on CPU EP

* clean up the code

* Fix build

* Define new ops

* refactor pyop - extract PyOpLibProxy class

* Hacks to run example

* implement the kernel compute func

* add back PyOP for comparision experiments

* debug info - thread id

* refine the kernels

* Polish code

(cherry picked from commit 4ed606f9a0)

* Fix a the Tensor address mismatch in C++ side

* PythonOpGrad compute

* add distributed test case

* refine test cases

* get dist.get_rank() in Autograd forward pass

* Add CUDA kernels

* Store float, int, and tuple of them as PythonOp's attributes

* Populate local changes

* Fix bugs

* PythonOp/PythonOpGrad CUDA kernels

* Support non-tensor inputs

* Single GPU FP16 Run Pass

(cherry picked from commit e539989e91e18ee997900292d3493b97d3eafa8a)

* Fix segement

* add basic test cases

* Save progress

* fix gradient builder for a Add op who have same inputs

* add test cases for auto grad fallback feature

* fix ref cnt issue. add thread id for debugging

* POC: remove interface class

* Remove interface classes

* Clean a bit

* Coarse-grained clean up after rebase master

* reset pyop and language_interop_ops to latest master

* Fix missing part during merge

* re-structure torch related language interop files

* Fix build

* Fix tests and build

* Fix build and basic unit tests

* Fix most of uts

* remove unnecessary import

* clean up and fix build when enabling language_interop_ops

* Fix single-GPU UTs

* Move runner register into ORT package

* Update dist UTs to new style

* Also fix distributed UTs and leaf gradient problem

* Static generation for constant args

* Move arg_positions_ to static field

* Rename some functions

* Move arg ceration into a function

* Clean output logic in PythonOp

* Move PythonOp's ctor

* Revise PythonOpGrad

* Fix "ORT only supports contiguous tensor for now" for inputs

* Fix evaulation mode error, add test & clean up

* clean up codes

* Fix issues introduced by recent master change (enabled symbolic shape infer)

* automatically register forward/backward function pointers && clean up

* Fix multi-output case

* Add a test back

* fix build and clean up

* RAII for function params PyObject

* Use new exporter

* Clean full name in new exporter

* Fix UTs

* Format a file

* Add "inplace" back

Remove a legacy comment

* Refine TorchProxy
1. Make TorchProxy a formal singleton class.
2. Remove unused Scope class.
3. Simplify the call to Forward and Backward. The two functions now
   automatically acquire and release GIL state, so user doesn't need
   any GIL-related calls.

* Format

* Add lock to avoid racing condition when registering Python objs

* Fix Python call param ref issues && Add RefcountTracker for debug build && Clean up

* clean up print

* Resolve part of comments && clean up

* Fix a potential bug

* track pyobject consistently

* move kernels to cpu provider as base class

* Refactor - 1. Extract PythonOpBase/PythonOpGradBase 2. Implement CPU kernels 3. Test coverage for CPU kernels

* Refine register code

* Add a missing macro

* Release python call result objects with PythonObjectPtr && Add UnRegisterContext && Track PyObject for Debugging && Clena up

* Fix random segfault issue - relasing a wrong ctx pointer for inplace cases

* put ref count in debug macro

* Move GIL out

* Refine tests

* Fix memory leak issue && forward output lifecycle issue:
1. Unregister the OrtValue PythonObject. Currently, the OrtValue shared same buffer with PythonOp/PythonOpGrad's output. So after those kernels outputs are released, the "leaked" OrtValue caused the shared buffer cannot be released.
2. According PyTorch forward+backward execution. The forward outputs (e.g. torch tensors) maintains the context/saved variables/dirty inputs, etc, which are used for backward execution, so its life should be after the backward runs. This change added such a depencencies between PythonOpGrad on PythonOp.

* Move dlpack->ortvalue into C++ to avoid temp object registration

* Fix the over released Py_False/Py_True && refine tests

* Clean up unused functions

* Always assume the first forward output is context so we don't need to test unused cases.

* Fix a memory leak

* move-copy unique_ptr & avoid C-style casting

* Use inplace attribute to determine if input tensors are copied

* Move DlpackCapsuleDestructor's to a common place

* Thread-safe TorchProxy

* Use OrtValue instead of OrtValue*

* Only keep checks for Debug build

* Wrap some long line per comment

* onnx_export_type --> kwargs

* Use requires_grads to create PythonOpGrad's inputs

* add missing files during master merge

* Fix build issue after merge

* Address two comments.
1. Internalize DlpackCapsuleDestructor
2. Change "(" to "]" for describing closed interval.

* Address some comments.
1. "override" -> "overwrite" to avoid using reserved keyword.
2. Call DLPack's helper to create OrtValue for avoiding repeated code.

* Address comments.
1. Pass std::mutex to registeration helpers so their callers don't
   have to lock the mutex expclicitly.
2. Rename "func_context_pool_mutex_" to "mutex_". This mutex is the global mutex for OrtTorchFunctionPool.

* Add bridging code to make cuda kernels work with merged master

* put debue macro check within RefCountTracker && use default logger for debug info && remove useless ortvalue_ptr interface && typos && revert unncessary blank line changes

* fix some comments

* Resolve more comments

* Capitalize a word

* use unique_ptr instead of ObjectPointer for PyObject management && add converntion

* Support symbolic shape

* Remove unused variable

* fix build

* Enable function registration for training only && rectify ToDlpack/FromDlpack merge with master.

* Don't add context for non-PythonOp opeartors (for example AtenOp)

* Fix build error

* Polish frontend part.
1. Avoid adding kwargs to ORTModule's ctor
2. Use onnx_export_type rather than kwargs for type safty
3. Fix some build bugs.

* Resolve simpler comments

* Resolve export related comments

* sync master && fix tests && fix non-training build error

* Fix build errors

* add target link lib

* windows build error

* Fix orttraining-linux-ci build

* disable autograd test && clean up

* fix linux orttraining ci build

* try fixing win build error

* Revise append calls in runner

* Enable custom function using a function

* Rename to avoid using reservied keyword

* Use list comprehension

* Set ORT random seed in tests

* Remove print code and fix ctx shape

* [] -> list()

* Move autograd.Function and nn.Module into corresponding functions

* Move test helpers

* Polish dist test a bit. Tried move helpers to helper file but it causes a deadlock.

* trying fix undefined reference

* Context is not managed by global pool

* Polish dist test

* Polish dist test

* Add enable_custom_autograd_function

* Remove enable_custom_autograd_function from ctors

* Add doc strings

* Shorter code

* Address comments

* Add one empty line

* revert a minor and not needed change

* Address comments

* Back to reference

* Fix windows builds

* Fix windows debug build fail to find "'python39_d.lib'"

* fix mac build error

* revert _to_contiguous change

* add debugging tag for orttraining-cpu-ci

* Fix the wrong PYTHON_LIBRARIES which is affected by PYTHON_LIBRARY given in build command

* add debugging info

* Fix the build in this case: PYTHON_LIBDIR: /opt/_internal/cpython-3.7.10/lib, PYTHON_EXECUTABLE: /opt/python/cp37-cp37m/bin/python3, PYTHON_MULTIARCH: x86_64-linux-gnu
PYTHON_LIBRARY_PATH python3.7m

* fix build error due to python lib not found

* Fixes
1. Release PyObject's
2. Not useing deepcopy because we assume autograd.Function's
   non-tensor inputs are static (constants) so there should
   be no side effect after calling any autograd.Function
   multiple times.

* Revert dtoc for decreasing refcnt

* add debugging log

* add debugging tag

* Fix a small leak

* Remove ONNX_FALLTHROUGH flag

* debug tag

* debug tag

* fix builds

* remove debug tag

* fix build

* fix builds

* fix build

* install python3 in centos, in case there is no libpython3.xm.so

* build python so for redhat

* add training cpu specific docker, build python so inside

* revert build-cpython change

* try fixing numpy include issue

* install_deps after re-installing cpython

* fix build && remove debug tag

* install openssl before cpython

* let's say: builds pass!

* add build flag for torch iterop, only enable it when training+Python is enabled

* skip ComputeBroadcastBackwardAxesDynamic for the shared inputs

* fix build

* add debug info for padgrad test

* Fix builds

* Split dlpack_converter into C++ and Python interfaces respecitively. Then different build use them as needed.

* clean up the changes

* fix addsubgradient builder

* Fix builds

* clean up

* clean up

* Address some comments.
1. Use pointer wraper to avoid calling Py_DECREF
2. Remove unregister_* functions
3. Allow repeated registration by skipping those with existing keys
4. Unregister context in PythonOpGrad

* Fix over-released Py_Boolean

Co-authored-by: Wei-Sheng Chin <wschin@outlook.com>
2021-06-07 13:01:21 -07:00
Guoyu Wang
fd23b8caad
Update mobilenetv2 quantization notebook (#7941)
* Update MobileNetV2 notebook for mobile

* Remove outputs of the notebook

* minor update

* Address CR comments

* update comments of the notebook
2021-06-04 18:15:10 -07:00
Ye Wang
4f82ad1b58
Topo sort the model before saving (#7913)
* checkin toposort

* review comments

* revert and add TODO
2021-06-02 16:57:08 -07:00
Tianlei Wu
71b05f74a2
fix duplicated node name (#7865) 2021-05-27 17:16:17 -07:00
Yufeng Li
94bb09bf47
fix topo sort in quant tool (#7833)
* fix topo sort in quant tool

* add unit test and make the topo sort stable
2021-05-26 17:53:35 -07:00
Xiaoyu Liu
224a664811
GPT-2 one step search tutorial (#7718)
* GPT2 with one step search tutorial
* remove quantization section

Co-authored-by: Xiaoyu Liu <xiaoyu@xiaoyu-VM.z4vh1dzj5eoevgybsksdpz2izh.jx.internal.cloudapp.net>
2021-05-18 12:31:39 -07:00
Young Jin Kim
e9057d2e49
ZCode FastFormers changes (#5827)
* Add FBGEMM submodule

* Add fbgemm based per-channel quantization

* Add missing logic for pre-layernorm transformer model fusion

* add support for structured pruning architecture -fastformers

* Fix windows build

* Add a default behavior when head_size is not present for the backward compatibility

* Remove FBGEMM and default to tensor-wise quantization, column-wise quantization will be enabled later

* Fixed some unit test errors

* Fix windows compile error and unit test errors

* delete the option removed from the upstream

* Addresses review comments and fixes a merge error

* Remove commented out code

* add non-zero zp support

* support A and B scale with any dimensions

* fix build breaks

* fix warning in MSVC

* Fix bug for not checking original float value names when treat it as not existing.

* Clean up head size

* Clean up python tools

* Enable per column quantization

* fix quant weight cleanup bug

* A few code clean up

* Some code clean-up

* Some code clean-up

* Change option name

* update default value

* Rename option and parameter names

* Missing argument name change

* Add tests for quantization options for attention and matmul

Co-authored-by: Yufeng Li <liyufeng1987@gmail.com>
Co-authored-by: Lei Zhang <zhang.huanning@hotmail.com>
2021-05-17 21:12:21 -07:00
Ye Wang
5e8086ad8e
Support fusions inside subgraphs in optimizer tool (#7701)
* skip subgraph when updating model

* intreim checkin

* interim checkin 2

* support transformers optimizations in subgraph

* change more files

* fix comments typo
2021-05-17 12:43:55 -07:00
Yufeng Li
6b0a7905ed
fix quant weight cleanup bug (#7707) 2021-05-14 22:04:35 -07:00
Zhang Lei
0f7721a019
Fix bug for not checking original float value names when treat it as not existing. (#7695) 2021-05-14 12:50:30 -07:00
Zhang Lei
033f0b3b7c
fix typo. (#7690) 2021-05-14 10:25:34 -07:00
Vincent Wang
dac24f7d63
Add ATenOp and call aten::embedding and its Backward Op from ORT (#7590)
* build with libtorch and impl torchembedding

* fix op shape infer

* local commit

* atenfunctionop

* call aten operator from online extension

* rollback build.py

* resolve comments

* bugfix

* fix build

* fix ortmodule test

* remove external outputs, resolve comments

* resolve comments

* export embedding to microsoft::atenop

* bugfix
2021-05-13 09:24:27 +08:00
Zhang Lei
1c7e683a95
Add Squeeze and Unsqueeze support for quantizaton tools. (#7673) 2021-05-12 14:56:46 -07:00
Zhang Lei
31d4413919
fix quantization tool bug when existing pass through only input (#7674) 2021-05-12 14:54:42 -07:00
Olivia Jain
29172d8f54
Setup EP Dashboard (#7321)
* setting up dashboard
* posting to ort dashboard
* creating separate docker file
* including common deps
* tracking latency over time
2021-05-11 10:33:39 -07:00
Tianlei Wu
55c086b664
symbolic shape inference improvements for contrib ops (#7606)
* add EmbedLayerNormalization
* use onnx shape inference for Unsqueeze
* Fix type warning in Attention
2021-05-07 17:03:24 -07:00
Tianlei Wu
d88da44066
Allow flexible order of Add inputs in Attention fusion (#7565) 2021-05-06 09:43:28 -07:00
Zhang Lei
9465948715
Quantization tools using one more extra_options on interface. (#7293)
handle nnapi special sigmoid options.
2021-05-05 13:51:50 -07:00
Zhang Lei
f6cefc92e2
Add quantized value map after quantize input node added. (#7558) 2021-05-04 15:27:56 -07:00
Tianlei Wu
3c9ece4a11
[transformers optimizer] catch symbolic shape inference exception and clean up (#7560)
catch symbolic shape inference exception.
no prune graph when there is inner graph (Loop/If/Scan)
add an wrapper for numpy_helper.to_array so that we can debug onnx graph without external data
remove fuse_mask that is not used any more in onnx_model_bert_tf.py
2021-05-03 20:42:13 -07:00
Tianlei Wu
731f9e5033
Fix symbolic shape inference for Unsqueeze (#7555)
* fix Unsqueeze shape inference
* add tests
2021-05-03 18:06:59 -07:00
Ryota Tomioka
d1cb8c9dc9
Support negative indices and fix bound checking in symbolic shape inference for Slice (#7401)
* Use positivity everywhere; handle negative index in Slice

* limit positivity to inputs

* make handle_negative_index private

* strengthen sympy comparison

* further strengthen compariso
n and a minor refactoring

* Add flip test

* Fall through if -int_max in handle_negative_index()

* minor fix for infer_Concat to include initializers

* Add more tests

* use simplify

* more tests
2021-05-03 09:07:55 -07:00
Xiaoyu Liu
994c2ed420
GPT2 one step beam search update with configuration support (#7425)
* check in early stop search as separate type
* rename to beam search configurations
* update do sample configuration flag help
* rename to configurable search step
* add option groups
* add more unit tests

Co-authored-by: Xiaoyu Liu <xiaoyu@xiaoyu-VM.z4vh1dzj5eoevgybsksdpz2izh.jx.internal.cloudapp.net>
2021-04-29 13:19:56 -07:00
thilow
22d7cde725
Fix a 'Squeeze' related issue in symbolic_shape_infer.py (#7380)
* Update symbolic_shape_infer.py

don't rely on static code infer in _infer_Squeeze_

* checking if dorpped axes might be =! 1

* Checking opset. Logging assumption that symbolic dimensions are unequal to 1.

* more checks
2021-04-28 13:13:04 -07:00
Zhang Lei
ada0fbbd2d
Implement qlinear concat and unit test. (#7341)
* Implement qlinear concat and unit test.
Add quantization tools for QLinearConcat and it quantization tests.

* Add kernel def hash for QLinearConcat.

* Change according to PR. Add qdq transformer support for QLinearConcat.

* Add QDQ Transformer unittest. Fix typo on domain.

* remove dup logic of no use.

* fix x86 build error.

* Update operator docs.
2021-04-26 13:38:40 -07:00
Xiaoyu Liu
913ea8264b
GPT2 with one step beam search (#7163)
* beam search refactoring checkin
* add factory class and deduplicate code
* one step beam search works on gpu

Co-authored-by: Xiaoyu Liu <xiaoyu@xiaoyu-VM.z4vh1dzj5eoevgybsksdpz2izh.jx.internal.cloudapp.net>
2021-04-20 06:23:52 -07:00
Tianlei Wu
aa9ab565f5
FastGelu fusion for Megatron model (#7344)
* add a fastgelu pattern from Megatron model

* update comment

* add test
2021-04-15 00:39:33 -07:00
Oliver Rausch
87bd836886
Fixes in symbolic shape inference (#7258)
* Add symbolic shape inference for Transpose

* Support steps in symbolic shape inference for Slice

* Add inference for BatchNormalization

* Address review changes

* Address review changes
2021-04-13 22:17:30 -07:00
Zhang Lei
f62db1a09c
quantization tools support qlinear average pool (#7309) 2021-04-13 18:22:42 -07:00
Zhang Lei
a4fdb4dbd9
Support transpose by merge Reshape etc into direct xint8 operators. (#7265)
* Suppose transpose by merge Reshape etc into direct xint8 operators.

* Add resize operator quantization support

* Add QDQ tests for resize, reshape, maxpool, transpose.
2021-04-08 18:00:35 -07:00
KeDengMS
0d49e53985
[Symbolic shape infer] fix scalar shape in Expand (#7285) 2021-04-08 10:26:28 -07:00
Olivia Jain
fb40602ea2
Mem trt (#6868)
* adding trt comparison and memory consumption

* creating separate docker file
2021-04-05 22:16:12 -07:00
Marek Šuppa
008065aab1
Update README.md (#7043)
* Fix the precision type (switch from nonexistent `int32` to `fp32`).
2021-04-05 10:03:14 -07:00
Yufeng Li
8d737f9770
handle optional input in quant topo sort (#7223) 2021-04-02 20:42:48 -07:00
Yufeng Li
c4ebc60870
sort quantized nodes in topo logical order (#7172) 2021-03-30 09:01:15 -07:00
Yufeng Li
77c19436c0
add a notebook for mobilenetv2 quantization (#7164)
* add a notebook for quant mobilenetv2
2021-03-29 13:24:14 -07:00
Ashwini Khade
b22e60bd44
pull onnx latest commit (#7102)
* update onnx commit

* fix test scripts to remove deprecated call

* update filters

* add registration for relu and cumsum ver 14

* add promote trilu to onnx domain

* update onnx-tensorrt submodule

* update flag

* update flag

* update dependencies

* fix android ci failure
2021-03-29 11:00:38 -07:00
Yufeng Li
3771e0bf10
update bert quantization notebook (#7137) 2021-03-25 18:12:53 -07:00
Yufeng Li
8e54b76e2d
QDQ implementation (#7033)
* Add QDQ basic implementation
2021-03-25 09:17:23 -07:00
Yufeng Li
fffe16cb43
Fix a bug in quant GEMM and add an unit test (#7111) 2021-03-23 16:39:35 -07:00
Yufeng Li
c965878a69
fix a bug in global average pool and add unit test (#6913)
* fix bug in QGlobalAveragePool

* add unit test for quant GlobalAveragePool

* not run quantization tests if disable_contrib_ops enabled
2021-03-22 20:01:27 -07:00
Scott McKay
b2c6617b0f
Use 'as_scalar' when checking the 'cond' value of 'If' (#7063)
#6884
2021-03-22 18:04:38 +10:00
Chi Lo
8c3b59a026
Quantization calibration refactor (#6893)
* Code refactor

* Modify code to tackle OOM when calibrating on larget dataset

* Fix mismatch issue when setting keepdims on ReduceMin/ReduceMax

* Add COCO val 2017 annotation

* Fix mismatch issue when setting keepdims on ReduceMin/ReduceMax

* Fix bug of "No module named:onnxruntime.quantization.CalTableFlatBuffers"

* Check and install flatbuffers module

* Add script to donwload coco dataset image and refactor example

* Fix bug of "No module
named:onnxruntime.quantization.CalTableFlatBuffers"

* Add CalTableFaltBuffers as module

* Remove annotation, user can download by themselves.

* Uncommet code

* Add back instances_val2017.json

* Make sure flatbuffers installed when ORT is installed

* Refactor code to call coco api

* Enable FP16 for example
2021-03-19 01:09:11 -07:00