You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2019/12/20 18:52:27 UTC

[GitHub] [incubator-tvm] tqchen commented on a change in pull request #4532: [RUNTIME] Support standardize runtime module

tqchen commented on a change in pull request #4532: [RUNTIME] Support standardize runtime module
URL: https://github.com/apache/incubator-tvm/pull/4532#discussion_r360520140
 
 

 ##########
 File path: python/tvm/module.py
 ##########
 @@ -118,31 +118,33 @@ def export_library(self,
             self.save(file_name)
             return
 
-        if not (self.type_key == "llvm" or self.type_key == "c"):
-            raise ValueError("Module[%s]: Only llvm and c support export shared" % self.type_key)
+        modules = self._collect_dso_modules()
         temp = _util.tempdir()
-        if fcompile is not None and hasattr(fcompile, "object_format"):
-            object_format = fcompile.object_format
-        else:
-            if self.type_key == "llvm":
-                object_format = "o"
+        files = []
+        is_system_lib = False
+        for module in modules:
+            if fcompile is not None and hasattr(fcompile, "object_format"):
+                object_format = fcompile.object_format
             else:
-                assert self.type_key == "c"
-                object_format = "cc"
-        path_obj = temp.relpath("lib." + object_format)
-        self.save(path_obj)
-        files = [path_obj]
-        is_system_lib = self.type_key == "llvm" and self.get_function("__tvm_is_system_module")()
-        has_imported_c_file = False
+                if module.type_key == "llvm":
+                    object_format = "o"
+                else:
+                    assert module.type_key == "c"
+                    object_format = "cc"
+            path_obj = temp.relpath("lib" + str(hash(module)) + "." + object_format)
+            module.save(path_obj)
+            files.append(path_obj)
+            is_system_lib = (module.type_key == "llvm" and
+                             module.get_function("__tvm_is_system_module")())
+            if module.type_key == "c":
+                options = []
+                if "options" in kwargs:
+                    opts = kwargs["options"]
+                    options = opts if isinstance(opts, (list, tuple)) else [opts]
+                opts = options + ["-I" + path for path in find_include_path()]
+                kwargs.update({'options': opts})
 
 Review comment:
   We are mutating kwargs, would it cause problem for if we have multiple c modules? should we only do it once and cache it, alternatively, always copy kwargs before mutating it.
   
   This reminds me that we need an additional testcase for C module.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services