|
2 | 2 | import pytest
|
3 | 3 | from absl.testing import parameterized
|
4 | 4 |
|
| 5 | +from conftest import skip_if_backend |
5 | 6 | from keras.src import backend
|
6 | 7 | from keras.src import layers
|
| 8 | +from keras.src import models |
7 | 9 | from keras.src import ops
|
8 | 10 | from keras.src import testing
|
9 | 11 |
|
@@ -112,12 +114,21 @@ def test_flatten_with_scalar_channels(self):
|
112 | 114 | expected_output=expected_output,
|
113 | 115 | )
|
114 | 116 |
|
115 |
| - def test_flatten_with_dynamic_batch_size(self): |
| 117 | + def test_flatten_symbolic_with_dynamic_batch_size(self): |
116 | 118 | input_layer = layers.Input(batch_shape=(None, 2, 3))
|
117 | 119 | flattened = layers.Flatten()(input_layer)
|
118 | 120 | self.assertEqual(flattened.shape, (None, 2 * 3))
|
119 | 121 |
|
120 |
| - def test_flatten_with_dynamic_dimension(self): |
| 122 | + def test_flatten_symbolic_with_dynamic_dimension(self): |
121 | 123 | input_layer = layers.Input(batch_shape=(5, 2, None))
|
122 | 124 | flattened = layers.Flatten()(input_layer)
|
123 | 125 | self.assertEqual(flattened.shape, (5, None))
|
| 126 | + |
| 127 | + @skip_if_backend("openvino", "Dynamic dimensions not supported by OpenVino") |
| 128 | + def test_flatten_with_dynamic_batch_size_and_dynamic_dimenstions(self): |
| 129 | + def generator(): |
| 130 | + yield (np.ones((3, 5, 7), dtype="float32"),) |
| 131 | + yield (np.ones((2, 7, 5), dtype="float32"),) |
| 132 | + |
| 133 | + model = models.Sequential([layers.Flatten()]) |
| 134 | + model.predict(generator()) |
0 commit comments