Commit Graph

50 Commits

Author SHA1 Message Date
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
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
wrongtest f4af81c5f7 [TIRScript] fix parse StringImm value in for loop annotations (#9755)
* fix parse strimm value in for annotations

* flatten buffer allow runtime.String attr value

* remove unused import

* rebase and ensure flattened attr order
2021-12-20 18:47:17 +08:00
Yuanjing Shi 5c2855e698 [TVMScript][FIX] Fix number of arguments for T.Buffer[...] (#9758)
* 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>
2021-12-17 21:09:12 +09:00
Wuwei Lin 405fa23bce [TIR][Schedule] Add Annotate/Unannotate primitive (#9742)
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: Wuwei Lin <wuwei@apache.org>
Co-authored-by: Xiyou Zhou <xiyou@octoml.ai>
2021-12-16 15:29:53 -08:00
driazati f0ae9d3313 Add make docs and doc building instructions (#9534)
* 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>
2021-12-13 16:33:58 -08:00
Yuanjing Shi 40ecfec1da [TVMScript] Improve printer for TIR syntax sugar (#9680) 2021-12-10 12:19:47 -05:00
Manupa Karunaratne 3ce4fe47ca [TIR][USMP] adding the pass to convert to pool offsets (#9418)
* [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
2021-12-09 14:45:16 +00:00
Yuanjing Shi e8889ae0e3 [TVMScript] Add syntax sugar for T.handle and T.match_buffer (#9492) 2021-12-08 10:30:27 -05:00
Yuanjing Shi c945b24c36 [TVMScript] Add for loop syntax sugar (#9620)
* add for loop syntax sugar

* remove prints

* better doc

* finish thread binding

* fix CI

* fix CI

* address comments

* update sstub

* fix CI

* remove failed test

* update stub

* address comments

* add decorator
2021-12-07 19:19:47 -05:00
Yuanjing Shi 459563d33b [TVMScript] Syntax sugar for reads & writes (#9634)
* add test file

* add syntax sugar support

* add comments

* cleanup

* update stub

* remove failed tests

* update stub with overload

* address comments
2021-12-06 20:00:43 -05:00
Tristan Konolige 7f683dabbe [TVMSCRIPT] Misc error message improvements (#9543)
* [TVMSCRIPT] Misc error message improvements

* only prevent indexing into handles with multiple indexes

* lint
2021-12-03 11:33:38 -08:00
wrongtest 86716a5f7d [TVMScript] support kTarget func attr in tir script (#9594)
* support kTarget func attr in tir script

* fix variable redefine lint error

* use Target::Export()

* fix cr issues
2021-12-01 12:46:48 -08:00
Siyuan Feng e5cbf46cdd [BUG][TVMScript] fix block range error (#9574) 2021-11-24 06:23:21 -08:00
Manupa Karunaratne 18730c45be [TIR][USMP] Added buffer info extraction pass (#8468)
* [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
2021-11-23 09:44:44 -08:00
Yuanjing Shi cdca84aa1d [TVMScript][Fix] Add type hints for more uncovered cases (#9505)
* 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
2021-11-22 18:55:38 -05:00
Siyuan Feng 3f9b72d1f6 [TVMScript] Report error if add attr to implicit root block (#9507)
* fix implict root block attrs

* lint
2021-11-15 13:07:35 -05:00
Yuanjing Shi 00b0a812e7 [TIR] Add type hint for TIR (#9432)
* add init

* get rid of span

* afs header

* update scope_handler

* rm tir/__init__.pyi

* fix linting

* fix lint

* new test case

* add axis module

* address comments

* redefine ty types

* lint

* address comments

* address comments

* fix ci

* add test cases

* fix CI

* address comments

* add types

* mypy --strict

* comments

* update test comments

* linting fix

* address comments

* add pylint for tir type check

* address comments

* move doc string

* comments

* getter setter

* add PrimExpr, IterVar and Var

* add sequence

* change for handle
2021-11-09 07:29:32 -08:00
Siyuan Feng c99f55f0a5 [TVMScript] Use // and % for FloorDiv/FloorMod (#9437) 2021-11-03 13:12:09 -04:00
Ruihang Lai 5e62db54ad [TVMScript] Parser for Lambdas, Parser/Printer for CommReducer (#9358)
* CommReducer Parser/Printer

* update argmax unit test

* update doc

* lint fix

* add unit tests with multiple reducers
2021-10-24 14:24:40 -07:00
Siyuan Feng d23688c3e5 update block syntax (#9286) 2021-10-18 13:59:17 -04:00
Manupa Karunaratne 2dae30372c Adding annotations for tir.allocate (#9168)
* 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
2021-10-07 20:44:59 +08:00
Bohan Hou 47095d765f [Unittest] Fixing unittest (#9180) 2021-10-02 17:49:20 +08:00
Siyuan Feng e7af601636 [TVMScript] Script namespace changes (#9115)
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Zihao Ye <zihaoye.cs@gmail.com>
Co-authored-by: Tristan Konolige <tristan.konolige@gmail.com>
2021-10-01 13:10:25 -07:00
Siyuan Feng e1ae821c7d Add while node support in TVMScript (#9004)
* support while

* update synr version
2021-09-14 13:55:42 -04:00
Siyuan Feng 22dbc3a932 [TVMScript] Enhance printer (#8934) 2021-09-06 14:18:24 -07:00
Siyuan Feng 8e27d6c18f fix error report on Store (#8895) 2021-09-01 17:49:12 -04:00
Siyuan Feng 2a8950b5c0 [TensorIR] Support for match_buffer from subregion (#8585)
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>
2021-07-30 22:06:38 -07:00
Ruihang Lai 5012462ef8 [TensorIR][M2a] Reduction Factoring (RFactor) (#8544)
Co-authored-by: Junru Shao <junrushao1994@gmail.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: Wuwei Lin <wuwei@apache.org>
2021-07-30 22:04:02 -07:00
masahi bef7bf9b2b [Refactor] Remove AttrStmt with storage_scope key (#8516)
* 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>
2021-07-29 14:29:14 -05:00
Tianqi Chen e664ef0be8 [PRINTER] Fix the repeatitive cast in scripr printing (#8531) 2021-07-24 16:53:00 +09:00
masahi 1a1be09c24 [Refactor] Remove scope attribute from Buffer class (#8463)
Co-authored-by: masa <masa@pop-os.localdomain>
2021-07-20 16:19:46 -04:00
Honghua Cao 44f1baf794 [TVMSCRIPT] Support tir.abs node in tvm script (#8488)
Co-authored-by: honghua.cao <honghua.cao@streamcomputing.com>
2021-07-16 22:13:58 -04:00
masahi 1a26733b8e [Refactor] Enforce attaching storage scope to PointerType (#8366)
* 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>
2021-07-13 15:32:42 -04:00
Honghua Cao 513fcf4bb7 [TVMSCRIPT] TVMScript Parser support BufferSlice indices (#8408)
Co-authored-by: honghua.cao <honghua.cao@streamcomputing.com>
2021-07-09 14:33:23 -04:00
Lunderberg ee65ab7a4a [PyLint] Minor updates to pass pylint locally. (#8424)
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>
2021-07-09 10:15:19 +08:00
Honghua Cao 35d71b1211 [TVMSCRIPT] add more type support in script function parameter (#8235)
* [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>
2021-06-23 17:05:05 +08:00
Tristan Konolige 96a7a5811f [TVMSCRIPT] Fix printing of rank 0 buffer access (#8215)
* [TVMSCRIPT] Fix printing of rank 0 buffer access

Also improve error messages and fix min/max/Select.

* fixes

* return fix

* remove print
2021-06-16 10:26:01 -07:00
Honghua Cao 55459e74dd [TVMSCRIPT] Add tir.min node in tvm script (#8219)
Co-authored-by: honghua.cao <honghua.cao@streamcomputing.com>
2021-06-09 09:52:28 -04:00
Mehrdad Hessar a1cd6d51b8 fix py files (#8194) 2021-06-04 23:22:46 +01:00
Siyuan Feng 22c8f8cca5 [TensorIR][Pass][M1c] FlattenBuffer (#7962)
Co-authored-by: Tianqi Chen <tqchen@users.noreply.github.com>
Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>
2021-05-03 10:28:28 -07:00
Manupa Karunaratne 1fb32b0551 [TIR] An analysis pass to calculate workspace size for primfuncs (#7859)
* 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>
2021-04-18 20:21:32 +08:00
Siyuan Feng 7f567264ae [TensorIR] [Script] adding support for opaque block (#7829)
* change complete tag

* add parsing support for opaque block

* address and add testcase

* address

* address
2021-04-13 14:08:48 -07:00
Siyuan Feng fffed0ff91 [TensorIR] TVMScript Parser/Printer (#7630)
Co-authored-by: Bohan Hou <32121147+spectrometerHBH@users.noreply.github.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Tianqi Chen <tqchen@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: Tristan Konolige <tristan.konolige@gmail.com>
Co-authored-by: Cody Yu <comaniac0422@gmail.com>
2021-03-20 16:22:53 -04:00
Tianqi Chen 7340c02d0e [TIR][REFACTOR] ForNode introduce thread binding and remove legacy field (#7306)
[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.
2021-01-18 23:00:11 -08:00
Tianqi Chen d777e7c612 [TIR][REFACTOR] Enforce allocate to use the correct var pointer hint. (#7216)
* [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>
2021-01-06 16:59:12 -08:00
Tristan Konolige fdfc7eb887 [TVMSCRIPT] Attach span information to tir nodes in tvmscript (#6910) 2020-12-04 20:03:08 -05:00
Tristan Konolige d164aac058 [TVMSCRIPT] Using diagnostics for TVM Script (#6797)
* [TVMSCRIPT] Using diagnostics for TVM Script

* fix lint

* More documentation, improve some error messages

* Apply suggestions from code review

Co-authored-by: Leandro Nunes <leandron85@gmail.com>

* Add synr to ci setup and setup.py

* remove typed_ast dependency

Co-authored-by: Leandro Nunes <leandron85@gmail.com>
2020-11-05 19:24:32 -05:00
Bohan Hou 129333b717 [TVMScript] refactor (#6734)
* [TVMScript] refactor

* [TVMScript] pylint

* [TVMScript] pylint
2020-10-22 06:59:31 -07:00
Tristan Konolige c662638772 Rename tvm.hybrid.script to tvm.script. (#6522) 2020-09-26 15:32:08 -07:00