tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-tvm] kumasento opened a new pull request #5146: Handle empty LLVMModule in GetFunction
Date Wed, 25 Mar 2020 14:07:31 GMT
kumasento opened a new pull request #5146: Handle empty LLVMModule in GetFunction
URL: https://github.com/apache/incubator-tvm/pull/5146
 
 
   #4847 introduces empty `LLVMModule`, which may appear when all the executable code are
optimized #4748 . An empty `LLVMModule` is built from an IR file that only specifies target
triplet and data layout.
   
   We just notice that existing logic in `LLVMModuleNode` may not consider this case properly.
As shown by @trevor-m in this [comment](https://github.com/apache/incubator-tvm/pull/4847#issuecomment-600221459),
`LLVMModuleNode::GetFunction` doesn't work properly.
   
   We dived into this problem and found out that `LLVMModuleNode` always assumes there exists
an entry function (see this [line](https://github.com/apache/incubator-tvm/blob/3aabbd9c30d247a31eb19ebf997d6074b14b5dd9/src/target/llvm/llvm_module.cc#L321-L322)).
If there is not, e.g., in an empty `LLVMModule`, we would have trouble, mostly in the form
of segfault.
   
   This PR mainly deals with the empty `LLVMModule` issue in `LLVMModuleNode::GetFunction`.
We assume that, without losing generality, a `LLVMModule` is empty if its `entry_func_` cannot
be found, i.e.:
   
   ```c++
   GetGlobalAddr(runtime::symbol::tvm_module_main) == 0
   ```
   
   We use this assumption as follows:
   
   1. When `LazyInitJIT` is called by `GetFunction`, we will validate the address of `entry_func_`
(by the condition above) first before we refer to it. 
   2. If `entry_func_` is empty, we can realize the current `LLVMModule` is empty and we should
return `nullptr`.
   
   Please let me know whether this help address your problem @trevor-m 

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

Mime
View raw message