15 Commits

Author SHA1 Message Date
Tianqi Chen 9edd5bd958 [REFACTOR] Remove tvm.runtime.packed_func and container shims; route via tvm_ffi (#19442)
## Summary

- Delete the three Python shim modules that re-exported tvm-ffi types
under `tvm.runtime` / `tvm.ir`:
`python/tvm/runtime/packed_func.py`, `python/tvm/runtime/container.py`,
`python/tvm/ir/container.py`.
- Drop the matching re-exports from `tvm.runtime`, `tvm.ir`, and `tvm`
package init files, so
`tvm.runtime.PackedFunc`, `tvm.runtime.ShapeTuple`,
`tvm.runtime.String`, `tvm.ir.Array`,
  `tvm.ir.Map`, and `tvm.container.Array` no longer exist.
- Migrate every productive caller, test, and tutorial to the canonical
names: `tvm_ffi.Function`,
`tvm_ffi.Shape`, `tvm_ffi.core.String`, `tvm_ffi.Array`, and
`tvm_ffi.Map`.

## Test plan

- [x] `pytest tests/python/all-platform-minimal-test` (75 passed, 77
skipped)
- [x] `pytest tests/python/runtime/test_runtime_container.py
tests/python/all-platform-minimal-test/test_runtime_packed_func.py` (20
passed)
- [x] `pytest tests/python/ir/test_node_reflection.py
tests/python/ir/test_container_structural_equal.py` (32 passed)
- [x] `pytest tests/python/relax/test_vm_build.py
tests/python/relax/test_vm_execbuilder.py
tests/python/relax/test_vm_codegen_only.py` (125 passed, 2 xfailed)
- [x] `pytest tests/python/relax/test_runtime_builtin.py
tests/python/relax/test_op_misc.py` (19 passed)
- [x] `pytest tests/python/target/test_target_target.py` (37 passed, 3
skipped)
- [x] `pre-commit run` clean on touched files
2026-04-25 11:02:08 -04:00
Tianqi Chen a8f1aced2f [FIX] Skip metal target tag registration for unsupported LLVM CPUs (#19427) 2026-04-22 08:16:12 -04: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
Balint Cristian bbd77ace31 Pick up vector length from 'zvlXXXb' (RVV) mattr for riscv (#17641) 2025-02-19 19:09:06 -05:00
Luke Hutton 726a141649 [Target] Use LLVM target parser for determining Arm(R) A-Profile Architecture features (#16425)
Currently, target features are determined by a set of fixed checks on
the target string. This works well for checking support of a small
number of simple features, but it doesn't scale. Some problems include:
- There are many non-trivial conditions for which a feature may(not) be
  available. It is easy to miss these with the current implementation.
- The inclusion of some features in a target string can imply other
  features. For example, "+sve" implies "+neon". This currently isn't
  taken into account.
- The tests in tests/cpp/target/parsers/aprofile_test.c suggest that
  targets such as "llvm -mcpu=cortex-a+neon" and "llvm -mattr=+noneon"
  are supported target strings. The features will be correctly parsed in
  TVM, however, they are not valid in LLVM. Therefore, it's possible
  that TVM and LLVM have different understanding of the features
  available.

This commit uses the more robust LLVM target parser to determine support
for the features in TVM. It leverages previous infrastructure added to
TVM for obtaining a list of all supported features given an input
target, and uses this to check the existance of certain features we're
interested in. It should be trivial to grow this list over time. As a
result of this change, the problems mentioned above are solved.

In the current form, this commit drops support for target strings such
as "llvm -mcpu=cortex-a+neon" and "llvm -mattr=+noneon". A scan of the
codebase suggests this functionality is not in use (only in test cases).
Should we feel the need to support them, or have a smoother migration
for downstream users of TVM we can add a translator to the parser to
convert these into LLVM compatible targets.
2024-03-27 15:53:46 +00:00
Balint Cristian ab1aef962a [Target][CI] Add LLVM functions for current system info (#15903) 2023-10-12 15:25:48 +09:00
Balint Cristian cf8521ad5c [Target] LLVM helper functions for any target info (#15761) 2023-09-27 14:09:53 -05:00
Balint Cristian 67df20faee [Target][TOPI] Use LLVM for x86 CPU feature lookup (#15685)
This PR leverage LLVM itself for CPU features lookup, replacing hard-coded lists.
In order to keep maintainability with X86 families & features we can rely on LLVM.

---
Changes:

* Introduce a single ```target_has_feature(XXX)``` replacing all ```target_has_XXX()```
* PY+FFI: expose new ```llvm_x86_get_archlist```, ```llvm_x86_get_features``` & ```llvm_x86_has_feature```
* PY:  expose new ```target_has_feature``` wrapper to ```_ffi.llvm_x86_has_feature```

---

There is a test unit for a comprehensive check with the old behaviour.
For better reliability, this way of feature checking can be implemented for other arches.
2023-09-14 12:06:31 -07:00
Tristan Konolige 24d2a38116 [LLVM,TIR] Print LLVM intrinsic names instead of ids (#9964)
* [LLVM,TIR] Print LLVM intrinsic names instead of ids

This makes it much easy to understand what is happening with llvm
intrinsics.

* add test, version llvm
2022-02-01 09:16:59 +09:00
driazati 99b9d4276f Introduction tutorial formatting fixes (#9539)
* Introduction tutorial formatting fixes

This fixes some rST issues I noticed while going through the getting started tutorial. Some of these shouldn't be too controversial like using ` instead of `` and consistency fixes. I noticed lots of the `.. note:`s have titles even though they don't really render as anything special in Sphinx, but the base `.. admonition:` does render the title in the top line. This looks nicer IMO and wastes less space but it could go either way, I didn't change it in all places yet either.

* Convert the rest of the tutorial `.. note::` directives to `.. admonition::`
* Fix compilation for matmul tutorial + some random formatting fixes
* Fix ambiguous links and remove namespace

Co-authored-by: driazati <driazati@users.noreply.github.com>
2021-11-25 11:19:12 +00: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
Tianqi Chen 44bffdb398 [REFACTOR][TIR] Migrate low-level pass functions to Pass Manager, (#5213)
- Migrate LowerTVMBultin
- Migrate inferFragment, LowerThreadAllreduce
- Migrate ThreadSync
- Refactor target::Build to directly take IRModule.
- Remove un-used legacy functions.
2020-04-02 13:22:23 -07:00
tqchen 51a265af01 [REFACTOR][PY][API-CHANGE] Establish tvm.target
Move the related target modules into tvm.target.

API change:
- tvm.target.current_target -> tvm.target.Target.current
- tvm.datatype -> tvm.target.datatype
2020-02-12 16:36:23 -08:00