haoyang9804 opened a new issue #10398:
URL: https://github.com/apache/tvm/issues/10398


   Followed by [this 
problem](https://discuss.tvm.apache.org/t/infertype-crashes-when-a-relay-function-call-another-function/12176),
 I made a simple change and it still causes crash.
   Below is my script:
   ```
   import tvm
   from tvm import relay
   mod = tvm.IRModule()
   
   x1 = relay.var("x1", dtype='float64', shape=())
   F1 = relay.Function([x1], x1)
   mod['F1'] = F1
   
   x2 = relay.var("x2", dtype='float64', shape=())
   f = mod.get_global_var('F1')
   y2 = f(x2)
   F2 = relay.Function([x2], y2)
   mod['main'] = F2
   
   mod = relay.transform.InferType()(mod)
   print(mod)
   ```
   The relay IR before InferType is 
   <img width="167" alt="4" 
src="https://user-images.githubusercontent.com/34816323/155886350-cdfd296e-6b21-4d7a-90b9-bf7e671bf232.png";>
   Crash message is
   <img width="757" alt="5" 
src="https://user-images.githubusercontent.com/34816323/155886360-fddf50b4-a858-4a53-97d3-abae42241755.png";>
   
   Curious about this problem, I wrote a .rly script named "mhy.rly" which is 
the same as F1 function before InferType
   ```
   #[version = "0.0.5"]
   
   def @F1(%x1: float64){
     %x1
   }
   ```
   And I change my python script into the following one, which I think has the 
same semantic as the first one.
   ```
   import tvm
   from tvm import relay
   from tvm.relay.prelude import Prelude
   mod = tvm.IRModule()
   mod.import_from_std("mhy.rly")
   
   x2 = relay.var("x2", dtype='float64', shape=())
   f = mod.get_global_var("F1")
   y2 = f(x2)
   F2 = relay.Function([x2], y2)
   mod['main'] = F2
   
   mod = relay.transform.InferType()(mod)
   print(mod)
   ```
   Now it runs smoothly and meet no crash.
   I think it may be a bug so I report it. Could someone give an explanation. 
Thanks!


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