Skip to content

Commit ecfe2b0

Browse files
authored
Integrate LLVM at 3e223e3 (#19978)
Integrate LLVM at llvm/llvm-project@3e223e3a2 Clean, no local changes. The .bc file update is a MLIR bytecode test file that contains a `tosa.mul` op, which had a breaking change so had to be adjusted. A TFLite import test is disabled pending the longer term fix outlined in #19777 . --------- Signed-off-by: Benoit Jacob <[email protected]>
1 parent 78ec7f2 commit ecfe2b0

File tree

11 files changed

+34
-29
lines changed

11 files changed

+34
-29
lines changed

.github/workflows/pkgci_unit_test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,8 @@ jobs:
7777
run: |
7878
source ${VENV_DIR}/bin/activate
7979
bash ./build_tools/scripts/setup_tf_python.sh
80-
python compiler/bindings/python/test/tools/compiler_tflite_test.py
80+
# TODO: reenable. Temporarily disabled due to a breaking change in
81+
# tosa.mul. This can be reenabled after the TensorFlow tools are
82+
# rebuilt with a newer llvm-project with the new tosa.mul.
83+
# python compiler/bindings/python/test/tools/compiler_tflite_test.py
8184
python compiler/bindings/python/test/tools/compiler_tf_test.py
Binary file not shown.

compiler/plugins/input/TOSA/InputConversion/test/apply_pdl_patterns_tosa.mlir

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@
4141
// CHECK: tosa.negate %[[RESULT]]
4242

4343
func.func @mlp_invocation(%lhs: tensor<2x4xf32>, %rhs : tensor<4x8xf32>) -> tensor<2x8xf32> {
44-
%lhs_3D = tosa.reshape %lhs {new_shape = array<i64 : 1, 2, 4>} : (tensor<2x4xf32>) -> tensor<1x2x4xf32>
45-
%rhs_3D = tosa.reshape %rhs {new_shape = array<i64 : 1, 4, 8>} : (tensor<4x8xf32>) -> tensor<1x4x8xf32>
44+
%lhs_shape = tosa.const_shape {value = dense<[1, 2, 4]> : tensor<3xindex>} : () -> !tosa.shape<3>
45+
%rhs_shape = tosa.const_shape {value = dense<[1, 4, 8]> : tensor<3xindex>} : () -> !tosa.shape<3>
46+
%lhs_3D = tosa.reshape %lhs, %lhs_shape : (tensor<2x4xf32>, !tosa.shape<3>) -> tensor<1x2x4xf32>
47+
%rhs_3D = tosa.reshape %rhs, %rhs_shape : (tensor<4x8xf32>, !tosa.shape<3>) -> tensor<1x4x8xf32>
4648
%0 = tosa.matmul %lhs_3D, %rhs_3D : (tensor<1x2x4xf32>, tensor<1x4x8xf32>) -> tensor<1x2x8xf32>
4749
%1 = tosa.clamp %0 {
48-
min_int = 0 : i64, max_int = 9223372036854775807 : i64,
49-
min_fp = 0.0 : f32, max_fp = 3.4028235e+38 : f32}
50+
min_val = 0.0 : f32, max_val = 3.4028235e+38 : f32}
5051
: (tensor<1x2x8xf32>) -> tensor<1x2x8xf32>
5152
%2 = tosa.negate %1 : (tensor<1x2x8xf32>) -> tensor<1x2x8xf32>
52-
%3 = tosa.reshape %2 {new_shape = array<i64 : 2, 8>} : (tensor<1x2x8xf32>) -> tensor<2x8xf32>
53+
%result_shape = tosa.const_shape {value = dense<[2, 8]> : tensor<2xindex>} : () -> !tosa.shape<2>
54+
%3 = tosa.reshape %2, %result_shape : (tensor<1x2x8xf32>, !tosa.shape<2>) -> tensor<2x8xf32>
5355
return %3 : tensor<2x8xf32>
5456
}

