This commit moves FuncOp out of the builtin dialect, and into the Func dialect. This move has been planned in some capacity from the moment we made FuncOp an operation (years ago). This commit handles the functional aspects of the move, but various aspects are left untouched to ease migration: func::FuncOp is re-exported into mlir to reduce the actual API churn, the assembly format still accepts the unqualified `func`. These temporary measures will remain for a little while to simplify migration before being removed. Differential Revision: https://reviews.llvm.org/D121266
38 lines
1.8 KiB
MLIR
38 lines
1.8 KiB
MLIR
// RUN: mlir-opt -pass-pipeline="func.func(convert-shape-constraints)" <%s | FileCheck %s
|
|
|
|
// There's not very much useful to check here other than pasting the output.
|
|
// CHECK-LABEL: func @cstr_broadcastable(
|
|
// CHECK-SAME: %[[LHS:.*]]: tensor<?xindex>,
|
|
// CHECK-SAME: %[[RHS:.*]]: tensor<?xindex>) -> !shape.witness {
|
|
// CHECK: %[[RET:.*]] = shape.const_witness true
|
|
// CHECK: %[[BROADCAST_IS_VALID:.*]] = shape.is_broadcastable %[[LHS]], %[[RHS]]
|
|
// CHECK: cf.assert %[[BROADCAST_IS_VALID]], "required broadcastable shapes"
|
|
// CHECK: return %[[RET]] : !shape.witness
|
|
// CHECK: }
|
|
func @cstr_broadcastable(%arg0: tensor<?xindex>, %arg1: tensor<?xindex>) -> !shape.witness {
|
|
%witness = shape.cstr_broadcastable %arg0, %arg1 : tensor<?xindex>, tensor<?xindex>
|
|
return %witness : !shape.witness
|
|
}
|
|
|
|
// CHECK-LABEL: func @cstr_eq(
|
|
// CHECK-SAME: %[[LHS:.*]]: tensor<?xindex>,
|
|
// CHECK-SAME: %[[RHS:.*]]: tensor<?xindex>) -> !shape.witness {
|
|
// CHECK: %[[RET:.*]] = shape.const_witness true
|
|
// CHECK: %[[EQUAL_IS_VALID:.*]] = shape.shape_eq %[[LHS]], %[[RHS]]
|
|
// CHECK: cf.assert %[[EQUAL_IS_VALID]], "required equal shapes"
|
|
// CHECK: return %[[RET]] : !shape.witness
|
|
// CHECK: }
|
|
func @cstr_eq(%arg0: tensor<?xindex>, %arg1: tensor<?xindex>) -> !shape.witness {
|
|
%witness = shape.cstr_eq %arg0, %arg1 : tensor<?xindex>, tensor<?xindex>
|
|
return %witness : !shape.witness
|
|
}
|
|
|
|
// CHECK-LABEL: func @cstr_require
|
|
func @cstr_require(%arg0: i1) -> !shape.witness {
|
|
// CHECK: %[[RET:.*]] = shape.const_witness true
|
|
// CHECK: cf.assert %arg0, "msg"
|
|
// CHECK: return %[[RET]]
|
|
%witness = shape.cstr_require %arg0, "msg"
|
|
return %witness : !shape.witness
|
|
}
|