|
| 1 | +// RUN: torch-mlir-opt <%s -convert-torch-to-linalg -split-input-file -verify-diagnostics | FileCheck %s |
| 2 | + |
| 3 | +// CHECK-LABEL: func.func @torch.aten.unflatten.int$static |
| 4 | +// CHECK: torch_c.to_builtin_tensor |
| 5 | +// CHECK: tensor.expand_shape |
| 6 | +// CHECK: torch_c.from_builtin_tensor |
| 7 | +func.func @torch.aten.unflatten.int$static(%arg0: !torch.vtensor<[2,6,4],f32>) -> !torch.vtensor<[2,2,3,4],f32> { |
| 8 | + %int1 = torch.constant.int 1 |
| 9 | + %int2 = torch.constant.int 2 |
| 10 | + %int3 = torch.constant.int 3 |
| 11 | + %0 = torch.prim.ListConstruct %int2, %int3 : (!torch.int, !torch.int) -> !torch.list<int> |
| 12 | + %1 = torch.aten.unflatten.int %arg0, %int1, %0 : !torch.vtensor<[2,6,4],f32>, !torch.int, !torch.list<int> -> !torch.vtensor<[2,2,3,4],f32> |
| 13 | + return %1 : !torch.vtensor<[2,2,3,4],f32> |
| 14 | +} |
| 15 | + |
| 16 | +// ----- |
| 17 | + |
| 18 | +// CHECK-LABEL: func.func @torch.aten.unflatten.int$negative_dim |
| 19 | +// CHECK: torch_c.to_builtin_tensor |
| 20 | +// CHECK: tensor.expand_shape |
| 21 | +// CHECK: torch_c.from_builtin_tensor |
| 22 | +func.func @torch.aten.unflatten.int$negative_dim(%arg0: !torch.vtensor<[2,6,4],f32>) -> !torch.vtensor<[2,2,3,4],f32> { |
| 23 | + %int-2 = torch.constant.int -2 |
| 24 | + %int2 = torch.constant.int 2 |
| 25 | + %int3 = torch.constant.int 3 |
| 26 | + %0 = torch.prim.ListConstruct %int2, %int3 : (!torch.int, !torch.int) -> !torch.list<int> |
| 27 | + %1 = torch.aten.unflatten.int %arg0, %int-2, %0 : !torch.vtensor<[2,6,4],f32>, !torch.int, !torch.list<int> -> !torch.vtensor<[2,2,3,4],f32> |
| 28 | + return %1 : !torch.vtensor<[2,2,3,4],f32> |
| 29 | +} |
| 30 | + |
| 31 | +// ----- |
| 32 | + |
| 33 | +// CHECK-LABEL: func.func @torch.aten.unflatten.int$inferred_size |
| 34 | +// CHECK: torch_c.to_builtin_tensor |
| 35 | +// CHECK: tensor.expand_shape |
| 36 | +// CHECK: torch_c.from_builtin_tensor |
| 37 | +func.func @torch.aten.unflatten.int$inferred_size(%arg0: !torch.vtensor<[3,12],f32>) -> !torch.vtensor<[3,2,6],f32> { |
| 38 | + %int1 = torch.constant.int 1 |
| 39 | + %int2 = torch.constant.int 2 |
| 40 | + %int-1 = torch.constant.int -1 |
| 41 | + %0 = torch.prim.ListConstruct %int2, %int-1 : (!torch.int, !torch.int) -> !torch.list<int> |
| 42 | + %1 = torch.aten.unflatten.int %arg0, %int1, %0 : !torch.vtensor<[3,12],f32>, !torch.int, !torch.list<int> -> !torch.vtensor<[3,2,6],f32> |
| 43 | + return %1 : !torch.vtensor<[3,2,6],f32> |
| 44 | +} |
| 45 | + |
| 46 | +// ----- |
| 47 | + |
| 48 | +// CHECK-LABEL: func.func @torch.aten.unflatten.int$dynamic_input |
| 49 | +// CHECK: torch_c.to_builtin_tensor |
| 50 | +// CHECK: tensor.expand_shape |
| 51 | +// CHECK: torch_c.from_builtin_tensor |
| 52 | +func.func @torch.aten.unflatten.int$dynamic_input(%arg0: !torch.vtensor<[?,6],f32>) -> !torch.vtensor<[?,2,3],f32> { |
| 53 | + %int1 = torch.constant.int 1 |
| 54 | + %int2 = torch.constant.int 2 |
| 55 | + %int3 = torch.constant.int 3 |
| 56 | + %0 = torch.prim.ListConstruct %int2, %int3 : (!torch.int, !torch.int) -> !torch.list<int> |
| 57 | + %1 = torch.aten.unflatten.int %arg0, %int1, %0 : !torch.vtensor<[?,6],f32>, !torch.int, !torch.list<int> -> !torch.vtensor<[?,2,3],f32> |
| 58 | + return %1 : !torch.vtensor<[?,2,3],f32> |
| 59 | +} |
| 60 | + |
| 61 | +// ----- |
| 62 | + |
| 63 | +// CHECK-LABEL: func.func @torch.aten.unflatten.int$two_dynamic_dims |
| 64 | +// CHECK: torch_c.to_builtin_tensor |
| 65 | +// CHECK: tensor.from_elements |
| 66 | +// CHECK: tensor.reshape |
| 67 | +// CHECK: torch_c.from_builtin_tensor |
| 68 | +func.func @torch.aten.unflatten.int$two_dynamic_dims(%arg0: !torch.vtensor<[?,12],f32>) -> !torch.vtensor<[?,?,?],f32> { |
| 69 | + %int1 = torch.constant.int 1 |
| 70 | + %2 = torch.aten.size.int %arg0, %int1 : !torch.vtensor<[?,12],f32>, !torch.int -> !torch.int |
| 71 | + %0 = torch.prim.ListConstruct %2, %2 : (!torch.int, !torch.int) -> !torch.list<int> |
| 72 | + %1 = torch.aten.unflatten.int %arg0, %int1, %0 : !torch.vtensor<[?,12],f32>, !torch.int, !torch.list<int> -> !torch.vtensor<[?,?,?],f32> |
| 73 | + return %1 : !torch.vtensor<[?,?,?],f32> |
| 74 | +} |
0 commit comments