This is an automated email from the ASF dual-hosted git repository.
echuraev 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 081cc2ef64 [Bugfix][Relay][Keras] Fix UpSampling2D about the wrong
assertion about size (#15082)
081cc2ef64 is described below
commit 081cc2ef64c866f6dc2e33dbf6912395d09ca749
Author: Qingchao Shen <[email protected]>
AuthorDate: Wed Jun 14 17:13:19 2023 +0800
[Bugfix][Relay][Keras] Fix UpSampling2D about the wrong assertion about
size (#15082)
* fix wrong assertion about unsample in keras.py
* Update test_forward.py
* Update test_forward.py
---
python/tvm/relay/frontend/keras.py | 4 +---
tests/python/frontend/keras/test_forward.py | 5 +++++
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/python/tvm/relay/frontend/keras.py
b/python/tvm/relay/frontend/keras.py
index 16192617fe..d963a5d160 100644
--- a/python/tvm/relay/frontend/keras.py
+++ b/python/tvm/relay/frontend/keras.py
@@ -767,10 +767,8 @@ def _convert_upsample(
params["scale_h"] = h
elif upsample_type == "UpSampling2D":
h, w = keras_layer.size
- if h != w:
- raise tvm.error.OpAttributeInvalid("Height must equal width for
operator Upsample.")
params["scale_h"] = h
- params["scale_w"] = h
+ params["scale_w"] = w
if hasattr(keras_layer, "interpolation"):
interpolation = keras_layer.interpolation
diff --git a/tests/python/frontend/keras/test_forward.py
b/tests/python/frontend/keras/test_forward.py
index debd50b37a..45935f87f4 100644
--- a/tests/python/frontend/keras/test_forward.py
+++ b/tests/python/frontend/keras/test_forward.py
@@ -389,6 +389,11 @@ class TestKeras:
x = keras_mod.layers.UpSampling2D(size=(3, 3),
interpolation=interpolation)(data)
keras_model = keras_mod.models.Model(data, x)
verify_keras_frontend(keras_model)
+ # Height and width are not equal for the attribute size
+ data = keras_mod.layers.Input(shape=(2, 1, 3))
+ x = keras_mod.layers.UpSampling2D(size=(1, 2),
interpolation=interpolation)(data)
+ keras_model = keras_mod.models.Model(data, x)
+ verify_keras_frontend(keras_model)
def test_forward_reshape(self, keras_mod):
"""test_forward_reshape"""