tvm.target
Target description and codegen module.
TVM uses JSON-based target configuration. Targets can be constructed via:
A config dictionary:
Target({"kind": "cuda", "arch": "sm_80"})A tag name:
Target("nvidia/nvidia-a100")A tag with overrides:
Target({"tag": "nvidia/nvidia-a100", "l2_cache_size_bytes": 12345})A kind name:
Target("cuda")
Use target.attrs["key"] to access target attributes such as
"arch", "max_num_threads", "mcpu", "libs", etc.
Use tvm.target.list_tags() to list all available target tags,
and tvm.target.register_tag() to register new tags.
Classes:
|
Target device information, use through TVM API. |
|
Kind of a compilation target |
|
A compile time representation for where data is to be stored at runtime, and how to compile code to compute it. |
Functions:
Returns a dict of tags, which maps each tag name to its corresponding target. |
|
|
Add a user-defined tag into the target tag registry. |
- class tvm.target.Target(target, host=None)
Target device information, use through TVM API.
Targets can be constructed from:
A JSON config dictionary:
Target({"kind": "cuda", "arch": "sm_80"})A tag name:
Target("nvidia/nvidia-a100")A tag with overrides:
Target({"tag": "nvidia/nvidia-a100", "l2_cache_size_bytes": 12345})A kind name:
Target("cuda")
Use
target.attrs["key"]to access target attributes.Examples
# From a tag target = Target("nvidia/nvidia-a100") # From a tag with attribute overrides target = Target({"tag": "qcom/hexagon-v68", "vtcm-capacity": 70000}) # From a config dictionary target = Target({"kind": "cuda", "arch": "sm_80"})
Methods:
from_device(device)Detects Target associated with the given device.
current([allow_none])Returns the current target.
get_kind_attr(attr_name)Get additional attribute about the target kind.
Returns the device_type for this target.
Returns the list of available target names.
target_or_current(target)Returns target, or the current target in the environment if target is None
- static from_device(device: str | Device) Target
Detects Target associated with the given device. If the device does not exist, there will be an Error.
- static current(allow_none=True)
Returns the current target.
- Parameters:
allow_none (bool) – Whether allow the current target to be none
- Raises:
ValueError if current target is not set. –
- get_kind_attr(attr_name)
Get additional attribute about the target kind.
- get_target_device_type()
Returns the device_type for this target.
- static list_kinds()
Returns the list of available target names.
- static target_or_current(target)
Returns target, or the current target in the environment if target is None
- class tvm.target.TargetKind(*args: Any, **kwargs: Any)
Kind of a compilation target
Attributes:
Returns the dict of available option names and types
Methods:
options_from_name(kind_name)Returns the dict of available option names and types from a name of TargetKind
- property options
Returns the dict of available option names and types
- class tvm.target.VirtualDevice(device=None, target=None, memory_scope='')
A compile time representation for where data is to be stored at runtime, and how to compile code to compute it.
Attributes:
The type of the virtual device.
The area of memory w.r.t.
The target describing how to compile for the virtual device.
The device id of the virtual device.
- property device_type_int
The type of the virtual device.
- property memory_scope
The area of memory w.r.t. the virtual device where data is stored.
- property target
The target describing how to compile for the virtual device.
- property virtual_device_id
The device id of the virtual device.
- tvm.target.list_tags() dict[str, Target] | None
Returns a dict of tags, which maps each tag name to its corresponding target.
- tvm.target.register_tag(name: str, config: dict[str, Any], override: bool = False) Target | None
Add a user-defined tag into the target tag registry.
- Parameters:
- Returns:
target – The target corresponding to the tag None if TVM is built in runtime-only mode.
- Return type:
Optional[Target]
Examples
register_tag("nvidia/gtx1080ti", config={ "kind": "cuda", "arch": "sm_61", })