areusch commented on a change in pull request #10311:
URL: https://github.com/apache/tvm/pull/10311#discussion_r819001845



##########
File path: src/runtime/hexagon/hexagon/hexagon_device_api_v2.cc
##########
@@ -84,7 +84,12 @@ void* HexagonDeviceAPIv2::AllocDataSpace(Device dev, size_t 
nbytes, size_t align
 }
 
 void HexagonDeviceAPIv2::FreeDataSpace(Device dev, void* ptr) {
-  CHECK(TVMDeviceExtType(dev.device_type) == kDLHexagon);
+  bool device = false;
+  if ((TVMDeviceExtType(dev.device_type) == kDLHexagon) ||
+      (DLDeviceType(dev.device_type) == kDLCPU)) {
+    device = true;
+  }
+  CHECK(device) << "dev.device_type: " << dev.device_type;

Review comment:
       ```suggestion
     bool is_valid_device = 
         (TVMDeviceExtType(dev.device_type) == kDLHexagon) ||
         (DLDeviceType(dev.device_type) == kDLCPU);
     CHECK(is_valid_device) << "dev.device_type: " << dev.device_type;
   ```

##########
File path: python/tvm/contrib/hexagon/hexagon.py
##########
@@ -248,3 +265,44 @@ def transform(func, mod, ctx):
 
 def ir_lower_vtcm_pass():
     return [(3, ir_lower_vtcm())]
+
+
+def create_aot_shared(so_name: Union[str, pathlib.Path], files, hexagon_arch: 
str, options=None):
+    """Export Hexagon AOT module."""
+    if not os.access(str(HEXAGON_CLANG_PLUS), os.X_OK):
+        raise Exception(
+            'The Clang++ "' + str(HEXAGON_CLANG_PLUS) + '" does not exist or 
is not executable.'
+        )
+    if not HEXAGON_TOOLCHAIN:
+        raise Exception(
+            " The environment variable HEXAGON_TOOLCHAIN is unset. Please 
export "
+            + "HEXAGON_TOOLCHAIN in your environment."
+        )
+    if not HEXAGON_SDK_PATH:
+        raise Exception(
+            " The environment variable HEXAGON_SDK_PATH is unset. Please 
export "
+            + "HEXAGON_SDK_PATH in your environment."
+        )
+
+    tvm_dir = pathlib.Path(os.path.dirname(os.path.realpath(__file__))) / ".." 
/ ".." / ".." / ".."
+    compute_arch = f"compute{hexagon_arch}"
+    compile_options = [
+        f"-I{tvm_dir / 'include'}",
+        f"-I{tvm_dir / '3rdparty' / 'dlpack' / 'include'}",
+        f"-I{tvm_dir / '3rdparty' / 'dmlc-core' / 'include'}",
+        f"-I{pathlib.Path(HEXAGON_SDK_PATH) / 'rtos' / 'qurt' / compute_arch / 
'include'/ 'posix'}",
+        f"-I{pathlib.Path(HEXAGON_SDK_PATH) / 'rtos' / 'qurt' / compute_arch / 
'include' / 'qurt'}",
+        f"-DDMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>",
+        f"-D_MACH_I32=int",
+    ]
+
+    # For debugging
+    for path in HEXAGON_SDK_INCLUDE_DIRS:
+        compile_options.append(f"-I{str(path)}")
+
+    cross_compile = cc.cross_compiler(
+        
compile_func=tvm.get_global_func("tvm.contrib.hexagon.hexagon.hexagon_clang_plus")()

Review comment:
       just curious, why do we register a PackedFunc to return a constant to 
python?




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