Commit Graph

3961 Commits

Author SHA1 Message Date
driazati 01fcdfcf5f [ci] Default to n=2 for test parallelism (#12414)
* Revert "[skip ci] Revert "[ci] Default to n=2 for test parallelism (#12376)" (#12413)"

This reverts commit 478b672f2b.

* [ci] Default to n=2 for test parallelism

This is attempt #2 of #12376 which was reverted in #12413. The changes
in `plugin.py` should keep all the tests on the same node so sporadic
failures don't happen due to scheduling.

Co-authored-by: driazati <driazati@users.noreply.github.com>
2022-08-25 10:55:58 -07:00
Matthew Brookhart 21db1eb586 [F2QI] Fix a rounding error on AvgPool when input and output affine scales differ (#12577)
cc @sfvaroglu @AndrewZhaoLuo
2022-08-25 09:23:46 -07:00
Luke Hutton f7c143608f [ETHOSN] Support conversion of add to depthwise (#12531)
In similar fashion to the conversion of mul to depthwise, this commit
converts add when one input is a constant of shape [1, ..., n] to a
depthwise convolution. If neither input is a constant, the add is
offloaded naturally like before.

The addition testing has been improved to use pytest features.
2022-08-25 17:17:22 +01:00
Yuanjing Shi 40bdea8d7a [PyTorch] Add aten::new_empty (#12591)
This PR intends to add `aten::new_empty` which is used for model like `hf_Longformer`.

cc: @masahi
2022-08-25 19:04:07 +09:00
Yaxing Cai b38738434b [TIR] Expose WMMA-related TensorCore builtins (#12589)
This PR exposes the following TIR operation in python:

`tvm_load_matrix_sync`: tested [here](https://github.com/apache/tvm/blob/cd8fd9121deb22b078c9fe73cd8a554e6e7a0e15/tests/python/unittest/test_tvmscript_roundtrip.py#L711)
`tvm_store_matrix_sync`: tested [here](https://github.com/apache/tvm/blob/cd8fd9121deb22b078c9fe73cd8a554e6e7a0e15/tests/python/unittest/test_tvmscript_roundtrip.py#L913)
`tvm_mma_sync`: tested [here](https://github.com/apache/tvm/blob/cd8fd9121deb22b078c9fe73cd8a554e6e7a0e15/tests/python/unittest/test_tvmscript_roundtrip.py#L860)
`tvm_bmma_sync`: add new unittest
`tvm_fill_fragment`: tested [here](https://github.com/apache/tvm/blob/cd8fd9121deb22b078c9fe73cd8a554e6e7a0e15/tests/python/unittest/test_tvmscript_roundtrip.py#L571)

Co-authored-by: yongwww <yongcale@gmail.com>

cc: @junrushao 


cc @Hzfengsy @junrushao1994

Co-authored-by: yongwww <yongcale@gmail.com>
2022-08-25 19:03:27 +09:00
Wuwei Lin 9aac161a46 [MetaSchedule] Add software pipeline in CUDA tensor core auto tensorization (#12544)
cc @Hzfengsy @junrushao @junrushao1994 @masahi @spectrometerHBH
2022-08-25 15:28:54 +09:00
Yaxing Cai cd8fd9121d [TIR] Expose shift_left and shift_right to Python (#12584)
This PR exposes the following TIR operation in python:

- `shift_left`: tested [here](https://github.com/apache/tvm/blob/1afd0593956066635ee49297b731726c9218c91c/tests/python/unittest/test_tir_transform_simplify.py#L487)
- `shift_right`: add new unittest

Co-authored-by: yongwww <yongcale@gmail.com>
2022-08-24 19:21:35 -07:00
Jyotsna Verma 1afd059395 [TOPI][Hexagon] Implement quantized avgpool (#12340)
* [TOPI][Hexagon] Implement quantized avgpool

* Fix pylint errors

* Needed to adjust input padding for int8 buffer layout

* Fix formatting issue

* Add unit test for fixed-point conversion utility function

Also, address review comments.

* Remove pytest.skip for test_avg_pool2d_slice.py to enable on-target testing

* Fix formatting issue

* Update python/tvm/topi/hexagon/utils.py

Co-authored-by: Christian Convey <christian.convey@gmail.com>

* Update comments and error messages

* Address review comments

* Import Tuple from typing

* Address pylint error

Co-authored-by: Christian Convey <christian.convey@gmail.com>
2022-08-24 11:55:50 -07:00
Farshid Salemi Parizi bf65b396c1 [Hexagon] Add support to run on multiple devices (#12504)
* working in parralel using worker

* creating launchers per test and clean up

* clean up

* ci change to distrube tests

* ci work with any number of devices

* fix running on simulator

* adding function docstring

* fix android_serial_number to always return a list of string

* lint issue

* fix internal error when skipping tests while androideserial number is not set

* lint issue
2022-08-24 10:29:30 -05:00
Yaxing Cai 038523e5a2 [TIR] Expose Vector-related API in Python (#12571)
This PR exposes the following TIR operation in python:

- `vectorlow`: tested [here](https://github.com/apache/tvm/blob/592148abf6866a41eefa736efca067d42f5aea86/python/tvm/tir/tensor_intrin/arm_cpu.py#L62)
- `vectorhigh`: tested [here](https://github.com/apache/tvm/blob/592148abf6866a41eefa736efca067d42f5aea86/python/tvm/tir/tensor_intrin/arm_cpu.py#L79)
- `vectorcombine`: add new unittest

Co-Authored-By: yongwww <yongcale@gmail.com>
2022-08-24 07:13:28 -07:00
Luke Hutton a0fe74b3c3 [ETHOSN] Support multiply conversion to depthwise (#12403)
Multiply can be supported when offloaded to the NPU by a conversion to a depthwise convolution operation. This is only supported when the multiply operation has a single single variable input with the other being a constant of shape [1, ..., C]. This commit adds a new pass "ConvertEquivalents" (name subject to change) to handle this conversion before codegen.
2022-08-24 13:45:57 +01:00
Christopher Sidebottom 592148abf6 [Target] Replace IsaAnalyzer with Target Features (#12322)
This is clean up to use the new `target.features` instead of `IsaAnalyzer`.
2022-08-24 11:24:05 +01:00
wrongtest 1ec2c36912 [TIR][CompactBufferAllocation] Improve upperbound estimation of buffer compaction (#12527)
Hi, this change wants to add some minor updation to region estimator used by buffer compaction:
- Add and clearify among `EstimateRegionStrictBound`, `EstimateRegionLowerBound` and `EstimateRegionUpperBound`
   
  Originally we have `EstimateRegionLowerBound`, actually it implements strict bound estimation IMO. Now add `upper` and `strict` version for where we actually want them.

- When estimating upperbounds (eg. in buffer compaction), try estimate each dimension independently when they are dependent accesses where `EstimateRegionLowerBound` is expected to fail. 

  Eg, `A[i, i], 3 < i < 16`  fails via `EstimateRegionLowerBound` who check indices be independent. But we can still try best to invoke strict bound analysis on each dimension individually.

- If range->extent == 1 for `EvalSet(range, dom)`, invoke `EvalSet(range->min, dom)` instead.
  
  Eg, `EvalSet([k*k, k*k+1), dom_k)` results to [-inf, +inf] due to current algorithm limitation but  `EvalSet(k*k, dom_k)` results to a range which makes more sense.
2022-08-24 17:44:22 +08:00
Nicola Lancellotti 989e5a1128 [ETHOSN] Add support for resize (#12535)
This commit adds support for the `resize` operator for
Arm(R) Ethos(TM)-N NPU.
2022-08-24 08:16:45 +01:00
Luke Hutton e468dc28ea [microNPU] Force compute_cycles_hint to be interpreted as an int64 value (#12558)
`compute_cycles` can be the size of an int64 value, however it seems
that when that value is attached to the IR as a pragma from Python,
it is interpreted as an `int`, rather than `int64_t`. This commit adds
an explicit cast to ensure the value is interpreted correctly.

The reason these values started appearing very large and randomly is
still yet to be solved, although the hope is that this fix will unblock
CI.

Change-Id: Idcdd7d37af1acd665590c87624446a025b50eb3d
2022-08-24 08:10:59 +01:00
crawlingcub 577826182f [PyTorch][Fix] Fix for numerically unstable logsigmoid (#12563)
* Fix numerical instability for log sigmoid

Fix numerical instability for log sigmoid in pytorch frontend

* update

* add test for overflow check

* merging two tests
2022-08-24 16:08:47 +09:00
Mehrdad Hessar c15cc5ef6d [Target] Remove deprecated parameters from target (#12416)
* remove depricated parameters in target

* lint

* fix cpp tests

fix

* remove more configs in test files

* address comments

* fix error

* fix hexagon

* fix micro tutorial

* fix integration tests

* fix hexagon

* lint

* fix unittest

* fix readme

* fix assert executor in target

* address comments

* fix tutorials

* fix hexagon target

* fix tutorial

* fix for tutorials

* hexagon
2022-08-24 13:02:27 +09:00
Gavin Uberti da5836f230 [AutoTVM] Add support for text buffers to ApplyHistoryBest (#12521)
Currently, AutoTVM's ApplyHistoryBest class does not support loading tuning logs from memory. This is a pet peeve of mine, as it requires you to work with a tempfile whenever writing autotuning tests. This is also just strange, as the rest of AutoTVM has support for text buffers (e.g. tvm.autotvm.callback.log_to_file supports passing in a text buffer, letting us write to but not read from them).

Additionally, ApplyHistoryBest handles input arguments very unintuitively. Before this PR, it allowed users to pass string filepaths, a list of string filepaths, or an Iterable (such as a list) of input and result tuples. However, it did not support taking in StringIO objects as mentioned above, nor pathlib.Path objects, nor combinations of a filepath and an Iterable of tuples.

In a perfect world, we would change ApplyHistoryBest to take as input a path-like object, file-like object, or an Iterable of input and result tuples (similar to what ApplyGraphBest takes as an argument). However, this would break the existing functionality to take as input a list of filepaths.

To be backwards compatible, while fixing this issue, this pull request defines a new type inside dispatcher.py:

Records = Union[
    Union[str, bytes, Path],  # Path-like objects
    TextIOBase,  # File-like objects
    Iterable[Tuple[MeasureInput, MeasureResult]],
]
It then rewrites ApplyHistoryBest.load so it takes the following arguments:

def load(self, records: Union[Records, Iterable[Records]]):
This PR also adds unit tests for this new functionality, and fixes a relevant bug in tests/micro/common/test_autotune.py in which a StringIO object was passed to apply_history_best, causing it to appear to pass but not actually read any data.
2022-08-23 09:32:56 -07:00
Matthew Brookhart dd7ae2d3e5 [Relay] Add Rsqrt to SimplifyExpr (#12363)
* Add Rsqrt to SimplifyExpr

* fix unit tests
2022-08-23 09:51:04 -06:00
Ashutosh Parkhi 52779f1273 [CMSIS-NN] Pad fusion with QNN Conv2D (#12353)
Pass that fuses nn.pad and qnn.conv2d for CMSIS-NN target.
2022-08-23 10:00:34 +01:00
Nicola Lancellotti 383bd41931 Fix TFLite 2.9 tests (#12130)
This pr fixes the tests that will be broken when we will update TFLite to
the 2.9 version.

We will update TensorFlow and TFLite versions to 2.9 so that we can
benefit from improvements in packaging to support multiple platforms
and Operating Systems.
2022-08-23 08:38:45 +01:00
Gavin Uberti 58f2139ffd [microTVM] Replace static fixtures with parameterization (#12530)
* Replace microTVM static fixtures with parameterization

* [microTVM] Only perform parameterization when fixture is present

* Reformat with black

* Fix Cortex-M tests

* Add docstring to pytest_generate_tests

* Remove trailing space from docstring
2022-08-22 18:59:26 -07:00
Gavin Uberti 5cef6bf559 [microTVM] Rework evaluate_model_accuracy into a more generic helper function (#12539)
* Add workaround for #12538

* Rework evaluate_model_accuracy into predict_labels_aot
2022-08-22 18:58:54 -07:00
Michal Piszczek 8e95bba697 Remove mutable defaults in mlp_model (#12546) 2022-08-22 17:11:40 -07:00
Tristan Konolige 1e399fa451 [TIR] Add pass to check for out of bounds memory access (#12352)
* [TIR] Add pass to check for out of bounds memory access

This is a conservative static analysis that checks to see if any out of
bounds array access occurs. It is not enabled by default.

* formatting

* manually construct local irmodule

* update comment

* fix bug in int_set
2022-08-22 13:35:40 -07:00
Michael J. Klaiber 902343a817 [BugFix][UMA] Fix order issue in uma_lower (#12447)
There was a flaw in uma_lower (see issue #12410) that lead in some case to a different argument ordering of the cached_func and the Relay function. This results in an incorrect lowering of the primfunc and eventually a wrong result of a run-time error, in some cases.

This commit adds code to correct the described misbehavior and a unit test case to check this end-to-end functionality with a TFLITE model.
2022-08-22 21:13:47 +01:00
driazati 4d7e7a8b57 [ci] xfail failing ethosu codegen tests (#12508)
This adds a testing utility so we can mark parameter combinations as
xfail without having to manually match each parameter from the name into
the code. The param strings here come directly from CI logs as in
https://ci.tlcpack.ai/blue/organizations/jenkins/tvm/detail/PR-12389/5/pipeline

Co-authored-by: driazati <driazati@users.noreply.github.com>
2022-08-22 10:35:08 -07:00
Josh Fromm 3f56851264 [TIR][Schedule] Support for specific consumer block targeting in cache_read (#12505)
* Add optional consumer blocks to cache_read.

* remove comments

* Fully functional

* Add test for consumer targetting.

* Formatting.

* Add missing parameter comment.

* Fix comments

* Simplify type of consumer_blocks in python.

* Change how consumer_blocks is printed in python.
2022-08-22 10:02:51 -07:00
Mohamad Katanbaf 40fd43e24b [MicroTVM] expose project options in autotuning (#12479)
* expose project_options in autotuning

* address comment

* address comment

Co-authored-by: Mohamad <mkatanbaf@users.noreply.github.com>
2022-08-22 09:58:11 -07:00
masahi 8146a9bf2c [TIR] Support AllocateConst nodes in TensorIR scheduling flow (#12489)
* [TIR] Support AllocConstantNode in CreatePrimFunc

* Handle AllocConstantNode in LeafBlockRemovalPlan

* Properly handle AllocConstNode in BufferAllocationLocator

* handle AllocateConst in EstimateFlops

* remove NDArray printing

* doc update

* add test

* cpplint

* Removed dependency on link-params attribute from target

* Restored NDArray printing to unbreak test
2022-08-22 23:03:40 +08:00
Luke Hutton 7c318d7196 [ETHOSN] Remove support for older versions of the driver stack (#12347)
Removes support for driver stack versions older than 22.05
(semantic 3.0.1). Additionally, changes the integration to make
version checks using semantic versioning rather than the previous
year.month versioning method.
2022-08-22 11:31:44 +01:00
chengven027-intellif e9aad35cf3 fix group conv3d pack kernel shape error (#12523) 2022-08-22 17:01:23 +09:00
Lite Ye 262906516a [TVMScript] Printer: add boolean operators to OperationDoc (#12518)
This PR adds boolean operators to OperationDoc. This is needed by the TIR expression printing because it has `tir::And` and `tir::Or`.

Tracking issue: #11912
2022-08-21 22:10:23 -07:00
Lite Ye cc769fdc95 [TVMScript] Printer entry point (#12462)
This PR:

- Adds an entry point for the TVMScript Unified Printer
- Adds a helper object class `RootNodeContainer` to provide an injection point for the actual printer implementation to add specialized logic on the root node to print.

Tracking issue: https://github.com/apache/tvm/issues/11912
2022-08-20 20:41:42 -07:00
Junru Shao 8ee4b604bc [MetaSchedule] Migrate MemoryDatabase to C++ (#12514)
This PR migrates the existing MemoryDatabase, which is implemented in
python at the moment, to C++. The original intent of having an in-memory
database that does not persist on disk is merely for testing, but as
times go on, we found it useful in production workflow, and thus decided
to migrate it C++ for potentially better performance.
2022-08-20 18:11:58 -04:00
Junru Shao 125c9caa02 [MetaSchedule] Implement ScheduleFn as a C++ class (#12513) 2022-08-20 18:11:13 -04:00
Junru Shao 3b3443bd12 [TIR][Schedule][UX] Beautify TIR Trace Printing (#12507)
Following https://github.com/apache/tvm/pull/12197, this PR introduces
`Schedule.show()` which convenience the user experience in the following
two aspects:
- Python syntax highlighting
- Outputs a schedule function instead of standalone instructions so that
it's easier to follow.

To demonstrate this change:
- Before `Schedule.show()` is introduced:
<img width="555" alt="image" src="https://user-images.githubusercontent.com/22515877/185713487-03722566-1df7-45c7-a034-c1460d399681.png">

- After this change:
<img width="583" alt="image" src="https://user-images.githubusercontent.com/22515877/185713564-c54f3a9d-cd52-4709-a8b8-d8a61361e611.png">
2022-08-20 18:10:19 -04:00
Mehrdad Hessar c83ee08c10 fix pytest (#12483) 2022-08-19 16:35:14 -07:00
Yulv-git bdcfa01eae [Fix] Fix some typos (#11503)
Fix some typos in src/.

Co-authored-by: driazati <driazati@users.noreply.github.com>
2022-08-19 16:31:30 -07:00
chengven027-intellif 9d6039b879 fix group_conv3d caculate error (#12500) 2022-08-20 08:30:47 +09:00
Mehrdad Hessar 8b3401ce6b [microTVM] Add config space to dense_dsp schedule (#12444)
* add config space

* lint

* lint
2022-08-19 15:40:08 -07:00
Krzysztof Parzyszek 6def53aeaa [Target] Only append default keys if target doesn't have any yet (#12474)
* [Target] Only append default keys if target doesn't have any yet

This allows target parsers to provide their own target keys. Without this
change, the default keys would always be appended, which may or may not
be desirable.

* Add "cpu" to ARM CPU keys

* Add "cpu" to the keys in the mprofile target parser

* Restore the mprofile cpptest, since the "cpu" key is back

* So the -device attribute is actually needed...
2022-08-18 18:11:23 -05:00
Aakanksha Verma 88928a40f1 [HEXAGON] Auto-vectorization (fp16) for v68 (#12397)
* Auto-vectorization (fp16) for v68

* use tvm.testing.main in fp16 test of tanh_slice op
2022-08-18 12:40:05 -05:00
Yaxing Cai 250b68e202 [TVMScript] IRBuilder, IRBuilderFrame base class (#12482)
* [TVMScript] IRBuilder, IRBuilderFrame base class

This PR introduces basic data structures of the generic IRBuilder
across the codebase.

IRBuilder is a general-purpose IRBuilder that can be used in TIR, Relax
and any other vendor-specific dialects; IRBuilderFrame is where contexual
information as stored in the IRBuilder.

* fix linter

* Update include/tvm/script/ir_builder/base.h

Co-authored-by: Junru Shao <junrushao1994@gmail.com>
2022-08-18 20:43:00 +08:00
arangasa 436c17f885 [HEXAGON][TOPI] This PR adjusts schedules so >64 length vector loads/stores are not generated at LLVM level. This is a workaround for an instruction selection issue in current version of llvm for hexagon (#12471) 2022-08-18 17:55:44 +09:00
Black f64a3bda25 [Frontend][Pytorch] Add axis N when maxpool3d layout is (C,D,H,W) (#12467)
* Add axis N if input is (C,D,H,W) layout.

* Add (C,D,H,W) test case.
2022-08-18 09:22:42 +09:00
Yaxing Cai b0b9bd976b [TIR] Expose TVM Backend API-related Builtins and Misc (#12468)
This PR exposes the following TIR operation in python:

`tvm_thread_allreduce`: tested [here](https://github.com/apache/tvm/blob/bcc7cde95c1e84b85f18c07110489350865b8cfe/tests/python/unittest/test_tvmscript_type.py#L135)
`type_annotation`: tested [here](https://github.com/apache/tvm/blob/bcc7cde95c1e84b85f18c07110489350865b8cfe/tests/python/unittest/test_tvmscript_roundtrip.py#L718)
`tvm_access_ptr`: tested [here](https://github.com/apache/tvm/blob/bcc7cde95c1e84b85f18c07110489350865b8cfe/tests/python/unittest/test_tvmscript_roundtrip.py#L717)
`tvm_throw_last_error`: tested [here](https://github.com/apache/tvm/blob/bcc7cde95c1e84b85f18c07110489350865b8cfe/tests/python/unittest/test_tvmscript_roundtrip.py#L343)
`TVMBackendAllocWorkspace`: tested [here](https://github.com/apache/tvm/blob/bcc7cde95c1e84b85f18c07110489350865b8cfe/tests/python/unittest/test_tvmscript_roundtrip.py#L340)
`TVMBackendAllocWorkspace`: tested [here](https://github.com/apache/tvm/blob/bcc7cde95c1e84b85f18c07110489350865b8cfe/tests/python/unittest/test_tvmscript_roundtrip.py#L465)

Co-Authored-By: yongwww <yongcale@gmail.com>
2022-08-17 12:06:19 -07:00
Yaxing Cai bcc7cde95c Expose Missing TIR Builtins to Python (#12466)
This PR exposes the following TIR operation in python:

`address_of`: tested [here](https://github.com/apache/tvm/blob/d2f9f254d275df256dbcbc5a9f8b3a07cee1d81f/tests/python/unittest/test_tvmscript_roundtrip.py#L3247)
`lookup_param`: tested [here](https://github.com/apache/tvm/blob/d2f9f254d275df256dbcbc5a9f8b3a07cee1d81f/tests/python/unittest/test_tir_usmp_analysis_extract_bufferinfo.py#L171)
`infinity`: add new unittest
`reinterpret`: tested [here](https://github.com/apache/tvm/blob/d2f9f254d275df256dbcbc5a9f8b3a07cee1d81f/tests/python/unittest/test_tvmscript_roundtrip.py#L2991)
`isnullptr`: tested [here](https://github.com/apache/tvm/blob/d2f9f254d275df256dbcbc5a9f8b3a07cee1d81f/tests/python/unittest/test_tvmscript_roundtrip.py#L260)

Co-Authored-By: yongwww <yongcale@gmail.com>
2022-08-17 02:26:45 -07:00
Yaoda Zhou 073304dadb [TVM PyTorch Integration] libstdc++ CXX11 ABI Compatibility & boolean tensor support (#12232)
* first commit

* rename

* cmake

* deprecated

* newline

* config

* config

* typo

* skip tvm_class

* rename

* delete ptr

* delete ptr

* save progress

* boolean support

* cmake file

* polish code

* compile config

* improving the codes

* format

* doc&errormsg

* zero-cost copy

* one step

* to ndarray

* extra output

* delete extra codes

* update test

* boolean support

* strong test

* decrease memory copy

* polish

* reformat

* polish

* remove redundant import

Co-authored-by: juda <yzhou@octoml.ai>
2022-08-17 17:33:37 +09:00
Krzysztof Parzyszek d2f9f254d2 Use std::string_view, remove experimental or pre-14 variants, NFC (#12460) 2022-08-16 21:38:29 -07:00