Commit Graph

3885 Commits

Author SHA1 Message Date
Farshid Salemi Parizi 48354ded38 [Hexagon] Add skip option for RPC server initialization (#12368)
* add hardware parallelism in hexagon

* fix name

* lint issue

* better description
2022-08-11 12:23:06 -07:00
Florin Blanaru ecfd9692a0 Unify name mangling in TVM (#12066)
* Add NameSupply and GlobalVarSupply

* Build GlobalVarSupply from IRModules instead of having it attached to an IRModule.

* Pass GlobalVarSupply when lowering shape funcs

* Partially replace instantiations of GlobalVar with GlobalVarSupply

* Construct GlobalVarSupply from IRModule

* Add tests for supply

* Add documentation for NameSupply and GlobalVarSupply

Co-authored-by: Florin-Gabriel Blanaru <fgb@system76-pc.localdomain>
2022-08-11 09:18:46 -07:00
Greg Bonik f5f5a75ae9 [TVMScript] Text underlining in DocPrinter based on Doc's source_paths (#12344)
This adds an ability to print a "diagnostic marker" based on a given ObjectPath. For example, say we are printing a fragment of TIR like
```
for i in T.serial(10):
    a[i] = 5
```
and we would like bring the user's attention to the bound of the loop:
```
for i in T.serial(10):
                  ^^
    a[i] = 5
```
In this case we would give the doc printer an object path that represents this loop bound, i.e. something like `path_to_underline=ObjectPath.root().attr("extent")`

Tracking issue: https://github.com/apache/tvm/issues/11912
2022-08-10 22:43:54 -07:00
driazati 06ac5cde84 [testing] Remove wrapper from @slow (#11566)
This makes it a normal pytest decorator so it doesn't incur test set up / tear down. This also makes the PR body the source of truth for skipping slow tests or not since it can be confusing sourcing it both from the PR and commit message.
2022-08-10 14:35:48 -07:00
Ivy Zhang 22ba659438 [BYOC-DNNL] add partition test on sum pattern (#12357)
* add partition test on sum pattern

* fix lint
2022-08-10 20:16:03 +09:00
kuizhiqing 7f100158a5 [DOCS] Fix tvm.build API doc layout
The newline in the pydoc breaks the layout of parameter inputs in API `tvm.build`
2022-08-10 10:45:07 +01:00
masahi 1a98ea2e4f [TIR] Minor fix to tensor intrin description (#12356) 2022-08-09 22:17:17 -07:00
Wuwei Lin a6c3b1f6c3 [TIR] Add int8 CUDA tensor core intrinsics (#12354) 2022-08-09 19:40:20 -07:00
Tristan Konolige 0c281b7064 [FIX,STORAGE REWRITE] Rewrite buffers in let statements (#12349)
Storage rewrite was missing a visitor for let statements so buffers
added in them would still refer to the pre-rewritten version. This error
was originally noticed when using `global.vtcm` buffers which get
changed to let statements by LowerVtcmAlloc.

Implementing the test for this change also required adding support for
vectorized datatypes to tvmscript. The solution included is a little
hacky and involes adding the datatypes to the `global()` table of each
module they need to be defined in.
2022-08-09 17:25:59 -07:00
Black 811584992c Infer the value of shape expr to avoid dynamic (#12313) 2022-08-09 17:09:17 -07:00
Josh Fromm aea82c6417 [MetaSchedule] Extend tune_tir to support tuning of specific blocks. (#12342)
* Added optional target blocks.

* Checkpoint for debugging.

* Building with packedfunc filter.

* Extended tune_tir API to support named blocks.

* Remove accidental import.

* Improve integration test.

* Change names for more consistency.

* Update integration test.
2022-08-09 14:44:26 -07:00
NaNAGISaSA 52d6b59a39 [AutoTVM][Fix] Fix wrong axis names of data_vec (#12303)
This PR is trying to fix the wrong axis names of data_vec. As the data_vec is nchwc format, the axis names should be batch, ic_chunk, ih, iw, ic_block, but not batch, ic_chunk, ih, ic_block, iw.
Although the following code does not use these last two axises, so it does not cause some bugs for now. But I think we should fix this.
2022-08-09 10:38:27 -07:00
Michael J. Klaiber 4c4fcee4c2 [UMA] UMA v1.0 (#12087)
* Add minimal working structure for generic interface

* Separate target definition from codegen

* Update file structure to support multiple NPU targets

* Add scheduling and pass support to codegen

* Update schedule function and pass registration

* Add generic partitioner for relay graph partitioning

* Add pattern-based relay graph partitioning and AOT codegen

* Update API

* Add UltraTrail relay passes and schedule function

* Update UltraTrail relay passes

* Add tir_to_runtime hook for UltraTrail

* Add operator strategy registration to lowering

* Add option to pass constants as attributes

* Refactor naming: Generic to UMA

* Change API to single user-facing backend class UMABackend

* Add initial codegen API

* [UMA] add a generic packed function to register targets

* Restructure files and add initial codegen

* Minor code cleanup

* Add UMA config and MergeCompilerRegion example

* Move UMA configuration to init parameters

* Add python hooks for C-codegen. Still has known restrictons

* Fix relay_to_tir hook to keep virtual device in main function

* Remove register schedules, scheduling is moved to passes for now

* Remove extract constants since non-scalar constants are now supported by TVM

* API documentation and some code fixes and cleanup

* Fix typo

* Fix UMA lowering

* Prototype for UMA-based target attribute registration

* Add default option and type deduction to register_target_attr

* Change pass phases to enum

* [Relay] Plumb external codegen target via Target.current() for all external codegen paths

(See https://discuss.tvm.apache.org/t/byoc-supporting-cutlass-byoc-with-collage/12796/6 for
context, which in turn is part of Collage (https://github.com/apache/tvm-rfcs/blob/main/rfcs/0062-collage.md).

We want both old-style (via relay.ext.$toolchain) and new-style (via "RelayToTIR" Pass
attribute on target kind) external codegen to be able to access the current 'external codegen'
Target instance via Target.current().

 - For old-style, plumb the true Target through TEComplier and push it on the context
   stack before calling relay.ext.$toolchain.

 - For new-style, pass the CompilationConfig to the RelayToTIRTargetHook pass, make the jump from
   "Compiler" attribute value to Target via the new CompilationConfig::FindPrimitiveTargetForKind
   method, and push on the stack before invoking the custom "RelayToTIR" pass.

While working on this discovered RelayToTIRTargetHook was incompatible with the VM's compilation
flow since RelayToTIRTargetHook assumes all "Compiler" attributed functions are inlined. Generalize
it to support both inline and global function styles.

Extend Target::IsExternalCodegen to recognize target kinds with "RelayToTIR" attributes as
external.

Update target hooks unit test to exercise new support for outline-style, picking up the current target,
and compiling via the VM.

* Use current target in lowering

* Use attr:kRelayToTIR

* Remove erronousely commited quick fix

* Towards test cases for uma

* Add test_uma

* Initial UMA structure for version 1

* [UMA]: conv2d unit test

* [UMA] update of tutorial

* [UMA] update of pass format, still issue with conv2d c code

* [UMA] refactoring of test_uma_lowering_with_umalower.py

* [UMA] refactoring of test_uma_lowering_with_umalower.py

* [UMA] Adding backend, codegen, patterns, strategies and run file for MyAiHw

* [UMA] update towards my_ai_hw usecase

* [UMA] working testcase for conv2d with uma

* [UMA] testcase

* [UMA] uma lower.py: replaced outdated function create_prim_func_from_outputs to be compatible withe latest content of "main"

* UMA: Move torch import to top to avoid free(): invalid pointer error

* Add stub files for targets

* Add tests for ultratrail codegen

* Adopt my_ai_hw accelerator for new target definition

* Add unit test for target attributes

* Test string arguments

* Extend target test

* [UMA] tutorial first versin

* [UMA] moved unit tests to contrib

* [UMA] renaming interfaces

* Fix umalower_tests in ci

* make uma a python module

* [UMA] Update of UMAv1 API + added testcases + tutorialV1

* [UMA] UMAv1

* [UMA] cmake file updated

* AOT test infrastructure adapted

* UMA: add __init__.py for uma.api

* Finish uma tests

* Use upstream version of dmlc-core

* [UMA] tir_to_runtime documentation update

* [UMA] cleanup

* [UMA] fix for test_partition

* [UMA] lint fix

* [UMA] lint fix

* [UMA] lint fix

* [UMA] lint fix

* [UMA] fix of build scripts for arm and i386

* Fix remaining linter errors

* [UMA] CMakeLists.txt added UMA tvm_option

* [UMA] added UMA tvm_option

* [UMA] guard against multiple registrations

* [UMA] fixed comments as pointed out in PR 12087

* [UMA] fixed comments as pointed out in PR 12087

* [UMA] skip uma tests if uma is not available

* [UMA] added UMA rst

* [UMA] Moved tutorial to RST file in gallery

* [UMA] moved uma cli to apps

* [UMA] change requests according to PR-12087

* [UMA] update and sync of uma_cli and tutorial

* [UMA] update of template passe: remove Pad block of Conv2D

* [UMA] lint updates

* [UMA] Test updates

* [UMA] fixes according to comments from PR 12087 discussion

* [UMA] lint updates

* [UMA] moved UMA _template file to apps

* [UMA] lint

* [UMA] Remove exceptions when dispatching over targets

* [UMA] vanilla pattern update

* [UMA] added mobilenet integration test

* [UMA] clang lint

* Remove tir to runtime

* [UMA] Use sequential for UMA relay passes

* Use comparison against BYOC flow in test_partition

* [UMA] tutorial update: moved code blocks to RST

* [UMA] tutorial update and lint fixes

* [UMA]  removing UMA from i386 build, as there is a fail in the CI pipeline due to missing CLANG for i386

* [BYOC-DNNL] covered case for sum node without attr

* [UMA] pylint

* [UMA] pylint

* [UMA] aot fix

* [UMA] Changes PR review

* [UMA] cc lint

* [UMA] cc lint

* Use better function name for te_lowering and annotate current target at TE functions

Co-authored-by: Paul Palomero Bernardo <paulpb@outlook.com>
Co-authored-by: Christoph Gerum <christoph.gerum@uni-tuebingen.de>
Co-authored-by: mbs-octoml <mbs@octoml.ai>
Co-authored-by: Christoph Gerum <gerum@informatik.uni-tuebingen.de>
2022-08-09 09:40:55 -07:00
Christian Convey 0c3c08372a [hexagon][topi] add sliced max_pool2 (#12169)
Add TOPI implementation of sliced max_pool2d,
with basic scheduling.
2022-08-09 09:28:59 -07:00
Tristan Konolige 151d6ab8ac [FIX,ROOFLINE] Only save tir functions for roofline (#12339)
Only collect TIR PrimFuncs in roofline's SaveLoweredTIR. SaveLoweredTIR
was saving the full Relay main function leading which could be
excessively large. Also improve the logic to only save functions right
before MakePackedAPI.
2022-08-09 15:22:37 +09:00
yuanfz bd763d3c23 [Topi] add x86 schedule for batch_norm (#12321)
* format black

* format black

* docstring

* typo
2022-08-09 15:22:22 +09:00
Ivy Zhang d6be6940bd [BYOC-DNNL] Bug Fix (#12314)
* add bias_add checker, check op's order in catched pattern

* fix wrong return in legalize_pad_avg_pool

* add check for pooling, ceil_mode=True has not been supported by onednn currently.

* fix lint

* fix test error
2022-08-09 15:20:13 +09:00
Josh Fromm b79f9501fd [Relay][Op] Multinomial (#12284)
* Add multinomial operator.
* Implemented Pytorch integration with multinomial.
* Fixed test paramatrization and added onnx integration.
* Add statistical testing.
* Make get_type more flexible.
2022-08-08 10:51:52 -07:00
Eric Lunderberg c4aab62c6d [TIR] Add tir::builtin::undef (#12266)
* [UnitTest] RemoveStoreUndef, simplest behavior

* [RemoveStoreUndef] First implementation

* [UnitTest] RemoveStoreUndef, stores that depend through LetStmt

* [UnitTest] RemoveStoreUndef, LetStmt handling, error on illegal usage

* [RemoveStoreUndef] Added error checking for illegal T.undef() usage

* Fix lint error

* Use const ref for list of stores to remove

* Verify that removed expression has no other side effects

* Fix lint error
2022-08-06 08:47:41 +08:00
wrongtest 2a7af612f7 [TIR][Schedule] Support annotate dict typed value (#12288)
* tir schedule support annotate dict typed value

* fix lint

* fix comment issues
2022-08-05 17:46:11 -07:00
Wuwei Lin 5821c1240e [TIR] Add DeclBuffer IR node and functors (#12300)
* [TIR] Add DeclBuffer node

* [TIR] Add IR functors for DeclBuffer

* [TVMScript] Add printer and parser for DeclBuffer

* Update printer

* Update printer

* Add test case

* lint

* fix
2022-08-05 14:59:01 -07:00
Lite Ye 0973248858 [TVMScript] Add source_paths to Doc (#12324)
This PR:

- Add the source_paths attribute to Doc base class.
- Add the corresponding Python binding for it.

This PR is depended by multiple tasks, including the diagnostic output in DocPrinter, VarTable and IRDocisifer.

Tracking issue: https://github.com/apache/tvm/issues/11912

Co-authored-by: Greg Bonik <gbonik@octoml.ai>
2022-08-05 13:33:38 -07:00
Eric Lunderberg 8a0911c429 [TIR] Add tir::builtin::assume (#12267)
* [RemoveAssume] Implemented T.assume in TVMScript, RemoveAssume

* [UnitTest] RemoveAssume, initial functionality tests
2022-08-05 10:43:45 -05:00
Michalis Papadimitriou 5d0367a137 [QNN] Add qnn op for abs to fix wrong scale on quantize (#12287)
* [QNN] Add qnn op for abs to solve wrong scale on quantize

* Fix for pylint to allow redefine abs

Co-authored-by: Michalis Papapdimitriou <mpapapdimitriou@octoml.ai>
2022-08-04 14:07:28 -06:00
Sevin F. Varoglu 2866f315f9 [FQ2I] Add attrs to adaptive_avg_pool1d (#12290)
* Add attrs to FQ2I adaptive_avg_pool1d

* Fix failing test and add param
2022-08-04 14:06:40 -06:00
zhang-yi-chi cfa55251b2 [Relay][Frontend][Onnx] Add RNN operation for ONNX frontend (#12213)
* Add RNN operation for ONNX frontend.

* link checks

* rm test_rnn_batchwise in unsupported_onnx_tests

* merge similar codes to class methods

* implement opset 14 and refactor test_forward

* reformat verify_rnn_helper

Co-authored-by: 张亦驰 <zhangyichi1@corp.netease.com>
2022-08-04 11:18:02 -07:00
Xiyou Zhou 46a8498ba9 [MetaSchedule] Enhance Conv2d NCHW Winograd Schedule Rules (#12127)
* Update winograd schedule rules.

* Remove extra part for setting local storage scope.

* Fix bgemm schedule.

* Add winograd tile size to annotation.

* Finish winograd schedule rules.

* Process add relu.

* Modify to nchw rules.

* Add missing nchw output rules.

* Add winograd conv2d nchw search space test.

* Fix lint.

* Leave consumer of output to autoinline.

* Remove bgemm rules.

* Remove bgemm schedule rule annotation.

* Update unit test.

* Fix test case.
2022-08-03 14:42:08 -07:00
Mehrdad Hessar 6f831137c9 [microTVM] Refactor pytest fixtures (#12207)
* Refactor micro test fixtures

* fix error

* fix scope

* address @guberti comments

* fix help message

* rename tvm_debug and added .gitignore

* fix bug

* fix bug
2022-08-03 10:58:15 -07:00
Greg Bonik 39ffe0a5ce [TVMScript] Add object path tracing to StructuralEqual (#12101)
Motivation: when two IR objects fail a structural equality check, currently there is no easy way to
find out which part of the IR caused the mismatch. In this PR, we modify the `StructuralEqual`
infrastructure to also optionally return a pair of `ObjectPath` objects that point to the mismatch.
(See https://github.com/apache/tvm/pull/11977). In the upcoming PRs, we will pass these paths to the
TIR printer, so that it could highlight the mismatch location nicely.

Tracking issue: https://github.com/apache/tvm/issues/11912
2022-08-03 01:28:59 -07:00
Mehrdad Hessar aa0d2bb098 [microTVM]Fix dense_dsp schedule in autotuning (#12271)
* dense layer used in autotune

* format
2022-08-02 16:05:23 -07:00
Josh Fromm b8893b557a [Relay][Op] Trilu operator implementation (#12124)
* Added topi trilu implementation

* Implemented and tested full Trilu op.

* Fix test type.

* Add tril zero tests.

* Add pytorch trilu integration.

* Clean up torch integration.

* Readded skip for zero tests.
2022-08-02 13:48:59 -06:00
masahi 1da66d7df2 [MetaSchedule] Check auto tensorization applicability in MultiLevelTilingWithIntrin (#12263)
* Check auto tensorization applicability in MultiLeveltilingwithintrin

* fix qbert loader

* add MultiLevelTiling rule in integartion test

* unused import

* fix cpp format

* add more test

* Check for tiling failure
2022-08-02 12:23:34 -07:00
Andrey Malyshev b05dca1f19 [Adreno] Add markup pass of relay tensors for static texture planning (#11878)
* [Adreno] Add static texture markup relay pass

Co-authored-by: Chris Sullivan <csullivan@octoml.ai>

* lint check

* Remove hardcoded texture limit, check through target options

* fix cpplint

* Add winograd into annotation pass

* fix clang

* Remove extra call of PlanDevice in OptimizeImpl

* Remove one more extra call of PlanDevice in OptimizeImpl

* Fix/add scopes for static texture planning tests

* Remove test_2conv2d as duplication of test_plan_device_issue

* remove comments in test_residual_block

* address review comments

* fix black hits

* Add textures test descriptions

* Address PR comments

Co-authored-by: Chris Sullivan <csullivan@octoml.ai>
2022-08-02 09:10:48 -07:00
Luke Hutton 759a648cd5 [TVMC] Only load extra targets when there are workspace pools (#12253)
After #11427, `tvmc compile` wouldn't work for external codegens that
don't have a `Target` registered by `TVM_REGISTER_TARGET_KIND`. Such
external codegens can be expected to have no workspace pools and may not
always have a target associated as their implementation predates this
mechanism. While it is likely a `Target` is specified for all external
codegens in the future, we should still support external codegens
without an associated `Target` until this is enforced.

Co-authored-by: Chris Sidebottom <chris.sidebottom@arm.com>
2022-08-02 10:10:40 +01:00
Luke Hutton a9df801543 [ETHOSN] Upgrade NPU driver stack to v22.05 (#11759)
* [ETHOSN] Upgrade NPU driver stack to v22.05

In updating the driver stack to v22.05 some additional things needed
changes:
* Prevent split being offloaded to the NPU which is not supported in
  v22.05.
* Removes compile algorithm configuration option since this was removed
  in v22.05. Versions before v22.05 will use the default option.
* Managing some API changes.
* Updating network compile hashes.
* Updating expected error message for overall scale bounds check.

Change-Id: I09343c398a1f47dec44e135ff8252a6315a9b63f

* fix decorator evaluation order

Change-Id: Ib1a34093b4011bdc20fca47d474eb1786218de98

* Return none if version doesn't exist

For some reason PyTest evaluates the second skipif decorator even
if the first one marks the test to be skipped. Thus, meaning test
collection fails when we want to check the version. The workaround
is to return None when the version is not available.

Change-Id: I7cdd8cc70a9ee3c193e9a900f1011829538d975b

* Update resnet hash after rebase

Change-Id: I7555c4a4d7db4f6c7aa8d476e39277fc5cba2f0d
2022-08-02 09:33:10 +01:00
Eric Lunderberg bca0385862 [UnitTest][TIR] Testing utility for before/after transform tests (#12264)
This PR adds `tvm.testing.CompareBeforeAfter`, a generalization of the `BaseBeforeAfter` utility previously used in `test_tir_transform_simplify.py`, which performs unit tests that perform a transformation on a TIR function and compare the results to an expected TIR output.  This arose when minimizing the boilerplate required for unit tests in the implementation of https://github.com/apache/tvm/issues/12261.
2022-08-01 17:46:35 -07:00
Matthew Brookhart c2ec95616e [Fq2i][ fix output type on fq2i binary ops with constant inputs (#12236)
* fix output type on fq2i binary ops with constant inputs

* allow off by one on test
2022-08-01 15:50:23 -07:00
Mehrdad Hessar e2d139af9d [microTVM][ARM] Enable tests that were skipped unintentionally (#12223)
* fix bug to enable tests

* fix import issue
2022-08-01 13:10:35 -07:00
Junru Shao 4ec8683fb6 [MetaSchedule][Test] Add unittests for CBR (#12252) 2022-08-01 20:36:24 +08:00
billishyahao a49273e050 Enable conv family fused with mish (#12228) 2022-08-01 17:56:49 +09:00
Lite Ye 834e998618 [TVMScript] Python Expression Precedence (#12148)
This PR:

- Handle expression (operator) precedence during Python code printing (`(* 1 (+ 2 3))` prints as
`1 * (2 + 3)`)
- Addresses remaining feedback from previous PR #12112
- Reformats Python import with isort

Tracking issue: #11912
2022-07-31 23:45:44 -07:00
Ivy Zhang c07d77f99c [BYOC-DNNL] add post_sum pattern (#12151)
* add post_sum pattern

* add checkers for sum pattern

* fix lint

* fix error in test_pass_partition_graph

* fix lint error
2022-08-01 10:32:52 +09:00
Junru Shao a842449d23 [MetaSchedule][Test] Add unittests for T2D (#12249) 2022-07-31 16:55:15 -07:00
Yaxing Cai a231a1d724 [Fix] Fix some errors in unittests (#12245)
- test_aot_legalize_packed_call.py: `T.preflattened_buffer` returns `void`
- test_tir_intrin.py: `type` here should be `buffer_type`
- test_tir_transform_flatten_buffer.py: `extents` should be `list`
- test_tir_transform_hoist_expression.py: change `tir` into `T` and register `Let` expression in `script/tir/intrin.py`
- test_tir_transform_storage_flatten.py: `T.allocate` has no argument named `strides`
2022-07-31 02:17:04 -07:00
woobinw 66a1b9f392 fix bug: KeyError, can't find some parameter key (#12211)
Co-authored-by: woobinw <Wubin.Wu@imgtec.com>
2022-07-30 23:37:53 -07:00
Matthew Brookhart 1d39f2c974 [FQ2I] fix unary op output affine type in fq2i (#12224)
* fix unary op output affine type in fq2i

* better names

* add option to force to positive values for ops that are undefined on negative values
2022-07-30 20:00:55 -07:00
Junru Shao 9f16b607c8 [TVMScript] Doc Definition (#12244)
This single-file PR is automatically generated by a script that describes the Doc AST.
2022-07-30 19:58:08 -07:00
Tristan Konolige 961a7c70d7 [ROOFLINE] Add CUDA support to roofline analysis (#12205)
* [ROOFLINE] Add CUDA support to roofline analysis

Add functions to estimate peak flops and bandwidth for CUDA. Add a new
registration mechanism to the roofline analysis to support adding any
target. This mechanism uses generic functions with overrides. New
targets only need to add `estimate_peak_bandwidth` and
`estimate_peak_flops` functions.

Also fix cuda codegen and tensorcore_infer_fragment.cc to support
filling matrix_a and matrix_b fragments.

* formatiing

* move statement back inside loops

* print out report for debugging

* default to avx2

* review comments
2022-07-30 16:35:25 -07:00
Jiawei Liu e756980b41 [UX][TVMSciprt] Use HTML formatter in notebook environments (#12240)
Previously we use ANSI color sequences to highlight TVM script. In jupyter notebook environments, such color sequence will be recoginized and translated to corresponding HTML to display things. 

This works fine for most notebook environments (including the jupyter notebook and the VS Code plugin). Recently, thanks to @tqchen, we found that Google Colab does not well support ansi color sequence for 24-bit colors (`JupyterLight` and `VSCDark`) that all its displayed colors are unexpectedly black/gray/white. To also bring highlighting in Colab, in this PR, we directly render the highlighted code with HTML when a notebook environment is detected.
2022-07-30 14:33:45 -07:00
arangasa c6d733a7eb [TOPI][HEXAGON] Implement depthwise conv2d slice op. (#12218) 2022-07-29 14:01:57 -05:00