Commit Graph

3326 Commits

Author SHA1 Message Date
Hans Brouwer 122be3fb18 Add group_conv2d_transpose_nchw to CUDA backend (#10423)
* add group_conv2d_transpose_nchw to CUDA backend

* simplify significantly, just add groups argument to conv2d_transpose_nchw
2022-03-02 12:48:49 +09:00
Kirill Snezhko bd14a4d36e Modify debug output (#10372)
1. Modify debug output to make it more readable
3. Replace magic number with a variable `error_ct_threshold`
3. Add function to set error counter threshold externally for debug purposes
2022-03-01 19:30:07 +09:00
chiwwang 111b2da137 RelayViz Graphviz renderer (#10400)
Following https://github.com/apache/tvm/pull/10085, this PR adds a
graphviz backend. It requires python `graphviz` package and `dot`
executable in the PATH, similar to `tedd.py`.

This implementation is much like a porting of `visualize` function in
https://tvm.apache.org/2020/07/14/bert-pytorch-tvm, except that
`node_attr_dict` is replaced with a callback `get_node_attr`.

`get_node_attr` can be somehow used to emphasize a set of nodes.
It might be useful if we encounter problems in inferences
and want to find nodes with certain types and attributes.

An example is provided in
https://github.com/chiwwang/tvm/blob/graphviz_renderer_example/test_viz.py

Its outputs are (conv2d with NCHW layout is green-colored):
https://github.com/chiwwang/tvm/blob/graphviz_renderer_example/mod_with_subgraph.pdf
https://github.com/chiwwang/tvm/blob/graphviz_renderer_example/mod_wo_subgraph.pdf
2022-03-01 12:50:33 +09:00
David Riazati 5b5d969b0c Add @slow decorator to run tests on main (#10057)
* Add @slow decorator to run tests on `main`

This adds the infrastructure discussed in https://discuss.tvm.apache.org/t/rfc-ci-skip-slow-tests-on-prs/11910, but without affecting any tests. As we investigate reasons behind [slow tests](https://gist.github.com/driazati/e009f09ff44c6bc91c4d95a8e17fd6f1) in CI, this decorator will allow us to move these to run only on `main` and not PRs after checking with all concerned parties.

* cleanup

Co-authored-by: driazati <driazati@users.noreply.github.com>
2022-02-28 10:59:57 -08:00
Bohan Hou 9ca2139d0f [TensorIR] Renormalize split pattern (#10401) 2022-02-28 04:01:04 -05:00
Ophir Frish b7caa128df Fixed a bug in the convert_fully_connected() function (#10371)
In case we need to change the output shape, need to convert the output_shape tuple to list before the change.
2022-02-28 08:12:31 +00:00
Hans Brouwer 40f881b958 Enable groups argument for conv2d_transpose on the cudnn backend (#10396)
* wip

* reset conv2d_transpose topi conv_mode to 1

* fix for 'Error: identifier “hfabs” is undefined'

* address @masahi's comments in pytorch test_forward

Co-authored-by: Masahiro Masuda <masahi129@gmail.com>
2022-02-28 09:28:56 +09:00
Andrew Reusch 01f306ffb7 Fix tvmc run error message when inputs aren't found. (#10017) 2022-02-26 12:37:52 -08:00
Hongyi Jin 4a9db23bb2 meta schedule misc update (#10389) 2022-02-26 19:52:07 +09:00
Hua Jiang 37f7e57a04 Fix plint error. (#10394)
plint complain error in parser.py and test_vm.py just fix it.
2022-02-26 18:08:45 +09:00
Zihao Ye 920654cf91 [Bugfix][TVMScript] Convert BufferSlice to BufferLoad when used as range/loop start and end (#10370)
A quick fix of the parser issue mentioned in #10327 .
Ranges and loops require `start` and `stop` to be PrimExpr, however, `BufferSlice` is not always scalar so it's not a `PrimExpr`.
This PR performs the transformation.
2022-02-25 13:49:05 -08:00
Xiyou Zhou b31a5ccb6a [MetaSchedule] Update Tuning Interfaces. (#10367)
This PR is further improvement of the meta schedule project (https://github.com/apache/tvm/issues/8473).

Co-authored-by: Junru Shao <<junrushao1994@gmail.com>>
Co-authored-by: Bohan Hou <<32121147+spectrometerHBH@users.noreply.github.com>>
Co-authored-by: Ruihang Lai <<lairuihangdongdong@qq.com>>
Co-authored-by: Hongyi Jin <<3231950289@qq.com>>
Co-authored-by: Wuwei Lin <<wuwei@apache.org>>
Co-authored-by: Siyuan Feng <<Hzfengsy@sjtu.edu.cn>>
2022-02-25 13:44:34 -08:00
Valery Chernov d62a364ba7 [VirtualMachine] new method allowing to set one input tensor by its index or name (#10293)
* set_input_with_index was implemented for VM

* clean code

* add getInputIndexFromName. add function descriptions. lint fix

* fix lint

* transfer comparison of parameter names number and assigned devices number to VMFunction constructor

* add GetVMFunctionWithName to Executable API

* clean code

* add SetInputWithName (set_input_with_name) to VM API

* join SetInputWithIndex and SetInputWithName to SetOneInputTensor (set_one_input) to VM API, the joined methods were removed

* fix lint

* some fixes after review

* add set_one_input method to python API of VirtualMachine

* pytests for set_input and set_one_input methods of VirtualMachine were implemented and checked

* CI restart

* construct simple model for pytests by relay instead of onnx tools (need for correct CI)

Co-authored-by: Valery Chernov <valery.chernov@deelvin.com>
2022-02-26 05:46:01 +09:00
Manupa Karunaratne d9fac4f305 [microNPU] adding more tests with USMP (#10362)
Adding a few tests to confirm memory usage
with and without USMP.

- Supporting the toggle to disable storage_rewrite.
- There is a slight change to tir_to_cs_translator to
   add index of Load nodes associated with NpuAddressRange objects
2022-02-25 11:28:50 +00:00
Krzysztof Parzyszek cb7f773218 [Hexagon] RPC server/client for simulator (#10361)
This is the C++ code for running Hexagon code on simulator via the
RPC mechanism. It is intended to be integrated into the current
HexagonLauncher, although the integration will require further changes
to the launcher python code.

The final goal is to be able to run the same file.py on either
hardware or simulator without needing to edit the python file, but
simply by changing the configuration of the execution platform
(i.e. something like --exectute-on=simulator as a command line or
in an environment variable). The exact details are still to be
determined.
2022-02-24 07:33:47 -06:00
Hua Jiang 4102ebf239 [Runtime][Pipeline Executor] multiple threads management and the data forwarding notification mechanism. (#10234)
* [Runtime][Pipeline Executor] multiple threads management and the
data forwarding notification mechanism.

In this patch we create working threads for each runtime of pipeline.
the threads would be terminated once the runtime class gets destroyed.

We also add a notification mechanism derived from the 'binding configuration'
of the runtime to forward the data notification.

* address review comments.

* address review comments.

* fix typo.

* fix typo.

* trigger build.

* address review comments.

* address review comments.

* address review comments.

* address review comments.
2022-02-24 20:10:20 +09:00
Matthew Barrett f1ff61a7b9 [microNPU][4] Add the cascader Proposal generator (#9959)
* [microNPU][4] Add the cascader Proposal generator

The Proposal generator takes optimal Plans and combines
them to find optimal 'Proposals' - sets of disjoint
Plans that cover every Part in a CascaderGraph. It
ultimately produces a Pareto-frontier of 'optimal'
Proposals in terms of estimated cycles and memory usage.

Change-Id: Id42099819a596496a5769bae22f08eeb75ec69b6

* Fixes

Change-Id: I4f5f2a298bd3bb379c7c8d179150358923b0dd66
2022-02-24 10:48:10 +00:00
Qiang Zhang b329544fc2 [Lint] Fix Pylint Issues (#10358) 2022-02-23 22:46:47 -08:00
David Riazati fbea56992d [skip ci] Fix onnx frontend lint (#10363)
This was broken in #10267, not sure how that commit passed CI (maybe some logic to figure out the PR diff in pylint is broken).

Co-authored-by: driazati <driazati@users.noreply.github.com>
2022-02-24 05:54:10 +09:00
SebastianBoblestETAS cc82214530 refactored GraphProto.from_onnx into smaller functions (#10267)
* refactored GraphProto.from_onnx into smaller functions

* black formatted file

* removed line that does not seem to make sense. Is there a purpose that I missed?

* just to trigger CI pipeline
2022-02-23 09:48:57 -08:00
Masahiro Masuda 894772975a [TOPI] VNNI support for batch matmul (#10332)
* add test

* compute added

* schedule works

* reuse dense_vnni schedule

* try an alternative approach to scheduling layout transform

* introduce a tunable knob to decide if compute_root

* check transpose condition

* support s8 + s8 input

* pylint
2022-02-23 21:38:57 +09:00
Sevin F. Varoglu faa2e6ad57 Add per channel quantization to QLinearConv and fix related bugs (#10354) 2022-02-23 19:09:20 +09:00
Masahiro Masuda 0abb1bdb04 [CUBLAS] Fix cublas batch matmul strategy plevel (#10351) 2022-02-23 17:18:57 +09:00
Ruihang Lai 270c1b3219 [TIR] Misc minor updates (#10335) 2022-02-23 15:16:03 +08:00
Tristan Konolige 6c6e873a13 [ARM_CPU] Conv2d int8 intrinsic for cortex-A72 (#10310)
* [ARM_CPU] Conv2d int8 intrinsic for cortex-A72

Add an intrinsic that performs a dot product of 8 4-element vectors at
once. Also conditionally inline fused operators into the main
convolution loop depending on convolutions size. Small convolution = no
inlining. Performance improves by ~20% on mobilenet on raspberry pi 4
and ~30% improvement on performance for the individual convolutions.

* ignore incorrect lints

* fixup fstring

* revert changes to conv2d_NCHWc (not int8)

* remove error check, apparently tests rely on it

* refactor alter op layout
2022-02-23 11:51:24 +09:00
Dmitriy Smirnov b5f1dabce4 [TIR] Tir constants integration into compilation pipeline (#8509)
* [TIR] Introduce tir.allocate_const to TIR

This PR is adding non-scalar constant representation in TIR. This is used to
express constants (i.e., parameters) in the TIR instead of bypassing the
TIR as it's done until now.

Change-Id: Id3afc4d7197260cb43ecde60f05ccbce3fc42430

Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Change-Id: Id4a09a637c9c1fd7d49989c6c10f474a78569e18

* [TIR] Integrate tir constant nodes in compilation pipeline

This PR integrates tir.allocate_const to the compilation pipeline to support --link-params.

Change-Id: Ic8d0cb75d596299fcae7078b304598afbf0c5494

Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Change-Id: Id98cc682bbfacfe75c4d8b260fd41658f1f196b2

* [TIR] tir.const extraction

This commit tries to implement an amendment to tir.constant RFC
with centralized storage of constant data within the IRModule
Please note that data and irmod_storage_idx are not mutual exclisive
further more the irmod_storage_idx is valid only immediatly after
prim func addition to the mod or after update within the mod.
If prim func is out of the the module scope then the index become
meangless. irmod_storage_idx also is not used in calculation of hash
function of the tir.constant node.

Change-Id: I40742ed580468b0252ea3fec02184cba65e20871

* unit test fixed

Change-Id: Ied2186554d4cbad44b2346216c8be92449e55732

* cmsis-nn codegen fix

Now handled case when params of the functions came as constants

Change-Id: I5874e182e34ef94e23048eaf3c61b01a56d91131

* Fixes for unittests

Change-Id: I5b82ee3f80337155706b5470973f494a301b5d90

* Rebasing tests fixes

Change-Id: I94ac87907081bab53c1dd1ab2db106ae057b4b19

* Linter: added method param description

Change-Id: I2f8c4c8d244b74c794abaa6079c46cc593ffcbdb

* Printing removal fix

This patch removes forgotten print in fuse_ops

Change-Id: I4bb5934f3b4cd5fde19d36a8e3319aae136bce8a

* Bugfix

Fixed concurrent map update bug here

Change-Id: Ifec3bf5030086d9079b9e493096f17dfd82297ec

* Reworked logic for not to introduce empty constant list to modue attrs

Change-Id: I082c85b3b4b70c218f0d714f5613ef6e178bd020

* Added support for tir builtin::tvm_access_ptr

This fixed unit tests for tests/python/integration/test_arm_mprofile_dsp.py

Change-Id: I10919f301ef9ddc3fd87f0e1a8414e9a52fc7938

* Unit test fix

Fixes unit tests in torch frontend

Change-Id: I6c179834f93dd202605d1ce5a7f07d987b9dc469

* Addressed requested changes

Addressed changes requested upstream

Change-Id: I741e52b89eb285732c23b1ac7ff277e757a088c3

* Namespace usage changed to conform earlier C++ standard

Change-Id: I1b29238cfe2a6bedb525f4f823a3a540f631d836

* Bugfix

Change-Id: I57a44b714b307278a243817ec2864e53ad31366b

* updated IRModuleNode::ExtractPrimFuncConstants

Updated IRModuleNode::ExtractPrimFuncConstants as per
request upstream.

Change-Id: I35db0145fb5827efd0445ce665d0c99465274016

* Minor changes

typo fixd
renamed ExtractPrimFuncConstants to ExtractConstants
removed getters/setters from FuseMutator and added parametrized
constructor

Change-Id: Ib2326805781779b88c963a8642ff683c8755956e

* Moved LinkedParam/LinkedParamNode

Moved LinkedParam/LinkedParamNode from tvm::tir namespace to tvm
namespace

Change-Id: Ie3f0303bd4f7890c6d680268c91f2051977bc7f4

* Addressed upstream comments

Changed BindParams argument to Array<NDArray>
Removed 'name' argument from te.const
Switched to in-depth comparision of NDArrays in constant de-duplication
Removed extra final comma from NDArrayToTIR
Changed return type of ConstantAllocationSize to int64_t
Made link_param a tvm.testing.parameter for test_fuse_take and test_fuse_gather_nd

Change-Id: I4285099cc63756aa5ebe91a5bd207d4135499b41

* Removed unnecessary forward declaration

+linter

Change-Id: I2a6c0d1f97773aeb1ae3f458da252a22079ccdb1

* Constant extractor now is a separate pass

Change-Id: Ia4adca9d3315b26fbdc006ef7c115900c081e303

* Added forgotten file + unit test fix

Change-Id: Ice305f4fefd13fe95e97574e6d63ffeb664621df

* Changed to IRModule pass

Refactored ExtractPrimFuncConstants to IRModule pass.
deDup -> DeDup
Refactored logic of Applicator supplementary class

Change-Id: I6c120d175eb6790ba90f176c4f856bde8f0c7c94

* bugfix after rebasing

Change-Id: Ie3ee6ea2479476a30f486baef74f20070f117942

* -v -> -vv to have more debug information

Change-Id: I12c63731663b9c9ea574b9ed5cb17311ba3cf701

Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
2022-02-22 23:33:30 +00:00
Matthew Brookhart 5956125ae4 [ONNX] only broadcast matmul if the shape has changed (#10321)
* [ONNX] only broadcast matmul if the shape has changed

* fix copy-pasta mistake
2022-02-22 15:36:31 -07:00
Masahiro Masuda 91b2e91b02 [Hexagon] Export ir_lower_vtcm_pass function in the init file (#10330) 2022-02-22 08:19:35 -06:00
chiwwang 55cfc4ad2d RelayViz interface and terminal ast-dump (#10085)
* RelayViz interface and terminal ast-dump.

This PR follows https://github.com/apache/tvm/pull/8668, with splitting
out interfaces class and terminal ast-dump implementation.

This visualizer is aimed for quick look-then-fix, so the interface is
simple. Despite that, customization is still possbile through
implementing interfaces defined in `interface.py` or overriding existent
implementations inside a renderer module, like `terminal.py`.

A tutorial is also provided in this PR.

A graphviz renderer will also be contributed after this PR.

* lint and typo
2022-02-22 11:41:40 +09:00
Ivy Zhang 9dd62b4ddb [BYOC-DNNL] add support for more ops and fusion patterns
[BYOC-DNNL] add support for more ops and fusion patterns
2022-02-22 10:41:31 +09:00
chiwwang d8d28bf509 [Relay] Fix TFlite frontend for unpack, stridedslice (#10333)
We found this while converting an RNN model.

The relay tflite frontend use squeeze at converting unpack, but when the
unpack.axis=0, `None` is passed to relay.squeeze(), which would squeeze
all dimensions with length 1, causing different results from TFLite.

A possible fix might be, assign the unpack.axis as-is to relay.squeeze()

As for stridedslice, when the tflite frontend handles shrink_axis_mask,
the wrapped `begin` should be used, instead of the original one which
can be negative. It can cause errors at
https://github.com/apache/tvm/blob/d65ff6594d4d6db0062537a1d43c0504173b8e5c/include/tvm/topi/detail/strided_slice.h#L140

Related cases are also added to the python test.
2022-02-22 09:05:27 +09:00
chiwwang 5a22c5609a [Docs] Fix an irrelevant sentence in relay.reverse (#10331)
It seems the sentence is from relay.repeat() and not related to
relay.reverse().
2022-02-22 05:05:17 +09:00
Manupa Karunaratne 2f937801de [microNPU] enable USMP (#10022)
This commit enables USMP in the microNPU codegen
and tests. The microNPU codegen is modified to
support Let nodes that are produced as from USMP.
2022-02-21 11:02:12 +00:00
Grant Watson 81df151935 Generate correct output tensor names in C Interface API (#10191) 2022-02-21 10:25:55 +00:00
Youlei Yang 8d7607581d [TIR] add support for multi-blocking layout and their transformation (#9996)
* add ceildiv and shapediv

* add boundary checking in layout_transform

* support multi-blocking and shape padding

* refine the log for shape transform

* add test for multi-blocking layout transform

* delete unwanted comments

* remove workaround

* fix lint errors
2022-02-21 14:02:16 +09:00
Colin Y. Li 73cf51b824 [TE][Fix] Comparison of the output tensor (#9829)
* [TE][Fix] Comparison of the output tensor

* fix hybrid op issue

* fix tensor replacement in schedule ops

* fix compute inline
2022-02-20 09:12:31 +08:00
Tristan Konolige 2c0a7c2a7e [TOPI] Add support for groupped conv3d (#9873)
* [TOPI] Add support for groupped conv3d

Change conv3d to use generic conv implementation which supports groupped
convolutions. Also, remove support for non-float16 tensorcore operations
as they cause large degradation in accuracy. Generic conv now supports
autoscheduler.

* correct none check

* add tests for floordiv simplification

* fixed incorrect test for autoscheduler

* formatting

* add groups to winograd

* fix tensorcore

* manually simplify index instead of relying on simplifier

* formatting

* add groups argument to conv3d_ncdhw_winograd_without_weight_transform

* formatting
2022-02-19 06:18:01 +09:00
Eric Lunderberg ffd517ad6e [UnitTest] Disable ptx mma tests on unsupported nvcc versions. (#10229)
* [UnitTest] Disable ptx mma tests on unsupported nvcc versions.

- Modified `tvm.contrib.nvcc.get_cuda_version` to return a
  `(major,minor,release)` tuple rather than a float.

- Implemented `tvm.testing.requries_nvcc_version` decorator to specify
  the minimum `(major,minor,release)` version needed to run a unit
  test.

- Applied decorated to unit tests in `test_tir_ptx_mma.py` that fail
  on earlier nvcc versions.

* Fix lint errors.

* Updated a few of the cuda version checks.

* More lint fixes.

* Only compare major/minor in find_libdevice, not release version.
2022-02-18 22:05:43 +09:00
AndrewZhaoLuo d716c2ae9c [FQ2I] Add support for some unary operators (#10273)
* initial commit

* lint
2022-02-18 16:07:46 +09:00
Wuwei Lin 316c5065d4 [TIR] Add software pipelining (#10066)
* [TIR] Add software pipelining

Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Xiyou Zhou <xiyou@octoml.ai>
Co-authored-by: Bohan Hou <32121147+spectrometerHBH@users.noreply.github.com>
Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
Co-authored-by: Hongyi Jin <3231950289@qq.com>
Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>

* fix

* fix

* lint

* fix

* format

* doc

* remove print

* lint

* lint

* doc

* Apply suggestions from code review

Co-authored-by: Junru Shao <junrushao1994@gmail.com>

* address comments

* address comments

* refactor FragmentInfo::GetSize

* remove unused

* refactor

* address comments

Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Xiyou Zhou <xiyou@octoml.ai>
Co-authored-by: Bohan Hou <32121147+spectrometerHBH@users.noreply.github.com>
Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
Co-authored-by: Hongyi Jin <3231950289@qq.com>
Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>
2022-02-17 22:16:18 -08:00
Alexey Voronov 7f249545c7 Add a conversion of individual operations in FQ2I pass. (#10239)
* Add a conversion of individual operations in FQ2I pass.

* apply review comments

* apply review comments 2
2022-02-17 11:15:49 -08:00
lhutton1 93cbadb75d [microNPU] Add support for LeakyReLU (#10127)
* [microNPU] Add support for LeakyReLU

Adds support for offloading an int8 Leaky ReLU activation function
to the NPU by legalizing to a LUT.

Change-Id: I63dd5b16a1a2a747b11f15a5b8124810e2ebf491

* refactor LeakyReLUParams to inherit from LutActivationParams

Change-Id: I35b59200b16a7eff1915f771ab6b5d9181d4f3ab
2022-02-17 06:52:03 +00:00
Josh Fromm f983769c59 [TVMC] Add an end_to_end benchmarking argument when benchmarking. (#10256)
* Add an end_to_end benchmarking argument to TVMC run.

* Add command line test.

* Fix comment syntax.

* Set device to cpu if end_to_end is on.

* Tickle CI
2022-02-17 10:28:06 +09:00
Piotr eF 75122db551 fix RPC waiting for device (#10255)
Co-authored-by: pfk-beta <this_email_isnot_working@gmail.com>
2022-02-17 05:49:30 +09:00
AndrewZhaoLuo 64e94abcbb [QNN] Register a bunch of unary elementwise ops (#10086)
* 0;276;0cinitial commit

* register a bunch of ops

* unary ops

* add a bunch of tests

* 0;276;0crefactor tests

* add tests to qnn

* comments on macros

* add back in log to pattern utils

* update floating point func description

* proper creating of calls to quantize and dequantize

* fix lowering process for using dequantize and quantize ops
2022-02-16 08:50:47 +09:00
Masahiro Masuda 0009a308d8 [TOPI] VNNI support for int8 dense (#10230)
* wip

* revert for now

* simplify blocking

* add bench script

* update type rel

* refactor tests

* end to end compilation working

* paralleize outer loop

* add shape check

* fused schedule first cut

* restore original test

* black

* add vnni check

* add relay test

* skip on ci

* check dtype

* lint

* make it tunable

* minor cleanup
2022-02-15 12:44:02 +09:00
Masahiro Masuda de73b99f72 [Torch] Fix conv2d transpose with group (#10235)
* [Torch] Fix conv2d transpose with group

* lint

* wrong issue number

* do not run test on cuda
2022-02-14 17:39:31 -08:00
Colin Y. Li ac9bf1fb8f [TVMC] Add configuration tir.add_lower_pass to option --pass-config (#9817) 2022-02-14 14:14:24 +00:00
Manupa Karunaratne 55849e651e [USMP] adding support for U2 and U3 usecases (#10193)
This commit adds a MemoryPools argument for
the compilation flow according to RFC0029.

Moreover, it is used to provide support for
external pools from the application layer
that could be pinned for different memories
and/or be reused between multiple inferences
of a model.
2022-02-14 09:54:06 +00:00
Siyuan Feng bb60ee96c0 [PyTorch] add var_mean support (#10233)
* [PyTorch] add var_mean support

* update mean_variance
2022-02-13 22:28:22 +09:00