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 2020/02/03 02:58:54 UTC

[GitHub] [incubator-tvm] FrozenGene commented on a change in pull request #4749: [AutoTVM] Support to pass additional compiler options

FrozenGene commented on a change in pull request #4749: [AutoTVM] Support to pass additional compiler options
URL: https://github.com/apache/incubator-tvm/pull/4749#discussion_r373905750
 
 

 ##########
 File path: python/tvm/module.py
 ##########
 @@ -162,13 +162,20 @@ def export_library(self,
                     f.write(_PackImportsToC(self, is_system_lib))
                 files.append(path_cc)
 
-        if has_c_module:
-            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})
+        # Make sure we won't pass {'options': None} or {'options': [None, '-std=c++11', ...]}
+        # to compiler. We can not prevent users doing the following code:
+        # f.export_library(path_dso, cc.create_shared, options=None)
+        # f.export_library(path_dso, cc.create_shared, options=[None, '-std=c++11'])
+        if "options" in kwargs or has_c_module:
+            opts = kwargs["options"] if "options" in kwargs else None
+            options = opts if isinstance(opts, (list, tuple)) else [opts]
+            options = [opt for opt in options if opt]
+            if has_c_module:
+                options = options + ["-I" + path for path in find_include_path()]
+            if not options:
+                del kwargs["options"]
+            else:
+                kwargs.update({'options': options})
 
 Review comment:
   Yes. Your way could avoid twice check of `has_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