62 Commits

Author SHA1 Message Date
Tianqi Chen 141c22fd8a [Refactor] Bring up tirx namespace (#18913)
This PR brings up the tirx namespace. We have been spliting out the
original tir namespace to include high-level component s_tir and this PR
updates the remaining low-level part as tirx namespace
2026-03-19 21:27:54 -07:00
Tianqi Chen 9a8320acbd [LINT][PYTHON] Modernize annotations with ruff UP rules (#18830)
This PR enables ruff pyupgrade (UP) rules with py310 target, auto-fixing
~5600 annotation modernizations (PEP 585 generics, PEP 604 unions,
deprecated typing imports).

Also removes from __future__ import annotations from ir/module.py and
rmsnorm.py, bumps requires-python to >=3.10, and removes absolute_import
aliases from topi/contrib files.
2026-02-27 21:29:47 -05:00
Tianqi Chen aa2e609136 [LINT] Modernize lint to use pre-commit hooks (#18807)
This PR migrates existing lint to use pre-commit hooks
2026-02-22 11:03:21 -05:00
Siyuan Feng e7c04f554b [Refactor] Introduce base Executable class and tvm.compile interface (#17710)
This refactor introduces a base Executable class and a `tvm.compile`
interface that can be used to compile both TIR and Relax programs.

`tvm.compile` will return an Executable object that can be used to call
either TIR or Relax functions.
2025-03-07 08:00:48 -05:00
Bohan Hou fc6775e770 [REFACTOR] move build flow from C++ to Python (#17665)
This PR moves build flow from C++ to python, enables more developer productivity and readabilities
2025-02-20 14:47:06 -05:00
Tianqi Chen 9f846bda5b [REFACTOR] Phase out te.schedule python components (#17658)
* [REFACTOR] Phase out te.schedule python components

This PR phases out te.schedule python components.
te.compute is kept around for future usages.
tir.Schedule is a more modern version of the scheduling that we can use onwards.

Doing so also helps us to cleanup the testcases that relies on
explicit full build and execution. As we move future unit testcases
towards structural equality based unit tests.

* Simplify CI to focus on UT

The main rationale is that we should only have very few target
dependent UT in tests/python/codegen and possible
a new category in future for op-level integration if needed.

* Re-enable wasm

* fix lint

* remove hybrid,sparse autodoc and remove tests

---------

Co-authored-by: Siyuan Feng <hzfengsy@sjtu.edu.cn>
2025-02-16 17:13:10 +08:00
Tianqi Chen ccaa534b2c [REFACTOR] Phase out relay python components (#17656)
This PR starts the step 0 to phase out relay from the current
development main branch.  This PR focuses on the python
components of relay, autotvm, auto_scheduler. To make the change
manageable, we will also do followup steps on te.Schedule and
c++ components in followup PRs.

To continue support community members who depends on
legacy flows, the [v0.19.0](https://github.com/apache/tvm/tree/v0.19.0)
branch will continue contain these components.


As noted in [discussion on phasing out legacy components](https://discuss.tvm.apache.org/t/phasing-out-legacy-components/17703/30),
this would help us to do two purposes:

- By removing outdated or redundant elements, we can significantly
reduce complexity and improve maintainability.
- Unify our focus: Concentrating our efforts on the new unity flow
will allow for more efficient development and innovation.

It is also a good opportunity for us to revisit and reduce CI time.
The past relay legacy flow contains a lot of end to end tests that
requires hardware resources to run and causing long CI time.
Moving onwards, we can focus more on unit-tests that focuses
on structural equality and runs within seconds, while be mindful
about tests that requires hardware resources (by restricting them
to specific folders and CI nightly in some cases).

---

Co-authored-by: Siyuan Feng <hzfengsy@sjtu.edu.cn>
2025-02-15 13:48:28 -05:00
Siyuan Feng 9e865b4b8f [Docs] Introduce Relax API and move legacy part to standalone page (#17286)
* [Docs] Introduce Relax API and move legacy part to standalone page

As the TVM project evolves, the Unity strategy has been the recommended
way to use Apache TVM applications. Hence, we are pushing documentation
for the Relax API to the forefront and moving the legacy part to a
standalone page, which may be removed in the future.

* update for ci

* update for ci
2024-08-22 18:16:56 -04:00
Eric Lunderberg b2204ae698 [IR] Default to empty attributes, instead of NULL (#16745)
* [IR] Default to empty attributes, instead of NULL

Prior to this commit, the default `DictAttrs` for an `IRModule`,
`tir::PrimFunc`, `relax::Function`, and `relay::Function` was a null
value.  At each callsite, the absence of a `DictAttrs` needed to be
treated as equivalent to an empty `DictAttrs`.  In C++, this typically
was done using the `foo->GetAttr` helper function, but in Python it
needed to be checked explicitly.  That is, every callsite needed to
check `if func.attrs is not None and attr_name in func.attrs`, rather
than only checking `if attr_name in func.attrs`.

Since most functions would have at least one attribute to specify the
global symbol, these bugs would often surface when working on
unrelated changes.

This commit changes the default attribute dictionary from
`NullValue<DictAttrs>()` to `DictAttrs()`.  This avoids having two
separate representations of an object without any attributes, and
allows the `if attr_name in func.attrs` pattern in the Python API.

* Remove no-longer-needed checks on attrs being present

* Fix up unit tests

* More unit test fixes

* Undo erroneous find/replace

* A few more unit tests

* Provide `DictAttrs.get`
2024-03-25 13:07:56 -05:00
Eric Lunderberg 7336debd8d [Bugfix][Relax] Remove call to tvm.build for empty TIR module (#16561)
Prior to this commit, if a lowered `IRModule` does not contain any TIR
functions, `tvm.relax.build` provided an empty `tir_mod`, which caused
a segfault during TIR compilation.  This could occur when
`tvm.relax.build` is called without an explicit target argument, for a
module that does not define any virtual devices.

This commit updates the `_filter_tir` utility function to return
`None` if there are no TIR functions, rather than an empty
`IRModule`.  In addition, checks for an empty `IRModule` are added to
`tvm.build` and `TIRToRuntime`, so that a similar failure mode would
raise an exception rather than producing a segfault.
2024-02-14 07:07:27 -06:00
Yong Wu 1c35c39264 [Unity] Add Relax multi-device e2e cases (#15823)
* [Unity] filter out non-GPU primfuncs in default_gpu_schedule

* Add relex heterogeneous e2e case

* Remove get_prim_func_device

* Update test cases

* Fix flake8

* fix lint

* Add test case for change of default_gpu_schedule

* fix comment
2023-12-20 13:52:56 -08:00
Christopher Sidebottom c9002509f6 [Target] Print deprecation warning before canonicalisation in build module (#12747)
Hopefully fixes #12742, as the warning should only be printed when a user passes `target_host`, in the current case if the user passes `None` as `target_host` it'll be processed by `canon_target_map_and_host` which seems to always produce a `target_host` and thus triggering the warning despite the user doing nothing wrong.
2022-09-15 14:03:21 -07:00
kuizhiqing 7f100158a5 [DOCS] Fix tvm.build API doc layout
The newline in the pydoc breaks the layout of parameter inputs in API `tvm.build`
2022-08-10 10:45:07 +01:00
Eric Lunderberg 45568c9963 [TIR] Improved error message if tir.Schedule passed to lower/build (#11913)
Previously, if a TIR Schedule is passed to `tvm.lower`, the error
message is returned `ValueError: ('Expected input to be an IRModule,
PrimFunc or Schedule, but got, ', <class
'tvm.tir.schedule.schedule.Schedule'>)`.  This can cause user
confusion, as the expected class name in the error message does not
differentiate between between a `tvm.te.Schedule` and a
`tvm.tir.Schedule`.  Updated error message to explicitly state that
this should be a `te.Schedule`.
2022-06-27 11:38:25 -07:00
Mark Shields afb67e64a1 Silence unnecessary 'host' deprecation warnings (#11499) 2022-05-27 17:10:40 -07:00
Mark Shields d1467777c6 Finish support for list-of-targets (#11382)
* Finish support for list-of-targets

This finishes the work started in https://github.com/apache/tvm/pull/11173 to support
'external codegen' targets in the N build-like API surfaces.

 - It turns out it's ok if a build is given only a single 'external codegen' target, so remove that check
   in CompilationConfig::Init. When Collage builds a 'candidate partition' it does so for a single target.
   As far as Collage is concerned it does not care whether the target is regular (eg Target("cuda")), or
   for a specific external codegen (eg Target("cutlass")), it just passes the target into the build.

 - Add CompilationConfig::FindPrimitiveTargetForKind which I'll later need to retrieve
   the external codegen Target instance corresponding to a "Compiler" attribute value.

 - Target.update_target_host_consist was supporting three API styles:
    - single target
    - map from device type to target
    - map from target to IRModule (for the ir_to_runtime API)
   I replaced all those calls with a more specialized 'canonicalize' call:
    - Target.canonicalize_target_and_host
    - Target.canonicalize_multi_targets_and_host
    - Target.canonicalize_target_map_and_host
   In particular, all the tuning interfaces (task extraction, tuning, tuning records) all explicitly
   *do not* support multiple targets since the underlying code just doesn't support that.

* - Lints
- Revert unintended changes

* - more lints

* - Fix model_library_format handling of target.
- Improve comments in compilation_config.h

* - Lints
- Update target/target_host params documentation

* - Fix micro library format tests
- Rev micro library format from 5 to 6
- Use Target.current() in a few places

* - eta contract comprehension

* - Woops, one more device: target map left
- Handle host already being in Target

* - lint

* - lint

* - Bug with append
- Take device type from target

* - Fix hexagon
2022-05-23 09:14:28 -07:00
Eric Lunderberg 6e1c6be452 [Driver] Remove duplicate PreProcessModuleForBuild (#10530)
* [Driver] Remove duplicate PreProcessModuleForBuild

`PreProcessModuleForBuild` was nearly identical to the `build()`
function in the same file.

* Name change, `tvm::TIRToRuntime`.
2022-03-22 11:31:48 -07:00
wrongtest 21abb6ea49 Fix for tvm.build()'s name warning (#9678)
* change default name of tvm.build() to None

* change lower name default to None

* fix lint

* lower() use "main" -> "default_function"

* remove default name's warning
2021-12-14 14:40:33 -08:00
wrongtest 0579b4b782 [DRIVER] Specify name when build with primfunc (#9602) 2021-12-01 14:03:00 -08:00
Christopher Sidebottom 0cb633777a [TVMC][Relay] Introduce executor and runtime parameters (#9352)
* [TVMC][Relay] Introduce executor and runtime parameters

This introduces `executor` and `runtime` into the various entrypoints but also into `tvmc` as `--executor` and `--runtime`. This touchs a lot of files and I've tried to update anywhere as necessary.

Notable, executor code generators now accept the initial `IRModule` rather than creating
it themselves so it can be annotated once.

Validated the demo application continues to classify the tabby cat with
new CLI options.

* Correct Graph Executor Python API
2021-11-19 17:11:40 -08:00
Tianqi Chen 137def8bf2 [TARGET] Move target_host usage to new target style. (#9497)
- Add deprecation warnings to functions with target_host parameters.
- Update the build usage to new target style.
2021-11-12 20:55:00 +08:00
Michalis Papadimitriou f5eb4c2d08 Rename build helper (#9297) 2021-10-16 17:15:30 -04:00
Lunderberg c279b94a65 [TE] Light refactoring of TE -> TIR paths. (#9263)
* [TE] Light refactoring of TE -> TIR paths.

- Added ScheduleToPrimFunc, extracting out common behavior in
  ScheduleToModule and auto_scheduler's feature extraction.

- Added `tvm.driver.build_module.schedule_to_module`, to avoid needing
  to 4-line boilerplate needed to do so.  Also makes deviations from
  the usual path (e.g. `debug_keep_trivial_loop`) much more explicit.

* Removed schedule_to_primfunc, replaced usage with schedule_to_module.

* Returned C++ function ScheduleToPrimfunc to be inside ScheduleToModule.
2021-10-16 12:01:01 +08:00
Michalis Papadimitriou 594f23d976 [Core][Build] Move build module transformations and utilities to C++ (#9103)
* Initial investigation

* More progress!

* More progress / notes

* rewrite build_for_device mostly in c++

* More progress

* Initial split of transformations applied to device and host as post split action from mixed module

* Combine duplicate passes after spliting mod on aot and vm flows

* Minor cleanup

* Move target mangling to driver_api.cc

* Move more build utlities to cpp driver api

* [Build][WIP] Moving build utilities to C++ from Python

* [Build] Remove comments

* [lint] Pass black

* More formating

* Move more build functionality into cpp

* Remove comments

* Remove unused defs and imports

* Address PR comments

* More PR comments

* More comments

* More comments

* Add comments on the new split function

* Fix PR comments on clarity

* Test CI

* Fix format

* Refactor build

* Expose splitted composite passes to python

* Format files

* Test fix

* Fix for annotating entry funcs on code targeting CPU

* Prevent entry funcs to be annotated when compiling for CPU with C runtime enabled

* Guard for aot executor entry

* Sphix format

* Sanity fix

* Sphinx fix

Co-authored-by: electriclilies <lilyorthsmith@gmail.com>
2021-10-14 01:09:02 -07:00
masahi 4b67daccb9 [CUDA] Support multiple TIR-level dynamic shared memory allocations (#8571) 2021-07-31 10:20:24 -04:00
Raghav-Chakravarthy 5bb01ef8ea fix typo (#8484)
* fix typo

* Fixed typos in documentation
2021-07-15 23:08:10 -07:00
Andrew Reusch 970aefffe9 Add "operator" style to Model Library Format (#8072)
* rename _update_target and document its function

* make tvm.build return OperatorModule to return multiple outputs

* allow retrieving the var names used in TIR repr

* add Operator Model Library Format and test

* Add pathlib convenience functions to utils.TempDirectory.

* fix tests

* black format

* git-clang-format

* pylint fixes

* add asf header

* change memory map to make more sense, fix tests

* address giuseros comments

* align GetVarName with future TypedPackedFunc

* fix test

* clang-format

* rev model library format to v4 (bad merge)
2021-07-02 23:10:55 +01:00
Lunderberg d9fe67259e [Docs] Prevented docs/1 file from being generated. (#8029)
* [Docs] Prevented docs/1 file from being generated.

Typo in tests/scripts/task_sphinx_precheck.sh caused $TVM_HOME/docs/1
file to be created with stderr output, rather than merged stderr and
stdout.

* [Docs] Corrected sphinx build warnings

- Previously, several warnings were generated by sphinx, but were
  unintentionally suppressed.  This PR resolves the sphinx warnings.

* [Docs] Corrected additional sphinx build warnings.

- Rebased on main and corrected warnings, now up to date as of commit
  53e4c603.

* [Docs] Corrected additional sphinx build warnings

- Rebased on main and corrected warnings, now up to date as of commit
  1f2ca068c.

* [Docs] Corrected additional sphinx build warnings

- Rebased on main and corrected warnings, now up to date as of commit
  d0791d3db.

* [Docs] Ignore sphinx warnings from missing "git describe" and sckit-learn versions.

Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
2021-06-24 10:27:29 -04:00
CircleSpin 9dd1286e91 Unify Python and C++ TIR lower API (#8110) 2021-06-12 06:57:38 -07:00
Siyuan Feng 711a603db8 [TensorIR][M1c] Lower and build TensorIR (#8044) 2021-05-15 16:35:17 -04:00
Christoph Gerum 6d555b6b43 Correctly build with -runtime=c without -system-lib (#7954) 2021-05-01 07:44:02 -04:00
Xiyou Zhou 0bd1536200 [Target] Add support for target object with host field compatible with previous api (#7534)
* Fix legacy code on target host

* Modify legacy code for target host change

* Add tests and fix merge issue

* Add condition for same host

* Modify all files for new target host api compatibility

* Add newline

* Change import format

* Optimize test file

* Add match error info for unit tests

* Fix for heterogeneous targets

* Fix format for dict iteration

* Fix target host type error

* Skip one testcase for tvm infinite loop bug

* Fixed bug for target map compatibility

* Fix another TargetsMap issue

* Fix typo and infinite loop error

* Temporary fix for handle issue

* Fix vm target

* Add condition support for str case

* Add GetHost function and fix previous bugs

* Fix measure_record.cc

* Fix search_task.cc

* Fix compiler.cc, memory_alloc.cc

* Fix driver_api.cc

* Fix format

* Fix bugs and GetHost function usage

* Fix clang format

* Fix bug

* Modify python tests

* Change python unit tests to new target api

* Fi test_runtime_heterogeneous.py

* Modify tutorials & remove extra print

* Update more tests to new api

* Refine the tutorial target usage

* change argument name for Target constructor function

* Fix target export function

* Fix and validate all tutorial usage

* Remove unused argument

* Fix format

* Fix bug in driver/build_module.py for heterogeneous target

* Fix bug in driver/build_module.py for heterogeneous target more

* Fix target host type error

* Fix cudnn target host bug

* Fix according to reviews, add helper function in python

* Refactor code as helper function

* Expand helper function

* Fix bug add and update python helper function

* Update target hosts

* Fix format & refresh function

* Fix unit test bug

* Fix bug in refreshing host

* Fix bug

* Add SetHost function

* Update export function

* Fix format

* Fix export bug in target

* Fix bug on host referencing

* Addtional tests

* Address review issues

* Fix format target.py

* Fix issues and format

* Add some 3rd party dependencies

* Merge main branch

* Fix target.h format

* Remove redundent import

* Fix function name

* Add parameter name

* Fix new code bug

* Fix bug in lowering
2021-03-31 10:44:39 -07:00
Haichen Shen fbfeee4ccb [Refactor] Rename TVMContext to Device (#7721) 2021-03-26 07:56:57 -04:00
Andrew Reusch 0ba37411aa [CRT] Create C-runtime-style metadata module for llvm builds (#7398)
* Create C-runtime-style metadata module for llvm builds.

* maybe address manupa's comment

* lint

* actually address manupa comments

* comment and rename

* git-clang-format

* pylint

* cpp warning

* try to fix apps/bundle_deploy

* black format

* build correct file

* Use save() for C++-runtime targeted artifacts.

* fix build_module LLVM metadata module conditions

* fix test comment

* black format

* further restrict CRT MetadataModule creation

* Fix test_link_params

* black format and address zhiics comments

* fix test_link_params, i think?
2021-02-23 09:54:43 -08:00
manupa-arm 9713d675c6 Created CSourceMetaData module for model metadata (#7002)
* Created CSourceMetaData module for model metadata

* Currently, there is a MetaData module to capture constants
  conditionaly if the runtime modules implement const init
  PackedFuncs. However, this one relies on a load process
  in which the metadata is created on volatile memory that
  may be not usable in uTVM environments.
* There is a need for model level metadata that is valid
  across all runtime modules such as the func registry
  when creating a system-lib.
* This commit implements a CSoureMetaData module to hold
  func registry that collects function names from the
  runtime module and generates a c source file to be
  linked with final artifact.
* Modified and added export_library for utvm

Change-Id: Ie2e8e2aea1a66520f03fe8af7cc5bdf27339ea10

* Created CSourceMetaData module for model metadata

* fixed llvm_module to return null pfs for
  get_symbol and get_const_vars

Change-Id: I84810e0695d4d6fb314af2469117f965eed71b51

* Created CSourceMetaData module for model metadata

*fixed bundle_deploy tests

Change-Id: I0d1332a4abbb6830531784c59264021bbbd7148a

* Created CSourceMetaData module for model metadata

*fixed export_library not to insert "options" when targeting tar
*fixed unit tests

Change-Id: Ia1686889498b71af66f1a0311a059154ad3c2c3e

* Created CSourceMetaData module for model metadata

* enable wasm to support csource metadata module
* disabled non DSOExportables from using csource metadata module

Change-Id: Ie09beaad35cbc2ef738d1d24d91e249b5e099569

* Created CSourceMetaData module for model metadata

* changed const pfs to be called only on external modules
  or DSOExportable modules

Change-Id: I6ad28f166c0fc27a2548c851bf9287ec805550d1

* Created CSourceMetaData module for model metadata

* CSourceMetadata module wrapper is only created for c/llvm targets

Change-Id: I13cb4140c17e2e1f91d495b15a1ff7eeab9fb14d

* Created CSourceMetaData module for model metadata

*target should be defined to use csourcemetdata module

Change-Id: Id8e55b23d0007a79c550334de2c0fec63d40171f

* Created CSourceMetaData module for model metadata

* reinstate llvm func registry

Change-Id: I53e0754b6fb533637f08b25e98064d8c04092de4

* Created CSourceMetaData module for model metadata

* addressed comments and fixed bugs

Change-Id: I26401685dc803aeaf7642c865df88d683419e859

* Created CSourceMetaData module for model metadata

* addressed a missed comment

Change-Id: I65e65c30bc780a946f3f1b8372c40a49a5c20582

* Created CSourceMetaData module for model metadata

* te build interface should only include c-source metadata if
  targetting "c"

Change-Id: Ie23cb8c6231c1f2de6d2827084774e3510288098

* Created CSourceMetaData module for model metadata

* c_source modules should be created only if they are
  non-DSO exportable

Change-Id: I53f2f8e9caa41f133446f8881b9dc541ebeee8cc

* Created CSourceMetaData module for model metadata

* documetation misalignment in source_module.cc

Change-Id: I83e2c29b1f2980ca65a694304720dc58a5cb7879

* Created CSourceMetaData module for model metadata

* typo : same object file written as a dependency in the Makefile

Change-Id: I8becc4196d286cfb6372768687b3c836799dcb78

* Created CSourceMetaData module for model metadata

* removed unused param from a brief

Change-Id: Ie4db2aca3b7ea147bd8c65ef5d1cc2146f530e76

* Created CSourceMetaData module for model metadata

* made export library use c as the format for c source modules

Change-Id: Ie2fd6204414f0fa43988a8082d18af7a3225e237

* Created CSourceMetaData module for model metadata

*addressed a nit

Change-Id: I6084b8c06ddfaaece295439dbab589e6e202b664
2020-12-21 14:07:33 -08:00
Matthew Brookhart 38273eeb39 [CUDA] Parallel Cuda Mergesort (#7099) 2020-12-21 08:48:29 -05:00
Tristan Konolige fdfc7eb887 [TVMSCRIPT] Attach span information to tir nodes in tvmscript (#6910) 2020-12-04 20:03:08 -05:00
Gus Smith 5aafff913b Bring Your Own Datatypes (#5812)
* 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>
2020-09-26 15:49:20 -07:00
Jared Roesch f13fed55cf [Format] Convert all Python code w/o CI (#6448)
* Add black setup

* Tweak pyproject.toml

* Fix syntax issues

* Fix

* Tweak

* Black all Python code
2020-09-11 22:17:24 +09:00
Junru Shao 6b6661ed92 [Target] Tags, Composite Target, Unified Interface (#6369)
* 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.
2020-09-10 08:39:04 -07:00
ANSHUMAN TRIPATHY 66b7ddb1f8 [TIR][Transform]Block scope hoisting added (#6238)
* Block scope hoisting added

* lowering flow added with 2 variants

* Fake commit to trigger ci with pass default enabled

* CI Failure resolved

* Optimize for if var list iteration

* More test case added

* Fake commit to disable failed test cases

* Pass default value restored

* [1] Review comment handled

* [2] Review comments handled
2020-08-31 14:19:33 -07:00
Junru Shao 0e1f816f0c [Target] Rename target_id => target_kind (#6199) 2020-08-03 18:50:32 -07:00
ANSHUMAN TRIPATHY a0c072e7af [TIR][Transform] HoistIfThenElse added (#6066)
* [TIR][Transform] HoistIfThenElse added

* lint error resolved

* Pass position changed

* pylint error resolved

* CI issues resolved

* Frontend tflite test case failure resolved

* [1] Review comment handled

* [2] Review comment handled

* [3] Review comment handled

* Lint error resolved
2020-08-03 13:50:11 -07:00
Junru Shao 6ce8a1cb5f [Target] Migrate data structure of TargetNode (#5960) 2020-07-02 12:23:57 -07:00
Menooker 9b7c0786f4 [DataType] Add bfloat16 (#5601) 2020-06-19 07:40:40 -07:00
Tianqi Chen b2640260cd [REFACTOR][TIR][API-Change] Migrate BuildConfig to PassContext. (#5668)
* [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>
2020-05-25 20:50:00 -07:00
Tianqi Chen 9d1d8a90ff [PYTHON] Add buffer name when creating tensor bindings (#5670) 2020-05-25 20:19:15 -07:00
Tianqi Chen 0833b07b41 [TIR][BUILD] Remove buffer params from pass config. (#5652)
Buffer configurations can be passed during construction
and does not need to be part of the build config.

This is a refactor step to simplify the BuildConfig for the PassContext migration.
2020-05-23 08:38:00 -07:00
Tianqi Chen b8c23d660d [TIR][REFACTOR] Remove ir_pass in favor of analysis/transform. (#5415)
This PR removes ir_pass(old style pass functions) in favor
of analysis/transform(new style pass manager).
2020-04-22 20:44:25 -07:00
Tianqi Chen d3277874a2 [PTYTHON] Migrate VTA TIR passes to the new pass manager. (#5397) 2020-04-21 14:23:18 -07:00