[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.
* Refactor the type checker to use diagnostics
Although this patch is very large and seemingly disjoint the
fixes are required to get it working for the entire stack.
I started with first changing InferType to use the diagnostics,
these weren't yet in the pass manager so this required changes
to module and module pass. InferType wasn't actually written
correctly as a pass requring refactoring there, then in order
to add spans to AST it required turning on AnnotateSpans which
in term required changes to the parser, and module to make
it possible to use the errors. These changes to parse and module
required changes to diagnostics and InferType. Althought seemingly
disconnected there are hidden cycles between the components which
require simultaneous change in order to remove the old error
reporting.
A huge change due to this patch is that the module no longer
implicitly type checks functions which are added.
* Apply suggestions from code review
Co-authored-by: Robert Kimball <bobkimball@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
* Apply suggestions from code review
Co-authored-by: Tristan Konolige <tristan.konolige@gmail.com>
* Clean up parser
* CR feedback
* Apply Bobs suggestions
* Fix up Python interface for diagnostics
* Fix test_ir_parser and formatting
* Fix cpplint
* Fix lint
* Fix format
* More lint
* Fix format
* Kill dead doc comment
* Fix documentation comment
* Rebase fixups
* Add docs for type.h
* Fix parser.cc
* Fix unittests
* Fix black
* Skip previously typechecked functions
* fix ACL
* Fix numerous issues
* Add repr method
* Fix issue with Pytest, I am ready to cry
* Fix the rest of tests
* Kill dead code
* Fix dignostic tests
* Fix more tests
* fix more tests (#11)
* Fix diagnostic.py deinit bug
* Fix deinit issue
* Format
* Tweak disabling of override
* Format
* Fix BYOC
* Fix TensorArray stuff
* Fix PyTorch
* Format
* Format
Co-authored-by: Robert Kimball <bobkimball@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Tristan Konolige <tristan.konolige@gmail.com>
Co-authored-by: Cody Yu <comaniac0422@gmail.com>
Co-authored-by: Zhi <5145158+zhiics@users.noreply.github.com>
* Add ChangeDatatype pass and unittest
* [WIP] Jared's work on Fri
This was work that Jared did on my computer, trying to get Inception v3 running.
* Fix simplify inference to work over different data types.
* Formatting
* Copy setup code from other test file
* Logging in Relay
* Remove duplicate TVM_DLL
* Add Sub, Mul, Div, Max to bfloat lib
* Fix previous broken rebased commit
* Remove line
* Add LowerCustomDatatypes to build passes
* Upcast ints to custom datatypes too, as well as to floats
* Add and use convert_ndarray
* Lower Call
* Relay: create constant scalars of custom dtypes
We use the same method we use in TVM: store the value in a double.
* Custom datatype formatting in Relay
* Update unittests
* Add simpler example that's not working yet
* Add Python unittests to Makefile
* Fix bug
* Fix function name in GetPackedFunc call
* convert_ndarray makes its own executor
* Add simple test case
* Move setup() calls
* Use convert_ndarray
* Change import to make it more specific
* Fix another Registry::Get call
* Allow users to register minimum functions for custom datatypes
This commit allows users to register global functions named
`tvm.datatype.min.<type name>` which take the number of bits in the custom type
and return the corresponding minimum value (as a double).
A similar commit will need to be created for max, whenever that ends up being
needed!
* Remove check for float
* Add test
* Fix inception test
* Add MobileNet
* Lower custom datatypes before intrinsics
* Add exp and sqrt bfloat functions
* [buggy commit] Lower intrinsics like sqrt, exp
This commit has bugs in it, I'm fairly certain.
* Formatting
* Fix bug
* Add lowering for new ops in test
* Add int to bfloat
* Remove print
* Add all tests
* Correct image size
* Add TODO
* Add "notbfloat" type
This type is for testing purposes. It just stores a float in a uint32. It was
used to confirm the fact that my bfloat "implementation" is very numerically
unstable and was causing issues when running the model.
* Convert arguments
Not sure how necessary this actually is.
* Rewrite custom datatype constants in Relay
* Add test_ops
* Print constants in Relay
* Use topi.testing
* Test conv2d
* Add test_model
* Comment out model tests
* Register notbfloat
This could be unregistered at some point later
* Add commented code
Remove later
* Add posit tests
* test_ops_same_function
* [temporary] move incomplete commit to macbook
* Add more to tests
* Formatting
* Uncomment add
* Remove bad tests
* Change comments
* Change function name and docstring
* Change main function
* Restructure tests
* Fix visibility of posit functions
* YAPF
* Switching keywords around to resolve build errors on some systems
* Improve test by running smaller mobilenet
* Add test_cast
* Change datatype name; add simple test
* Rename to posit32
* Merge 3 posit types into one file
* Add a nop type
* Remove bfloat
* Refactor test comments
* Refactor conv2d test
* Add optional tolerance arguments
* Add posit8 and posit16
* Add comment about posit8
* Whoops -- actually add noptype to CMakeLists
* Add rtol, atol to run_workload
* Add noptype to tests
* Run noptype over other models, too
* Pass correct arguments to calls
* Fix line length errors
* Raise tolerances (again) to avoid flaky test
* fix style
* add test for tanh, log, sigmoid
* Remove references to bfloat, notbfloat
* Change comments
* Remove old test file
* fix min func
* refactoring unit test file
* use posits es2
* cleanup
* comment
* coment if_then_else
* support different bit widths
* use random seed to create stable tests
* update documentation
* removed nop-type and code consistency
* add batchnorm test
* rebase and update
* fix tests and format
* pylint
* change order of include
* include order
* fix style
* remove posit c linkage
* update universal
* fix style
* fix test
* fix overflow error with minfunc and posits
* style
* use change_dtype to convert params
* update universal
* fix fatal error
* fix constant repr
* minor update to posites2
* update universal
* fix rst
* fix invalid import and sqrt
* update universal
* comments
* comments and expand testing
* increase atol/rtol for custom[posites2]32
* Re-add newline
* Remove comment
* Remove opt level and comment
* Change docstring
* Add TODO
* Add file header and newline
* Update docstring
* Update file docstring
* Update docstrings
* Delete todos
* create_min_lower_func
* add better debugging message
* docs
* add BYODT tutorial
* add todo
* Reformat some of tutorial to RST, plus code fixes
* tutorial notebook runs now
* fix hyperlink
* rebase
* add to tutorial
* fix mobilenet model
* add skip tag
* black lint
* add compiler flag and add dummy float
* myfloat and posites2 test
* remove universal
* lint
* lint
* add setup
* build with USE_POSIT for CI/CD
* fix posit cmake
* add cd /
* undo docker changes
* change tutorial to use myfloat
* move files
* lint
* fix
* remove filter
* fix lint
* fix suggestions
Co-authored-by: Jared Roesch <roeschinc@gmail.com>
Co-authored-by: Andrew Liu <andrewlliu@gmail.com>
* Add `set_attr_preprocessor` to TargetKind registry, which is used to pre-process attribute maps.
* Use `set_attr_preprocessor` for NVPTX and ROCm backend to check and add mcpu and mtriple.
* Add TargetTag registration and retrieval on C++ side and python side. Allow creation of Target using the tag name.
* Unify target creation on C++ side, replace Target::Create and Target::FromConfig with the constructor.
* Unify target creation on python side, deprecate tvm.target.create and encourage direct use of the constructor of tvm.target.Target instead.
* Add initial support for composite target.
* [REFACTOR][TIR] Migrate BuildConfig to PassContext.
This PR migrates the TIR configurations from BuildConfig to the
PassContext used by the unified IR.
Moving forward, PassContext will be the unified way to configure passes in the TVM stack.
Changes
- Refactored TVM_PASS_REGISTER_CONFIG_OPTION to take in the reference type.
- Removed BuildConfig.
- Migrated the passes to use PassContext.
* Update include/tvm/ir/attrs.h
Co-authored-by: Zhi <5145158+zhiics@users.noreply.github.com>
Co-authored-by: Zhi <5145158+zhiics@users.noreply.github.com>
Substitute now takes a std::function to customize more replacing behaviors.
Co-authored-by: Siyuan Feng <hzfengsy@sjtu.edu.cn>
Co-authored-by: Siyuan Feng <hzfengsy@sjtu.edu.cn>
* [TIR][REFACTOR] Remove te::Tensor dependencies from TIR passes.
te::Tensor is an useful object for tensor expression, but brings
un-necessary reverse dependency in TIR nodes such as Provide and Realize.
This PR is a first step to remove this dependency. We will use Buffer in all the places
where the te::Tensor was used. The rough correspondence are:
- Provide -> BufferStore
- Realize -> BufferRealize
- HalideCall -> BufferLoad.
After this change, we can not use IRModule of PrimFuncs cleanly to represent TIR
at any point of the optimizations. Buffer will serve as the abstraction for the TIR data
models to represent the intermediate storages and their constraints.
We still keep Realize/HalideCall and Provide as TIR nodes for now to make the change minimum.
Right after ScheduleOps, we call SchedulePostProcToPrimFunc to canonicalize the temporary IR
generated by TE(which contains these nodes) to the TIR.
The TIR optimizations are now mostly migrated to to the pass manager.
Followup PRs are needed to migrate the remaining few passes.
* Fix dev tutorial
* [REFACTOR][TIR] Migrate all low-level passes to the Pass Manager.
This PR migrates the tvm.lower to return IRModule of PrimFuncs
instead of the LoweredFuncs.
* Remove LoweredFunc.
* [DOCS] Various sphinx related fix.
- Use :ref: for reference.
- Use :py:class: to refer to API docs.
- Update installation guide to also refer to the download page.
- Only move html contents in doxygen.
* Address review comments
* Update wording
* relay op strategy
fix lint
bitpack strategy
bitserial_dense (#6)
* update strategy
* address comments
fix a few topi test
Dense strategy (#5)
* dense
* add biforst; remove comments
* address comment
Refactor x86 conv2d_NCHWc (#4)
* Refactor x86 conv2d
* Add x86 depthwise_conv2d_NCHWc
* Add back topi x86 conv2d_nchw
* Merge x86 conv2d_nchw and conv2d_NCHWc
* Minor fix for x86 conv2d
fix more strategy
Add x86 conv2d_NCHWc_int8 strategy (#8)
* Add x86 conv2d_NCHWc_int8 strategy
* Remove contrib_conv2d_nchwc_int8
* Fix generic conv2d_NCHWc for int8
* Fix topi arm_cpu conv2d_NCHWc_int8
update x86 conv2d
enable specify relay ops to be tuned for autotvm
add cuda conv2d strategy
add conv2d strategy for rocm
add conv2d strategy for hls
add conv2d strategy for arm cpu
add conv2d strategy for mali
add conv2d strategy for bifrost
add conv2d strategy for intel graphics
clean up and fix lint
remove template keys from autotvm
remove 2 in the func name
address comments
fix
* fix bugs
* lint
* address comments
* add name to op implement
* Modify topi tests (#9)
* Add pooling, reorg, softmax and vision
* Add lrn
* fix topi test
* fix more topi test
* lint
* address comments
* x
* fix more tests & bugs
* Modify more tests (#10)
* Modify tests for bitserial_conv2d, bitserial_dense, bitserial_conv2d_rasp and bnn
* Minor fix
* More minor fix
* fix more test
* try to update vta using strategy
* fix cpptest
* x
* fix rebase err
* Fix two tests (#11)
* change autotvm log format
* lint
* minor fix
* try fix vta test
* fix rebase err
* tweak
* tmp hack for vta pass
* fix tutorial
* fix
* fix more tutorials
* fix vta tutorial
* minor
* address comments
* fix
* address comments
* fix cpptest
* fix docs
* change data structure name and api
* address comments
* lint
* fix rebase err
* updates
* fix winograd test
* fix doc
* rebase
* upgrade tophub version number
* fix bug
* re-enable vta tsim test after tophub is upgraded
* fix vta test to use the correct args so the config can be found in tophub
Co-authored-by: Yao Wang <kevinthesunwy@gmail.com>