Skip to content

Commit 2fa6c64

Browse files
committed
Improve tests
1 parent 3833091 commit 2fa6c64

File tree

2 files changed

+161
-31
lines changed

2 files changed

+161
-31
lines changed

mlir/test/Dialect/Linalg/invalid.mlir

Lines changed: 119 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,125 @@ func.func @reduce_non_operation_name(%arg0: tensor<4xf32>, %arg1: tensor<f32>) -
19311931

19321932
// -----
19331933

1934+
//===----------------------------------------------------------------------===//
1935+
// linalg.pooling_nhwc_*
1936+
//===----------------------------------------------------------------------===//
1937+
1938+
func.func @pooling_nhwc_max_unsigned_float_type(
1939+
%input: tensor<1x4x4x1xf32>,
1940+
%filter: tensor<2x2xf32>,
1941+
%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32> {
1942+
// expected-error @+1 {{unsupported operation: unsigned max not on uint}}
1943+
%0 = linalg.pooling_nhwc_max_unsigned {dilations = dense<1> : tensor<2xi64>,
1944+
strides = dense<1> : tensor<2xi64>}
1945+
ins (%input, %filter: tensor<1x4x4x1xf32>, tensor<2x2xf32>)
1946+
outs (%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>
1947+
return %0 : tensor<1x2x2x1xf32>
1948+
}
1949+
1950+
// -----
1951+
1952+
func.func @pooling_nhwc_max_unsigned_i1(
1953+
%input: tensor<1x4x4x1xi1>,
1954+
%filter: tensor<2x2xi1>,
1955+
%init_val: tensor<1x2x2x1xi1>) -> tensor<1x2x2x1xi1> {
1956+
// expected-error @+1 {{unsupported operation: unsigned max not on uint}}
1957+
%0 = linalg.pooling_nhwc_max_unsigned {dilations = dense<1> : tensor<2xi64>,
1958+
strides = dense<1> : tensor<2xi64>}
1959+
ins (%input, %filter: tensor<1x4x4x1xi1>, tensor<2x2xi1>)
1960+
outs (%init_val: tensor<1x2x2x1xi1>) -> tensor<1x2x2x1xi1>
1961+
return %0 : tensor<1x2x2x1xi1>
1962+
}
1963+
1964+
// -----
1965+
1966+
func.func @pooling_nhwc_min_unsigned_float_type(
1967+
%input: tensor<1x4x4x1xf32>,
1968+
%filter: tensor<2x2xf32>,
1969+
%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32> {
1970+
// expected-error @+1 {{unsupported operation: unsigned min not on uint}}
1971+
%0 = linalg.pooling_nhwc_min_unsigned {dilations = dense<1> : tensor<2xi64>,
1972+
strides = dense<1> : tensor<2xi64>}
1973+
ins (%input, %filter: tensor<1x4x4x1xf32>, tensor<2x2xf32>)
1974+
outs (%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>
1975+
return %0 : tensor<1x2x2x1xf32>
1976+
}
1977+
1978+
// -----
1979+
1980+
func.func @pooling_nhwc_min_unsigned_i1(
1981+
%input: tensor<1x4x4x1xi1>,
1982+
%filter: tensor<2x2xi1>,
1983+
%init_val: tensor<1x2x2x1xi1>) -> tensor<1x2x2x1xi1> {
1984+
// expected-error @+1 {{unsupported operation: unsigned min not on uint}}
1985+
%0 = linalg.pooling_nhwc_min_unsigned {dilations = dense<1> : tensor<2xi64>,
1986+
strides = dense<1> : tensor<2xi64>}
1987+
ins (%input, %filter: tensor<1x4x4x1xi1>, tensor<2x2xi1>)
1988+
outs (%init_val: tensor<1x2x2x1xi1>) -> tensor<1x2x2x1xi1>
1989+
return %0 : tensor<1x2x2x1xi1>
1990+
}
1991+
1992+
// -----
1993+
1994+
//===----------------------------------------------------------------------===//
1995+
// linalg.pooling_nwc_*
1996+
//===----------------------------------------------------------------------===//
1997+
1998+
func.func @pooling_nwc_max_unsigned_float_type(
1999+
%input: tensor<1x4x1xf32>,
2000+
%filter: tensor<2xf32>,
2001+
%init_val: tensor<1x2x1xf32>) -> tensor<1x2x1xf32> {
2002+
// expected-error @+1 {{unsupported operation: unsigned max not on uint}}
2003+
%0 = linalg.pooling_nwc_max_unsigned {dilations = dense<1> : tensor<1xi64>,
2004+
strides = dense<1> : tensor<1xi64>}
2005+
ins (%input, %filter: tensor<1x4x1xf32>, tensor<2xf32>)
2006+
outs (%init_val: tensor<1x2x1xf32>) -> tensor<1x2x1xf32>
2007+
return %0 : tensor<1x2x1xf32>
2008+
}
2009+
2010+
// -----
2011+
2012+
func.func @pooling_nwc_max_unsigned_i1(
2013+
%input: tensor<1x4x1xi1>,
2014+
%filter: tensor<2xi1>,
2015+
%init_val: tensor<1x2x1xi1>) -> tensor<1x2x1xi1> {
2016+
// expected-error @+1 {{unsupported operation: unsigned max not on uint}}
2017+
%0 = linalg.pooling_nwc_max_unsigned {dilations = dense<1> : tensor<1xi64>,
2018+
strides = dense<1> : tensor<1xi64>}
2019+
ins (%input, %filter: tensor<1x4x1xi1>, tensor<2xi1>)
2020+
outs (%init_val: tensor<1x2x1xi1>) -> tensor<1x2x1xi1>
2021+
return %0 : tensor<1x2x1xi1>
2022+
}
2023+
2024+
// -----
2025+
2026+
func.func @pooling_nwc_min_unsigned_float_type(
2027+
%input: tensor<1x4x1xf32>,
2028+
%filter: tensor<2xf32>,
2029+
%init_val: tensor<1x2x1xf32>) -> tensor<1x2x1xf32> {
2030+
// expected-error @+1 {{unsupported operation: unsigned min not on uint}}
2031+
%0 = linalg.pooling_nwc_min_unsigned {dilations = dense<1> : tensor<1xi64>,
2032+
strides = dense<1> : tensor<1xi64>}
2033+
ins (%input, %filter: tensor<1x4x1xf32>, tensor<2xf32>)
2034+
outs (%init_val: tensor<1x2x1xf32>) -> tensor<1x2x1xf32>
2035+
return %0 : tensor<1x2x1xf32>
2036+
}
2037+
2038+
// -----
2039+
2040+
func.func @pooling_nwc_min_unsigned_i1(
2041+
%input: tensor<1x4x1xi1>,
2042+
%filter: tensor<2xi1>,
2043+
%init_val: tensor<1x2x1xi1>) -> tensor<1x2x1xi1> {
2044+
// expected-error @+1 {{unsupported operation: unsigned min not on uint}}
2045+
%0 = linalg.pooling_nwc_min_unsigned {dilations = dense<1> : tensor<1xi64>,
2046+
strides = dense<1> : tensor<1xi64>}
2047+
ins (%input, %filter: tensor<1x4x1xi1>, tensor<2xi1>)
2048+
outs (%init_val: tensor<1x2x1xi1>) -> tensor<1x2x1xi1>
2049+
return %0 : tensor<1x2x1xi1>
2050+
}
2051+
2052+
// -----
19342053

19352054
//===----------------------------------------------------------------------===//
19362055
// Tests for generic infrastructure for named Ops. The actual Ops used are
@@ -1958,30 +2077,3 @@ func.func @matmul_invalid_mixed_types(%t: tensor<?xf16>, %f: vector<4xf16>)
19582077
func.return %0, %f : tensor<?xf16>, vector<4xf16>
19592078
}
19602079

1961-
// -----
1962-
1963-
func.func @pooling_nhwc_max_unsigned_non_integer_elem_type(
1964-
%input: tensor<1x4x4x1xf32>,
1965-
%filter: tensor<2x2xf32>,
1966-
%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32> {
1967-
// expected-error @+1 {{unsupported operation: unsigned max not on uint}}
1968-
%0 = linalg.pooling_nhwc_max_unsigned {dilations = dense<1> : tensor<2xi64>,
1969-
strides = dense<1> : tensor<2xi64>}
1970-
ins (%input, %filter: tensor<1x4x4x1xf32>, tensor<2x2xf32>)
1971-
outs (%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>
1972-
return %0 : tensor<1x2x2x1xf32>
1973-
}
1974-
1975-
// -----
1976-
1977-
func.func @pooling_nhwc_min_unsigned_non_integer_elem_type(
1978-
%input: tensor<1x4x4x1xf32>,
1979-
%filter: tensor<2x2xf32>,
1980-
%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32> {
1981-
// expected-error @+1 {{unsupported operation: unsigned min not on uint}}
1982-
%0 = linalg.pooling_nhwc_min_unsigned {dilations = dense<1> : tensor<2xi64>,
1983-
strides = dense<1> : tensor<2xi64>}
1984-
ins (%input, %filter: tensor<1x4x4x1xf32>, tensor<2x2xf32>)
1985-
outs (%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>
1986-
return %0 : tensor<1x2x2x1xf32>
1987-
}

mlir/test/Dialect/Linalg/named-ops.mlir

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,11 @@ func.func @pooling_nhwc_max_tensor(%input: tensor<1x4x4x1xf32>) -> tensor<1x2x2x
707707

708708
// -----
709709

710-
// CHECK-LABEL: func @pooling_nhwc_max_unsigned_tensor
710+
// CHECK-LABEL: func @pooling_nhwc_max_unsigned_i32
711711
// CHECK: %{{.+}} = linalg.pooling_nhwc_max_unsigned
712712
// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x1xi32>, tensor<3x3xi32>)
713713
// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x1xi32>) -> tensor<1x2x2x1xi32>
714-
func.func @pooling_nhwc_max_unsigned_tensor(%input: tensor<1x4x4x1xi32>) -> tensor<1x2x2x1xi32> {
714+
func.func @pooling_nhwc_max_unsigned_i32(%input: tensor<1x4x4x1xi32>) -> tensor<1x2x2x1xi32> {
715715
%fake = tensor.empty() : tensor<3x3xi32>
716716
%init = tensor.empty() : tensor<1x2x2x1xi32>
717717
%cst = arith.constant 0 : i32
@@ -722,6 +722,25 @@ func.func @pooling_nhwc_max_unsigned_tensor(%input: tensor<1x4x4x1xi32>) -> tens
722722
return %res : tensor<1x2x2x1xi32>
723723
}
724724

725+
// -----
726+
727+
// CHECK-LABEL: func @pooling_nwc_max_unsigned_i32
728+
// CHECK: %{{.+}} = linalg.pooling_nwc_max_unsigned
729+
// CHECK-SAME: dilations = dense<1> : tensor<1xi64>
730+
// CHECK-SAME: strides = dense<1> : tensor<1xi64>
731+
// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x1xi32>, tensor<3xi32>)
732+
// CHECK-SAME: outs(%{{.+}} : tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
733+
func.func @pooling_nwc_max_unsigned_i32(%input: tensor<1x4x1xi32>) -> tensor<1x2x1xi32> {
734+
%fake = tensor.empty() : tensor<3xi32>
735+
%init = tensor.empty() : tensor<1x2x1xi32>
736+
%cst = arith.constant 0 : i32
737+
%fill = linalg.fill ins(%cst : i32) outs(%init : tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
738+
%res = linalg.pooling_nwc_max_unsigned {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}
739+
ins(%input, %fake: tensor<1x4x1xi32>, tensor<3xi32>)
740+
outs(%fill: tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
741+
return %res : tensor<1x2x1xi32>
742+
}
743+
725744
// -----
726745
// CHECK-LABEL: func @pooling_nwc_max_tensor
727746
// CHECK: %{{.+}} = linalg.pooling_nwc_max
@@ -1034,11 +1053,11 @@ func.func @pooling_nhwc_min_tensor(%input: tensor<1x4x4x1xf32>) -> tensor<1x2x2x
10341053

10351054
// -----
10361055

1037-
// CHECK-LABEL: func @pooling_nhwc_min_unsigned_tensor
1056+
// CHECK-LABEL: func @pooling_nhwc_min_unsigned_i32
10381057
// CHECK: %{{.+}} = linalg.pooling_nhwc_min_unsigned
10391058
// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x1xi32>, tensor<3x3xi32>)
10401059
// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x1xi32>) -> tensor<1x2x2x1xi32>
1041-
func.func @pooling_nhwc_min_unsigned_tensor(%input: tensor<1x4x4x1xi32>) -> tensor<1x2x2x1xi32> {
1060+
func.func @pooling_nhwc_min_unsigned_i32(%input: tensor<1x4x4x1xi32>) -> tensor<1x2x2x1xi32> {
10421061
%fake = tensor.empty() : tensor<3x3xi32>
10431062
%init = tensor.empty() : tensor<1x2x2x1xi32>
10441063
%cst = arith.constant 0 : i32
@@ -1051,6 +1070,25 @@ func.func @pooling_nhwc_min_unsigned_tensor(%input: tensor<1x4x4x1xi32>) -> tens
10511070

10521071
// -----
10531072

1073+
// CHECK-LABEL: func @pooling_nwc_min_unsigned_i32
1074+
// CHECK: %{{.+}} = linalg.pooling_nwc_min_unsigned
1075+
// CHECK-SAME: dilations = dense<1> : tensor<1xi64>
1076+
// CHECK-SAME: strides = dense<1> : tensor<1xi64>
1077+
// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x1xi32>, tensor<3xi32>)
1078+
// CHECK-SAME: outs(%{{.+}} : tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
1079+
func.func @pooling_nwc_min_unsigned_i32(%input: tensor<1x4x1xi32>) -> tensor<1x2x1xi32> {
1080+
%fake = tensor.empty() : tensor<3xi32>
1081+
%init = tensor.empty() : tensor<1x2x1xi32>
1082+
%cst = arith.constant 0 : i32
1083+
%fill = linalg.fill ins(%cst : i32) outs(%init : tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
1084+
%res = linalg.pooling_nwc_min_unsigned {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}
1085+
ins(%input, %fake: tensor<1x4x1xi32>, tensor<3xi32>)
1086+
outs(%fill: tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
1087+
return %res : tensor<1x2x1xi32>
1088+
}
1089+
1090+
// -----
1091+
10541092
// CHECK-LABEL: func @pooling_nwc_min_tensor
10551093
// CHECK: %{{.+}} = linalg.pooling_nwc_min
10561094
// CHECK-SAME: dilations = dense<1> : tensor<1xi64>

0 commit comments

Comments
 (0)