Commit Graph

3278 Commits

Author SHA1 Message Date
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
David Riazati 2ac6cfe41c Fix more ONNX URLs (#10220)
PR #10218 was not enough for this fix so this should probably run through full CI to make sure it got everything.

cc @mousius @masahi

Co-authored-by: driazati <driazati@users.noreply.github.com>
2022-02-11 20:47:27 +09:00
Kirill Snezhko 61b66cd112 PackedFunction to return params from the .so module, show warning when no params are set (#9811)
* PackedFunction to return params from the .so module, show warning when no params are set

* Linter checkup

* Autoset of params, tests for get_graph_params

* Linter checkup

* Check that inputs were set before run

* Return the original implementation if Run

* Fix RPC behavior
2022-02-10 08:18:18 -08:00
FranckQC 09f7be28a1 Implementation of Common Subexpression Elimination for TIR (#9482)
* Initial implementation of Common Subexpression Elimination for TIR (#703)

The goal of this PR is to implement a Common Subexpression Elimination (CSE) pass for TIR, which aims at identifying redundant computations (both within statements and within expressions), and to replace them by a new fresh variable, introduced before the first occurrence of the redundant computation.

Note that it does not only try to do commoning on full expressions, but it is also able to do it on subexpressions. For instance, if the program computes the expression (w+x) + (y+z) and the expression (w+x)+u, it will introduce the subexpression (w+x) into a new variable.

If we want so, it will be easily possible in the future to make the notion of equivalence between terms more flexible, allowing for instance to identify expressions modulo commutativity (identifying for instance (x+y) with (y+x)), modulo associativity (identifying for instance (x+y)+z with x+(y+z)), etc. Replacing only the function bool EquivalentTerms(const PrimExpr& a, const PrimExpr& b) will be the only thing needed in order to do that. The typical way to rewrite it for such extensions would be to compute a canonical representant of a and a canonical representant of b and to then compare them with the strict syntactical equality.

The main CSE pass is declared and implemented respectively in the files common_subexpr_elim.h and common_subexpr_elim.cc.
The function Stmt CommonSubexpressionEliminator::VisitStmt(const Stmt& stmt) is a good entry point as it contains many comments about what the pass is doing.

The general idea of this pass is that it tries to introduce at the current level (the current root) the computations that are redundant and which are possible to introduce there (they should only contain variables that are in scope). This notion of variables in scope is implemented with a context, which is a vector of pairs (var, MaybeValue). The context is not only used for checking that variables that appear in candidate computations are known at this point, but also for checking if a computation has already been introduced into a variable.

For a greater flexibility in the future, there is a strong distinction already in place between :

    - Syntactic computations, which are maintained in a hashtable which associates expressions (the computations already seen) to size_int (the number of times the computation has been seen).
    - Semantic entities, which are obtained from the syntactic computations by merging equivalent computations (where this notion of "equivalent" is customizable). Semantic entities are stored into a vector of pairs (expr, size_int) where, again, the number is the number of times that expr or equivalent computations have been seen.

The VisitStmt() method starts by computing the syntactic computations (implemented in an auxiliary analysis), then it merges equivalent computations to obtain the semantic computations. Then it sorts these semantic computations from biggest to smallest in order to always consider first the biggest computations. The rest will essentially be a loop over all these candidates, which will stay sorted.

When dealing with a candidate computation, there are three cases that can happen:

    1 - Rare case A variable in the context already contains this computation. This variable can't have been introduced by the CSE, as we would have performed the replacements at the same time (see case 2). So this is the case where the user himself (or the previous TIR passes) has written something like "let x = A in ...A...A...)"
    -> In this case, we simply perform the replacements of A with x in the current result. These replacements are done by an auxiliary transform/Mutator, declared and implemented in replace_expr_selected.h and in replace_expr_selected.cc.

    2 - Case where we need to introduce the current computation inside a new variable This is the case where all the variables used by the current computation are within scope (i.e. are present in the context) and where our internal heuristic/predicate tells us to introduce this computation into a new variable.
    -> In this case, a new variable new_var_i is generated, all the locations that use this computation in result are replaced by this fresh variable (using the same auxiliary Mutator mentioned in 1.), and the current result is replaced by let new_var_i = currentComputation in result.

    3 - Case where we can't or don't want to introduce this computation inside a new variable This is the case where we either can't introduce the current computation inside a new variable (because it contains variables that are not yet in scope there) or because our internal heuristic/predicate did not want to introduce it.
    -> In this case, we will compute the direct sub-expressions of the current computation (implemented by an auxiliary analysis), and we will add them to the vector of semantic computations so that they have a chance to be considered later. Note that they are added while still preserving the order.
    Note that we do not add all the sub-expressions of the current expression but only its direct subexpressions given the fact that we always consider them from biggest to smallest, and given that some candidates are mutually exclusive. Otherwise it would be computationally more intensive and it would pose the problem of cleaning the vector of candidate computations when one of them gets introduced into a variable. Evaluating them lazily by only looking at the direct sub-expressions is at the same time more efficient and simpler.

Once the entire vector of semantic computations has been tried, the main function VisitStmt() calls the general dispatcher , which will in turn call the appropriate handlers. The only specific task of overridden handlers will be to update the context appropriately as new variables are introduced into scope (via Let-In, via For loop, etc) or leave the current scope. Thus, they will update the context appropriately before and after the calls to VisitStmt() and VisitExpr() on the child nodes.

* Added empty newline at the end of every new file

* Rolled-back the pointer to the submodule vta-hw

* Improved the CSE by not commoning at the toplevel redundant computations that only appear in one of the possible execution path (for instance, only in the then/else branch of an IF statement). Redundant computations that appear only in a specific execution path are now being commoned at the entrance of their specific execution path instead of earlier at the toplevel. Introducing them at the toplevel was an anti-optimization as the redundant computation might not have been comptued at all. Added two additional tests for this too.

* Spelling and comment

* Improved the CSE by not commoning at the toplevel redundant computations that only appear in one of the possible execution path (for instance, only in the then/else branch of an IF statement). Redundant computations that appear only in a specific execution path are now being commoned at the entrance of their specific execution path instead of earlier at the toplevel. Introducing them at the toplevel was an anti-optimization as the redundant computation might not have been comptued at all. Added two additional tests for this too.

* Revert "Improved the CSE by not commoning at the toplevel redundant computations that only appear in one of the possible execution path (for instance, only in the then/else branch of an IF statement). Redundant computations that appear only in a specific execution path are now being commoned at the entrance of their specific execution path instead of earlier at the toplevel. Introducing them at the toplevel was an anti-optimization as the redundant computation might not have been comptued at all. Added two additional tests for this too."

This reverts commit c4138d9afc28e79f107a4eccf988a6d93221eb5a.

* Fixed reference used for no reason instead of normal variable.

* Added comment explaning why we do not need the union/intersection over N tables at the moment (because we would only use it for N=3)

* Did most of the changes suggested by upstream

* Continued to work on the remarks given on the public repo.

* Final remarks addressed, small formatting things, and fixing things reported by the linter

* Last linter fix.

* Fixing newline

* Adding newline missing.

* Minor commit for style fo conform with clang-format

* Removed trailing space at end of line

* And more minor style changes

* Fixing style of the python test files

* And one more for style in python tests!

* This linter is very annoying to force the style of indentation in a comment, in a test file. It makes it harder to read in this case! And that incitates people to not write comments

* Deactivate the CSE pass for the lowering tests as it would otherwise do some commoning, and improve the way the CSE recurse + test added for cascade commonings

* Fixing new lint offenses

* Removing debug statement

* Restore other test file to its previous state

* One more for the linter...

* Linter again, this time for the new test...

* again

* again...

* Deactivating the CSE pass for another lowering test as it does some commoning

* Disabling the CSE for the a test for GPU too

* Trying to fix a VTA test by disabling the CSE pass for it, as it probably does some commoning

* Complying with the linter

* Restarting the CI 1/2

* Restarting the CI 2/2

* Restarting CI 1/2

* Restarting CI 2/2

* Slightly reduce size of large pretty printer test, copied from https://github.com/apache/tvm/pull/10026/commits/ae98f9e7809cbf8d910fa16bfeac8364196e57d7

* Trying to resolve the problems on the weird tests

* Linter.

* Restarting CI which has skipped the MacOS build for no reason 1/2

* Restarting CI which has skipped the MacOS build for no reason 2/2

* Commented buggy tests

* Linter...

* Restore the VTA tests, and use trick kindly given  by Masa to disable the CSE pass for the VTA tests, as vta.build() overwrittes the config

* New fix, which this time does not break the doc (VTA uses a set with {} for the disabled passes instead of a list with [] for some reason

* More VTA fixes

* vta tutorial fix

Co-authored-by: Masahiro Masuda <masahi129@gmail.com>
2022-02-10 21:46:23 +09:00
Qiang Zhang 7a00843d14 [RPC] Add Missing Command Line Option "through-proxy" of RPC Server (#10188) 2022-02-10 09:36:58 +00:00
AndrewZhaoLuo 5e4e2393e2 [QNN] Lookup operations for hard to implement operators (#10053)
* initial tanh impl

* smalls error

* support uint and int lookup into tables

* reinterpret cast, working tanh tests

* refactor relay func creation

* basic casting tests

* explicitly say do not handle multi-channel lookups

* add example funcs

* fix silent fail

* fix some bugs with floating point funcs not working

* add TODO

* add tood

* canonicalizations

* refactor integer lookup ops into own folder

* fq2i stuff

* clean up existing tests

* flesh out todo

* more tests

* test on keeping shape good

* lookup table fix

* replace canonicalization for rsqrt

* remove canonicalization of rsqrt

* add asf headers

* topi tests

* gather supports unsigned integer tests

* fix things

* move to legalization

* jostle ci

* linting

* use take instead of gather

* remove gather changes

* undo changes

* undo changes

* undo changes

* move thing in range

* initial tanh impl

* smalls error

* support uint and int lookup into tables

* reinterpret cast, working tanh tests

* refactor relay func creation

* basic casting tests

* explicitly say do not handle multi-channel lookups

* add example funcs

* fix silent fail

* fix some bugs with floating point funcs not working

* add TODO

* add tood

* canonicalizations

* refactor integer lookup ops into own folder

* fq2i stuff

* clean up existing tests

* flesh out todo

* more tests

* test on keeping shape good

* lookup table fix

* replace canonicalization for rsqrt

* remove canonicalization of rsqrt

* add asf headers

* gather supports unsigned integer tests

* fix things

* move to legalization

* jostle ci

* linting

* use take instead of gather

* remove gather changes

* undo changes

* undo changes

* undo changes

* move thing in range

* lint

* remove unneeded line

* jostle

Co-authored-by: andrewzhaoluo (generated by with_the_same_user script) <andrewzhaoluo@system76-pc.localdomain>
2022-02-09 10:54:54 -08:00
Christopher Sidebottom b0783b079e [TVMC] Add codegen args to tvmc (#10190)
* [TVMC] Add codegen args to tvmc

This enables external codegen arguments similar to those for `Target`s:

```
tvmc compile --target=cmsis-nn,c --target-cmsis-nn-mcpu=cortex-m55
```

* Add CMSIS-NN decorator to dependent tests
2022-02-09 14:29:20 +00:00
Yuchi Wen e23999e24b [Torch] Run torch JIT pass lower_all_tuples before conversion. (#10186)
* [Torch] Run torch JIT pass lower_all_tuples before conversion.

* [Torch] Input containing tuples will disable lower_all_tuples.

Co-authored-by: wenyuchi.wyc <wenyuchi.wyc@alibaba-inc.com>
2022-02-09 22:31:57 +09:00
lhutton1 928236713d [microNPU] Add support for pack and unpack (#9960)
* [microNPU] Add support for pack and unpack

Pack is represented by a series of `expand_dims` operations
followed by a `concatenate` in Relay. Unpack is represented
by a `split` followed by a series of `squeeze` operations in
Relay. This commit legalizes `expand_dims` and `squeeze` to
reshape operations while making use of existing legalization
techniques for `split` and `concatenate` so that pack and
unpack can be offloaded to the NPU.

Change-Id: I3fbebb4ece5ca04598f8e587b9e6c0ddf280266d

* rebase and add tests for expand dims and squeeze

Change-Id: Ic6a9fd77b61368720328bfe82032490bcc66152c
2022-02-09 12:14:29 +00:00
Samuel Panijel 345dc37a07 [ETHOSN] Add support for mean on Ethos-N78 (#10130)
Adding the support of mean on Ethos-N78, which is based on
an underlying pattern matching scheme.
The operator is tested with 2 shapes: 4 and 3 dimensions.

Co-authored-by: Samuel Panijel <samuel.panijel@arm.com>
2022-02-09 12:12:37 +00:00
Sevin F. Varoglu 824772489e [FQ2I] Add topk to FQ2I (#10170)
* Add topk/dyn.topk to FQ2I

* Remove dyn.topk

* Add uint8 to sort
2022-02-08 10:08:01 -07:00
Masahiro Masuda 35a7992fe2 [CUTLASS] Add parallel split-k support to wgrad (#10185)
* [CUTLASS] Add split-k support to wgrad

commit 60b73a91b79d644d8c95f682eedaf47a89abba0d
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Tue Feb 8 10:43:11 2022 +0900

    pylint

commit ae2e7187256316c48c915c3c187feb5cd4d4dbd4
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Sun Feb 6 14:51:52 2022 +0900

    Add split-k support for wgrad

    commit 43820d50055b0bd17b736f5c5830321c7509a20a
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Sun Feb 6 10:07:34 2022 +0900

        fix and add doc

    commit 446a95b0aabc5ab69cdd2e414b812aab1c557f42
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Sun Feb 6 09:48:38 2022 +0900

        dw conv2d properly supported for wgrad

    commit adc4e22d2e03a99f30ebb6a5e956a1749de693f0
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Sat Feb 5 16:32:42 2022 +0900

        fix overwriting template

    commit 040eab000bc5f162c6e9aca70ae6d29378fe65bc
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Sat Feb 5 16:06:27 2022 +0900

        black

    commit e5a07c24b7463552b8e545710d25472159bcc127
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Sat Feb 5 16:03:10 2022 +0900

        add reduction in profiler

    commit be89334ab981d536d010dd765c9cf601dbdae5e0
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Sat Feb 5 06:58:03 2022 +0900

        adding split k reduction to conv2d profiler

    commit ae09b0fbdc3a472eb320d866c054f73b3142f21c
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Fri Feb 4 11:52:59 2022 +0900

        fixed conv2d_backward_weight typerel for dw conv2d

        commit 16fe5313fd1219e2e7d531ef9b36f64bb557e5e7
        Author: Masahiro Masuda <masahi129@gmail.com>
        Date:   Thu Feb 3 12:59:22 2022 +0900

            wip

        commit 2167c2543340a285bb1985e8fe37e11aed51fb9b
        Author: Masahiro Masuda <masahi129@gmail.com>
        Date:   Thu Feb 3 04:22:19 2022 +0900

            fix conv2d type rel for depth wise and grouped conv2d

    commit 14b12e5dd84fc34691d585213387198f091eefc5
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Fri Feb 4 05:01:03 2022 +0900

        remove split_k.py

    commit b14127179c43f71c3ce5ccc7b4ca678a099e5497
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Fri Feb 4 04:48:21 2022 +0900

        workaround for invalid split_k_slice

    commit 6e4c7e1d77d89f124abc77dbcdab69eff8a5d961
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Fri Feb 4 02:43:58 2022 +0900

        support split k in profiler

    commit 2eb1cf43c7f56f0537cf249855054b5cbd357b13
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Fri Feb 4 02:31:03 2022 +0900

        improvement

    commit 0bce8f3778a6bb05607232a0997d25681e55ce7c
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Thu Feb 3 18:20:12 2022 +0900

        fixed for fp16 output

    commit 30df1bd5282a4d326856382726d4e63ee8c27e8e
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Thu Feb 3 17:50:33 2022 +0900

        fp32 output works

    commit 7a519956b8d103464dff83b4f01b75973f4a33b0
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Thu Feb 3 14:30:22 2022 +0900

        fix

    commit 4a383e2c7c37148a563e9cf34968fb7da3aaf91f
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Thu Feb 3 14:05:24 2022 +0900

        update c++ codegen

    commit 6206e388cc7062cbef0b3c8c47fcd228b44b6818
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Thu Feb 3 13:46:05 2022 +0900

        wip

    commit 0ece49b53e773ebc1ea71c7667abc0cbb29d91bf
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Thu Feb 3 03:05:21 2022 +0900

        wip

    commit 08a6147940d9911fd65a890a4d90beb68176fc03
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Wed Feb 2 13:10:21 2022 +0900

        test worked with fp32 output

    commit 084d5c47666df92ba6c2c1445d5a23de0193a119
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Wed Feb 2 12:35:18 2022 +0900

        fix compile error for fprop

    commit 31f25436c5aca1a75336fa1a8d1c8a25a4936ee8
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Wed Feb 2 12:18:06 2022 +0900

        compiled

    commit c2098e79ade47117f2c32132da864b1fa73fce4a
    Author: Masahiro Masuda <masahi129@gmail.com>
    Date:   Wed Feb 2 11:11:43 2022 +0900

        wip

commit a14585020151d0e09bb9bac549285dceb13e55e1
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Sun Feb 6 14:46:16 2022 +0900

    fixed for sm75

commit 61515062ef4576bf5b4e7e9e800f7f705738809c
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Sun Feb 6 14:32:46 2022 +0900

    all tests work

commit 041c094b3646e0f521f5bd2c4f6f6b5b1cff7b97
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Sun Feb 6 14:19:09 2022 +0900

    dw conv2d properly supported for wgrad

commit 2191918743a4e9ffb8254f3786d817be57ff49cc
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Wed Feb 2 09:14:05 2022 +0900

    wgrad tests now work under pytest

commit 78f76df1eb1602f66cacb888a97b6b267f8600a7
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Wed Feb 2 07:31:54 2022 +0900

    run black

commit 0a82149fe0586b0bf449fc7f3a1fa9809e9b38d2
Author: Masahiro Masuda <masahi129@gmail.com>
Date:   Wed Feb 2 06:12:39 2022 +0900

    [CUTLASS] Add wgrad support (without split-k)

* pylint

* add more doc

* more doc clarification
2022-02-08 08:34:42 -08:00
Ruihang Lai 470a1c7f2e [BugFix][TVMScript] Use operator is when recognizing TIR Module (#10175)
* [BugFix][TVMScript] Use operator `is` when recognizing TIR module

* Test
2022-02-07 23:23:42 -08:00
Mei Ye 98fcca1720 Support PyTorch grid_sample (#10184)
* [relay] Fix stack overflow in device_planner observed on windows due to recursive function calls.

* Revert "[relay] Fix stack overflow in device_planner observed on windows due to recursive function calls."

This reverts commit 70581364771e2415b37b202a9fa6a937f275cfc6.

* [PyTorch] Add grid_sample with zeros and border padding mode for PyTorch.
2022-02-08 14:57:15 +09:00
Masahiro Masuda 7fd73b2663 [CUTLASS] Initial support for conv2d wgrad (#10177)
* [CUTLASS] Add wgrad support (without split-k)

* run black

* wgrad tests now work under pytest

* dw conv2d properly supported for wgrad

* all tests work

* fixed for sm75

* cpplint

* fix conv2d grad test
2022-02-08 10:28:20 +09:00
Sunghyun Park 22c488e3a8 [MetaSchedule] Add target field to MetaScheduleContext (#10169)
* Add target field to MetaScheduleContext

* fix linter issues
2022-02-06 20:06:26 -08:00
Martin Kröning 774df1d12d TVMC: Don't divide trials by zero tasks (#10164)
If there are no tasks to tune, the number of trails is meaningless.

Co-authored-by: Martin Kröning <martin.kroening@neclab.eu>
2022-02-06 16:16:21 +00:00
Altan Haan 34d70dea0d [Relay][VM] Relay VM memory liveness/lifetime analysis (#10026)
* WIP VM memory planning

* tuple projection

* support if

* lint

* remove old comment

* WIP check in attempt at CFG analysis

* rewrite CFG analysis in stages, support ADTs

* lint

* fix small bug in alias elimination, try fix VM profiler error

* update DCE tests since allocations can be DCE'd

* optimize worklist to reduce runtime

* add docs, rename pass to ManifestLifetimes

* add tests, more comments, proper VM profiler fix

* lint

* ci please

* address nits

* retry ci again

* retry ci once again :)

* fix sneaky memory leak due to cyclic refs

* fix didn't work but retry ci anyway

* slightly reduce size of large pretty printer test
2022-02-05 12:37:53 -07:00
Masahiro Masuda 95aac9224e [Torch] Experimental support for FX-quantized models (#10091)
* works on resnet18 and deeplabv3

* yolo5 conversion worked

* fixed sigmoid

* [Torch] Support clamp_min, clamp_max

* fixed clamp_min

* fixed quantize for 1 dim input

* cleanup

* improve inline_qparam impl

* add clamp_min/max test

* add fx quant test

* cleanup

* skip build in testing

* black

* improve clamp conversion

* leave TODO on inf handling
2022-02-04 11:32:57 -08:00
Hongyi Jin 3ca5c2bd54 [Meta Schedule] Allow Non-strict Population Size in Evolutionary Search (#10163) 2022-02-04 23:39:30 +08:00
Matthew Brookhart cbf6468c39 [Relay] Align strided slice shape functions (#10155)
* fix static strided slice shape func for out-of-bounds negative stride slicing

* Trigger CI

* Trigger CI
2022-02-04 18:20:58 +09:00
lhutton1 a8741e2d0f [microNPU] Fix layout assignment in layout optimizer pass (#10143)
Fixes the layout optimizer incorrectly assigning layouts for graphs with
more complex topologies than previously considered. Specifically, this
commit now ensures that intermediate layouts match (e.g. parent output =
child input) and that all consumers are taken into account when altering
the output layout - something not done previously due to an incorrect
traversal order.

Previously, the input layout was always altered if the producer was an
NPU operation without regard to the output layout of that operation.
Additionally, is was possible for the output layout to be incorrectly
set due to a depth-first post-order of traversal of the graph, meaning
it was possible for not all consumers to be taken into account when
altering the layout.

Now the `AnalyzeConsumers` pass is run before `LayoutOptimization` which
determines a mapping from NPU operation to list of boolean values that
represent whether or not each consumer is an NPU operation. Since this
is completed before `LayoutOptimization`, all consumers are guaranteed
to be taken into account when altering the output layout. In turn, the
input layouts can correctly be determined by checking whether the output
of the producer will be altered.

Change-Id: I04e9605da65fa9f12801109dd50c5e3f08cbc73c
2022-02-04 07:59:27 +09:00
Eric Lunderberg 455c02a833 [TVMScript] Support T.buffer_decl using data pointer from Let/Allocate (#10099)
* [TVMScript] Added unit tests demonstrating desired functionality

* [TVMScript] Implemented parsing of T.Ptr[...]

These can be generated when exporting to TVMscript, but were not
parsable after being generated.

* [TVMScript] Updated buffer_var printing

LetStmt and AllocateNode can both be used to generate handles that are
used in Buffer objects.  In these cases, the Buffer declarations must
go after the handle declaration, not in the function header.

* Moved printing of var and buffer_decl into separate statements.

* Updated following @shingjan's review comments.
2022-02-03 12:04:37 -08:00
Matthew Barrett f2b7e82adf [microNPU][3] Plan generation for the cascader (#9890)
* [microNPU][3] Plan generation for the cascader

The cascader creates 'Plans' which describe how
to schedule subgraphs. As part of the cascading
algorithm, it's necessary to explore a large
variety of Plans which are Pareto optimal (in
terms of memory usage and performance). This is
done by the Plan generation algorithm.

This commit adds the TensorConfig and Plan data
structures which hold information on how to schedule
the tensors/operators. Additionally, it includes
functions to calculate Pareto frontiers which are
used to cull sub-optimal Plans.

Change-Id: Ia358b2a1b29bd810df4441027752ced75812ad4e

* Fixes to lint/test

Change-Id: If4e083a3c96af75a8ffa72510704818d21a477d9

* Improve python docs

Change-Id: I831137f8235665bc20ab4c060cc7049ffd48088a

* Fix enum hashing issue with old gcc

Change-Id: Ifbe97eb33b1ef313710f24c687a8155421a3c195
2022-02-03 19:26:09 +00:00
lhutton1 2e6702c133 [microNPU] Add support for transpose convolution (#9855)
Adds support for legalizing transpose convolution to
a microNPU conv2d operation for the case when strides==(2, 2),
dilation==(1, 1) and no padding of the output is required.

Change-Id: I485e2571913b3dcd7c75c46304f2f9a82f630ee0
2022-02-03 05:56:15 +00:00
Jinkun Lin 8727c607f9 [onnx] fix onnx where broadcast (#10106)
* fix onnx where bcast

* jostle ci

* jostle ci

* jostle ci
2022-02-02 10:01:57 -08:00
Siyuan Feng ded4065366 [Misc] typo and nit fixes (#10145) 2022-02-02 09:49:09 -08:00
Ashutosh Parkhi cb3d7e2271 [CMSIS-NN] Convert scalar constants to tensor constants (#10100) 2022-02-02 17:05:32 +00:00
Margaret Qian efe662fe66 [Relay][Pass] Add a relay pass to extract fake quantized ops (#10089)
* add relay pass to collect fake quantized ops

* add more tests

* more tests

* lint

* lint

* remove unused imports

* update comment

* lint

* reuse SubgraphExtractor and update test assertions

* remove print

* lint

* remove unneeded comment

Co-authored-by: Margaret Qian <mqian@octoml.ai>
2022-02-01 20:57:45 -08:00
Josh Fromm ac4815c0d0 [AutoScheduler] Allow device specification for AutoScheduler Runners. (#10123)
* Changed the python api to support device.

* Finished implementation and updated tests.

* Fix typo.
2022-02-02 08:09:27 +09:00
Tristan Konolige 780f88a425 [FIX,AUTOTVM] Add backtraces to tuning errors (#9901)
* [FIX,AUTOTVM] Add backtraces to tuning errors

Collects tracebacks in LocalBuilder and LocalRunner and adds them to the
error messages.

* formatting

* correctly unpack traceback and exception

* add assert

* fix?

* one remaining measureresult

* formatting

* fixed
2022-02-01 14:20:42 -08:00
Masahiro Masuda a1f51aa230 [CUTLASS] Conv2d dgrad (#10110)
* add conv2d transpose nhwc cudnn test

* support conv2d transpose nhwc direct offload to cudnn

* add cutlass dgrad support

* remove unused arg

* allow target none

* fix beta initiaization condition

* disable dynamic dense fp16 test since it fails on cuda 11.6
2022-02-02 05:51:57 +09:00
Matthew Barrett 339f8886f4 [USMP] Add performance characteristics to PoolInfo (#10005)
* [USMP] Add performance characteristics to PoolInfo

Scheduling algorithms that wish to optimize around
memory pools require further information about the
perfomance characteristics of those pools. This
commit adds clock frequency, bandwidth, latency and
burst length as optional fields to PoolInfo.

Change-Id: I4cf3f35324d093fb38e874f0f2e587cb84d4ba1e

* Remove unused import

Change-Id: I1e2ef885425f4361b80c2bab9261ec129e61a756
2022-02-01 18:12:46 +00:00
Tristan Konolige 187aeb5fe8 [AUTOTVM] Use opt level 3 when extracting tasks (#10065)
* [AUTOTVM] Use opt level 3 when extracting tasks

Autotvm was implicitly ignoring opt_level when extracting tasks because
pass opt_level is a thread local variable and extraction happens in a
new thread. Not having opt_level 3 causes alter op layout to not
fire, which in turn prevents tuning from finding all possible kernels.

* disable alter op layout
2022-02-01 12:26:46 +09:00
Tristan Konolige 24d2a38116 [LLVM,TIR] Print LLVM intrinsic names instead of ids (#9964)
* [LLVM,TIR] Print LLVM intrinsic names instead of ids

This makes it much easy to understand what is happening with llvm
intrinsics.

* add test, version llvm
2022-02-01 09:16:59 +09:00
Huang, Guangtai dad8f62fc1 [Bugfix][Op] Fix shape inference of adv_index (#9717)
* init

* test

* lint
2022-01-31 09:53:45 -08:00
lhutton1 02a7a4182f [microNPU] Add support for nearest neighbor and bilinear upsampling (#9841)
* [microNPU] Add support for nearest neighbor and bilinear upsampling

Adds support for 2x2 nearest neighbor and bilinear upsampling. In the
case of bilinear upsampling with align_corners set to true, the
upsampling size must be `2*input_size - 1` (as opposed to `2*input_size`).

Change-Id: I95d215eabfaac983629dcdedcda2b90efb8e0ddf

* rebase and add support for no-upsampling case.

Change-Id: I840d8ee3671a40c5c99f22119442c349dbed39cf
2022-01-31 16:05:21 +00:00
Leo-arm 3de25b83f9 [ETHOSN] Per-tensor support for int8 operations (#10018)
* Per-axis quantization to follow
2022-01-31 11:38:04 +00:00
Grant Watson 3b20c21f9e [microTVM] Include standalone_crt dependencies in MLF (#10095)
* Adds runtime to AOTExecutorFactoryModule
 * Standalone CRT files are added to MLF tarball if runtime is crt
 * external_dependencies info added to metadata.json for crt runtime
 * microNPU demo Makefile references standalone crt files from MLF tarball
2022-01-31 10:50:29 +00:00
KennyTang1988 f2d60fe968 [Caffe Frontend] Add support for Power layer (#9655)
Co-authored-by: tangkun <kun.tang@hexintek.com>
2022-01-31 15:49:50 +09:00
Tony d8d00530bb [Fix Bug]fix the bugs of keras frontend when parsing LSTM, GRU, RNN layers. (#9850)
* [Fix Bug]fix the bugs of keras frontend when parsing LSTM, GRU, RNN layers.

* Reformat files with black formatter.

Co-authored-by: AndrewZhaoLuo <andrew.zhao.luo@gmail.com>
2022-01-30 21:55:18 -08:00
Xiyou Zhou 779dc51e13 [MetaSchedule][M4a] User-API: Tune-TE/TIR/Relay (#10079)
* Add tuning scripts for tir, te & relay.

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>

Minor fix.

Nits.

Add back tests.

* slightly improve tune.py

Co-authored-by: Junru Shao <junrushao1994@gmail.com>
2022-01-30 13:50:24 +08:00
Siyuan Feng 538347e49f [MetaSchedule] postproc: rewrite_cooperative_fetch (#10081)
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: Ruihang Lai <lairuihangdongdong@qq.com>
Co-authored-by: Hongyi Jin <3231950289@qq.com>
Co-authored-by: Wuwei Lin <wuwei@apache.org>

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: Ruihang Lai <lairuihangdongdong@qq.com>
Co-authored-by: Hongyi Jin <3231950289@qq.com>
Co-authored-by: Wuwei Lin <wuwei@apache.org>
2022-01-29 16:59:09 -05:00
Sunghyun Park ba651974c8 [MetaSchedule][M4b] Testcases for TensorRT builder/runner (#10055)
Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
Co-authored-by: Bohan Hou <32121147+spectrometerHBH@users.noreply.github.com>
Co-authored-by: Hongyi Jin <3231950289@qq.com>
Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Xiyou Zhou <xiyou@octoml.ai>
2022-01-29 13:31:07 -08:00
Ruihang Lai 4d0dac3e55 [MetaSchedule][M4a] Mutator: Mutate-Tile-Size (#10092)
* [MetaSchedule][M4a] Mutator: Mutate-Tile-Size

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: Wuwei Lin <wuwei@apache.org>

* Python 3.8 has no `math.prod`

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: Wuwei Lin <wuwei@apache.org>
2022-01-29 12:24:03 +08:00
Mehrdad Hessar 6a274af9cb [Hexagon] Update hexagon API build instruction and cleanup hexagon_proxy_rpc (#10068)
* Fix hexagon api build and Update Readme

* Cleanup hexagon_proxy_rpc

* Target Hack

* Remove hack

* address @cconvey comments

* remove the rest of proxy rpc
2022-01-28 16:55:22 -06:00
Hongyi Jin 85d42f894e [MetaSchedule][M4a] Mutator: Mutate Parallel (#10096) 2022-01-28 15:52:21 -05:00
Hua Jiang 80d4d05e83 [Runtime][PipelineExecutor] Pipeline Executor Sequential execution (#10082)
* [Runtime][PipelineExecutor] Pipeline Executor Sequential execution

In the first, adding the "get output" logic. Secondly, adding the the sequential executing
logic of pipeline executor. In the last, testing the pipeline executor interface and
checking the output data.

* Address review comments.

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

* trigger build.

Co-authored-by: Cody Yu <comaniac0422@gmail.com>
2022-01-28 12:36:31 -08:00
Manupa Karunaratne 7b9fd1e2ab [microNPU] Removing constant args from PrimFunc (#9951)
Before this commit, microNPU creates PrimFunc as if
it accepts constants from the callee. This commit
changes the PrimFunc to remove the constants as an
argument to PrimFunc as they are not provided from
the main function.
2022-01-28 15:07:37 +00:00