blob: 0c6aca5e6a5d7943efbb6e5a6939d348e8245ca8 [file] [log] [blame]
River Riddle36550692022-03-08 03:16:031// RUN: mlir-opt -pass-pipeline="func.func(convert-shape-constraints)" <%s | FileCheck %s
Sean Silva9ed1e5872020-09-18 20:55:522
3// There's not very much useful to check here other than pasting the output.
4// CHECK-LABEL: func @cstr_broadcastable(
5// CHECK-SAME: %[[LHS:.*]]: tensor<?xindex>,
6// CHECK-SAME: %[[RHS:.*]]: tensor<?xindex>) -> !shape.witness {
Sean Silva9ed1e5872020-09-18 20:55:527// CHECK: %[[RET:.*]] = shape.const_witness true
Tres Popp3842d4b2021-02-10 09:24:328// CHECK: %[[BROADCAST_IS_VALID:.*]] = shape.is_broadcastable %[[LHS]], %[[RHS]]
River Riddleace01602022-02-04 04:59:439// CHECK: cf.assert %[[BROADCAST_IS_VALID]], "required broadcastable shapes"
Sean Silva9ed1e5872020-09-18 20:55:5210// CHECK: return %[[RET]] : !shape.witness
11// CHECK: }
River Riddle3028bf72022-04-20 23:12:2512func.func @cstr_broadcastable(%arg0: tensor<?xindex>, %arg1: tensor<?xindex>) -> !shape.witness {
Sean Silva9ed1e5872020-09-18 20:55:5213 %witness = shape.cstr_broadcastable %arg0, %arg1 : tensor<?xindex>, tensor<?xindex>
14 return %witness : !shape.witness
15}
16
Benjamin Kramer73cb58d2021-03-01 19:41:1217// CHECK-LABEL: func @cstr_eq(
18// CHECK-SAME: %[[LHS:.*]]: tensor<?xindex>,
19// CHECK-SAME: %[[RHS:.*]]: tensor<?xindex>) -> !shape.witness {
20// CHECK: %[[RET:.*]] = shape.const_witness true
21// CHECK: %[[EQUAL_IS_VALID:.*]] = shape.shape_eq %[[LHS]], %[[RHS]]
River Riddleace01602022-02-04 04:59:4322// CHECK: cf.assert %[[EQUAL_IS_VALID]], "required equal shapes"
Benjamin Kramer73cb58d2021-03-01 19:41:1223// CHECK: return %[[RET]] : !shape.witness
24// CHECK: }
River Riddle3028bf72022-04-20 23:12:2525func.func @cstr_eq(%arg0: tensor<?xindex>, %arg1: tensor<?xindex>) -> !shape.witness {
Benjamin Kramer73cb58d2021-03-01 19:41:1226 %witness = shape.cstr_eq %arg0, %arg1 : tensor<?xindex>, tensor<?xindex>
27 return %witness : !shape.witness
28}
29
Sean Silva9ed1e5872020-09-18 20:55:5230// CHECK-LABEL: func @cstr_require
River Riddle3028bf72022-04-20 23:12:2531func.func @cstr_require(%arg0: i1) -> !shape.witness {
Sean Silva9ed1e5872020-09-18 20:55:5232 // CHECK: %[[RET:.*]] = shape.const_witness true
River Riddleace01602022-02-04 04:59:4333 // CHECK: cf.assert %arg0, "msg"
Sean Silva9ed1e5872020-09-18 20:55:5234 // CHECK: return %[[RET]]
35 %witness = shape.cstr_require %arg0, "msg"
36 return %witness : !shape.witness
37}