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

 ##########
 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:
   For better readability, i would change update_kwargs to has_c_module, and 
move the update_kwargs logic to the end(before fcompile)

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


With regards,
Apache Git Services

Reply via email to