jikechao opened a new pull request, #14824:
URL: https://github.com/apache/tvm/pull/14824

   ### Expected Behavior 
   TVM rejects the invalid attribute value `threshold=None` immediately rather 
than accepting it and producing a different result with Keras. 
   
   
   
   ### Actual Behavior
   
![image](https://github.com/apache/tvm/assets/29506758/380d7b45-01dd-483a-979d-55e775514e09)
   
   
   ### Steps to reproduce
   ```
   import tvm
   import tvm.relay as relay
   import numpy as np
   from tensorflow import keras
   from tensorflow.keras import layers, models
   
   
   input_shape = (1, 2, 3, 4)
   input_data = np.random.random(input_shape)
   x = layers.Input(shape=input_shape[1:], dtype='float32')
   
   layer = keras.layers.ReLU(threshold=None)  # threshold of a ReLU layer 
cannot be the None value. Received: None
   layer.set_weights(layer.get_weights())
   
   y = layer(x)
   model = models.Model(x, y)
   print(model.summary())
   # model.save('model.h5')
   res_keras = model.predict(input_data)
   
   shape_dict = {'input_1': input_shape}
   mod, params = relay.frontend.from_keras(model, shape_dict)
   
   with tvm.transform.PassContext(opt_level=1):
       model = relay.build_module.create_executor("graph", mod, tvm.cpu(0), 
'llvm', params).evaluate()  # crash
   
   test_x_tvm = input_data
   res_tvm = model(tvm.nd.array(test_x_tvm.astype('float32'))).numpy()
   
   np.testing.assert_allclose(res_keras, res_tvm, atol=1e-3, rtol=1e-3)
   ```
   
   cc @echuraev @Hzfengsy 
   


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