* 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>
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
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.
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.
* 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.
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.
* 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>
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.
* 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
* [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
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>
* [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>
* 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>
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
* 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
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>
* [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
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.
- 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`
* [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
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.