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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to