You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "LeshengJin (via GitHub)" <gi...@apache.org> on 2023/09/08 23:31:24 UTC
[GitHub] [tvm] LeshengJin opened a new pull request, #15714: [Target][Device] Auto detect target and create device from str in torch style
LeshengJin opened a new pull request, #15714:
URL: https://github.com/apache/tvm/pull/15714
- Target auto detection: `Target.auto_detect()`.
- Target created from device: `Target.from_device("cuda")` or `Target.from_device(tvm.cuda())`
- create device from str: `tvm.device("cuda:0")` or tvm.device("cuda", 0)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao merged pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao merged PR #15714:
URL: https://github.com/apache/tvm/pull/15714
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] LeshengJin commented on pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "LeshengJin (via GitHub)" <gi...@apache.org>.
LeshengJin commented on PR #15714:
URL: https://github.com/apache/tvm/pull/15714#issuecomment-1714935460
I have rebased it to `main`. Thanks! @Hzfengsy
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323589599
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
+ target_triple = get_global_func("tvm.codegen.llvm.GetDefaultTargetTriple")()
+ process_triple = get_global_func("tvm.codegen.llvm.GetProcessTriple")()
+ host_cpu = get_global_func("tvm.codegen.llvm.GetHostCPUName")()
+ print(
+ f"Host CPU dection:\n Target triple: {target_triple}\n "
+ f"Process triple: {process_triple}\n Host CPU: {host_cpu}"
+ )
+ if target_triple.startswith("x86_64-"):
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "x86_64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+ # should start with "arm64-"
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "arm64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+
+
+def _detect_metal(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "metal",
+ "max_shared_memory_per_block": 32768,
+ "max_threads_per_block": dev.max_threads_per_block,
+ "thread_warp_size": 32,
+ },
+ host=_detect_metal_host(),
+ )
+
+
+def _detect_cuda(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "cuda",
+ "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,
+ "registers_per_block": 65536,
+ "arch": "sm_" + dev.compute_version.replace(".", ""),
+ }
+ )
+
+
+def _detect_rocm(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "rocm",
+ "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:
+ return Target(
+ {
+ "kind": "vulkan",
+ "max_threads_per_block": dev.max_threads_per_block,
+ "max_shared_memory_per_block": dev.max_shared_memory_per_block,
+ "thread_warp_size": dev.warp_size,
+ "supports_float16": 1,
+ "supports_int16": 1,
+ "supports_int8": 1,
+ "supports_16bit_buffer": 1,
+ }
+ )
+
+
+def _detect_opencl(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("opencl")
+
+
+def _detect_cpu(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("llvm")
+
+
+def auto_detect_local_target() -> Target:
+ """Automatically detects the target representing a local GPU or falls
+ back to CPU as a target if no compatible GPU is found. Supported
+ local GPU types: ["cuda", "metal", "rocm", "vulkan", "opencl"].
+
+ Returns
+ -------
+ target : Target
+ The detected target.
+ """
+ for device_type in ["metal", "rocm", "cuda", "vulkan", "opencl"]:
+ dev = device(device_type)
+ if not dev.exist:
+ continue
+ print(f"Detect local GPU type: {device_type}")
Review Comment:
remove this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323590402
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
+ target_triple = get_global_func("tvm.codegen.llvm.GetDefaultTargetTriple")()
+ process_triple = get_global_func("tvm.codegen.llvm.GetProcessTriple")()
+ host_cpu = get_global_func("tvm.codegen.llvm.GetHostCPUName")()
+ print(
+ f"Host CPU dection:\n Target triple: {target_triple}\n "
+ f"Process triple: {process_triple}\n Host CPU: {host_cpu}"
+ )
+ if target_triple.startswith("x86_64-"):
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "x86_64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+ # should start with "arm64-"
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "arm64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+
+
+def _detect_metal(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "metal",
+ "max_shared_memory_per_block": 32768,
+ "max_threads_per_block": dev.max_threads_per_block,
+ "thread_warp_size": 32,
+ },
+ host=_detect_metal_host(),
+ )
+
+
+def _detect_cuda(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "cuda",
+ "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,
+ "registers_per_block": 65536,
+ "arch": "sm_" + dev.compute_version.replace(".", ""),
+ }
+ )
+
+
+def _detect_rocm(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "rocm",
+ "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:
+ return Target(
+ {
+ "kind": "vulkan",
+ "max_threads_per_block": dev.max_threads_per_block,
+ "max_shared_memory_per_block": dev.max_shared_memory_per_block,
+ "thread_warp_size": dev.warp_size,
+ "supports_float16": 1,
+ "supports_int16": 1,
+ "supports_int8": 1,
+ "supports_16bit_buffer": 1,
+ }
+ )
+
+
+def _detect_opencl(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("opencl")
+
+
+def _detect_cpu(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("llvm")
+
+
+def auto_detect_local_target() -> Target:
+ """Automatically detects the target representing a local GPU or falls
+ back to CPU as a target if no compatible GPU is found. Supported
+ local GPU types: ["cuda", "metal", "rocm", "vulkan", "opencl"].
+
+ Returns
+ -------
+ target : Target
+ The detected target.
+ """
+ for device_type in ["metal", "rocm", "cuda", "vulkan", "opencl"]:
+ dev = device(device_type)
+ if not dev.exist:
+ continue
+ print(f"Detect local GPU type: {device_type}")
+ target = SUPPORT_DEVICE[device_type](dev)
+ return target
+
+ print("Failed to detect local GPU, falling back to CPU as a target")
+ return _detect_cpu(device("cpu"))
Review Comment:
return None instead
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323586916
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
+ target_triple = get_global_func("tvm.codegen.llvm.GetDefaultTargetTriple")()
+ process_triple = get_global_func("tvm.codegen.llvm.GetProcessTriple")()
+ host_cpu = get_global_func("tvm.codegen.llvm.GetHostCPUName")()
+ print(
+ f"Host CPU dection:\n Target triple: {target_triple}\n "
+ f"Process triple: {process_triple}\n Host CPU: {host_cpu}"
+ )
+ if target_triple.startswith("x86_64-"):
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "x86_64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+ # should start with "arm64-"
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "arm64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+
+
+def _detect_metal(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "metal",
+ "max_shared_memory_per_block": 32768,
+ "max_threads_per_block": dev.max_threads_per_block,
+ "thread_warp_size": 32,
+ },
+ host=_detect_metal_host(),
+ )
+
+
+def _detect_cuda(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "cuda",
+ "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,
+ "registers_per_block": 65536,
+ "arch": "sm_" + dev.compute_version.replace(".", ""),
+ }
+ )
+
+
+def _detect_rocm(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "rocm",
+ "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:
+ return Target(
+ {
+ "kind": "vulkan",
+ "max_threads_per_block": dev.max_threads_per_block,
+ "max_shared_memory_per_block": dev.max_shared_memory_per_block,
+ "thread_warp_size": dev.warp_size,
+ "supports_float16": 1,
+ "supports_int16": 1,
+ "supports_int8": 1,
+ "supports_16bit_buffer": 1,
Review Comment:
Do not hardcode, instead use `VulkanDeviceProperties` provided here: https://github.com/apache/tvm/blob/main/src/runtime/vulkan/vulkan_device.h#L212
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323582365
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
+ target_triple = get_global_func("tvm.codegen.llvm.GetDefaultTargetTriple")()
+ process_triple = get_global_func("tvm.codegen.llvm.GetProcessTriple")()
+ host_cpu = get_global_func("tvm.codegen.llvm.GetHostCPUName")()
+ print(
+ f"Host CPU dection:\n Target triple: {target_triple}\n "
+ f"Process triple: {process_triple}\n Host CPU: {host_cpu}"
+ )
+ if target_triple.startswith("x86_64-"):
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "x86_64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+ # should start with "arm64-"
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "arm64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+
+
+def _detect_metal(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "metal",
+ "max_shared_memory_per_block": 32768,
+ "max_threads_per_block": dev.max_threads_per_block,
+ "thread_warp_size": 32,
+ },
+ host=_detect_metal_host(),
Review Comment:
No need for host for now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323595717
##########
python/tvm/target/target.py:
##########
@@ -148,6 +150,45 @@ def export(self):
def with_host(self, host=None):
return _ffi_api.WithHost(self, Target(host))
+ @staticmethod
+ def from_device(device: Union[str, Device]) -> "Target":
+ """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"]
Review Comment:
```suggestion
Supported device types: ["cuda", "metal", "rocm", "vulkan"]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] Hzfengsy commented on pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "Hzfengsy (via GitHub)" <gi...@apache.org>.
Hzfengsy commented on PR #15714:
URL: https://github.com/apache/tvm/pull/15714#issuecomment-1712386404
I guess it should be a PR to `main` branch instead of `unity`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323581208
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
Review Comment:
Remove this temporarily and save it for later CPU detection. See also PR: https://github.com/apache/tvm/pull/15685
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323589023
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
+ target_triple = get_global_func("tvm.codegen.llvm.GetDefaultTargetTriple")()
+ process_triple = get_global_func("tvm.codegen.llvm.GetProcessTriple")()
+ host_cpu = get_global_func("tvm.codegen.llvm.GetHostCPUName")()
+ print(
+ f"Host CPU dection:\n Target triple: {target_triple}\n "
+ f"Process triple: {process_triple}\n Host CPU: {host_cpu}"
+ )
+ if target_triple.startswith("x86_64-"):
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "x86_64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+ # should start with "arm64-"
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "arm64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+
+
+def _detect_metal(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "metal",
+ "max_shared_memory_per_block": 32768,
+ "max_threads_per_block": dev.max_threads_per_block,
+ "thread_warp_size": 32,
+ },
+ host=_detect_metal_host(),
+ )
+
+
+def _detect_cuda(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "cuda",
+ "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,
+ "registers_per_block": 65536,
+ "arch": "sm_" + dev.compute_version.replace(".", ""),
+ }
+ )
+
+
+def _detect_rocm(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "rocm",
+ "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,
Review Comment:
also detect `compute_version` here: https://github.com/apache/tvm/blob/main/src/runtime/rocm/rocm_device_api.cc#L68-L78
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323589278
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
+ target_triple = get_global_func("tvm.codegen.llvm.GetDefaultTargetTriple")()
+ process_triple = get_global_func("tvm.codegen.llvm.GetProcessTriple")()
+ host_cpu = get_global_func("tvm.codegen.llvm.GetHostCPUName")()
+ print(
+ f"Host CPU dection:\n Target triple: {target_triple}\n "
+ f"Process triple: {process_triple}\n Host CPU: {host_cpu}"
+ )
+ if target_triple.startswith("x86_64-"):
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "x86_64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+ # should start with "arm64-"
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "arm64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+
+
+def _detect_metal(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "metal",
+ "max_shared_memory_per_block": 32768,
+ "max_threads_per_block": dev.max_threads_per_block,
+ "thread_warp_size": 32,
+ },
+ host=_detect_metal_host(),
+ )
+
+
+def _detect_cuda(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "cuda",
+ "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,
+ "registers_per_block": 65536,
Review Comment:
remove this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323595003
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
+ target_triple = get_global_func("tvm.codegen.llvm.GetDefaultTargetTriple")()
+ process_triple = get_global_func("tvm.codegen.llvm.GetProcessTriple")()
+ host_cpu = get_global_func("tvm.codegen.llvm.GetHostCPUName")()
+ print(
+ f"Host CPU dection:\n Target triple: {target_triple}\n "
+ f"Process triple: {process_triple}\n Host CPU: {host_cpu}"
+ )
+ if target_triple.startswith("x86_64-"):
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "x86_64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+ # should start with "arm64-"
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "arm64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+
+
+def _detect_metal(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "metal",
+ "max_shared_memory_per_block": 32768,
+ "max_threads_per_block": dev.max_threads_per_block,
+ "thread_warp_size": 32,
+ },
+ host=_detect_metal_host(),
+ )
+
+
+def _detect_cuda(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "cuda",
+ "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,
+ "registers_per_block": 65536,
+ "arch": "sm_" + dev.compute_version.replace(".", ""),
+ }
+ )
+
+
+def _detect_rocm(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "rocm",
+ "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:
+ return Target(
+ {
+ "kind": "vulkan",
+ "max_threads_per_block": dev.max_threads_per_block,
+ "max_shared_memory_per_block": dev.max_shared_memory_per_block,
+ "thread_warp_size": dev.warp_size,
+ "supports_float16": 1,
+ "supports_int16": 1,
+ "supports_int8": 1,
+ "supports_16bit_buffer": 1,
+ }
+ )
+
+
+def _detect_opencl(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("opencl")
+
+
+def _detect_cpu(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("llvm")
+
+
+def auto_detect_local_target() -> Target:
+ """Automatically detects the target representing a local GPU or falls
+ back to CPU as a target if no compatible GPU is found. Supported
+ local GPU types: ["cuda", "metal", "rocm", "vulkan", "opencl"].
+
+ Returns
+ -------
+ target : Target
+ The detected target.
+ """
+ for device_type in ["metal", "rocm", "cuda", "vulkan", "opencl"]:
+ dev = device(device_type)
+ if not dev.exist:
+ continue
+ print(f"Detect local GPU type: {device_type}")
+ target = SUPPORT_DEVICE[device_type](dev)
+ return target
+
+ print("Failed to detect local GPU, falling back to CPU as a target")
+ return _detect_cpu(device("cpu"))
+
+
+def detect_target_from_device(dev: Union[str, Device]) -> Target:
+ """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"]
+
+ Returns
+ -------
+ target : Target
+ The detected target.
+ """
+ if isinstance(dev, str):
+ dev = device(dev)
+ device_type = Device.MASK2STR[dev.device_type]
+ if device_type not in SUPPORT_DEVICE:
+ raise ValueError(
+ f"Unsupported device type: {device_type}, "
+ f"currently auto detection only supports {SUPPORT_DEVICE.keys()}"
+ )
Review Comment:
```suggestion
if device_type not in SUPPORT_DEVICE:
raise ValueError(
f"Auto detection for device `{device_type}` is not supported."
f"Currently only supports: {SUPPORT_DEVICE.keys()}"
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323596774
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
+ target_triple = get_global_func("tvm.codegen.llvm.GetDefaultTargetTriple")()
+ process_triple = get_global_func("tvm.codegen.llvm.GetProcessTriple")()
+ host_cpu = get_global_func("tvm.codegen.llvm.GetHostCPUName")()
+ print(
+ f"Host CPU dection:\n Target triple: {target_triple}\n "
+ f"Process triple: {process_triple}\n Host CPU: {host_cpu}"
+ )
+ if target_triple.startswith("x86_64-"):
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "x86_64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+ # should start with "arm64-"
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "arm64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+
+
+def _detect_metal(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "metal",
+ "max_shared_memory_per_block": 32768,
+ "max_threads_per_block": dev.max_threads_per_block,
+ "thread_warp_size": 32,
+ },
+ host=_detect_metal_host(),
+ )
+
+
+def _detect_cuda(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "cuda",
+ "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,
+ "registers_per_block": 65536,
+ "arch": "sm_" + dev.compute_version.replace(".", ""),
+ }
+ )
+
+
+def _detect_rocm(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "rocm",
+ "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:
+ return Target(
+ {
+ "kind": "vulkan",
+ "max_threads_per_block": dev.max_threads_per_block,
+ "max_shared_memory_per_block": dev.max_shared_memory_per_block,
+ "thread_warp_size": dev.warp_size,
+ "supports_float16": 1,
+ "supports_int16": 1,
+ "supports_int8": 1,
+ "supports_16bit_buffer": 1,
+ }
+ )
+
+
+def _detect_opencl(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("opencl")
+
+
+def _detect_cpu(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("llvm")
+
+
+def auto_detect_local_target() -> Target:
Review Comment:
we are being too intelligent here :) probably we at least want users to provide which device they are interested in
##########
python/tvm/target/target.py:
##########
@@ -148,6 +150,45 @@ def export(self):
def with_host(self, host=None):
return _ffi_api.WithHost(self, Target(host))
+ @staticmethod
+ def from_device(device: Union[str, Device]) -> "Target":
+ """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"]
+
+ Returns
+ -------
+ target : Target
+ The detected target.
+ """
+ from .detect_target import ( # pylint: disable=import-outside-toplevel
+ detect_target_from_device,
+ )
+
+ return detect_target_from_device(device)
+
+ @staticmethod
+ def auto_detect() -> "Target":
Review Comment:
remove this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323593544
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
+ target_triple = get_global_func("tvm.codegen.llvm.GetDefaultTargetTriple")()
+ process_triple = get_global_func("tvm.codegen.llvm.GetProcessTriple")()
+ host_cpu = get_global_func("tvm.codegen.llvm.GetHostCPUName")()
+ print(
+ f"Host CPU dection:\n Target triple: {target_triple}\n "
+ f"Process triple: {process_triple}\n Host CPU: {host_cpu}"
+ )
+ if target_triple.startswith("x86_64-"):
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "x86_64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+ # should start with "arm64-"
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "arm64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+
+
+def _detect_metal(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "metal",
+ "max_shared_memory_per_block": 32768,
+ "max_threads_per_block": dev.max_threads_per_block,
+ "thread_warp_size": 32,
+ },
+ host=_detect_metal_host(),
+ )
+
+
+def _detect_cuda(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "cuda",
+ "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,
+ "registers_per_block": 65536,
+ "arch": "sm_" + dev.compute_version.replace(".", ""),
+ }
+ )
+
+
+def _detect_rocm(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "rocm",
+ "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:
+ return Target(
+ {
+ "kind": "vulkan",
+ "max_threads_per_block": dev.max_threads_per_block,
+ "max_shared_memory_per_block": dev.max_shared_memory_per_block,
+ "thread_warp_size": dev.warp_size,
+ "supports_float16": 1,
+ "supports_int16": 1,
+ "supports_int8": 1,
+ "supports_16bit_buffer": 1,
+ }
+ )
+
+
+def _detect_opencl(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("opencl")
+
+
+def _detect_cpu(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("llvm")
+
+
+def auto_detect_local_target() -> Target:
+ """Automatically detects the target representing a local GPU or falls
+ back to CPU as a target if no compatible GPU is found. Supported
+ local GPU types: ["cuda", "metal", "rocm", "vulkan", "opencl"].
+
+ Returns
+ -------
+ target : Target
+ The detected target.
+ """
+ for device_type in ["metal", "rocm", "cuda", "vulkan", "opencl"]:
+ dev = device(device_type)
+ if not dev.exist:
+ continue
+ print(f"Detect local GPU type: {device_type}")
+ target = SUPPORT_DEVICE[device_type](dev)
+ return target
+
+ print("Failed to detect local GPU, falling back to CPU as a target")
+ return _detect_cpu(device("cpu"))
+
+
+def detect_target_from_device(dev: Union[str, Device]) -> Target:
+ """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"]
+
+ Returns
+ -------
+ target : Target
+ The detected target.
+ """
+ if isinstance(dev, str):
+ dev = device(dev)
+ device_type = Device.MASK2STR[dev.device_type]
+ if device_type not in SUPPORT_DEVICE:
+ raise ValueError(
+ f"Unsupported device type: {device_type}, "
+ f"currently auto detection only supports {SUPPORT_DEVICE.keys()}"
+ )
+ if not dev.exist:
+ raise ValueError(f"Device {dev} does not exist in the local environment.")
Review Comment:
```suggestion
if not dev.exist:
raise ValueError(f"Cannot detect device `{dev}`. Please make sure the device and its driver is installed properly, and TVM is compiled with the driver")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] junrushao commented on a diff in pull request #15714: [Target][Device] Auto detect target and create device from str in torch style
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15714:
URL: https://github.com/apache/tvm/pull/15714#discussion_r1323587239
##########
python/tvm/target/detect_target.py:
##########
@@ -0,0 +1,169 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Detect target."""
+from typing import Union
+
+from . import Target
+from .._ffi import get_global_func
+from .._ffi.runtime_ctypes import Device
+from ..runtime.ndarray import device
+
+
+def _detect_metal_host() -> "Target":
+ target_triple = get_global_func("tvm.codegen.llvm.GetDefaultTargetTriple")()
+ process_triple = get_global_func("tvm.codegen.llvm.GetProcessTriple")()
+ host_cpu = get_global_func("tvm.codegen.llvm.GetHostCPUName")()
+ print(
+ f"Host CPU dection:\n Target triple: {target_triple}\n "
+ f"Process triple: {process_triple}\n Host CPU: {host_cpu}"
+ )
+ if target_triple.startswith("x86_64-"):
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "x86_64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+ # should start with "arm64-"
+ return Target(
+ {
+ "kind": "llvm",
+ "mtriple": "arm64-apple-macos",
+ "mcpu": host_cpu,
+ }
+ )
+
+
+def _detect_metal(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "metal",
+ "max_shared_memory_per_block": 32768,
+ "max_threads_per_block": dev.max_threads_per_block,
+ "thread_warp_size": 32,
+ },
+ host=_detect_metal_host(),
+ )
+
+
+def _detect_cuda(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "cuda",
+ "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,
+ "registers_per_block": 65536,
+ "arch": "sm_" + dev.compute_version.replace(".", ""),
+ }
+ )
+
+
+def _detect_rocm(dev: Device) -> Target:
+ return Target(
+ {
+ "kind": "rocm",
+ "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:
+ return Target(
+ {
+ "kind": "vulkan",
+ "max_threads_per_block": dev.max_threads_per_block,
+ "max_shared_memory_per_block": dev.max_shared_memory_per_block,
+ "thread_warp_size": dev.warp_size,
+ "supports_float16": 1,
+ "supports_int16": 1,
+ "supports_int8": 1,
+ "supports_16bit_buffer": 1,
+ }
+ )
+
+
+def _detect_opencl(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("opencl")
+
+
+def _detect_cpu(dev: Device) -> Target: # pylint: disable=unused-argument
+ return Target("llvm")
Review Comment:
Let's remove those two because auto detect doesn't seem to be properly supported yet
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org