compiler/plugins/input/TOSA/InputConversion/test/tosa.pdl.mlir

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ pdl.pattern @mlp : benefit(1) {
4949
%rhs_type = pdl.type
5050
%rhs = pdl.operand : %rhs_type
5151
%matmul_type = pdl.type
52-
%min_int = pdl.attribute = 0 : i64
53-
%max_int = pdl.attribute
5452
%min_fp = pdl.attribute = 0.0 : f32
5553
%max_fp = pdl.attribute
5654
%matmul = pdl.operation "tosa.matmul"(%lhs, %rhs : !pdl.value, !pdl.value)
@@ -63,8 +61,7 @@ pdl.pattern @mlp : benefit(1) {
6361
%matmul_result = pdl.result 0 of %matmul
6462
%relu_type = pdl.type
6563
%relu = pdl.operation "tosa.clamp"(%matmul_result : !pdl.value) {
66-
"min_int" = %min_int, "max_int" = %max_int,
67-
"min_fp" = %min_fp, "max_fp" = %max_fp}
64+
"min_val" = %min_fp, "max_val" = %max_fp}
6865
-> (%relu_type : !pdl.type)
6966

7067
pdl.rewrite %matmul {

samples/custom_dispatch/cpu/mlp_plugin/mlp_tosa.mlir

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
#x86_64_target = #hal.executable.target<"llvm-cpu", "embedded-elf-x86_64", {
3333
data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
3434
native_vector_size = 32 : index,
35-
target_triple = "x86_64-none-elf"
35+
target_triple = "x86_64-none-elf",
36+
cpu = "generic"
3637
}>
3738

3839
// The target devices that the program will run on. We can compile and run with
@@ -45,15 +46,17 @@
4546

4647
module @example attributes {hal.device.targets = [#cpu_target]} {
4748
func.func @mlp_invocation(%lhs: tensor<2x4xf32>, %rhs : tensor<4x8xf32>) -> tensor<2x8xf32> {
48-
%lhs_3D = tosa.reshape %lhs {new_shape = array<i64 : 1, 2, 4>} : (tensor<2x4xf32>) -> tensor<1x2x4xf32>
49-
%rhs_3D = tosa.reshape %rhs {new_shape = array<i64 : 1, 4, 8>} : (tensor<4x8xf32>) -> tensor<1x4x8xf32>
49+
%lhs_shape = tosa.const_shape {value = dense<[1, 2, 4]> : tensor<3xindex>} : () -> !tosa.shape<3>
50+
%rhs_shape = tosa.const_shape {value = dense<[1, 4, 8]> : tensor<3xindex>} : () -> !tosa.shape<3>
51+
%lhs_3D = tosa.reshape %lhs, %lhs_shape : (tensor<2x4xf32>, !tosa.shape<3>) -> tensor<1x2x4xf32>
52+
%rhs_3D = tosa.reshape %rhs, %rhs_shape : (tensor<4x8xf32>, !tosa.shape<3>) -> tensor<1x4x8xf32>
5053
%0 = tosa.matmul %lhs_3D, %rhs_3D : (tensor<1x2x4xf32>, tensor<1x4x8xf32>) -> tensor<1x2x8xf32>
5154
%1 = tosa.clamp %0 {
52-
min_int = 0 : i64, max_int = 9223372036854775807 : i64,
53-
min_fp = 0.0 : f32, max_fp = 3.4028235e+38 : f32}
55+
min_val = 0.0 : f32, max_val = 3.4028235e+38 : f32}
5456
: (tensor<1x2x8xf32>) -> tensor<1x2x8xf32>
5557
%2 = tosa.negate %1 : (tensor<1x2x8xf32>) -> tensor<1x2x8xf32>
56-
%3 = tosa.reshape %2 {new_shape = array<i64 : 2, 8>} : (tensor<1x2x8xf32>) -> tensor<2x8xf32>
58+
%result_shape = tosa.const_shape {value = dense<[2, 8]> : tensor<2xindex>} : () -> !tosa.shape<2>
59+
%3 = tosa.reshape %2, %result_shape : (tensor<1x2x8xf32>, !tosa.shape<2>) -> tensor<2x8xf32>
5760
return %3 : tensor<2x8xf32>
5861
}
5962
}

samples/custom_dispatch/cpu/mlp_plugin/mlp_tosa_spec.pdl.mlir

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ pdl.pattern @mlp : benefit(1) {
5050
%lhs = pdl.operand : %lhs_type
5151
%rhs = pdl.operand : %rhs_type
5252
%matmul_type = pdl.type
53-
%min_int = pdl.attribute = 0 : i64
54-
%max_int = pdl.attribute
5553
%min_fp = pdl.attribute = 0.0 : f32
5654
%max_fp = pdl.attribute
5755
%matmul = pdl.operation "tosa.matmul"(%lhs, %rhs : !pdl.value, !pdl.value)
@@ -63,8 +61,7 @@ pdl.pattern @mlp : benefit(1) {
6361
%matmul_result = pdl.result 0 of %matmul
6462
%relu_type = pdl.type
6563
%relu = pdl.operation "tosa.clamp"(%matmul_result : !pdl.value) {
66-
"min_int" = %min_int, "max_int" = %max_int,
67-
"min_fp" = %min_fp, "max_fp" = %max_fp}
64+
"min_val" = %min_fp, "max_val" = %max_fp}
6865
-> (%relu_type : !pdl.type)
6966

7067
pdl.rewrite %matmul {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Minimized from dynamic_tosa_quantized_fully_connected_issue_10859.mlir
22

33
func.func @clamp(%arg0: tensor<?xi8>) ->tensor<?xi8>{
4-
%1 = tosa.clamp %arg0 {max_fp = 0.000000e+00 : f32, max_int = 127 : i64, min_fp = 0.000000e+00 : f32, min_int = -128 : i64} : (tensor<?xi8>) -> tensor<?xi8>
4+
%1 = tosa.clamp %arg0 {max_val = 127 : i8, min_val = -128 : i8} : (tensor<?xi8>) -> tensor<?xi8>
55
return %1 : tensor<?xi8>
66
}

tests/e2e/regression/dynamic_tosa_quantized_fully_connected_issue_10859.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
func.func @main(%arg0: tensor<256xi8>, %arg1: tensor<2xi32>, %arg2: tensor<2x32xi8>, %arg3: tensor<32xi32>, %arg4: tensor<32x32xi8>, %arg5: tensor<32xi32>, %arg6: tensor<32x3360xi8>, %arg7: tensor<?x3360xi8>) -> (tensor<?x2xi8>) {
44
%0 = tosa.fully_connected %arg7, %arg6, %arg5 {input_zp = -128 : i32, weight_zp = 0 : i32} : (tensor<?x3360xi8>, tensor<32x3360xi8>, tensor<32xi32>) -> tensor<?x32xi32>
55
%1 = tosa.rescale %0 {double_round = true, input_zp = 0 : i32, multiplier = array<i32:1101627623>, output_zp = -128 : i32, per_channel = false, scale32 = true, shift = array<i8:36>} : (tensor<?x32xi32>) -> tensor<?x32xi8>
6-
%2 = tosa.clamp %1 {max_fp = 0.000000e+00 : f32, max_int = 127 : i64, min_fp = 0.000000e+00 : f32, min_int = -128 : i64} : (tensor<?x32xi8>) -> tensor<?x32xi8>
6+
%2 = tosa.clamp %1 {max_val = 127 : i8, min_val = -128 : i8} : (tensor<?x32xi8>) -> tensor<?x32xi8>
77
%3 = tosa.fully_connected %2, %arg4, %arg3 {input_zp = -128 : i32, weight_zp = 0 : i32} : (tensor<?x32xi8>, tensor<32x32xi8>, tensor<32xi32>) -> tensor<?x32xi32>
88
%4 = tosa.rescale %3 {double_round = true, input_zp = 0 : i32, multiplier = array<i32:1255393165>, output_zp = -128 : i32, per_channel = false, scale32 = true, shift = array<i8:35>} : (tensor<?x32xi32>) -> tensor<?x32xi8>
9-
%5 = tosa.clamp %4 {max_fp = 0.000000e+00 : f32, max_int = 127 : i64, min_fp = 0.000000e+00 : f32, min_int = -128 : i64} : (tensor<?x32xi8>) -> tensor<?x32xi8>
9+
%5 = tosa.clamp %4 {max_val = 127 : i8, min_val = -128 : i8} : (tensor<?x32xi8>) -> tensor<?x32xi8>
1010
%6 = tosa.fully_connected %5, %arg2, %arg1 {input_zp = -128 : i32, weight_zp = 0 : i32} : (tensor<?x32xi8>, tensor<2x32xi8>, tensor<2xi32>) -> tensor<?x2xi32>
1111
%7 = tosa.rescale %6 {double_round = true, input_zp = 0 : i32, multiplier = array<i32:1879992488>, output_zp = 44 : i32, per_channel = false, scale32 = true, shift = array<i8:39>} : (tensor<?x2xi32>) -> tensor<?x2xi8>
1212
%8 = tosa.table %7, %arg0 : (tensor<?x2xi8>, tensor<256xi8>) -> tensor<?x2xi8>

tests/e2e/tosa_ops/clamp.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
func.func @tensor_float() {
22
%0 = util.unfoldable_constant dense<[1.0, 0.0, 4.5, 2.0]> : tensor<4xf32>
3-
%result = tosa.clamp %0 {min_int = 1 : i64, max_int = 4 : i64, min_fp = 1.0 : f32, max_fp = 4.0 : f32} : (tensor<4xf32>) -> tensor<4xf32>
3+
%result = tosa.clamp %0 {min_val = 1.0 : f32, max_val = 4.0 : f32} : (tensor<4xf32>) -> tensor<4xf32>
44
check.expect_almost_eq_const(%result, dense<[1.0, 1.0, 4.0, 2.0]> : tensor<4xf32>) : tensor<4xf32>
55
return
66
}
77

88
func.func @tensor_int() {
99
%0 = util.unfoldable_constant dense<[1, 0, 5, 2]> : tensor<4xi32>
10-
%result = tosa.clamp %0 {min_int = 1 : i64, max_int = 4 : i64, min_fp = 1.0 : f32, max_fp = 4.0 : f32} : (tensor<4xi32>) -> tensor<4xi32>
10+
%result = tosa.clamp %0 {min_val = 1 : i32, max_val = 4 : i32} : (tensor<4xi32>) -> tensor<4xi32>
1111
check.expect_eq_const(%result, dense<[1, 1, 4, 2]> : tensor<4xi32>) : tensor<4xi32>
1212
return
1313
}

tests/e2e/tosa_ops/reshape.mlir

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
func.func @tensor_downrank() {
22
%0 = util.unfoldable_constant dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>
3-
%result = tosa.reshape %0 { new_shape = array<i64: 4> } : (tensor<2x2xi32>) -> tensor<4xi32>
3+
%1 = tosa.const_shape {value = dense<[4]> : tensor<1xindex>} : () -> !tosa.shape<1>
4+
%result = tosa.reshape %0, %1 : (tensor<2x2xi32>, !tosa.shape<1>) -> tensor<4xi32>
45
check.expect_eq_const(%result, dense<[1, 2, 3, 4]> : tensor<4xi32>) : tensor<4xi32>
56
return
67
}
78

89
func.func @tensor_uprank() {
910
%0 = util.unfoldable_constant dense<[1, 2, 3, 4]> : tensor<4xi32>
10-
%result = tosa.reshape %0 { new_shape = array<i64:2, 2> } : (tensor<4xi32>) -> tensor<2x2xi32>
11+
%1 = tosa.const_shape {value = dense<[2, 2]> : tensor<2xindex>} : () -> !tosa.shape<2>
12+
%result = tosa.reshape %0, %1 : (tensor<4xi32>, !tosa.shape<2>) -> tensor<2x2xi32>
1113
check.expect_eq_const(%result, dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>) : tensor<2x2xi32>
1214
return
1315
}
1416

1517
func.func @tensor_crossrank() {
1618
%0 = util.unfoldable_constant dense<[[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32>
17-
%result = tosa.reshape %0 { new_shape = array<i64:3, 2> } : (tensor<2x3xi32>) -> tensor<3x2xi32>
19+
%1 = tosa.const_shape {value = dense<[3, 2]> : tensor<2xindex>} : () -> !tosa.shape<2>
20+
%result = tosa.reshape %0, %1 : (tensor<2x3xi32>, !tosa.shape<2>) -> tensor<3x2xi32>
1821
check.expect_eq_const(%result, dense<[[1, 2], [3, 4], [5, 6]]> : tensor<3x2xi32>) : tensor<3x2xi32>
1922
return
2023
}

0 commit comments

Comments
 (0)