* [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>
* [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
* [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>
* [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>
* [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
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
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>
* [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>
* [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
* [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
* [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.
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.
* [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'.
* [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>
* 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>
This PR unifies the existing `EvolutionarySearchConfig`, `ReplayFuncConfig` and `ReplayTraceConfig` into `TuneConfig`, and refactored the logic in `meta_schedule/tune.py`
* 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>
* [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.
* 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.
* [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