Skip to content

Commit

Permalink
[Target][Detect] Add OpenCL device
Browse files Browse the repository at this point in the history
This PR adds OpenCL device for automatic target detection.
  • Loading branch information
mengshyu committed Apr 6, 2024
1 parent aef7ff6 commit 0625f11
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion python/tvm/target/detect_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ def _detect_rocm(dev: Device) -> Target:
)


def _detect_opencl(dev: Device) -> Target:
return Target(
{
"kind": "opencl",
"max_shared_memory_per_block": dev.max_shared_memory_per_block,
"max_threads_per_block": dev.max_threads_per_block,
"thread_warp_size": dev.warp_size,
}
)


def _detect_vulkan(dev: Device) -> Target:
f_get_target_property = get_global_func("device_api.vulkan.get_target_property")
return Target(
Expand Down Expand Up @@ -99,7 +110,7 @@ def detect_target_from_device(dev: Union[str, Device]) -> Target:
----------
dev : Union[str, Device]
The device to detect the target for.
Supported device types: ["cuda", "metal", "rocm", "vulkan"]
Supported device types: ["cuda", "metal", "rocm", "vulkan", "opencl"]
Returns
-------
Expand Down Expand Up @@ -128,4 +139,5 @@ def detect_target_from_device(dev: Union[str, Device]) -> Target:
"metal": _detect_metal,
"vulkan": _detect_vulkan,
"rocm": _detect_rocm,
"opencl": _detect_opencl,
}

0 comments on commit 0625f11

Please sign in to comment.