This is an automated email from the ASF dual-hosted git repository.

masahi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 9e265ff5f0 [Bugfix][Relay][keras] Fix the bug about the attribute 
'output_padding' in Deconv (#15060)
9e265ff5f0 is described below

commit 9e265ff5f008c6bb6318c8786e8d4527b699523c
Author: Qingchao Shen <[email protected]>
AuthorDate: Fri Jun 9 07:04:45 2023 +0800

    [Bugfix][Relay][keras] Fix the bug about the attribute 'output_padding' in 
Deconv (#15060)
    
    * fix deconv about the parameter output_padding
    
    * add test cases to capture the in deconv
    
    * Update keras.py
---
 python/tvm/relay/frontend/keras.py          | 4 ++++
 tests/python/frontend/keras/test_forward.py | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/python/tvm/relay/frontend/keras.py 
b/python/tvm/relay/frontend/keras.py
index 86131a6216..16192617fe 100644
--- a/python/tvm/relay/frontend/keras.py
+++ b/python/tvm/relay/frontend/keras.py
@@ -421,6 +421,8 @@ def _convert_convolution(inexpr, keras_layer, etab, 
data_layout, input_shape=Non
         params["groups"] = in_channels
     else:
         params["channels"] = n_filters
+    if is_deconv and keras_layer.output_padding:
+        params["output_padding"] = keras_layer.output_padding
     if keras_layer.padding == "valid":
         pass
     # we insert a separate pad operator
@@ -507,6 +509,8 @@ def _convert_convolution3d(inexpr, keras_layer, etab, 
data_layout, input_shape=N
         "kernel_layout": kernel_layout,
     }
     params["channels"] = n_filters
+    if is_deconv and keras_layer.output_padding:
+        params["output_padding"] = keras_layer.output_padding
 
     if keras_layer.padding == "valid":
         pass
diff --git a/tests/python/frontend/keras/test_forward.py 
b/tests/python/frontend/keras/test_forward.py
index 4a3b0108f8..debd50b37a 100644
--- a/tests/python/frontend/keras/test_forward.py
+++ b/tests/python/frontend/keras/test_forward.py
@@ -321,6 +321,9 @@ class TestKeras:
         data = keras_mod.layers.Input(shape=(32, 32, 128))
         conv_funcs = [
             keras_mod.layers.Conv2DTranspose(filters=64, kernel_size=(2, 2), 
padding="valid"),
+            keras_mod.layers.Conv2DTranspose(
+                filters=2, kernel_size=(3, 3), strides=(2, 2), 
output_padding=(1, 1)
+            ),
         ]
         for conv_func in conv_funcs:
             x = conv_func(data)
@@ -619,6 +622,9 @@ class TestKeras:
                 filters=1, kernel_size=(3, 3, 3), padding="valid", 
use_bias=False
             ),
             keras_mod.layers.Conv3DTranspose(filters=10, kernel_size=(2, 2, 
2), padding="valid"),
+            keras_mod.layers.Conv3DTranspose(
+                filters=2, kernel_size=(3, 3, 3), strides=(2, 2, 2), 
output_padding=(1, 1, 1)
+            ),
         ]
         for conv_func in conv_funcs:
             x = conv_func(data)

Reply via email to