Commit Graph

3689 Commits

Author SHA1 Message Date
Mehrdad Hessar 648154d808 [MLF] Add support for multiple modules in Model Library Format (#11464) 2022-06-17 12:27:52 -07:00
Kathryn (Jinqi) Chen 0fdc0eab51 [MetaSchedule] Distributed Measurement (#11683)
This PR includes the distributed measurement of tuning candidates using builder and async runner, as well as some auxiliary functions. It enables multiple builders and multiple runners with a tracker connecting in between. The hierarchy of files in the database can be further compacted to make the database more concise.
2022-06-17 11:55:39 -07:00
Ashutosh Parkhi dffc3108bb [CMSIS-NN] Fixed the case with repeating operands in the QNN binary ops (#11732) 2022-06-17 17:42:49 +01:00
apeskov 5aabeb741f Enable QNN primitives for DNNL runtime (#11642)
* [DNNL] Enable QNN primitives

Signed-off-by: Alexander Peskov <peskovnn@gmail.com>

* [DNNL] add qnn test

Signed-off-by: Alexander Peskov <peskovnn@gmail.com>

* typo fix

Signed-off-by: Alexander Peskov <peskovnn@gmail.com>
2022-06-17 20:10:00 +09:00
Karl Koscher 7433b2fd41 Add optional mem_scope parameter to tvm.nd.array and tvm.nd.copyto (#11717) 2022-06-17 14:28:13 +09:00
Junru Shao 7e376e2599 [MetaSchedule][Minor] Organize Testing Scripts (#11751) 2022-06-16 18:01:20 -07:00
Junru Shao d0650bad66 [Bugfix][MetaSchedule] Filter out dynamic extents (#11747)
Previously only static shape computation is allowed in our tuning
system. However, one special case is overlooked: the reduction iter vars
could still have dynamic iteration domains which depend on other data
parallel vars. This PR rules out this case by carefully checking all the
loop extents during task extraction.

Related issue: https://github.com/apache/tvm/issues/11746.
2022-06-16 19:19:48 +08:00
wrongtest 24010db6c0 [TVMScript] Support roundtrip of LetNode (#11742)
Just a missing support for `tir.LetNode`
2022-06-15 23:11:41 -07:00
Junru Shao 89e1a6c3f2 [TIR] Add preserve-unit-iters (#11585) 2022-06-16 13:42:12 +08:00
yuanfz 47ef9466b2 [Pytorch] Add quantized::leaky_relu (#11729)
* emptycommit 2nd try

* add operator and test

* example output

* lint with black

* register param index

* remove assert as it is a warning in torch

* fix algo bug

Co-authored-by: yuanfz <42092999+FZYUAN-1@users.noreply.github.com>
2022-06-16 12:48:52 +09:00
Gavin Uberti ddb43e2ab0 [microTVM] Add support for the Raspberry Pi Pico via Arduino (#11694)
* Add RP2040 support
2022-06-15 16:45:06 -07:00
Xiyou Zhou 6ce41be327 [MetaSchedule] Modify Profiler Timers (#11735)
Minor modification to scoped timers to cover 99% of all the time cost during MS tuning. Allow `ApplyHistoryBest` and `TaskExtraction` time to be counted during tune_relay.
2022-06-15 13:40:10 -07:00
Junru Shao fdc3c0274b [MetaSchedule] Developer Ergonomics Enhancement II (#11727)
Follow-up of #11622, per discussion with @Kathryn-cat

- [x] Allow using a string `"default"` in `TuneContext` to quickly specify a set of target-specific
rules
- [x] Enhance detection of `ScheduleFn` in `TuneContext` to make it easier for users to quickly try
out template-driven scheduling on TIR.

Next PR:
- Add `TuneContext.tune` to allow directly tuning without task scheduler.

Co-Authored-By: Kathryn (Jinqi) Chen <65606304+Kathryn-cat@users.noreply.github.com>
2022-06-15 13:00:06 -07:00
Florin Blanaru a64368be0e [ci] Skip failing tests in wheel (#11705)
Some python tests are failing in the wheel. This PR skips them if the environment variable `WHEEL_TEST` is set.

This PR is related to https://github.com/tlc-pack/tlcpack/pull/115.
2022-06-15 11:16:25 -07:00
Jyotsna Verma 9d98da2736 [Hexagon] Implement avg_pool2d slice op (#11417)
* Implement avg_pool2d slice op

* Address review comments and fix the STIR schedule

* Fix formatting issues

* Address pylint errors

* Additional formatting issues

* more pylint fixes

* Changed arch version to v68 for now

* Changing arch version back to v69

* Move the test to tests/python/contrib/test_hexagon/topi
2022-06-15 12:40:37 -05:00
Jason f942d19788 [TVMC] Fix error while compile paddle model with tvmc (#11730)
The tvmc command will throw a error while the passed path of model is not exist, But for PaddlePaddle model, it contains 2 file model_name.pdmodel and model_name.pdiparams, we only pass the prefix like inference_model/model_name.

This pr is same with https://github.com/apache/tvm/pull/11108 
Since the origin PR didn't update for a long time, I send this new PR
2022-06-15 10:02:04 -07:00
Ashutosh Parkhi 3cb4597ed4 [CMSIS-NN] Fixed error in finding input's dtype in maxpool (#11701) 2022-06-15 16:47:26 +01:00
Junru Shao 1312658093 [MetaSchedule] Apply-History-Best Task Filtering (#11692)
This PR enables task filtering in Apply-History-Best, which is used in
Relay/Relax integration. Previously, even though a task is ruled out
during task extraction, it still shows up in Relay compilation due to
the lack of filtering on `Apply-History-Best`. However, TE-to-TIR
conversion `te.CreatePrimFunc` doesn't support all cases with hybrid
operators involved, which leads to post-tuning failure affecting
multiple models.
2022-06-15 13:10:24 +08:00
Jinkun Lin d2e2f71b14 Fix 1d-softmax schedule. (#11719) 2022-06-15 09:31:54 +09:00
Alan MacDonald 5b3cef30f9 [microTVM][zephyr] Add support for host-driven AoT execution on zephyr (#11650)
* - add support for host-driven AoT execution on zephyr;
- add initial version of reference counting to prevent python code from inadvertently freeing tensors during garbage collection;
- add support for numerical indices to host-drive AoT get_input();
- add two initial tests for host-driven AoT execution on zephyr;
- rename existing zephyr AoT exec. test;

* address PR feedback

* increase stack size to accommodate qemu_riscv64 stack usage
2022-06-14 15:28:25 -07:00
Siva 27b0aad5a5 [BYOC-OpenCLML] OpenCLML integration with TVM. (#10243)
* [BYOC-OpenCLML] OpenCLML integration with TVM.

* [BYOC-OpenCLML] Cleanup and review.
2022-06-14 19:30:28 +09:00
AndrewZhaoLuo b659332a4c [AutoTVM][Autoscheduler] Default build funcs inherit PassContext (#11632)
* init commit

* lint

* empty commit

* test results

* reset progress

* lint

* fix
2022-06-13 15:20:09 -07:00
Jinkun Lin 85a190af7d Fix onnx round import with float64 inputs. (#11685)
* Fix onnx round import with float64 inputs.

* Fix lint and optimize dtype mapping.
2022-06-13 09:31:38 -07:00
Chris Sullivan 1420df7744 [TE] Support schedulable TIR compute definitions in TOPI (#11589)
This PR adds `te.extern_primfunc` which provides the interface around TE ExternOp that allows a TVMScript defined schedulable TIR PrimFunc to be inlined into a TE compute graph. The result is that TIR can be used for compute definitions in Relay OpStrategies and, paired with meta-scheduler support in relay as introduced in #10578, these compute definitions can be scheduled and tuned as demonstrated in the attached tests.  

Prior to this, compute definitions were limited to those definable in TE only. As a consequence of this patch and ongoing improvements to TVMScript meta-programming (#11097), TOPI can be extended to include compute and scheduling functions targeting schedulable TIR uniformly.
2022-06-13 08:50:19 -07:00
Xiyou Zhou e61ad7ab82 [MetaSchedule] Add Profiler Support For Tuning Efficiency Optimization (#11486)
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
2022-06-13 08:41:53 -07:00
Junru Shao 0df69611b2 [MetaSchedule] JSONDatabase Utilities (#11680)
This PR adds some utility to JSONDatabase to accelerate its loading/saving time.
2022-06-11 00:18:10 -07:00
billishyahao d0da0b94de Fix typos in target warn of dnnl (#11678) 2022-06-10 22:49:50 -07:00
Wuwei Lin a8d60392ba [TIR] Register CUDA WMMA tensor intrinsics (#11677)
* Register CUDA wmma tensor intrins

* Meta programming to generate wmma intrin

* format

* fix

* fix wmma_store

* lint

* Update cuda.py
2022-06-11 13:16:47 +09:00
Mark Shields dfc8e95604 [BYOC] Make CUTLASS BYOC integration 'Collage friendly' (#11631)
* [BYOC] Make CUTLASS BYOC integration 'Collage friendly'

(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).

Currently CUTLASS has four entry points:
 - The usual 'partition_for_cutlass' partitioning function, using the
   standard pattern table and pass machinery (see cutlass/build.py).
 - A 'tune_cutlass_kernels' function which augments CUTLASS partition
   functions with the results of building and running test kernels (see cutlass/build.py).
 - A 'relay.ext.cutlass' external codegen function which inspects the
   turning results and generates a CSourceModule for each partitions
   (see cutlass/codegen.cc).
 - A 'build_cutlass_kernels_vm' function which runs 'export_library' with
   all the nvcc compiler options needed to build all the CSourceModules
   (see cutlass/bild.py).

For Collage we'd like CUTLASS to have only two entry points: 'partition_for_cutlass',
and 'relay.ext.cutlass' or equivalent. This makes the CUTLASS external codegen integration
composable with other integrations, which in turn helps Collage avoid having to understand any
external codegen APIs other than the global pattern table and the custom compilation function/pass.

Collage also tends to end up requiring multiple partitions for the same backend since it is
more aggressive at mixing-and-matching smaller sub-graphs between backends. Thus we'd also like
to make sure all tuning, generated code and compilation overhead is shared between all such CUTLASS
partitions.

So, in this PR:
 - We add all the CUTLASS-specific tuning and compilation options as new Target
   attributes for the 'external codegen' "cutlass" TargetKind (cutlass/target.cc).
   The user now has one place to provide those settings, and we've already done the
   legwork to plumb the target instance.
 - We replace 'relay.ext.cutlass' with a 'RelayToTIR' custom pass hook
   'CompileForCutlass' (see cutlass/codegen.cc). This pass obviously can see all
   the CUTLASS partitions in the IRModule, so we can now share tuning results
   between them all and can be sure to generate a single CSourceModule. The pass can
   also invoke the compiler to yield a StaticModule, which we've also already done the
   legwork to support. In this way all CUTLASS-specific steps are handled at once.
 - For convenience we supply 'finalize_modules' and 'finalize_modules_vm' which
   invoke nvcc for final linking (using export_library as usual). However, there's now
   nothing CUTLASS specific in those helpers other than their overriding of the 'compiler' to
   be nvcc.
 - test_cutlass.py is updated to use the new API.

 Though this is a breaking change for existing users of the CUTLASS integration the
 change is pretty minor, as shown in test_cutlass.py.

* - Masa's comments

* - Remove unnecessary save.
2022-06-11 11:52:29 +09:00
Kathryn (Jinqi) Chen 50c6a9896d [MetaSchedule] Generate MetaSchedule Dataset (#11641)
In order to build a dataset for improving the cost model for MetaSchedule, I added several files
including importing models to TVM, extracting tuning tasks, and sampling measure candidates.
Meanwhile, I exposed some methods in C++ to the Python side to assist the process.
2022-06-10 18:15:05 -07:00
Tristan Konolige 7de8980f24 [FIX,METASCHEDULER] Fix tune_te (#11676)
`tune_te` was broken because it passed a primfunc to `tune_tir`. Now it
is wrapped in an IRModule. Also the test is re-enabled.
2022-06-10 18:14:00 -07:00
Qianshui 705993e485 [DNNL][CBLAS][BYOC] Unifles all MKLDNN/DNNL to DNNL (#11638)
* unifies all MKLDNN/DNNL_CODEGEN to DNNL

* translate -lib=mkldnn to -libs=dnnl in target

* type check added before

* rebase and update conv2d from mkldnn to dnnl
2022-06-11 08:47:40 +09:00
billishyahao e8712a9198 [BYOC][DNNL] Improve performance of DNNL BYOC dense operator (#11513)
* Enhance dnnl byoc dense operators performance by 1) introducing gelu fusion and 2) introducing alter dense weight layout.

* fix lint issue

* add unittest for dense pack

* Make code compatible after introducing TensorRequisite(PR-11345)

* Fix comments & refactor code

* Fix lint

* Fix partition graph unittest case

* Fix comments

* Fix comments

* Fix lint
2022-06-11 08:45:18 +09:00
Mehrdad Hessar dc522a6ff6 [Hexagon] Run single RPC server on Android in each testing session (#11547)
* Reuse hexagon launcher in test session

* separate random name generation

* revert get_aot_executor

* Fix launcher for simulator case

* add stop server for simulator
2022-06-10 16:33:24 -05:00
Nicola Lancellotti e7f793d0ad Add assert message (#11665)
Change-Id: I88f19c7105cce048d2f52d50450a551fb12162dc
2022-06-10 17:31:13 +01:00
Qianshui f117244ac4 [DNNL][Relay extern-schedule] DNNL Conv2D Kernel enable by assigning "-libs=mkldnn" (#11571)
* enable oneDNN conv op by using -libs=mkldnn

* add channel last format support and let oneDNN chose blocked format.

* remove unnecessary changes

* reformat 3 files

* reformat 1 file

* change the argument name

* change the argument name

* rename the arguments

* fix cpp lint issue

* fix cpp lint issue

* fix cpp lint issue

* clang reformated

* adjust .py import for testing

* function existence check in test
2022-06-10 20:59:09 +09:00
Junru Shao 6fca5c657a [MetaSchedule] Developer Ergonomics Enhancement (#11622)
Per discussion with @Kathryn-cat

- [x] Move `initialize_with_tune_context` as private API `_initialize_with_tune_context`, and
encourage using `TuneContext.initialize`
- [x] Instead of using bunch of import statements, encourage using `ms.xxx` as the prefix
(e.g. `ms.database.MemoryDatabase`) to organize things better
- [x] Move `DefaultLLVM`, `DefaultCUDA` to a separate file and make them more discoverable
- [x] Move `DummyDatabase` to `tvm.meta_schedule.database.MemoryDatabase` given it's actually useful
- [x] Delegate class members' methods in `TuneContext`, for example, having
`TuneContext.generste_design_space` from `TuneContext.space_generator.generste_design_space`

Next PR:
- Allow using a string `"default"` in `TuneContext` as well as `tune_relay/tir/te` to quickly
specify a set of target-specific rules
- Add `TuneContext.tune` to allow directly tuning without task scheduler.
- Enhance detection of `ScheduleFn` in `TuneContext` to make it easier for users to quickly try out
template-driven scheduling on TIR.

Co-Authored-By: Kathryn (Jinqi) Chen <65606304+Kathryn-cat@users.noreply.github.com>
2022-06-09 22:09:40 -07:00
Masahiro Masuda 53d163c968 [TIR, CUDA] Add pass to replace global to shared memory copy with cp.async (#11658)
* [TIR, CUDA] Add pass to replace global to shared memory copy with cp.async

* add missing doc

* black

* missing src

* clang format

* clang format

* check against nested async scope
2022-06-09 19:05:18 -07:00
Tristan Konolige fe299d7688 [TVMSCRIPT] Improve tvmscript type hints (#11654)
* [TVMSCRIPT] Improve tvmscript type hints

- Change numeric types to classes so they work as function arguments.
- Add var as a class.
- Add floordiv, index, and mod to PrimExpr.

* use Union
2022-06-09 17:45:36 -07:00
Gavin Uberti 762bed0d0d [microTVM] Add support for Arduino Portenta H7 (#11636)
* Add support for Portenta H7

* Add Portenta H7 to supported boards in README

* Rerun tests
2022-06-10 08:58:35 +09:00
Eric Lunderberg af0128158c [TIR][Schedule] Allow named block and buffer arguments in Schedule (#11624)
* [Schedule] Allowed string argument as block arg

This has previously been implemented for `Schedule.transform_layout`
in https://github.com/apache/tvm/pull/11296, extending to allow for
block arguments in all `Schedule` methods.

This change was only made for arguments that must be a `BlockRV`.  For
arguments that may be either a `BlockRV` or another
type (e.g. `Schedule.get_child_blocks` accepts either `BlockRV` or
`LoopRV`), this sugar is not implemented, to avoid ambiguity.

* [Schedule] Allowed string argument to Schedule.reindex

Similar to https://github.com/apache/tvm/pull/11269, which added this
functionality to `Schedule.transform_layout`.

* CI test update
2022-06-09 13:34:32 -07:00
czh978 f528a9a1cd [Frontend][TFLite] Improve support for half_pixel_centers in resize (#11521)
* add resize_nearest_neighbor op test

* Improve support for half_pixel_centers in resize
2022-06-09 10:33:44 -07:00
Sunghyun Park 87502ddd90 [PASS] Refactor a couple of TIR passes - BindTarget, AnnotateEntryFunc, Filter, LowerInitBlock (#11628)
This PR fixes a few inconsistent pass registration and add testcases for them. 
- `LowerInitBlock` had mismatch between its pass name and ffi key.
- `BindTarget`, `AnnotateEntryFunc`, `Filter` were not following the name convention of tir passes and they were not registered in FFI registry.
2022-06-09 10:14:46 -07:00
FranckQC d8678a6a9a [TIR] CSE pass : Restrict the equivalence to be decided by a normal form - avoids comparison of terms (#11574)
The CSE pass had been designed for potentially allowing comparisons (and commonings) of equivalent terms (like (x+y)+z and x+(y+z)), where **the notion of being equivalent was customizable, and no assumption was made about it**. That means that the implementation of the equivalence test function `EquivalentTerms()` - which was at the moment just calling the syntactical equality test `EqualTerms()` - could be replaced later by a cleverer equality test.

However, having such a generic way of comparing elements meant that in the function `SyntacticToSemanticComputations()`, where we were going from a hashtable of syntactical entities to what I called a vector of "semantical entites" (which are just canonical forms/representants of classes of equivalence of terms), **the only way was to compare each pair**.
That resulted in a quadratic behavior of this function, but there was no way around it as in order to merge equivalent entities into their class of equivalence, we had to compare them.

**This PR essentially does the following:**

- When computing the classes of equivalences of terms (therefore transforming a ComputationTable (i.e. a hashtable) into a vector of classes of equivalence) : **instead of comparing each pair of terms, relies on a normalization procedure to obtain a normal form for each of them**.
That transforms a small part of the algorithm that was quadratic to n.logn. However, it's difficult to see improvements in practice, in particular for average sized programs, as that part was a "small" quadratic to a "big" n.logn (finding things in a hash-table, copying it to a vector, etc).
It was probably going from a complexity of ~O(((n²-n)/2) + n.logn) to a complexity of ~O(3n + n.logn), so potential gains would only be expected for very large programs.

- Completely gives the user the possibility to turn ON/OFF the semantical comparisons of terms. It is turned OFF by default (as it's quite longer to compile with it ON, unsurprisingly), which means that by default, the equivalence coincides with the (syntactical) equality of terms.
    As the pass was written with the possibility to do these additional commonings (like (x+y)+z and x+(y+z)), it was a good time to fully plug that completely, up to the Python user who can now turn that ON if he wants to. But again, it is OFF by default, so no real change on that.

To run it ON, simply do:
`with tvm.transform.PassContext(config={'tir.enable_equiv_terms_in_cse_tir':True}):`
before calling `build()`

- When this boolean is set to ON, it uses a simple implementation of the normalization function with equivalences that uses `arith::Analyzer::Simplify` as noted by in https://github.com/apache/tvm/pull/10544 . Note that this is not a real normalization procedure as it is incomplete (i.e., it is not guarantee to converge to the normal form), but it is correct, and it works well with most properties : associativity of +, distributivity of * on +, etc.

- Clarifies and enhance the test base for the pass. In particular, it adds the tests that were written in https://github.com/apache/tvm/pull/10544 but which did not make it through.

- Also add the test ( https://github.com/AndrewZhaoLuo/TVM-Sandbox/blob/19284ddbd6bb28af61c0c2aa8bb334c5c53731a7/tir/test_inconsistent_tir_lowering.py#L1 ) demonstrating the (older) non-deterministic lowering and put it into a proper test, as I found it useful for making sure that this does not happen again. It has been copied from https://github.com/apache/tvm/pull/10663 and only slightly adapted (in particular for doing the comparison of hashes automatically instead of printing them and relying on a human to compare them).
2022-06-09 09:32:15 -07:00
Egor Churaev 2f9d9b4e5c [OpenCL] Implement conv2d_winograd algorithm for Adreno (#11543)
* Implement conv2d_winograd algorithm for Adreno

* Implement gtest for OpenCL texture pool

* Implement conv2d_nhwc_winograd for Adreno

* Minor refactoring

* Fix lint

* Apply comments

* Apply comments

* Fix lint
2022-06-09 13:31:55 +09:00
Sevin F. Varoglu df4f4c0b4b [ONNX] Add ReduceSum opset13 support (non-dynamic) (#11606)
* [ONNX] Add ReduceSum opset13 support (non-dynamic)

* Add check

* Add support for constant axis

* noop

* Rework logic
2022-06-08 14:08:06 -07:00
Mehrdad Hessar 97e681dc34 [Hexagon] Add random string to workspace name (#11593) 2022-06-08 13:23:58 -07:00
billishyahao 9817338508 [BYOC][DNNL] Enable layer normalization in DNNL byoc. (#11508)
* Enable layer normalization in DNNL byoc.

* Added unittest for layer norm and make code compatible after introducing TensorRequisite(PR-11345)

* Fix lint issue

* Fix clang format issue
2022-06-09 04:12:36 +09:00
Xiyou Zhou 96a513cd97 Patch replay trace. (#11621) 2022-06-08 11:39:42 -07:00
Philipp van Kempen e19cf20054 TVMC: Allow to overwrite TVM_CONFIGS_JSON_DIR via environment variables (#11623)
If a non-default location for the build directory is used, e.g. set via TVM_LIBRARY_PATH
we need to provide the user a way to overwrite CONFIGS_JSON_DIR as well.
2022-06-08 14:21:29 +01:00