tvm_tirx.target.Target#

class tvm_tirx.target.Target(target, host=None)#

Bases: Object

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"})
export()#
with_host(host=None)#

Return a copy of this target with the given host.

Parameters:

host (Optional[Union[str, Dict, Target]]) – The new host target. None removes the host.

Returns:

target (Target) – The target with the updated host.

static from_device(device)#

Detects Target associated with the given device. If the device does not exist, there will be an Error.

Parameters:
  • dev (Union[str, Device]) – The device to detect the target for. Supported device types: [“cuda”, “metal”, “rocm”, “vulkan”, “opencl”, “cpu”]

  • device (str | Device)

Returns:

target (Target) – The detected target.

Return type:

Target

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. –

property features#
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

property attrs#
property host#
property keys#
property kind#
property tag#