A quick fix of the parser issue mentioned in #10327 .
Ranges and loops require `start` and `stop` to be PrimExpr, however, `BufferSlice` is not always scalar so it's not a `PrimExpr`.
This PR performs the transformation.
* [TIR] Introduce tir.allocate_const to TIR
This PR is adding non-scalar constant representation in TIR. This is used to
express constants (i.e., parameters) in the TIR instead of bypassing the
TIR as it's done until now.
Change-Id: Id3afc4d7197260cb43ecde60f05ccbce3fc42430
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Change-Id: Id4a09a637c9c1fd7d49989c6c10f474a78569e18
* [TIR] Integrate tir constant nodes in compilation pipeline
This PR integrates tir.allocate_const to the compilation pipeline to support --link-params.
Change-Id: Ic8d0cb75d596299fcae7078b304598afbf0c5494
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Change-Id: Id98cc682bbfacfe75c4d8b260fd41658f1f196b2
* [TIR] tir.const extraction
This commit tries to implement an amendment to tir.constant RFC
with centralized storage of constant data within the IRModule
Please note that data and irmod_storage_idx are not mutual exclisive
further more the irmod_storage_idx is valid only immediatly after
prim func addition to the mod or after update within the mod.
If prim func is out of the the module scope then the index become
meangless. irmod_storage_idx also is not used in calculation of hash
function of the tir.constant node.
Change-Id: I40742ed580468b0252ea3fec02184cba65e20871
* unit test fixed
Change-Id: Ied2186554d4cbad44b2346216c8be92449e55732
* cmsis-nn codegen fix
Now handled case when params of the functions came as constants
Change-Id: I5874e182e34ef94e23048eaf3c61b01a56d91131
* Fixes for unittests
Change-Id: I5b82ee3f80337155706b5470973f494a301b5d90
* Rebasing tests fixes
Change-Id: I94ac87907081bab53c1dd1ab2db106ae057b4b19
* Linter: added method param description
Change-Id: I2f8c4c8d244b74c794abaa6079c46cc593ffcbdb
* Printing removal fix
This patch removes forgotten print in fuse_ops
Change-Id: I4bb5934f3b4cd5fde19d36a8e3319aae136bce8a
* Bugfix
Fixed concurrent map update bug here
Change-Id: Ifec3bf5030086d9079b9e493096f17dfd82297ec
* Reworked logic for not to introduce empty constant list to modue attrs
Change-Id: I082c85b3b4b70c218f0d714f5613ef6e178bd020
* Added support for tir builtin::tvm_access_ptr
This fixed unit tests for tests/python/integration/test_arm_mprofile_dsp.py
Change-Id: I10919f301ef9ddc3fd87f0e1a8414e9a52fc7938
* Unit test fix
Fixes unit tests in torch frontend
Change-Id: I6c179834f93dd202605d1ce5a7f07d987b9dc469
* Addressed requested changes
Addressed changes requested upstream
Change-Id: I741e52b89eb285732c23b1ac7ff277e757a088c3
* Namespace usage changed to conform earlier C++ standard
Change-Id: I1b29238cfe2a6bedb525f4f823a3a540f631d836
* Bugfix
Change-Id: I57a44b714b307278a243817ec2864e53ad31366b
* updated IRModuleNode::ExtractPrimFuncConstants
Updated IRModuleNode::ExtractPrimFuncConstants as per
request upstream.
Change-Id: I35db0145fb5827efd0445ce665d0c99465274016
* Minor changes
typo fixd
renamed ExtractPrimFuncConstants to ExtractConstants
removed getters/setters from FuseMutator and added parametrized
constructor
Change-Id: Ib2326805781779b88c963a8642ff683c8755956e
* Moved LinkedParam/LinkedParamNode
Moved LinkedParam/LinkedParamNode from tvm::tir namespace to tvm
namespace
Change-Id: Ie3f0303bd4f7890c6d680268c91f2051977bc7f4
* Addressed upstream comments
Changed BindParams argument to Array<NDArray>
Removed 'name' argument from te.const
Switched to in-depth comparision of NDArrays in constant de-duplication
Removed extra final comma from NDArrayToTIR
Changed return type of ConstantAllocationSize to int64_t
Made link_param a tvm.testing.parameter for test_fuse_take and test_fuse_gather_nd
Change-Id: I4285099cc63756aa5ebe91a5bd207d4135499b41
* Removed unnecessary forward declaration
+linter
Change-Id: I2a6c0d1f97773aeb1ae3f458da252a22079ccdb1
* Constant extractor now is a separate pass
Change-Id: Ia4adca9d3315b26fbdc006ef7c115900c081e303
* Added forgotten file + unit test fix
Change-Id: Ice305f4fefd13fe95e97574e6d63ffeb664621df
* Changed to IRModule pass
Refactored ExtractPrimFuncConstants to IRModule pass.
deDup -> DeDup
Refactored logic of Applicator supplementary class
Change-Id: I6c120d175eb6790ba90f176c4f856bde8f0c7c94
* bugfix after rebasing
Change-Id: Ie3ee6ea2479476a30f486baef74f20070f117942
* -v -> -vv to have more debug information
Change-Id: I12c63731663b9c9ea574b9ed5cb17311ba3cf701
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
* [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.
* fix parse strimm value in for annotations
* flatten buffer allow runtime.String attr value
* remove unused import
* rebase and ensure flattened attr order
* fix number of arguments
* make test clear
* Update tests/python/unittest/test_tvmscript_syntax_sugar.py
Co-authored-by: Wuwei Lin <vincentl13x@gmail.com>
* only tuple for now
Co-authored-by: Wuwei Lin <vincentl13x@gmail.com>
* Update doc building instructions and pin dependencies
This pins the dependencies for the docs and adds `pytest` as a
dependency which was missing when I built. Tested out the
requirements.txt with a fresh `ubuntu:focal` Docker image to verify that
the required depedencies work.
* Address comments, add Makefile for docs and add to instructions
* Use Python for running scripts
* Fix lint, add lint command
* Add option for cpu to only run the precheck, address comments
* Fix 'make doc' usage, add some -x's
* Fix bad condition on --cpu, add defaults for envs
* Fix another 'make doc'
* Fix for running on MacOS
Co-authored-by: driazati <driazati@users.noreply.github.com>
* [TIR][USMP] adding the pass to convert to pool offsets
This commit adds a transform pass that consumes
the planned pool allocations using memory planning algorithm
that convertes them to pool offsets.
* adds two test cases for a linear structure with two pools
* adds test case with a single pool for residual structures
Change-Id: I9d31e854461b5c21df72d1452120d286b96791c0
* [TIR][USMP] adding the pass to convert to pool offsets
* Adding a toggle to produce TIR that is TVMScript printable for unit
testing
* Fixing the unit tests
* Ensure deterministic pool variable ordering.
Change-Id: I317675df03327b0ebbf4ca074255384e63f07cd6
* [TIR][USMP] adding the pass to convert to pool offsets
Fixing the references after changes in the memory planning
algorithm.
Change-Id: Id7c22356fd5de43d10a2b4fc70e978af2c6d599d
* [TIR][USMP] adding the pass to convert to pool offsets
* fixing the lint
Change-Id: I7ff920b92d14a9919c930a4b35a2169c77a57dd1
* [TIR][USMP] adding the pass to convert to pool offsets
* removing unnecessary defitinitions
* remove global var map
* adding explaination for let bindings to pointer type
Change-Id: I31bd1a9f3057ee7f06252263565b0f75c51e6d13
* [TIR][USMP] adding the pass to convert to pool offsets
* rebase changes
* making imports absolute
* fixing typos and removing unnecesary lines
Change-Id: I4c94b9955b001513fecb39ca94f81b1ad99c7bfc
* [TIR][USMP] adding the pass to convert to pool offsets
* fixing typos
Change-Id: I42c557fd394aefdf8c2e825c4e88770eb0732f9b
* [TIR][USMP] Added buffer info extraction pass
This commit adds a pass that takes the main (call graph of operators)
TIR PrimFunc and each operators also as TIR PrimFunc. The pass will
traverse through all TIR PrimFunc starting the from main. Thereafter,
it will extract information from tir.allocates. Among the information,
the liveness conflicts are reported.
* Added test for a linear model
* Added test for parallel/serial mixed for loops
* Added test for a substructure of inception-style model.
* Exposed buffer_info creation to python
* Added member functions to update pool info
* Unit tests to cover functionality of buffer_info
Change-Id: I5e163ac3e83c830629a5d34ed4407c9962701c60
* [TIR][USMP] Added buffer info extraction pass
Swap key-value pairs of returned values of the buffer_info
extraction pass.
Change-Id: Ia4f7289592bc776ef6189a41a7891038751bf31f
* [TIR][USMP] Added buffer info extraction pass
Updating the USMP utility tests to include tests
that test creation of PoolInfo and PoolAllocation
Objects.
Change-Id: I5d349d0ffcac6b0160072d832dd9d5418699228e
* [TIR][USMP] Added buffer info extraction pass
* Removing the unnecessary header : include/tvm/tir/usmp/analysis.h
* Some nits and cleanup
Change-Id: Iac3ddd9428c56cd8ef49cf643e797bf6fdf4e97a
* [TIR][USMP] Added buffer info extraction pass
* Change the class data members to have a trailing underscore
Change-Id: I71809b3c73b0bc0cd133fad1392ae8c17c895ee4
* [TIR][USMP] Added buffer info extraction pass
Adding more documentation for data structures
and the approach
Change-Id: Ide2bfffaeff9add86853b6992017264e5d796299
* [TIR][USMP] Added buffer info extraction pass
* Added more documentation
* Added functionality to handle multiple calls
for the same PrimFunc with a test.
Change-Id: Ib7c27b3cf17f415067a224f1e57d8b928f4c7c6f
* [TIR][USMP] Added buffer info extraction pass
* Attaching targets to PrimFuncs in the util test case
Change-Id: I82960512659a346f6242b2b5789ec1120f8ea2cf
* add support for prevously uncovered cases
* remove PrimExpr import
* add exp test and mypy ignore
* disable ling too long
* resolve long line
* nit
* add dtype to unary ops
* Adding annotation for tir.allocate
This commit is adding annotations for tir.allocate
node to be used as hints for future transformations.
Change-Id: I02a3a875c38c3edd449385da5b741ef4958bb47f
* Adding annotation for tir.allocate
* adding tvmscript support
* adding tir text printing support
Change-Id: Id0b6725b2e79c23f6b8ff192772f1ea4125a27c2
* Remove all attr::storage_scope usage
* pyformat
* fixed VTA tests
* Update TIR text printer to print storage_scope on allocate
* print storage scope in AllocateNode ReprPrinter
* Fixed accidently removed scope tag check
* remove unused function
Co-authored-by: masa <masa@pop-os.localdomain>
* Add storage scope to ProducerRealize, always create a buffer with scope
* update schedule_ops.cc
* update schedule_postproc_to_primfunc.cc
* restore more realize_scope
This reverts commit b66c3baa54feeb8e34016713a1be21802b3296bf.
* make the default scope be "" instead of None in ir builder
* restore realize_scope visit in storage_flatten.cc
* update storage_access.cc
* make sure buffer var is of PointerType in ir builder
This reverts commit e650b6c24cabd52a073064e51c2e4fee816e88fd.
* enforce default storage scope of global
* added remap pass but does not work yet
* fixed all reduce issue
This reverts commit 8e20003c5325085ed22ee57180aca18644b3b5ab.
* simplify
* trying mitigation for aot test
* merge remaining changes from initial branch
* remove use of attr::storage_scope from codegen
* restore a visit to AttrStmt with attr::storage_scope in storage_rewrite
* disable check
* lint fix
* revert default scope to ""
* format
* fix volatile access to shared mem in lower all reduce
* fixed gpu coorporative load/store test
* pass storage scope to PointerType in tvm script parser
This reverts commit 99cfb9d18781dcfdea169d920450f9063ab18b6b.
* fixed tvmscript roundtrip test
* fixed tir flatten buffer test
* fixed test_tir_transform_hoist_if.py
* use storage scope global by default in aot_executor_codegen.cc
* add missing default storage scope in create_primfunc.cc
* restore StorageInfo struct in llvm backend
* UpdateStorageScope -> WithStorageScope
* fixed lower warp memory test
* GetStorageScope -> GetPtrStorageScope
* Enable storage scope invariant check in AttrStmt constructor
* remove GetPtrStorageScope and WithStorageScope from public header
* move RemapStorageScope to its own file
* add more method to RemapStorageScope
* update lower_thread_allreduce to use RemapStorageScope
* RemapStorageScope -> UpdatePointerStorageScope
* remove realize_scope from hybrid script
* removed realize_scope in schedule_ops
* remove realize_scope from schedule_postproc_to_primfunc
* remove remaining realize_scope usage from schedule_ops.cc
* remove realize_scope usage from storage_flatten.cc
* fixed test_tir_transform_lower_warp_memory.py following realize_scope removal
* Add storage scope to ProducerRealize, always create a buffer with scope
* update schedule_ops.cc
* update schedule_postproc_to_primfunc.cc
* restore more realize_scope
This reverts commit b66c3baa54feeb8e34016713a1be21802b3296bf.
* make the default scope be "" instead of None in ir builder
* restore realize_scope visit in storage_flatten.cc
* update storage_access.cc
* make sure buffer var is of PointerType in ir builder
This reverts commit e650b6c24cabd52a073064e51c2e4fee816e88fd.
* enforce default storage scope of global
* added remap pass but does not work yet
* fixed all reduce issue
This reverts commit 8e20003c5325085ed22ee57180aca18644b3b5ab.
* simplify
* trying mitigation for aot test
* merge remaining changes from initial branch
* remove use of attr::storage_scope from codegen
* restore a visit to AttrStmt with attr::storage_scope in storage_rewrite
* disable check
* lint fix
* revert default scope to ""
* format
* fix volatile access to shared mem in lower all reduce
* fixed gpu coorporative load/store test
* pass storage scope to PointerType in tvm script parser
This reverts commit 99cfb9d18781dcfdea169d920450f9063ab18b6b.
* fixed tvmscript roundtrip test
* fixed tir flatten buffer test
* fixed test_tir_transform_hoist_if.py
* use storage scope global by default in aot_executor_codegen.cc
* add missing default storage scope in create_primfunc.cc
* restore StorageInfo struct in llvm backend
* UpdateStorageScope -> WithStorageScope
* fixed lower warp memory test
* GetStorageScope -> GetPtrStorageScope
* Enable storage scope invariant check in AttrStmt constructor
* remove GetPtrStorageScope and WithStorageScope from public header
* move RemapStorageScope to its own file
* add more method to RemapStorageScope
* update lower_thread_allreduce to use RemapStorageScope
* RemapStorageScope -> UpdatePointerStorageScope
* remove realize_scope from hybrid script
* removed realize_scope in schedule_ops
* remove realize_scope from schedule_postproc_to_primfunc
* remove remaining realize_scope usage from schedule_ops.cc
* remove realize_scope usage from storage_flatten.cc
* fixed test_tir_transform_lower_warp_memory.py following realize_scope removal
* Address comments
* Remove blank line diff
Co-authored-by: Masahiro Masuda <masahi@129@gmail.com>
Co-authored-by: masa <masa@pop-os.localdomain>
With either the ci_lint docker image, or the matched version of
pylint==2.4.4, I got two lint errors running locally that didn't show
up in the CI. Fixing them.
Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
* [TVMSCRIPT] add float type support in script function
* [TVMSCRIPT] add more type support in script function parameter
Co-authored-by: honghua.cao <honghua.cao@streamcomputing.com>
* Add workspace size calculation for primfuncs
This commit introduces functionality to query the workspace size
as required by a tir primfunc by looking at tir.allocates inside of it
Change-Id: I6f8ca90408b6e35d17ec818998a0f158a268a2a6
* Add workspace size calculation for primfuncs
*change int --> size_t
Change-Id: If7fafec0269937d70184e7696e44386b74116d86
* Add workspace size calculation for primfuncs
* int --> size_t change for analysis.h
Change-Id: I9e5c5e5f8458663390c50cf56f1a11910687928d
* Add workspace size calculation for primfuncs
* lambda scope fix
Change-Id: I0c9b4c529150de8e0a5e170887cc935b7d0f6af2
Co-authored-by: Chenfan <jcf94@outlook.com>
[TIR][REFACTOR] ForNode update
- Remove deprecated device_api.
- Add ThreadBinding for_type.
- Add additional annotations.
More style consistency refactor to make the ForNode
to be consistent with rest of the codebase.
- ForType => ForKind
- Add constant prefix k to enum consts per Google C style
- Introduce ForKind to the python side.
* [TIR][REFACTOR] Enforce allocate to only accept buffer_var with correct PtrType.
This is a refactoring step to cleanup legacy issue of opaque buffer
var without ptr type information. Now all the allocation comes with the right
pointer data type. Places touched:
- TVMScript Parser: add the right info to get the correct pointer type.
- Cross thread all reduce: set the right pointer type.
- Storage rewrite: setup the right pointer type.
- Custom dtype: remap the variables with new pointer type.
x
* Address comments
Co-authored-by: Tristan Konolige <tristan.konolige@gmail.com>
Co-authored-by: Tristan Konolige <tristan.konolige@gmail.com>