slyubomirsky opened a new issue, #13626:
URL: https://github.com/apache/tvm/issues/13626

   The following Relay program causes the debug interpreter to crash before it 
even starts evaluation:
   ```python
   import tvm
   from tvm import relay
   
   modtext = """                                                                
                                                     
   #[version = "0.0.5"]                                                         
                                                     
   def @main() -> int16 {                                                       
                                                     
     %29 = fn () -> fn () -> int16 {                                            
                                                     
       fn () -> int16 {                                                         
                                                     
         0i16                                                                   
                                                     
       }                                                                        
                                                     
     };                                                                         
                                                     
     %30 = (%29,);                                                              
                                                     
     %34 = %30.0;                                                               
                                                     
     %41 = %34();                                                               
                                                     
     %41()                                                                      
                                                     
   }                                                                            
                                                     
   """
   
   mod = tvm.parser.fromtext(modtext)
   relay.create_executor("debug", mod=mod, target="llvm").evaluate()
   ```
   
   Here is the resulting crash:
   ```
   Traceback (most recent call last):
     File "/home/slyubomirsky/code/sandbox/test.py", line 23, in <module>
       relay.create_executor("debug", mod=mod, target="llvm").evaluate()
     File 
"/home/slyubomirsky/code/tvm/python/tvm/relay/backend/interpreter.py", line 
171, in evaluate
       return self._make_executor()
     File 
"/home/slyubomirsky/code/tvm/python/tvm/relay/backend/interpreter.py", line 
233, in _make_executor
       func = _backend.EvalFunction(self.mod, expr, self.device, self.target)
     File "/home/slyubomirsky/code/tvm/python/tvm/_ffi/_ctypes/packed_func.py", 
line 237, in __call__
       raise get_last_ffi_error()
   tvm._ffi.base.TVMError: Traceback (most recent call last):
     24: TVMFuncCall
     23: _ZN3tvm7runtime13PackedFuncObj
     22: 
tvm::runtime::TypedPackedFunc<tvm::runtime::TypedPackedFunc<tvm::runtime::ObjectRef
 (tvm::runtime::Array<tvm::RelayExpr, void>)> (tvm::IRModule, tvm::RelayExpr, 
DLDevice, 
tvm::Target)>::AssignTypedLambda<tvm::runtime::TypedPackedFunc<tvm::runtime::ObjectRef
 (tvm::runtime::Array<tvm::RelayExpr, void>)> (*)(tvm::IRModule, 
tvm::RelayExpr, DLDevice, 
tvm::Target)>(tvm::runtime::TypedPackedFunc<tvm::runtime::ObjectRef 
(tvm::runtime::Array<tvm::RelayExpr, void>)> (*)(tvm::IRModule, tvm::RelayExpr, 
DLDevice, tvm::Target), std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> >)::{lambda(tvm::runtime::TVMArgs 
const&, tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs 
const&, tvm::runtime::TVMRetValue*) const
     21: tvm::relay::EvalFunction(tvm::IRModule, tvm::RelayExpr, DLDevice, 
tvm::Target)
     20: tvm::relay::Prepare(tvm::IRModule, tvm::CompilationConfig const&)
     19: tvm::transform::Pass::operator()(tvm::IRModule) const
     18: tvm::transform::Pass::operator()(tvm::IRModule, 
tvm::transform::PassContext const&) const
     17: tvm::transform::SequentialNode::operator()(tvm::IRModule, 
tvm::transform::PassContext const&) const
     16: tvm::transform::Pass::operator()(tvm::IRModule, 
tvm::transform::PassContext const&) const
     15: tvm::transform::SequentialNode::operator()(tvm::IRModule, 
tvm::transform::PassContext const&) const
     14: tvm::transform::Pass::operator()(tvm::IRModule, 
tvm::transform::PassContext const&) const
     13: tvm::transform::ModulePassNode::operator()(tvm::IRModule, 
tvm::transform::PassContext const&) const
     12: _ZN3tvm7runtime13PackedFuncObj
     11: tvm::runtime::TypedPackedFunc<tvm::IRModule (tvm::IRModule, 
tvm::transform::PassContext)>::AssignTypedLambda<tvm::relay::transform::(anonymous
 namespace)::PlanDevicesCore(tvm::CompilationConfig)::{lambda(tvm::IRModule, 
tvm::transform::PassContext)#1}>(tvm::relay::transform::(anonymous 
namespace)::PlanDevicesCore(tvm::CompilationConfig)::{lambda(tvm::IRModule, 
tvm::transform::PassContext)#1})::{lambda(tvm::runtime::TVMArgs const&, 
tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs const&, 
tvm::runtime::TVMRetValue*) const
     10: tvm::relay::transform::(anonymous namespace)::DeviceAnalyzer::Analyze()
     9: tvm::relay::MixedModeVisitor::VisitExpr(tvm::RelayExpr const&)
     8: tvm::relay::MixedModeVisitor::VisitLeaf(tvm::RelayExpr const&)
     7: tvm::relay::transform::(anonymous 
namespace)::DeviceAnalyzer::VisitExpr_(tvm::relay::FunctionNode const*)
     6: tvm::relay::MixedModeVisitor::VisitExpr(tvm::RelayExpr const&)
     5: tvm::relay::MixedModeVisitor::VisitLeaf(tvm::RelayExpr const&)
     4: tvm::relay::transform::(anonymous 
namespace)::DeviceAnalyzer::VisitExpr_(tvm::relay::TupleNode const*)
     3: tvm::relay::transform::DeviceDomains::UnifyExprCollapsed(tvm::RelayExpr 
const&, std::shared_ptr<tvm::relay::transform::DeviceDomain> const&)
     2: 
tvm::relay::transform::DeviceDomains::CollapseOrFalse(std::shared_ptr<tvm::relay::transform::DeviceDomain>
 const&, std::shared_ptr<tvm::relay::transform::DeviceDomain> const&)
     1: 
tvm::relay::transform::DeviceDomains::UnifyOrNull(std::shared_ptr<tvm::relay::transform::DeviceDomain>,
 std::shared_ptr<tvm::relay::transform::DeviceDomain>)
     0: 
tvm::relay::transform::DeviceDomains::JoinOrNull(std::shared_ptr<tvm::relay::transform::DeviceDomain>
 const&, std::shared_ptr<tvm::relay::transform::DeviceDomain> const&)
     File "/home/slyubomirsky/code/tvm/src/relay/transforms/device_domains.cc", 
line 106
   TVMError: 
   ---------------------------------------------------------------
   An error occurred during the execution of TVM.
   For more information, please see: https://tvm.apache.org/docs/errors.html
   ---------------------------------------------------------------
   
     Check failed: lhs->args_and_result_.size() == rhs->args_and_result_.size() 
(1 vs. 0) : Device domains:
   fn():?94801234141904?
   and
   ?94801234296080?
   do not have the same kind and can't be unified.
   ```
   
   Interestingly, the following two variations of the program do not result in 
a crash:
   ```
   #[version = "0.0.5"]
   def @main() -> int16 {
     %29 = fn () -> int16 {
        0i16
     };
     %30 = (%29,);
     %34 = %30.0;
     %34()
   }
   ```
   
   ```
   #[version = "0.0.5"]
   def @main() -> int16 {
     %29 = fn () -> fn () -> int16 {
       fn () -> int16 {
         0i16
       }
     };
     %41 = %29();
     %41()
   }
   ```


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to