diff --git a/external/llvm-project b/external/llvm-project index f1b922188..6f9c25167 160000 --- a/external/llvm-project +++ b/external/llvm-project @@ -1 +1 @@ -Subproject commit f1b922188ead5ca492c8d8edd47921b013a22ae0 +Subproject commit 6f9c25167d16acff3ff8e4f54a8c14a2a175fc59 diff --git a/test/Conversion/TorchToSCF/basic.mlir b/test/Conversion/TorchToSCF/basic.mlir index eb0e71512..136bffe28 100644 --- a/test/Conversion/TorchToSCF/basic.mlir +++ b/test/Conversion/TorchToSCF/basic.mlir @@ -2,15 +2,15 @@ // CHECK-LABEL: func @torch.prim.if( // CHECK-SAME: %[[VAL_0:.*]]: !torch.bool) -> !torch.int { -// CHECK: %[[VAL_1:.*]] = torch.constant.int 2 -// CHECK: %[[VAL_2:.*]] = torch.constant.int 1 -// CHECK: %[[VAL_3:.*]] = torch_c.to_i1 %[[VAL_0]] -// CHECK: %[[VAL_4:.*]] = scf.if %[[VAL_3]] -> (i64) { -// CHECK: %[[VAL_5:.*]] = torch_c.to_i64 %[[VAL_1]] -// CHECK: scf.yield %[[VAL_5]] : i64 +// CHECK: %[[VAL_1:.*]] = torch_c.to_i1 %[[VAL_0]] +// CHECK: %[[VAL_2:.*]] = torch.constant.int 2 +// CHECK: %[[VAL_3:.*]] = torch_c.to_i64 %[[VAL_2]] +// CHECK: %[[VAL_4:.*]] = torch.constant.int 1 +// CHECK: %[[VAL_5:.*]] = torch_c.to_i64 %[[VAL_4]] +// CHECK: %[[VAL_6:.*]] = scf.if %[[VAL_1]] -> (i64) { +// CHECK: scf.yield %[[VAL_3]] : i64 // CHECK: } else { -// CHECK: %[[VAL_6:.*]] = torch_c.to_i64 %[[VAL_2]] -// CHECK: scf.yield %[[VAL_6]] : i64 +// CHECK: scf.yield %[[VAL_5]] : i64 // CHECK: } // CHECK: %[[VAL_7:.*]] = torch_c.from_i64 %[[VAL_8:.*]] // CHECK: return %[[VAL_7]] : !torch.int @@ -28,23 +28,23 @@ func @torch.prim.if(%arg0: !torch.bool) -> !torch.int { // CHECK-LABEL: func @aten.prim.if$nested( // CHECK-SAME: %[[VAL_0:.*]]: !torch.bool, // CHECK-SAME: %[[VAL_1:.*]]: !torch.bool) -> !torch.int { -// CHECK: %[[VAL_2:.*]] = torch.constant.int 2 -// CHECK: %[[VAL_3:.*]] = torch.constant.int 3 -// CHECK: %[[VAL_4:.*]] = torch.constant.int 4 -// CHECK: %[[VAL_5:.*]] = torch_c.to_i1 %[[VAL_0]] -// CHECK: %[[VAL_6:.*]] = scf.if %[[VAL_5]] -> (i64) { -// CHECK: %[[VAL_7:.*]] = torch_c.to_i1 %[[VAL_1]] -// CHECK: %[[VAL_8:.*]] = scf.if %[[VAL_7]] -> (i64) { -// CHECK: %[[VAL_9:.*]] = torch_c.to_i64 %[[VAL_2]] -// CHECK: scf.yield %[[VAL_9]] : i64 +// CHECK: %[[VAL_2:.*]] = torch_c.to_i1 %[[VAL_0]] +// CHECK: %[[VAL_3:.*]] = torch_c.to_i1 %[[VAL_1]] +// CHECK: %[[VAL_4:.*]] = torch.constant.int 2 +// CHECK: %[[VAL_5:.*]] = torch_c.to_i64 %[[VAL_4]] +// CHECK: %[[VAL_6:.*]] = torch.constant.int 3 +// CHECK: %[[VAL_7:.*]] = torch_c.to_i64 %[[VAL_6]] +// CHECK: %[[VAL_8:.*]] = torch.constant.int 4 +// CHECK: %[[VAL_9:.*]] = torch_c.to_i64 %[[VAL_8]] +// CHECK: %[[VAL_10:.*]] = scf.if %[[VAL_2]] -> (i64) { +// CHECK: %[[VAL_11:.*]] = scf.if %[[VAL_3]] -> (i64) { +// CHECK: scf.yield %[[VAL_5]] : i64 // CHECK: } else { -// CHECK: %[[VAL_10:.*]] = torch_c.to_i64 %[[VAL_3]] -// CHECK: scf.yield %[[VAL_10]] : i64 +// CHECK: scf.yield %[[VAL_7]] : i64 // CHECK: } -// CHECK: scf.yield %[[VAL_11:.*]] : i64 +// CHECK: scf.yield %[[VAL_12:.*]] : i64 // CHECK: } else { -// CHECK: %[[VAL_12:.*]] = torch_c.to_i64 %[[VAL_4]] -// CHECK: scf.yield %[[VAL_12]] : i64 +// CHECK: scf.yield %[[VAL_9]] : i64 // CHECK: } // CHECK: %[[VAL_13:.*]] = torch_c.from_i64 %[[VAL_14:.*]] // CHECK: return %[[VAL_13]] : !torch.int diff --git a/test/Dialect/TorchConversion/func-backend-type-conversion.mlir b/test/Dialect/TorchConversion/func-backend-type-conversion.mlir index 909492966..a3281834c 100644 --- a/test/Dialect/TorchConversion/func-backend-type-conversion.mlir +++ b/test/Dialect/TorchConversion/func-backend-type-conversion.mlir @@ -5,22 +5,16 @@ // CHECK-LABEL: func @identity( // CHECK-SAME: %[[ARG:.*]]: tensor) -> tensor { -// CHECK: %[[TENSOR:.*]] = torch_c.from_builtin_tensor %[[ARG]] : tensor -> !torch.vtensor<[],f32> -// CHECK: %[[MEMREF:.*]] = torch_c.to_builtin_tensor %[[TENSOR]] : !torch.vtensor<[],f32> -> tensor -// CHECK: return %[[MEMREF]] : tensor +// CHECK: return %[[ARG]] : tensor func @identity(%arg0: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> { return %arg0 : !torch.vtensor<[],f32> } // CHECK-LABEL: func @block_arguments( // CHECK-SAME: %[[ARG:.*]]: tensor) -> tensor { -// CHECK: %[[T1:.*]] = torch_c.from_builtin_tensor %[[ARG]] : tensor -> !torch.vtensor<[],f32> -// CHECK: %[[M1:.*]] = torch_c.to_builtin_tensor %[[T1]] : !torch.vtensor<[],f32> -> tensor -// CHECK: br ^bb1(%[[M1]] : tensor) +// CHECK: br ^bb1(%[[ARG]] : tensor) // CHECK: ^bb1(%[[BBARG:.*]]: tensor): -// CHECK: %[[T2:.*]] = torch_c.from_builtin_tensor %[[BBARG]] : tensor -> !torch.vtensor<[],f32> -// CHECK: %[[M2:.*]] = torch_c.to_builtin_tensor %[[T2]] : !torch.vtensor<[],f32> -> tensor -// CHECK: return %[[M2]] : tensor +// CHECK: return %[[BBARG]] : tensor func @block_arguments(%arg0: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> { br ^bb1(%arg0: !torch.vtensor<[],f32>) ^bb1(%bbarg: !torch.vtensor<[],f32>): @@ -38,9 +32,7 @@ func @call_source() -> !torch.vtensor<[],f32> { } // CHECK-LABEL: func @call_sink( // CHECK-SAME: %[[ARG:.*]]: tensor) { -// CHECK: %[[TENSOR:.*]] = torch_c.from_builtin_tensor %[[ARG]] : tensor -> !torch.vtensor<[],f32> -// CHECK: %[[MEMREF:.*]] = torch_c.to_builtin_tensor %[[TENSOR]] : !torch.vtensor<[],f32> -> tensor -// CHECK: call @sink(%[[MEMREF]]) : (tensor) -> () +// CHECK: call @sink(%[[ARG]]) : (tensor) -> () // CHECK: return func private @sink(!torch.vtensor<[],f32>) func @call_sink(%arg0: !torch.vtensor<[],f32>) { @@ -50,8 +42,8 @@ func @call_sink(%arg0: !torch.vtensor<[],f32>) { // CHECK-LABEL: func @unconverted_op_in_body() -> tensor { // CHECK: %[[TENSOR:.*]] = "test.source"() : () -> !torch.vtensor<[],f32> -// CHECK: %[[MEMREF:.*]] = torch_c.to_builtin_tensor %[[TENSOR]] : !torch.vtensor<[],f32> -> tensor -// CHECK: return %[[MEMREF]] : tensor +// CHECK: %[[BUILTIN_TENSOR:.*]] = torch_c.to_builtin_tensor %[[TENSOR]] : !torch.vtensor<[],f32> -> tensor +// CHECK: return %[[BUILTIN_TENSOR]] : tensor func @unconverted_op_in_body() -> !torch.vtensor<[],f32> { %0 = "test.source"() : () -> !torch.vtensor<[],f32> return %0 : !torch.vtensor<[],f32> @@ -98,27 +90,21 @@ func @bwhile(%arg0: i64, %arg1: i64) -> i64 { // CHECK-LABEL: func @identity$torch.bool( // CHECK-SAME: %[[ARG:.*]]: i1) -> i1 { -// CHECK: %[[TORCH_BOOL:.*]] = torch_c.from_i1 %[[ARG]] -// CHECK: %[[I1:.*]] = torch_c.to_i1 %[[TORCH_BOOL]] -// CHECK: return %[[I1]] : i1 +// CHECK: return %[[ARG]] : i1 func @identity$torch.bool(%arg0: !torch.bool) -> !torch.bool { return %arg0 : !torch.bool } // CHECK-LABEL: func @identity$torch.int( // CHECK-SAME: %[[ARG:.*]]: i64) -> i64 { -// CHECK: %[[TORCH_INT:.*]] = torch_c.from_i64 %[[ARG]] -// CHECK: %[[I64:.*]] = torch_c.to_i64 %[[TORCH_INT]] -// CHECK: return %[[I64]] : i64 +// CHECK: return %[[ARG]] : i64 func @identity$torch.int(%arg0: !torch.int) -> !torch.int { return %arg0 : !torch.int } // CHECK-LABEL: func @identity$torch.float( // CHECK-SAME: %[[ARG:.*]]: f64) -> f64 { -// CHECK: %[[TORCH_FLOAT:.*]] = torch_c.from_f64 %[[ARG]] -// CHECK: %[[F64:.*]] = torch_c.to_f64 %[[TORCH_FLOAT]] -// CHECK: return %[[F64]] : f64 +// CHECK: return %[[ARG]] : f64 func @identity$torch.float(%arg0: !torch.float) -> !torch.float { return %arg0 : !torch.float }