jikechao opened a new pull request, #15122: URL: https://github.com/apache/tvm/pull/15122
This PR fixed a bug about `dilation_rate` in SeparableConv2D. The attribute `dilation_rate` about SeparableConv2D layer has the following constraints in [Keras documentation](https://keras.io/api/layers/convolution_layers/separable_convolution2d/#:~:text=dilation_rate%3A%20An%20integer%20or%20tuple/list%20of%202%20integers%2C%20specifying%20the%20dilation%20rate%20to%20use%20for%20dilated%20convolution.): > **dilation_rate: An integer or tuple/list of 2 integers, specifying the dilation rate to use for dilated convolution.** TVM always considered the `dilation_rate` as a default value. This will lead to wrong calculation results. This PR fix this bug and added the bug-triggering test cases.  ### 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 = (2, 32,32,3) input_data = np.random.random(size=input_shape) x = layers.Input(shape=input_shape[1:], dtype='float32') kwargs={'filters':2,'kernel_size':[3, 3],'dilation_rate':2,} layer = keras.layers.SeparableConv2D(**kwargs) layer.set_weights(layer.get_weights()) y = layer(x) model = models.Model(x, y) model.summary() res_keras = model(input_data) shape_dict = {'input_1': input_shape} mod, params = relay.frontend.from_keras(model, shape_dict,layout='NHWC') 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('float32'))).numpy() np.testing.assert_allclose(res_keras, res_tvm, atol=1e-3, rtol=1e-3) ``` cc @Hzfengsy @echuraev -- 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]
