tkonolige commented on code in PR #11066:
URL: https://github.com/apache/tvm/pull/11066#discussion_r859232848


##########
python/tvm/utils/__init__.py:
##########
@@ -0,0 +1,303 @@
+# 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.
+"""Utilities operating at a graph/model or other "high" level"""
+import csv
+import subprocess
+from typing import Dict, Union, Optional
+import numpy as np
+
+from .. import auto_scheduler, relay, tir, device, nd, IRModule, build, topi, 
transform
+from ..target import Target
+from ..runtime import profiler_vm, profiling, Device, num_threads
+from ..script import tir as T
+
+
+def _create_args(mod, dev, func_name="main"):
+    args = []
+    for arg in mod[func_name].params:
+        args.append(
+            nd.array(
+                np.zeros([x.value for x in arg.type_annotation.shape], 
arg.type_annotation.dtype),
+                device=dev,
+            )
+        )
+    return args
+
+
+def _estimated_features(mod, params, target):
+    comp = relay.vm.VMCompiler()
+    mod, params = comp.optimize(mod, params=params, target=target)
+    return {
+        prim.attrs["hash"]: (name, 
auto_scheduler.feature.named_features_from_primfunc(prim))
+        for name, prim in mod.functions.items()
+        if isinstance(prim, tir.PrimFunc)
+    }
+
+
+def _vec_width_registers(target, vec_width, num_vector_registers):
+    if vec_width is None:
+        if target.device_name == "":  # indicates x86

Review Comment:
   I don't think the hexagon target string you have provided there is correct. 
If I look at every "builtin" target provided by tvm, they all set the `-device` 
flag to something (with the exception of hexagon).
   
   ```
   In [2]: tvm.target.arm_cpu()
   Out[2]: llvm -keys=arm_cpu,cpu -device=arm_cpu -link-params=0 -model=unknown
   
   In [3]: tvm.target.hexagon()
   Out[3]: hexagon -keys=hexagon -link-params=0 -mattr=+hvxv66,+hvx-length128b 
-mcpu=hexagonv66 -mtriple=hexagon
   
   In [4]: tvm.target.cuda()
   Out[4]: cuda -keys=cuda,gpu -arch=sm_86 -max_num_threads=1024 -model=unknown 
-thread_warp_size=32
   
   In [5]: tvm.target.bifrost()
   Out[5]: opencl -keys=bifrost,opencl,gpu -device=bifrost -max_num_threads=256 
-model=unknown -thread_warp_size=1
   
   In [6]: tvm.target.intel_graphics()
   Out[6]: opencl -keys=intel_graphics,opencl,gpu -device=intel_graphics 
-max_num_threads=256 -model=unknown -thread_warp_size=16
   
   In [7]: tvm.target.mali()
   Out[7]: opencl -keys=mali,opencl,gpu -device=mali -max_num_threads=256 
-model=unknown -thread_warp_size=1
   
   In [8]: tvm.target.rasp()
   Out[8]: llvm -keys=arm_cpu,cpu -device=arm_cpu -link-params=0 -mattr=+neon 
-model=bcm2837 -mtriple=armv7l-linux-gnueabihf
   
   In [9]: tvm.target.riscv_cpu()
   Out[9]: llvm -keys=arm_cpu,cpu -device=arm_cpu -link-params=0 -mabi=lp64d 
-mcpu=sifive-u54 -model=sifive-u54 -mtriple=riscv64-unknown-linux-gnu
   
   In [10]: tvm.target.rocm()
   Out[10]: rocm -keys=rocm,gpu -max_num_threads=256 -mcpu=gfx900 
-model=unknown -mtriple=amdgcn-amd-amdhsa-hcc -thread_warp_size=64
   ```
   (I have been unable to find any documentation on what `device` actually 
means/does).
   
   If you have a better way to detect x86, I'd be happy to use it. The only way 
I've seen this detection done in the codebase is by looking at `mcpu`.
   
   I'd love to have this information available from the targets, but all the 
x86 code in topi appears to do it the way I do it here.



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