Commit Graph

2499 Commits

Author SHA1 Message Date
Nicola Lancellotti ec3b16094b Add support for the quantized TANH operator to relay TFLite frontend (#8024)
Change-Id: I70df765e1562fa586ed0ffd0e07b8858f7fbb831
2021-05-20 14:03:51 +01:00
Siyuan Feng 1203d732d4 [TensorIR] change IntRV to ExprRV (#8077) 2021-05-20 08:20:42 -04:00
masahi 0d96f9553e [Relay, TOPI] Support dynamic slicing on first few axes, keeping the rest static (#8068)
* Supporting dynamic slice on first few axes

* fix index normalization

* update dynamic slice tests

* pylint fix

* fix loop index dtype

* fix more dtype issue
2021-05-20 11:06:39 +09:00
apeskov 052231969b Custom dyld linker for iOS mach-o executable files (#7875)
* [IOS-RPC] Fix compilation iOS_PRC app

Signed-off-by: Alexander Peskov <peskovnn@gmail.com>
2021-05-19 12:22:44 -04:00
liyuchao 17bbf02095 [Autoscheduler] Add sparse conv2d(1*1) support for auto_scheduler (#8065)
* add sparse conv2d support for auto_scheduler

* add description

* fix bug

* fix annotation

* Lint fix

Co-authored-by: laiyin.lyc <laiyin.lyc@alibaba-inc.com>
2021-05-19 18:52:56 +08:00
Muyang Li 53c3456095 [AutoScheduler] Make RecordReader error-free (#8066)
* fix bugs in the auto scheduler record:

* reformat the code

* reformat the code

* use the os.path.abspath

* change error to warning

* reformat the warning code
2021-05-19 18:50:35 +08:00
Trevor Morris e8045b1f2b Only allow 4d or 5d inputs to TRT nn.pad (#8073) 2021-05-19 14:11:33 +08:00
Tristan Konolige 476f0ff13f [CONTAINER] Add default python iterator for Map. (#8061)
* [CONTAINER] Add default python iterator for Map.

* formatting

* add keys(), values()
2021-05-19 14:10:53 +08:00
Krzysztof Parzyszek 94f009ee9f [Frontend][TFLite] Use axis.size instead of len(axis) (#8060)
The variable axis is an ndarray.
2021-05-18 18:30:00 -04:00
Trevor Morris 93f3010593 Move infer_value to _get_list_param (#8051) 2021-05-18 14:25:25 -07:00
Chris Sullivan c510c2b72e [IR] Add storage scope to PointerType (#8017)
* Add storage scope to PointerType.

* Apply suggestions from code review

Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
2021-05-18 09:27:00 -04:00
XuanAnyvision 365484e054 allow module exits without del (#8063) 2021-05-18 08:58:56 -04:00
Andrey Malyshev f3b1586f53 Fix recast of relay ops without attributes (#8043)
* Fix recast of ops without attributes

* fix test for pylint pass
2021-05-17 09:05:32 -07:00
Siyuan Feng 711a603db8 [TensorIR][M1c] Lower and build TensorIR (#8044) 2021-05-15 16:35:17 -04:00
Yuchen Jin c083ac73d8 [Tests] Fix requires_gpu (#8050) 2021-05-15 10:33:03 -04:00
Tianqi Chen dfe4cebbda [RUNTIME] Improve signal handling in python env. (#7919)
* [RUNTIME] Improve signal handling in python env.

Python execution environment handles the signal by caching
the signal a state and invokes the handler when execution
goes into the python interpreter.

This model can cause problem when runnning a long running
c++ function. As keyboard interrupt can only be caught in the end.

Additionally, because python registered special signal handlers.
Socket operations can return EINTR that needs to be explicitly
retried when the interrupt is not a KeyboardInterrupt.

This PR adds the following changes to resolve these problems.

- Allow execution env(python) to register CheckSignals function
  to the TVM runtime.
- Add runtime::EnvCheckSignals to check the signal error.
- Add retry when EINTR is encountered in socket.
- Register the python C API functions in cython mode.

To testout the EnvCheckSignals, run the following code

```python
import tvm.testing
tvm.testing.run_check_signal(10)
```

Note that the C API functions are only registered in cython FFI mode
because ctypes have problems invoking these functions. This however
won't affect the correctness, but will defer the interrupt handling
to function return sites.

Co-authored-by: Andrew Reusch <areusch@octoml.ai>
Co-authored-by: Robert Kimball <bobkimball@gmail.com>

* Address comments

* Alternative implementation that preserves python exception.

* Address comments

* Update check signals

Co-authored-by: Andrew Reusch <areusch@octoml.ai>
Co-authored-by: Robert Kimball <bobkimball@gmail.com>
2021-05-14 21:17:14 -04:00
chiwwang e52b8172e9 Fix AttributeError when TEST_DATA_ROOT_PATH is set (#8047)
Initiate a Path object from TEST_DATA_ROOT_PATH to fix the error:
AttributeError: 'str' object has no attribute 'mkdir'
2021-05-14 17:51:23 -04:00
Jeffrey-Sima aa7bfe73d9 Pytorch Conv Transpose Padding Fix (#7958)
* fix conv transpose import from TF

* fix String::fromwe() to String::from()

* * fixing pytorch converter to take into account the output_padding parameter for conv transpose operations
* updating pytorch converter to correctly convert conv1d to conv1d in tvm inestead of a flattened conv2d unless under circumstances of grouped convolution
* updating pytorch converter to correctly convert conv1d transpose to conv1d transpose in tvm instead of a flattened conv2d transpose
* added tests to cover these latest additions

* * removing print statements used for debugging

* * fixing typos and formatting

* * fixing formatting

* * fixing grammar

* * formatting fixes

* * updated formatting after running pylint and python_format checks

Co-authored-by: Mikael Sevenier <mikael.sevenier@sima.ai>
2021-05-15 06:34:25 +09:00
Manupa Karunaratne 9272c023a9 [uTVM][AOT] Adding workspace byte alignment (#8019)
* Adding workspace byte alignment

* This commit adds byte alignment support for workspaces
* Updating AoT tests to use calculate workspaces

Change-Id: I88380d875269e1ffa4a51a9cceefd51b3042f1a7

* Adding workspace byte alignment

* fixed aot_memory cpp tests
* add new error type for stack allocator bad frees

Change-Id: Iadb4770ac761ef5edb80308e18120443d269c83d

* Adding workspace byte alignment

* addressing comments + LIFO change

Change-Id: I1e8ad47e11e220f879bf936da2abb3d111db89f0

* Adding workspace byte alignment

* addressing comments further

Change-Id: Idb07d28b55520d8897d7dbcb9ef4aad5e3e7b35c

* Adding workspace byte alignment

* addressing comments - add a default constant to alignment

Change-Id: Id3f486bfdc0bd57d54b3c4097885cb54675196ca
2021-05-14 10:54:12 -07:00
Nadav Eidelstein 6069a70760 Fix minor issues in the tvmc tune CLI (#8039)
* [TVMC] convert timeout flag to int

fixes Check failed: type_code_ == kDLInt (11 vs. 0) : expected int but got str
when setting the timeout option using the cli flag.

* [TVMC] fix typo in tvmc tune help
2021-05-14 10:07:06 -07:00
Yuchen Jin bd7cda9ad9 Rename gpu to cuda in java/rust/typescript (#8036)
* rename gpu to cuda in java/rust/typescript

* fix rpc test to call cuda
2021-05-14 08:07:45 -04:00
Josh Fromm c999a840cb [Relay][AlterOpLayout] Fix strided slice type change. (#8022)
* Fixed strided_slice alteroplayout bug.

* add test for non standard int8 conv2d padding.

* Add test for large index slices.

* Us same dtype as input in strided slice.
2021-05-13 10:26:27 -06:00
LiangLiu 158aeddd7f [ONNX] QLinearConv Support (#8007)
* Add QLinearConv for onnx frontend

* Reformat

* Squeeze 1D tensor for weight_scale & weight_zero_point

* Doing dequatize -> quantize if y_scale is not constant
2021-05-13 09:58:27 -06:00
Robert Kimball b81f3f7a7f Remove warning which is adding too much noise (#7975) 2021-05-13 10:00:15 -04:00
Zilin Zhu 39fa759906 fix docs of threefry_split and threefry_generate (#8035) 2021-05-13 09:22:07 -04:00
Yuchen Jin 43c2ea72bc Rename gpu to cuda, and bump dlpack to v0.5 (#8032) 2021-05-13 09:11:40 -04:00
Matthew Brookhart ed283b82bb support concat in recast (#8028) 2021-05-12 23:43:36 -07:00
anwang2009 0f41d47bb4 Remove minimum seed constraint on XGB Tuner (#7992)
* remove minimum seed

* reset 3rdparty dep

* add items to 'visited', parametrize min seed records

* add comment

* fix lint

* add tests
2021-05-11 10:44:01 -07:00
Josh Fromm c30f099b9e Fix bug with non-fp32 gemm in onnx frontend. (#8011) 2021-05-11 09:16:54 -07:00
alter-xp 2077ee2f9a add onnx reverse sequence op (#7771)
Co-authored-by: xp224797 <xp224797@alibaba-inc.com>
2021-05-10 09:58:26 -06:00
Trevor Morris 4c1a6aa956 [BYOC][TensorRT] Add nn.batch_matmul, nn.layer_norm, erf (#8005) 2021-05-08 09:35:53 -04:00
Manupa Karunaratne c0690496af Improved MLF to contain workspace info (#7938)
* Improved MLF to contain workspace info

Added functionality to calculate workspace, io and constant
memory required by each primfunc and main function. Moreover,
the workspace information required by each primfunc and main
is reported in metadata.json in the Model Library Format(MLF).
- added functionality to record tir and relay primfuncs
- added tests for model_library_format changes

Change-Id: Ib4a8b787345aa35f8a1645e8a648fad84de37bce

* Improved MLF to contain workspace info

* disable AoT for now
* addressing comments

Change-Id: I5f041ec461b02dac6ea9c96ea50eb400d55eef53

* Improved MLF to contain workspace info

* addressed comments
* added aot executor support

Change-Id: I9b54a7939d8ccb3c6ce0454f0fe62866ac66eb5c

* Improved MLF to contain workspace info

* removed redundant utils.py

Change-Id: I256dd88fab31a595bf9509bd1c4ab59b0c145b1e

* Improved MLF to contain workspace info

* removed redundant ffi api

Change-Id: I9ad6795aa839edfdfd05b902d4531fb0a20e894d
2021-05-07 14:54:40 -07:00
Siyuan Feng 4122a6aed4 [TensorIR] CreatePrimFunc from TE (#7987)
Co-authored-by: Tianqi Chen <tqchen@users.noreply.github.com>
Co-authored-by: Wuwei Lin <wuwei@apache.org>
Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>
2021-05-07 13:31:31 -07:00
zackcquic 254563a314 [RELAY] Enable registering op with python (#8002)
Add a new API register_op

Note: Implementing a op by pure python is still limited:
  1. Custom type relation (add_type_rel()) is still not
     available in python.

  2. Setting number inputs (set_num_inputs()) needs
     plevel > 128 in python.
     (see tests/python/relay/test_ir_op.py)
2021-05-07 11:29:02 -04:00
Yuchen Jin 8d9a1dfe77 [DLPACK] Support the new python array api with DLPack (#7993)
* [DLPACK] Support the new python array api with dlpack

* Fix lint
2021-05-06 22:51:49 -07:00
Trevor Morris d18186757c [Frontend][Keras] Support nested layers recursively in keras frontend (#7949)
* Support nested layers recursively in keras frontend

* Fix lint

* Fix issue

* Fix formatting

* Fix unit test
2021-05-06 11:13:24 -06:00
Tristan Konolige bbf7fdb8c0 [FIX] Fix autoscheduler tuning on sparse matrices where there are multiple with the same shape (#7974)
* [FIX] Fix autoscheduler tuning on sparse matrices where there are multiple with the same shape

* formatting

* remove unreachable code
2021-05-06 10:58:48 +08:00
Giuseppe Rossini f85cab2052 [AOT] Introducing AOT in TVM (#7785)
* [AOT] Introducing AOT in TVM

This change adds the code generation and minimal runtime API to use the
Ahead Of Time (AOT) compilation flow. The main logic is contained in:

- src/relay/backend/aot_codegen.cc

Which produces a TIR PrimFunc traversing the Relay graph

The runtime interface (authored by @mousius) leaves a gap for future
iterations using platform-specific features from RTOS.

Currently AOT runs successfully on x86 in a host OS, running these
tests on micro is coming soon.

This PR is based on the RFC described here: https://discuss.tvm.apache.org/t/implementing-aot-in-tvm/9206

Co-authored-by: Christopher Sidebottom <Christopher.Sidebottom@arm.com>
Change-Id: I9f731c953231f129e1472298915dddc01788efd7

* Rebasing 2

Change-Id: Ia0a533a49960f1cb4bf3c3833511e539cf7c459f

* Applying comments/refactoring

Change-Id: Iea1832355f8b1d4c921d02c6b4ceec7db3a681c1

* Fixing comments + refactoring - 2

Change-Id: I7200cc17b297e42bf67dcdef6f643e86991ca0a8

* fix linting

Change-Id: Iba6544ac7101595696b352b8702345cf916625f6

* fix linting - 2

Change-Id: I7f80d16005f2c621d37a9aae2cbbd61df0277cbe

* fix linting - 3

Change-Id: I7a1ba40afeea46d5f122563a20cd4b2f08751a1e

* fix tests

Change-Id: I1297ccc54dd6d93647f421e0beb226f410bf73f5

* Addressing comments - 3

Change-Id: Id25d1382c30d6d0a0013b5e8986fb8cd886666dc

* Addressing comments - 4

Change-Id: Ibe29676abe3b75161b5a0903e007118a8318d862

* fix tests - 2

Change-Id: I2117f9d4392bfd87102ecbef0993c8b320f479a0

* fix tests - 3

Change-Id: Ic0373543b0f9a54dbd4dc32d428272f7293200ba

* fix tests - 4

Change-Id: I8a6f229c9a3a9e169779c8d49cbfa3f473348b1f

* Addressing comments - 5

Change-Id: Ib9ccd07c87392034a21b2eb70955d0b091b780f1

* fix tests - 5

Change-Id: I4b13c3b548ced414991e83072e9e6fc99b64f939

* fix tests - 6

Change-Id: Id5af1f778ae25bc60849cc054a605181c1b7a765

* addressing comments - 6

Change-Id: Id94a2bbcaae891f9498d41be538f13a952f55b81

* fix linting - 4

Change-Id: I371a0aa5b81824b5a3a1278fac22ace57832027a

* add missing file

Change-Id: If359bef96dd0773ead4f75f0d9f5234276347e2d

* fix build

Change-Id: I73fc1feb6f7b5d454a528e3289228484dc2b07d5

* addressing comments - 7

Change-Id: I7f908f3908ffc77e408391f62edcc06f2600c6c2

* addressing comments - 8

Change-Id: I90bced4e18259a6d42e6a406d93958e204f3859e

* rebasing

Change-Id: Id28751b069bd046f00faee301b2b446b2ea4fab8

* Addressing comments - 9

Change-Id: I06c9f280de0a9bf0ca5545bbbbfcc70cb66831b3

* fix tests - 7

Change-Id: I739f29779862f05def36e5f3e0722019596d17f8

* Addressing comments - 9

Change-Id: Ie736f40a5225f4e56e79006753d7732127da5408

* Applying comments + fixing tests

Change-Id: I83e16068b93aaccc7a86b79d42f13328bc76b53d

* Applying comments - 10

Change-Id: I443d72f53913849f3c28fd6e416162d1ca99e647

* Addressing comments - 11

Change-Id: I7fefbd0076949b9c38d0abbf2759ebf1502de330

* Addressing comments - 11

Change-Id: Iad028144d7b394b2dd2fce41a35ca689d1680200

* fix tests - 7

Change-Id: I14286e665dcdba1e9bc10bb5a27dd6ced50372b0

* fixing tests -8

Change-Id: I7b4c966da9680870ceda1704c749ee3bdc751926

* fixing tests - 9

Change-Id: Icf62128a604998ed1b7d5af4cbeadf7d39196d0b

Co-authored-by: Christopher Sidebottom <Christopher.Sidebottom@arm.com>
2021-05-05 11:21:22 -07:00
Xingyu Zhou ae31a3399b [Frontend][Tensorflow]add batch_dim support for gatherV2 (#7951)
* add batch_dim support

* fix lint

* add check for num of arguments for topi.take

* fix gpu test cases

* add check for batch_dims in take_grad
2021-05-05 09:37:00 -07:00
Trevor Morris 26a5e299be [Frontend][Keras] Fix Dense with 3d inputs (#7753)
* Fix keras rnn dense

* Fix unit test

* Fix unit test
2021-05-04 18:46:26 -06:00
Tristan Konolige 9070c65889 [SPARSE] Improve sparse performance on ROCM (#7935)
* [SPARSE] Improve sparse performance on ROCM

The current sparse dense gpu kernel uses warp level storage to handling
caching of data. Warp level storage uses shuffle intrinsics, which are
slow on rocm (because they actually read and write to shared memory).
Rocm does provide intrinsics to do the correct memory management, but
they are not available through tvm. Instead this PR switches to using
shared memory on rocm devices. Performance is about 2x faster.

* default to shared mem

* formatting

* formatting
2021-05-05 04:25:06 +09:00
AndrewZhaoLuo 38e0bbed7d [ONNX][TOPI][Relay]Support dilations in pooling operators (#7928)
* change more pooling operators

dilations -> dilation to match old field names in conv

fix python interface into new relay nodes

fix order of arguments

update type relation for dilations

change topi interface to use dilations

* spooky, there are two implementations! Change to 1 topi

use generic poolnd instead of 2d implementation for topi

remove old pooling topi

* rename pool --> pool2d in topi

change pool -> pool2d, make topi tests work now

make op level 2 pass with interface changes

fix dilation being hardcoded to 1

proper calculation for avgs among dilations

proper avg pool padding behavior

change name of pool test to pool2d test

* add poolnd baseline implementation

more fixes to edge cases for poolnd, delete old versions

replace topi tests with new baseline python version

clean up tests

make tests more readable kind of

add dilation topi tests FINALLY

remove see_pool.py

remove dilation from grad

* fix subtle implementation detail between topi and baseline python pool op

* rewrite tests to be more generic for relay pooling ops

add relay dilation tests, FINALLY

add some comments to testing code

linting and formatting

add ASF header

make 10/10 for black formatting lol

more appeasing the formatting gods

wow

add parameters to documentation

fix test import

Jostle CI

fix more broken unit tests using old version of pool

fix wrong var used for bound calc

add dilation to arm tests

add docstring to python make funcs

* fix pattern utils out of place args

* properly forward more tests to use dilations in pooling

formatting

more formatting

relax constraints on test to make it pass

relax more constraints

fix some pytorch frontend errors

fix error

better test conditions

jostle build

* fix padding bug with ceil mode

jostle build

cleaner pool condition

remove see_pool.py again

* add dilations field to onnx importer

blacking files

black file

* address matthew's comments
2021-05-04 10:24:21 -06:00
Josh Fromm 18ce8e4b82 [TVMC] A simplified TVMC API for python scripting (Part 1). (#7823)
* Introduce new TVMC Python API.

* Add simple testing model.

* Split result utils into stand-alone file.
2021-05-04 07:59:34 -07:00
Trevor Morris 0e3d850983 [BYOC][TensorRT] Fixes for explicit batch mode, Support reduce to scalar, Support split op (#7967) 2021-05-04 01:06:32 -07:00
Tianqi Chen 284faf241f [RPC] Make tracker jupyter friendly (#7961)
This PR uses the PopenWorker to handle the tracker start up
and makes the tracker jupyter friendly.
2021-05-03 13:41:02 -07:00
Siyuan Feng 22c8f8cca5 [TensorIR][Pass][M1c] FlattenBuffer (#7962)
Co-authored-by: Tianqi Chen <tqchen@users.noreply.github.com>
Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>
2021-05-03 10:28:28 -07:00
Mehrdad Hessar 8c56ce3b90 [Graph Executor Debugger] Fix parameter dump (#7903)
* remove debug mode

* reformat

* format

* address comments

* add single call for all layers

* fix test

* revert

* address comments

* address comments

* fix rerun node

* fix error

* format

* raise error on array()

* fix java

* Revert "fix java"

This reverts commit c4cf952dbc5c9c32d65ef0ca05d6ecbb5c06d5aa.

* bring back for java api

* fix error

* cleanup

* format

* rm redundancy

* add last execution track

* trigger build

* address comments

* format

* fix name overlap

* Trigger Build

* trigger build

* trigger

* trigger
2021-05-03 10:17:05 -07:00
Josh Fromm cea7cf16ce Improve dtype detection in loop to fix onnx tests. (#7934) 2021-05-03 09:16:27 -06:00
Matthew Brookhart c380a699e2 [ONNX] More Unit Tests! (#7956)
* support same lower and maxpool in autopad

* fix isinf tests

* lower tolerance on roialign test becuase the onnx result is cropped to 4 decimal places

* slow support for bottom-k

* throw with nullptr in gathernd and scatternd, fix typo

* fix lint

* fix a copy typo
2021-05-03 13:02:29 +09:00
Tianqi Chen dd5379f88a [NVCC] Bugfix nvcc command tool that relies on the compile time env (#7964)
* [NVCC] Bugfix nvcc command tool that relies on the compile time env

* Update python/tvm/contrib/nvcc.py

Co-authored-by: Cody Yu <comaniac0422@gmail.com>

Co-authored-by: Cody Yu <comaniac0422@gmail.com>
2021-05-03 13:01:15 +09:00