|
40 | 40 | "rand_one_and_half_size": lambda: (torch.rand(2, 4, 8, 3), (12, 4), None, False),
|
41 | 41 | }
|
42 | 42 |
|
| 43 | +test_data_suite_dynamic = { |
| 44 | + # (test_name, test_data, size, scale_factor, compare_outputs) |
| 45 | + "rand_double_scale": lambda: (torch.rand(2, 4, 8, 3), None, 2.0, False), |
| 46 | + "rand_double_scale_one_dim": lambda: ( |
| 47 | + torch.rand(2, 4, 8, 3), |
| 48 | + None, |
| 49 | + (1.0, 2.0), |
| 50 | + False, |
| 51 | + ), |
| 52 | +} |
| 53 | + |
43 | 54 |
|
44 | 55 | class UpsamplingNearest2d(torch.nn.Module):
|
45 | 56 | def __init__(
|
@@ -161,3 +172,159 @@ def test_upsample_nearest2d_vec_tosa_BI_nearest(test_data: torch.Tensor):
|
161 | 172 | pipeline.pop_stage(-1)
|
162 | 173 |
|
163 | 174 | pipeline.run()
|
| 175 | + |
| 176 | + |
| 177 | +@common.parametrize("test_data", test_data_suite_dynamic) |
| 178 | +def test_upsample_nearest2d_dynamic_MI_nearest(test_data: torch.Tensor): |
| 179 | + test_data, size, scale_factor, compare_outputs = test_data() |
| 180 | + |
| 181 | + batch_size = torch.export.Dim("batch", min=0, max=1000) |
| 182 | + input_height = torch.export.Dim("input_height", min=0, max=1000) |
| 183 | + input_width = torch.export.Dim("input_width", min=0, max=1000) |
| 184 | + |
| 185 | + dynamic_shapes = {"x": {0: batch_size, 2: input_height, 3: input_width}} |
| 186 | + |
| 187 | + pipeline = TosaPipelineMI[input_t1]( |
| 188 | + UpsamplingNearest2d(size, scale_factor), |
| 189 | + (test_data,), |
| 190 | + aten_op, |
| 191 | + exir_op=[], |
| 192 | + dynamic_shapes=dynamic_shapes, |
| 193 | + ) |
| 194 | + if not compare_outputs: |
| 195 | + pipeline.pop_stage(-1) |
| 196 | + pipeline.run() |
| 197 | + |
| 198 | + |
| 199 | +@common.parametrize("test_data", test_data_suite_dynamic) |
| 200 | +def test_upsample_nearest2d_dynamic_BI_nearest(test_data: torch.Tensor): |
| 201 | + test_data, size, scale_factor, compare_outputs = test_data() |
| 202 | + |
| 203 | + batch_size = torch.export.Dim("batch", min=0, max=2) |
| 204 | + input_height = torch.export.Dim("input_height", min=0, max=8) |
| 205 | + input_width = torch.export.Dim("input_width", min=0, max=8) |
| 206 | + |
| 207 | + dynamic_shapes = {"x": {0: batch_size, 2: input_height, 3: input_width}} |
| 208 | + |
| 209 | + pipeline = TosaPipelineBI[input_t1]( |
| 210 | + UpsamplingNearest2d(size, scale_factor), |
| 211 | + (test_data,), |
| 212 | + aten_op, |
| 213 | + exir_op=[], |
| 214 | + dynamic_shapes=dynamic_shapes, |
| 215 | + ) |
| 216 | + if not compare_outputs: |
| 217 | + pipeline.pop_stage(-1) |
| 218 | + pipeline.run() |
| 219 | + |
| 220 | + |
| 221 | +@common.parametrize("test_data", test_data_suite_dynamic) |
| 222 | +def test_upsample_nearest2d_dynamic_MI_interpolate(test_data: torch.Tensor): |
| 223 | + test_data, size, scale_factor, compare_outputs = test_data() |
| 224 | + |
| 225 | + batch_size = torch.export.Dim("batch", min=0, max=2) |
| 226 | + input_height = torch.export.Dim("input_height", min=4, max=8) |
| 227 | + input_width = torch.export.Dim("input_width", min=3, max=8) |
| 228 | + |
| 229 | + dynamic_shapes = { |
| 230 | + "x": { |
| 231 | + 0: batch_size, |
| 232 | + 2: input_height, |
| 233 | + 3: input_width, |
| 234 | + } |
| 235 | + } |
| 236 | + |
| 237 | + pipeline = TosaPipelineMI[input_t1]( |
| 238 | + Interpolate(size, scale_factor), |
| 239 | + (test_data,), |
| 240 | + aten_op, |
| 241 | + exir_op=[], |
| 242 | + dynamic_shapes=dynamic_shapes, |
| 243 | + ) |
| 244 | + if not compare_outputs: |
| 245 | + pipeline.pop_stage(-1) |
| 246 | + pipeline.run() |
| 247 | + |
| 248 | + |
| 249 | +@common.parametrize("test_data", test_data_suite_dynamic) |
| 250 | +def test_upsample_nearest2d_dynamic_BI_interpolate(test_data: torch.Tensor): |
| 251 | + test_data, size, scale_factor, compare_outputs = test_data() |
| 252 | + |
| 253 | + batch_size = torch.export.Dim("batch", min=0, max=2) |
| 254 | + input_height = torch.export.Dim("input_height", min=4, max=8) |
| 255 | + input_width = torch.export.Dim("input_width", min=3, max=8) |
| 256 | + |
| 257 | + dynamic_shapes = { |
| 258 | + "x": { |
| 259 | + 0: batch_size, |
| 260 | + 2: input_height, |
| 261 | + 3: input_width, |
| 262 | + } |
| 263 | + } |
| 264 | + |
| 265 | + pipeline = TosaPipelineBI[input_t1]( |
| 266 | + Interpolate(size, scale_factor), |
| 267 | + (test_data,), |
| 268 | + aten_op, |
| 269 | + exir_op=[], |
| 270 | + dynamic_shapes=dynamic_shapes, |
| 271 | + ) |
| 272 | + if not compare_outputs: |
| 273 | + pipeline.pop_stage(-1) |
| 274 | + pipeline.run() |
| 275 | + |
| 276 | + |
| 277 | +@common.parametrize("test_data", test_data_suite_dynamic) |
| 278 | +def test_upsample_nearest2d_dynamic_MI_upsample(test_data: torch.Tensor): |
| 279 | + test_data, size, scale_factor, compare_outputs = test_data() |
| 280 | + |
| 281 | + batch_size = torch.export.Dim("batch", min=0, max=1000) |
| 282 | + input_height = torch.export.Dim("input_height", min=0, max=1000) |
| 283 | + input_width = torch.export.Dim("input_width", min=0, max=1000) |
| 284 | + |
| 285 | + dynamic_shapes = { |
| 286 | + "x": { |
| 287 | + 0: batch_size, |
| 288 | + 2: input_height, |
| 289 | + 3: input_width, |
| 290 | + } |
| 291 | + } |
| 292 | + |
| 293 | + pipeline = TosaPipelineMI[input_t1]( |
| 294 | + Upsample(size, scale_factor), |
| 295 | + (test_data,), |
| 296 | + aten_op, |
| 297 | + exir_op=[], |
| 298 | + dynamic_shapes=dynamic_shapes, |
| 299 | + ) |
| 300 | + if not compare_outputs: |
| 301 | + pipeline.pop_stage(-1) |
| 302 | + pipeline.run() |
| 303 | + |
| 304 | + |
| 305 | +@common.parametrize("test_data", test_data_suite_dynamic) |
| 306 | +def test_upsample_nearest2d_dynamic_BI_upsample(test_data: torch.Tensor): |
| 307 | + test_data, size, scale_factor, compare_outputs = test_data() |
| 308 | + |
| 309 | + batch_size = torch.export.Dim("batch", min=0, max=2) |
| 310 | + input_height = torch.export.Dim("input_height", min=0, max=8) |
| 311 | + input_width = torch.export.Dim("input_width", min=0, max=8) |
| 312 | + |
| 313 | + dynamic_shapes = { |
| 314 | + "x": { |
| 315 | + 0: batch_size, |
| 316 | + 2: input_height, |
| 317 | + 3: input_width, |
| 318 | + } |
| 319 | + } |
| 320 | + |
| 321 | + pipeline = TosaPipelineBI[input_t1]( |
| 322 | + Upsample(size, scale_factor), |
| 323 | + (test_data,), |
| 324 | + aten_op, |
| 325 | + exir_op=[], |
| 326 | + dynamic_shapes=dynamic_shapes, |
| 327 | + ) |
| 328 | + if not compare_outputs: |
| 329 | + pipeline.pop_stage(-1) |
| 330 | + pipeline.run() |
0 commit comments