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/21 12:43:25 UTC

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

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

 ##########
 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:
   In my opinion, we shouldn't have problem. Because we should only have one kwargs[option] even we have multiple C modules. So, even we enter into multiple times, we only append duplicate `find_include_path()` results. But we could only do it once to avoid duplicate includes. My updated code uses one `cache_kwargs` to make it sure we only enter this condition once, if you have good suggestion, you could comment it again.

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