Commit Graph

3532 Commits

Author SHA1 Message Date
wrongtest 552f06ed45 support round-trip for T.Ptr in tvmscript (#11179) 2022-04-30 08:15:26 +08:00
Jiawei Liu 9ea4fa2450 [fix] vec * mat in matmul in onnx converter (#11174)
* fix: vec * mat in matmul in onnx converter

* fix: pylint

* fix: vec-mat matmul

* fix test

* fix test
2022-04-30 08:17:40 +09:00
Wuwei Lin 3414b3fae0 [MetaSchedule] Allow optional params to be None (#11188) 2022-04-29 12:54:27 -07:00
Mehrdad Hessar 6b45f8dc4a Remove micro_dev (#11169) 2022-04-29 09:22:45 -07:00
albert qing 7710dfd557 [TIR] Get read/write access precisely for opaque access. (#11110)
* [TIR] Get read/write access precisely for opaque access.

When the opaque access is wrapped with tvm_access_ptr, we can get the access_mask
from tvm_access_ptr in BlockReadWriteDetector and put this opaque access to read_regions
or write_regions according to access_mask.

* [TIR] Add parameter extent for access_ptr.

Co-authored-by: sqing <qing.siqi@intellif.com>
2022-04-28 21:00:29 +08:00
Ashutosh Parkhi 72e11baabb [CMSIS-NN] Moved TFLite model making to common area (#10939)
* [CMSIS-NN] Moved TFLite model making to common area

Change-Id: Ic4dbc1919ff0b481c05daf7e57cf9b055c714c9c

* Fixed lint issues with tensorflow import

Change-Id: I7a520beec9c244e9c790d3e82733c2fb476f7e5e

* Resolved merge conflict with main

Change-Id: Iefe58dd321efae6eae26cd54a31c5923d0f1e32b

* Made TFLite layer creation explicit

Change-Id: I7fbf6a5a2163c1fada49477f86d84f1bc09bd57c

* Lint fix: added a missing docstring

Change-Id: If1fb8bb09c538c04e333ccab65a20cff247a504d
2022-04-28 10:17:15 +01:00
AndrewZhaoLuo 9fd279b40a [Graph Debugger] Expose way to benchmark individual nodes. (#11000)
* initial

* secondary commit

* docs

* match tests

* fix test

* use std::fixed, max precision, typed pack func, fix isnan

* comments on docs

* address tristan comments

* add test

* tristan comments

* use skipif

* empty commit

* empty commit

* jostle again

* remove assert statement
2022-04-28 10:03:29 +09:00
Altan Haan 94269a8952 fix incorrect pos ids generation in EmbedLayerNormalization (#11149) 2022-04-27 15:59:30 -07:00
blackkker 141c8b8c4b [Frontend][ONNX] Update softmax calculation method when dimension > 2 (#11123)
* update Softmax with uniform operator

* add testcases for softmax
2022-04-27 10:36:29 -07:00
Siyuan Feng c09a24dcdc [TVMScript] Support TVMScript template meta-programming over variables (#11097)
This PR supports a simple meta-programming paradigm for TVMScript, which allows users to get access to var definition in the Python environment.
2022-04-27 01:38:00 -07:00
Masahiro Masuda 68464841ea [Metaschedule] Auto tensorization for CPU / GPU dot product (#11088)
* [Metaschedule] Auto-tensorization for CPU / GPU dot product

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

* doc update

* add vnni conv2d test

* add dp4a test

* adding tests for rewrite_tensorize

* add rewrite_tensorize test

* add missing pydoc

* black

* more doc

* adding auto tensorize integration test

* add dp4a test

* fix target name

* fix dtype in test

* skip bert test

* replace hard-coded llvm intrinsic id in test with look up

* remove unnecessary include, add doc for the rest of params

* update postproc.h

* update doc

* fix shape in te matmul workload

* fix newline in cppdoc

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: Wuwei Lin <wuwei@apache.org>
2022-04-26 10:17:44 -07:00
wrongtest 4dc47df369 allow constant value let binding in script (#11115) 2022-04-26 15:04:35 +08:00
Leandro Nunes 4330c21888 [Python] Populate setuptools description with README.md (#11078)
* [Python] Populate setuptools description with README.md

Adds the description metadata for the setuptools descriptor file
`setup.py` with the contents of our existing README.md, which is
a common practice.

* Update python/setup.py

Co-authored-by: driazati <9407960+driazati@users.noreply.github.com>

* Update python/setup.py

Co-authored-by: driazati <9407960+driazati@users.noreply.github.com>

* Import pathlib and apply black formats.

Co-authored-by: driazati <9407960+driazati@users.noreply.github.com>
2022-04-25 17:39:35 -07:00
Manupa Karunaratne ce29f02f4c [USMP] Adding support for U4 usecase (#10785)
* [USMP] Adding support for U4 usecase

This commit adds support for placing I/O
tensors within the workspace buffer.

This is enabled using PassConfig option
tir.usmp.use_workspace_io. Once it is enabled,
it will remove the I/O tensors from the TIR
main PrimFunc and replace them with Allocate
nodes that is annotated to contain Input and
Output tensors.

The USMP will plan memory for them accordingly.
(i.e. it will re-use space used by them for
intermediaries depending on the liveness).

This will only be supported with C Interface API.
Thus, this commit produces two functions to the
metadata sources to obtain input and output structs
that points to location inside the workspace struct.

Change-Id: I4c7e750ead9a880ba900602c17f53a125f97dbf9

* fixup! [USMP] Adding support for U4 usecase

Change-Id: I78f03d36b12b4a5e8eae8d11701f51019489defc

* fixup! [USMP] Adding support for U4 usecase

Change-Id: I857f3d0ba7bc192d56d750c44b232998b2876e7a
2022-04-25 17:37:59 -07:00
Mehrdad Hessar dca94ec9d1 [Hexagon] Add test for registered schedules (#11016)
* add hexagon schedule tests

* moved tests to sub-directories
2022-04-25 17:18:19 -07:00
Nyakku Shigure 4015916a06 convert full-width characters to half-width characters (#11112)
* `)` -> `)`

* `】` -> `]`

* `、`

* `,` -> `,`
2022-04-25 15:13:21 -07:00
Ziqang XU 1aee5e1728 Complete pytorch grid_sample (#10504)
Pytorch's grid_sample() supports various interpolation options:
(1) data dimension: 2D / 3D
(2) interpolation method: nearest / bilinear / bicubic
(3) padding_mode: zeros / border / reflection
(4) align_corners: True / False

However, TVM only supports a part of above options:
(1) data dimension: 2D
(2) interpolation method: bilinear
(3) padding_mode: zeros / border
(4) align_corners: True

This commit completes the options not supported by TVM, and keeps existing
grid_sample of onnx/pytorch uninfluenced.

Co-authored-by: shukun.net
2022-04-25 17:17:49 -03:00
blackkker 57d57afb5c update for using new functions (#11100) 2022-04-25 17:23:56 +01:00
Gustavo Romero 24e5498021 [TVMC] compile/tune: Check if FILE exists (#10865)
Currently when a non-existing FILE is passed to 'tvmc tune' it throws
a traceback because a FileNotFoundError exception is not handled. Since
there is no need for such abrupt exit, and the trace can also confuse
users, this commit fixes it by checking if FILE indeed exists, kindly
informing the user about the non-existing FILE before exiting.

Add test for verifying if 'tvmc compile' and 'tvmc tune' commands handle
correctly the FILE option when it is invalid (e.g. missing, a dir, or a
broken link).

A TVMCException will be generated by test_tune_rpc_tracker_parsing test
because FILE will be set by pytest to a mock object, which is not a
valid input. Since FILE argument is irrelevant for the test in question,
circumvent the Mock hijack of FILE argument by setting it before using
mock.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
2022-04-25 15:47:01 +01:00
Elen Kalda d2db9cb0d8 [microNPU] Integrate the cascader (#10862)
* [microNPU] Integrate the cascader

Integrate the cascader into the codegen and optionally enable it
with the enable_cascader flag. Includes placeholder MemoryRegions until
integration with the PoolInfos provided by a user.

Co-authored-by: Matthew Barrett <matthew.barrett@arm.com>

* Fix linting and a docstring

* Plumbing and testing improvements

Plumb the workspace memory pools into into the cascader and make
the tests to check for the memory reduction.

* enable_cascader() -> is_cascader_enabled()

* Check for the exact value of workspace size

* Remove unused ACCEL_TYPES

* Linting...

Change-Id: If2d92846f05a7e8b21be767163841084538805a9

* Rebasing...

Co-authored-by: Matthew Barrett <matthew.barrett@arm.com>
2022-04-25 10:08:38 +01:00
Mehrdad Hessar 822d863770 [Hexagon] Add mobilenet test (#11104)
* Add mobilenet test on Hexagon

* Address comments

* fix import and remove extra function
2022-04-23 10:00:55 -05:00
Yuanjing Shi 60e43e16a0 [Auto Scheduler]add task name during printing table info (#11098)
* add task name during printing table info

* address comments and fix lint

* better look

* fix linting

* fix linting again
2022-04-23 09:46:53 +09:00
Peter Salas 8691cbed0b [CONTRIB] Add PopenWorker process recycling (#11094)
* [CONTRIB] Add PopenWorker process recycling

* Clarify docstrings

Co-authored-by: Peter Salas <psalas@octoml.ai>
2022-04-22 15:21:00 -07:00
Eric Lunderberg 83672c65c7 [Analysis] Exposed Analyzer::CanProveEqual to Python API (#11102)
* [Analysis] Exposed Analyzer::CanProveEqual to Python API

Checking for `analyizer.simplify(lhs-rhs) == 0` was a frequent pattern
in Python unit tests, and already had a utility function in the C++
public API.  Exposing this utility function to Python allowed this
pattern to be cleaned up.

* Replaced more cases of .simplify with .can_prove_equal
2022-04-23 07:00:10 +09:00
Mehrdad Hessar effc23df7c [Hexagon] AoT with LLVM Codegen on Hexagon (#11065)
* AOT with LLVM Codegen on Hexagon

* Address comments
2022-04-21 15:49:18 -07:00
stoa 60a9e23104 STM32: add as a new target (#9385)
* STM32: add as a new target

* STM32: Target takes a board ID rather then a series.

* STM32: target series.

* STM32: Fixed lint issues.
2022-04-21 14:15:52 -07:00
Nicola Lancellotti c07a46327c [microNPU] Integrate rolling buffers in Arm(R) Ethos(TM)-U (#10344)
* [microNPU] Integrate rolling buffers in Arm(R) Ethos(TM)-U

Change-Id: Iede5e68981a063f6eb1e118433cc2c92e175af52

* Add documentation for create_tiles

* Fix linter issues

* Fix integration tests
2022-04-21 19:16:24 +01:00
Siyuan Feng 876e253227 [TIR] StmtFunctor RenewDefs (#10843)
* [TIR] StmtFunctor RenewDefs

In this PR, I introduce a StmtFunctor `RenewDefs` for deep copy all definition nodes in PrimFunc (including Var, Buffer, and IterVar). This functor can create a new PrimFunc with the same behavior as the old one but contains different Nodes.

This Functor may help TIR fusion or inline multiple PrimFuncs

* add ut

* address comments

* address comments

* lint

* lint
2022-04-21 10:55:04 -07:00
Eric Lunderberg ba4cc6c1f2 [TVMScript] Allow val = buf[index] without type annotation (#11060)
* [TVMScript] Allow `val = buf[index]` without type annotation

Other instances of `var = expr` were previously allowed without
requiring a type annotation, by using the dtype of the expression as
the dtype of `var`.  This behavior didn't work for `buf[index]`
expressions, which are internally represented as `BufferSlice` python
objects, and only converted to `BufferLoad` primexprs when used as an
expression.

This commit adds a `dtype` property to `BufferSlice`, allowing
`buf[index]` to be used in a let statement without a type annotation.

* Reverted a wider change

Automatically adding a type annotation to Var if it could be
determined from the dtype let the unit test directly compare the
annotated and unannotated versions of buffer load.  Unfortunately, it
also broke 54 unrelated tests, so that change is removed from this PR.
2022-04-21 10:09:24 -07:00
Jocelyn S 97ae25cf83 [FQ2I] Add log op to FQ2I (#10924)
* unary op for resize2d and test

* renamed test

* added log in quantized form

* black'd some files

* changed suggested commentary
2022-04-21 09:58:56 -07:00
Masahiro Masuda a6ef5af158 [CI] Update GPU image for oneflow v0.7 (#11085) 2022-04-21 13:33:50 +01:00
Xiyou Zhou b952425b2d Restart popen pool. (#11074)
Retrigger CI.

Address issues.

Retrigger CI.
2022-04-21 18:54:11 +09:00
Masahiro Masuda 0070b6cc05 [TIR] Add TileWithTensorIntrin (#11075)
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: Wuwei Lin <wuwei@apache.org>

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: Wuwei Lin <wuwei@apache.org>
2022-04-21 11:08:10 +09:00
ah cheng 7612b22cf5 [Frontend][ONNX]support Pool2D layout is CHW (#11034)
* support  Pool layout is CHW

* fix lint test

* change the if condition
2022-04-20 11:21:34 -07:00
Sevin F. Varoglu 58b7a5a268 [QNN] Support input scale and zp of 1-element vector in qnn.conv2d_transpose (#10952)
* Support input scale and zp of 1-element vector in qnn.conv2d_transpose

* Lint
2022-04-20 09:47:37 -07:00
Leandro Nunes 970f868272 [TVMC] Add configuration json files to the Python package (#11063)
Add the `configs` directory to be part of the installed version of
TVM in the setuptools configuration, and introduce a new function
to load the `configs` directory from the right paths both when TVM
is locally installed for development, as well as, when it is installed
as a package.
2022-04-20 14:22:36 +01:00
Jacob Bohlin 0b957802b0 [microNPU] Cascader performance model bugfixes (#10510)
* [microNPU] Performance model bugfixes

* Fixed incorrect num_blocks calculations for both BufferModes.
* Fixed similar issues with Read/Write byte calculations.
* Fixed an issue where the 'partkernel' flag was not propagated to
  the performance estimation code.
* Fixed single buffering check incorrectly used output shape and
  block rather than the input shape and block.
* Fixed block config not aligned to micro block for Elementwise.

Change-Id: Ide6b231bc1a17c65bed20129d2179a215ada14b2

* Address review comment

Changed incorrect usage of 'max_width' to 'max_depth'.
2022-04-20 10:10:47 +01:00
Masahiro Masuda 3823b39b8a [TIR] Utility function to decide loop mapping for auto tensorization (#11050)
* [TIR] Add TensorizeInfo and GetTensorizeLoopMapping

* expose PreOrderVisit to python

* add test case

* add conv2d nchwc test

* add mma test

* add arm nhwc conv2d test

* Revert "add arm nhwc conv2d test"

This reverts commit eb147f33bb02d62a0eacc9cdfe777ac047ee1bc9.

* refine

* add doc

* update

* fixd condition

* black

* pylint

* Update python/tvm/tir/schedule/analysis.py

Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>

* run black

* bring back logic in original code to support loop permutation

* add comment

* simplify

* minor fix to test

Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>

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: Wuwei Lin <wuwei@apache.org>
2022-04-19 20:01:24 -07:00
Krzysztof Parzyszek 24d5539c43 [Hexagon] Pass stack size to simulator (#11046)
Increase the default stack size to 256kB, since this is the minimum
main thread stack size in QuRT on simulator.
2022-04-19 10:15:55 -05:00
Alexey Voronov 312b552b11 Add FlattenAtrousConv transformation (#10996) 2022-04-19 21:21:45 +09:00
Christopher Sidebottom 94f28b29c5 [TVMC] Add --config argument for config files (#11012)
* [TVMC] Add `--config` argument for config files

Collecting common configurations for users of TVM and exposing them gracefully in tvmc using a `--config` option
as defined in https://github.com/apache/tvm-rfcs/blob/main/rfcs/0030-tvmc-comand-line-configuration-files.md

Co-authored-by: Shai Maor <shai.maor@arm.com>

* Add correct test guards

Co-authored-by: Shai Maor <shai.maor@arm.com>
2022-04-19 11:50:12 +01:00
Andrew Reusch 4178617fcf [AOT] Support LLVM backend with C++ runtime (#10753)
* add get_c_struct_name() method to Metadata to distinguish struct type name in llvm

* add metadata serialization support to llvm codegen

* Organize MetadataQueuer into a separate file.

* Add DiscoverArraysVisitor to metadata_utils

* Fill DLTensor metadata in LegalizePackedCalls.

* Improve error message from Call asserts

* Pass non-String device_context down to codegen.

 * this is necessary to allow CodeGenCPU to emit calls that include resource_handle.

* Scope usage of lvalue refs in LowerTVMBuiltin to avoid corrupt memory.

* test fixes

* Also fill preflattened_buffer_map (TODO, maybe don't do this)

* Fix C codegen.

* Set USMP elem_offset to 0.

* Clarify calculation of byte_offset from elem_offset.

* fix tests

* Fix arm compile warning

* Fix hexagon test.

 * previously I believe we required interface_api == "c", but
   this really means to generate C API bindings, and we are generating
   "packed" bindings.
 * I think "c" was chosen here because the distinction between
   interface-api and use-unpacked-api is confusing. "c" interface-api
   means to generate an entrypoint API for microcontrollers that
   accepts bare data buffers. "packed" interface-api means to generate
   a TVMBackendPackedCFunc entrypoint. use-unpacked-api forms the same
   determination for the operator functions.
 * A further confusion here is that there are two ways to call
   "packed" operator functions: tir.tvm_builtin_call_packed and
   tir.tvm_builtin_call_cpacked. This distinction describes whether or
   not to late-bind calls via TVMBackendGetFuncFromEnv. Right now, AOT
   only ever requires call_cpacked because target_host == target, and
   for all suitable target_host, we expect a single DSO-exportable
   runtime.Module. When we move away from this by introducing
   heterogeneous target support to AOT, we can use this as a condition
   to help us choose between call_cpacked and call_packed (and
   possibly add a compile-time option to assert it is call_cpacked,
   for situations where we really don't want call_packed).

* Document T.preflattened_buffer

* Fix test_aot_legalize_packed_calls

* Address manupa comments

* Fix convert_pool_allocations_to_offsets test.

* lint

* Fix T.preflattened_buffer

* Add preflattened_buffer_map to TIRTextPrinter

* Fix tests

* Fix BYOC

* Fix invoking C device API.

* remove comments

* Address Mousius comments

* lint

* lint

* Fix GMock linking on new CMake

* address masahi comment

Co-authored-by: Masahiro Masuda <masahi129@gmail.com>
2022-04-18 18:44:46 -07:00
Mehrdad Hessar f6171914a7 [Hexagon] Adjust RPC read buffer size from python (#11022)
* added buffer size

* remove default size
2022-04-18 17:32:53 -07:00
Junru Shao 0b9bcf0e7a [MetaSchedule][Refactor] Introduce TuneConfig (#10986)
This PR unifies the existing `EvolutionarySearchConfig`, `ReplayFuncConfig` and `ReplayTraceConfig` into `TuneConfig`, and refactored the logic in `meta_schedule/tune.py`
2022-04-18 00:38:41 -07:00
chengruichang 9f3da1cbae [Frontend][Paddle] Fix pool2d op (#11029)
* fix pool2d op

* [frontend][Paddle] Fix pool2d Op

* reformat files
2022-04-18 13:49:41 +09:00
Valery Chernov fafabc96c1 [VirtualMachine] Zero copy in set_input when input is DLTensor (#11003)
* method of creating of NDArray from external DLTensor was implemented

* set input without copying for DLTensor source

* code clean up

* update description and comments after review

Co-authored-by: Valery Chernov <valery.chernov@deelvin.com>
2022-04-15 15:31:01 -07:00
Hua Jiang 351f31b51c [Runtime][PipelineExecutor]Add forwarding queue logic for set input. (#10990)
* [Runtime][PipelineExecutor]Add forwarding queue logic for set input.
When the set_input function get called, a runtime of pipeline may not
yet finish the former computation work then the new set_input call would
break the current computation logic, to avoid such issue, we add the
forwarding queue logic to guarantee the order of input data consuming.

* polish the documents.
2022-04-16 07:03:04 +09:00
billishyahao 37db213a84 [QNNParam] Refactor the implmentation of QNNParam (#11011)
* The patch is to simplify the implmentation of QNNParam and make it more friendly to Python 2.x.

* Empty-Commit

* fix error about boolean value of Tensor with more than one value is ambiguous.
2022-04-15 10:13:19 -07:00
Eric Lunderberg 8bfe3bbb3c [Arith] Updated arith::DetectIterMap to keep extent=1 components (#10980)
* [Arith] Updated arith::DetectIterMap to keep extent=1 components

Previously, arith::DetectIterMap simplified the output expression by
replacing iteration variables with extent==1 with their value.  This
prevented the return value from being used in
arith::InverseAffineIterMap to solve for the variable, as it no longer
existed in the returned expressions.

This commit changes arith::DetectIterMap to keep the iteration
variable even if extent==1, and adds a motivating unit test that
requires this updated behavior.

* Updated to retain default behavior of DetectIterMap

To avoid breaking existing test cases, updated to maintain the same
default behavior, but a flag to maintain trivial iterators in the
result.

* Updated FFI and Python API for DetectIterMap
2022-04-15 10:02:56 -07:00
Masahiro Masuda a9d86e61b6 [Metaschedule] Support tuning on rocm and vulkan target (#11017) 2022-04-15 15:11:41 +09:00