[MLIR][Standard] Add `assert` operation to the standard dialect
Differential Revision: https://reviews.llvm.org/D83117
This commit is contained in:
parent
dad1868772
commit
bcedc4fa0a
|
@ -379,7 +379,7 @@ def AllocaOp : AllocLikeOp<"alloca", AutomaticAllocationScopeResource> {
|
|||
operands. For example:
|
||||
|
||||
```mlir
|
||||
%0 = alloca() : memref<8x64xf32>
|
||||
%0 = alloca() : memref<8x64xf32>
|
||||
```
|
||||
|
||||
The optional list of dimension operands are bound to the dynamic dimensions
|
||||
|
@ -387,7 +387,7 @@ def AllocaOp : AllocLikeOp<"alloca", AutomaticAllocationScopeResource> {
|
|||
bound to the second dimension of the memref (which is dynamic).
|
||||
|
||||
```mlir
|
||||
%0 = alloca(%d) : memref<8x?xf32>
|
||||
%0 = alloca(%d) : memref<8x?xf32>
|
||||
```
|
||||
|
||||
The optional list of symbol operands are bound to the symbols of the
|
||||
|
@ -395,7 +395,7 @@ def AllocaOp : AllocLikeOp<"alloca", AutomaticAllocationScopeResource> {
|
|||
the symbol 's0' in the affine map specified in the allocs memref type.
|
||||
|
||||
```mlir
|
||||
%0 = alloca()[%s] : memref<8x64xf32,
|
||||
%0 = alloca()[%s] : memref<8x64xf32,
|
||||
affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>>
|
||||
```
|
||||
|
||||
|
@ -441,6 +441,34 @@ def AndOp : IntArithmeticOp<"and", [Commutative]> {
|
|||
let hasFolder = 1;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// AssertOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def AssertOp : Std_Op<"assert"> {
|
||||
let summary = "Assert operation with message attribute";
|
||||
let description = [{
|
||||
Assert operation with single boolean operand and an error message attribute.
|
||||
If the argument is `true` this operation has no effect.
|
||||
Otherwise, the program execution will abort.
|
||||
The provided error message may be used by a runtime to propagate the error
|
||||
to the user.
|
||||
|
||||
Example:
|
||||
|
||||
```mlir
|
||||
assert %b, "Expected ... to be true"
|
||||
```
|
||||
}];
|
||||
|
||||
let arguments = (ins I1:$arg, StrAttr:$msg);
|
||||
|
||||
let assemblyFormat = "$arg `,` $msg attr-dict";
|
||||
|
||||
// AssertOp is fully verified by its traits.
|
||||
let verifier = ?;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// AssumeAlignmentOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -18,3 +18,7 @@ func @test_index_cast_tensor_reverse(%arg0 : tensor<i64>) -> tensor<index> {
|
|||
return %0 : tensor<index>
|
||||
}
|
||||
|
||||
func @assert(%arg : i1) {
|
||||
assert %arg, "Some message in case this assertion fails."
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue