You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "jikechao (via GitHub)" <gi...@apache.org> on 2023/07/17 11:01:35 UTC

[GitHub] [tvm] jikechao opened a new issue, #15338: [Wrong results] Why the graph executor give a wrong inference result about int32

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

   For the type `int32` or `uint32`, the graph executor always gives the wrong inference results.
   In the below statement, if we replace 'graph' with 'vm' or 'aot', the results will be correct.
   
   `model = relay.build_module.create_executor("graph", mod, tvm.cpu(0), 'llvm', params).evaluate()`
   ![image](https://github.com/apache/tvm/assets/29506758/0de2cf70-659e-4143-a4b5-3af364241df4)
   
   
   
   ### Steps to reproduces
   ```
   import tvm
   import tvm.relay as relay
   import numpy as np
   from tensorflow import keras
   from tensorflow.keras import layers, models
   
   input_shape = (1, 16)
   #input_data = np.random.random(size=input_shape)
   dtype = 'int32'
   input_data = np.random.randint(4, size=input_shape)
   
   x = layers.Input(shape=input_shape[1:], dtype=dtype)
   
   layer = keras.layers.Dropout(rate=0.2)
   layer.set_weights(layer.get_weights())
   
   y = layer(x)
   model = models.Model(x, y)
   res_keras = model(input_data)
   
   res_keras2 = model(input_data)
   
   shape_dict = {'input_1': input_shape}
   mod, params = relay.frontend.from_keras(model, shape_dict)
   with tvm.transform.PassContext(opt_level=3):
       model = relay.build_module.create_executor("graph", mod, tvm.cpu(0), 'llvm', params).evaluate()
   
   test_x_tvm = input_data
   res_tvm = model(tvm.nd.array(test_x_tvm.astype(dtype))).numpy()
   
   np.testing.assert_allclose(res_keras, res_tvm, atol=1e-3, rtol=1e-3)
   
   ```
   
   
   ### Actual behavior
   ![image](https://github.com/apache/tvm/assets/29506758/c1c41794-ef17-4ec9-991b-ffc1539c2293)
   
   
   @echuraev @Hzfengsy @shingjan 
   Could you help me confirm this is a bug in TVM?  Thank you in advance!
   


-- 
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: commits-unsubscribe@tvm.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] Hzfengsy commented on issue #15338: [Wrong results] Why the graph executor give a wrong inference result about int32

Posted by "Hzfengsy (via GitHub)" <gi...@apache.org>.
Hzfengsy commented on issue #15338:
URL: https://github.com/apache/tvm/issues/15338#issuecomment-1637909816

   It should be a bug I think. Thanks for pointing it out


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Wrong results] Why the graph executor give a wrong inference result about int32 [tvm]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen closed issue #15338: [Wrong results] Why the graph executor give a wrong inference result about int32
URL: https://github.com/apache/tvm/issues/15338


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org