River Riddle | 3655069 | 2022-03-08 03:16:03 | [diff] [blame] | 1 | // RUN: mlir-opt -pass-pipeline="func.func(convert-shape-constraints)" <%s | FileCheck %s |
Sean Silva | 9ed1e587 | 2020-09-18 20:55:52 | [diff] [blame] | 2 | |
| 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 Silva | 9ed1e587 | 2020-09-18 20:55:52 | [diff] [blame] | 7 | // CHECK: %[[RET:.*]] = shape.const_witness true |
Tres Popp | 3842d4b | 2021-02-10 09:24:32 | [diff] [blame] | 8 | // CHECK: %[[BROADCAST_IS_VALID:.*]] = shape.is_broadcastable %[[LHS]], %[[RHS]] |
River Riddle | ace0160 | 2022-02-04 04:59:43 | [diff] [blame] | 9 | // CHECK: cf.assert %[[BROADCAST_IS_VALID]], "required broadcastable shapes" |
Sean Silva | 9ed1e587 | 2020-09-18 20:55:52 | [diff] [blame] | 10 | // CHECK: return %[[RET]] : !shape.witness |
| 11 | // CHECK: } |
River Riddle | 3028bf7 | 2022-04-20 23:12:25 | [diff] [blame] | 12 | func.func @cstr_broadcastable(%arg0: tensor<?xindex>, %arg1: tensor<?xindex>) -> !shape.witness { |
Sean Silva | 9ed1e587 | 2020-09-18 20:55:52 | [diff] [blame] | 13 | %witness = shape.cstr_broadcastable %arg0, %arg1 : tensor<?xindex>, tensor<?xindex> |
| 14 | return %witness : !shape.witness |
| 15 | } |
| 16 | |
Benjamin Kramer | 73cb58d | 2021-03-01 19:41:12 | [diff] [blame] | 17 | // 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 Riddle | ace0160 | 2022-02-04 04:59:43 | [diff] [blame] | 22 | // CHECK: cf.assert %[[EQUAL_IS_VALID]], "required equal shapes" |
Benjamin Kramer | 73cb58d | 2021-03-01 19:41:12 | [diff] [blame] | 23 | // CHECK: return %[[RET]] : !shape.witness |
| 24 | // CHECK: } |
River Riddle | 3028bf7 | 2022-04-20 23:12:25 | [diff] [blame] | 25 | func.func @cstr_eq(%arg0: tensor<?xindex>, %arg1: tensor<?xindex>) -> !shape.witness { |
Benjamin Kramer | 73cb58d | 2021-03-01 19:41:12 | [diff] [blame] | 26 | %witness = shape.cstr_eq %arg0, %arg1 : tensor<?xindex>, tensor<?xindex> |
| 27 | return %witness : !shape.witness |
| 28 | } |
| 29 | |
Sean Silva | 9ed1e587 | 2020-09-18 20:55:52 | [diff] [blame] | 30 | // CHECK-LABEL: func @cstr_require |
River Riddle | 3028bf7 | 2022-04-20 23:12:25 | [diff] [blame] | 31 | func.func @cstr_require(%arg0: i1) -> !shape.witness { |
Sean Silva | 9ed1e587 | 2020-09-18 20:55:52 | [diff] [blame] | 32 | // CHECK: %[[RET:.*]] = shape.const_witness true |
River Riddle | ace0160 | 2022-02-04 04:59:43 | [diff] [blame] | 33 | // CHECK: cf.assert %arg0, "msg" |
Sean Silva | 9ed1e587 | 2020-09-18 20:55:52 | [diff] [blame] | 34 | // CHECK: return %[[RET]] |
| 35 | %witness = shape.cstr_require %arg0, "msg" |
| 36 | return %witness : !shape.witness |
| 37 | } |