Skip to content

Commit db73052

Browse files
committed
Improve tests
1 parent 2e49cdf commit db73052

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
@@ -1913,6 +1913,125 @@ func.func @reduce_non_operation_name(%arg0: tensor<4xf32>, %arg1: tensor<f32>) -
19131913

19141914
// -----
19151915

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

19172036
//===----------------------------------------------------------------------===//
19182037
// Tests for generic infrastructure for named Ops. The actual Ops used are
@@ -1940,30 +2059,3 @@ func.func @matmul_invalid_mixed_types(%t: tensor<?xf16>, %f: vector<4xf16>)
19402059
func.return %0, %f : tensor<?xf16>, vector<4xf16>
19412060
}
19422061

1943-
// -----
1944-
1945-
func.func @pooling_nhwc_max_unsigned_non_integer_elem_type(
1946-
%input: tensor<1x4x4x1xf32>,
1947-
%filter: tensor<2x2xf32>,
1948-
%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32> {
1949-
// expected-error @+1 {{unsupported operation: unsigned max not on uint}}
1950-
%0 = linalg.pooling_nhwc_max_unsigned {dilations = dense<1> : tensor<2xi64>,
1951-
strides = dense<1> : tensor<2xi64>}
1952-
ins (%input, %filter: tensor<1x4x4x1xf32>, tensor<2x2xf32>)
1953-
outs (%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>
1954-
return %0 : tensor<1x2x2x1xf32>
1955-
}
1956-
1957-
// -----
1958-
1959-
func.func @pooling_nhwc_min_unsigned_non_integer_elem_type(
1960-
%input: tensor<1x4x4x1xf32>,
1961-
%filter: tensor<2x2xf32>,
1962-
%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32> {
1963-
// expected-error @+1 {{unsupported operation: unsigned min not on uint}}
1964-
%0 = linalg.pooling_nhwc_min_unsigned {dilations = dense<1> : tensor<2xi64>,
1965-
strides = dense<1> : tensor<2xi64>}
1966-
ins (%input, %filter: tensor<1x4x4x1xf32>, tensor<2x2xf32>)
1967-
outs (%init_val: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>
1968-
return %0 : tensor<1x2x2x1xf32>
1969-
}

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)