'check' Dialectlink
A dialect implementing test assertions for IREE modules.
- 'check' Dialect
- Operations
- check.expect_all_true (Check::ExpectAllTrueOp)
- check.expect_almost_eq (Check::ExpectAlmostEqOp)
- check.expect_almost_eq_const (Check::ExpectAlmostEqConstOp)
- check.expect_eq (Check::ExpectEqOp)
- check.expect_eq_const (Check::ExpectEqConstOp)
- check.expect_false (Check::ExpectFalseOp)
- check.expect_true (Check::ExpectTrueOp)
- Operations
Operationslink
check.expect_all_true
(Check::ExpectAllTrueOp)link
Checks that the operand contains only values that are true
Syntax:
operation ::= `check.expect_all_true` (`` `<` $device^ `>`)?
`` `(` $operand `)` attr-dict `:` type($operand)
Verifies that the operand contains true values, which are represented by any non-zero integer.
Issues a non-fatal failure if the verification fails.
check.expect_all_true<%device>(%arg0) : !hal.buffer_view
check.expect_all_true(%arg1) : tensor<2x2xi32>
Operands:link
Operand | Description |
---|---|
device |
device |
operand |
buffer_view or tensor of signless integer values |
check.expect_almost_eq
(Check::ExpectAlmostEqOp)link
Checks that the operands are almost equal
Syntax:
operation ::= `check.expect_almost_eq` (`` `<` $device^ `>`)?
`` `(` $lhs `,` $rhs (`` `,` `atol` $atol^)? (`` `,` `rtol` $rtol^)? `)`
attr-dict `:` type($lhs)
Verifies that the buffer view or tensor operands with float elements satisfy
the Numpy-style fuzzy-comparision condition with parameters atol
,
rtol
, defined exactly as in NumPy isclose():
https://github.com/numpy/numpy/blob/7297f3117d84745bfade1e2f9aec3531e5917500/numpy/_core/numeric.py#L2447-L2449
The condition being verified on each lhs and rhs value is:
lhs == rhs || (isfinite(rhs) && abs(lhs - rhs) <= atol + rtol * abs(rhs)).
Note that the lhs == rhs
part is needed for the case (lhs=+inf, rhs+inf)
to return true. Indeed, in that case, lhs-rhs is NaN.
Issues a non-fatal failure if the verification fails.
The atol
, rtol
parameters may be omitted, in which case some default
value is used. The default atol
is nonzero, while the default rtol
is
zero, which makes these comparision behave closer to exact comparisons as
the values being compared get large.
This default behavior is supported for legacy compatibility and to support
some use cases that legitimately don't care, but the majority of use cases
should care and so should provide explicit atol
, rtol
values.
check.expect_almost_eq(%arg0, %arg1, atol 1.0e-2, rtol 1.0e-3) : tensor<5xf32>
Attributes:link
Attribute | MLIR Type | Description |
---|---|---|
atol | ::mlir::FloatAttr | 32-bit float attribute |
rtol | ::mlir::FloatAttr | 32-bit float attribute |
Operands:link
Operand | Description |
---|---|
device |
device |
lhs |
buffer_view or tensor of floating-point values |
rhs |
buffer_view or tensor of floating-point values |
check.expect_almost_eq_const
(Check::ExpectAlmostEqConstOp)link
Checks that the tensor operand is almost equal to some constant
Syntax:
operation ::= `check.expect_almost_eq_const` (`` `<` $device^ `>`)?
`` `(` $lhs `,` $value (`` `,` `atol` $atol^)? (`` `,` `rtol` $rtol^)? `)`
attr-dict `:` type($lhs)
This op is just a convenience wrapper around the expect_almost_eq op.
Verifies that the buffer view or tensor operands with float elements satisfy
the Numpy-style fuzzy-comparision condition with pararameters atol
,
rtol
. More details in the description of expect_almost_eq
.
Issues a non-fatal failure if the verification fails.
check.expect_almost_eq_const(%const0, dense<[0.999999, 2.0]> : tensor<5xf32>, atol 1.0e-2, rtol 1.0e-3) : tensor<5xf32>
Attributes:link
Attribute | MLIR Type | Description |
---|---|---|
value | ::mlir::ElementsAttr | constant vector/tensor attribute |
atol | ::mlir::FloatAttr | 32-bit float attribute |
rtol | ::mlir::FloatAttr | 32-bit float attribute |
Operands:link
Operand | Description |
---|---|
device |
device |
lhs |
tensor of floating-point values |
check.expect_eq
(Check::ExpectEqOp)link
Checks that the tensor or buffer view operands are equal
Syntax:
operation ::= `check.expect_eq` (`` `<` $device^ `>`)?
`` `(` $lhs `,` $rhs `)` attr-dict `:` type($lhs)
Verifies that the operands are exactly equal.
Issues a non-fatal failure if the verification fails.
check.expect_eq(%arg0, %arg1) : tensor<5xi32>
Operands:link
Operand | Description |
---|---|
device |
device |
lhs |
buffer_view or tensor of any type values |
rhs |
buffer_view or tensor of any type values |
check.expect_eq_const
(Check::ExpectEqConstOp)link
Checks that the tensor operand is equal to some constant
Syntax:
operation ::= `check.expect_eq_const` (`` `<` $device^ `>`)?
`` `(` $lhs `,` $value `)` attr-dict `:` type($lhs)
Verifies that the tensor operand is exactly equal to a constant attribute.
Issues a non-fatal failure if the verification fails.
This op is just a convenience wrapper around the expect_eq op.
check.expect_eq_const(%arg0, dense<[1, 2]> : tensor<2xi32>) : tensor<2xi32>
Attributes:link
Attribute | MLIR Type | Description |
---|---|---|
value | ::mlir::ElementsAttr | constant vector/tensor attribute |
Operands:link
Operand | Description |
---|---|
device |
device |
lhs |
tensor of any type values |
check.expect_false
(Check::ExpectFalseOp)link
Checks that the operand is false
Syntax:
operation ::= `check.expect_false` `(` $operand `)` attr-dict `:` type($operand)
Verifies that the operand contains a false value, which is represented by zero.
Issues a non-fatal failure if the verification fails.
check.expect_false(%arg0) : i32
Operands:link
Operand | Description |
---|---|
operand |
signless integer |
check.expect_true
(Check::ExpectTrueOp)link
Checks that the operand is true
Syntax:
operation ::= `check.expect_true` `(` $operand `)` attr-dict `:` type($operand)
Verifies that the operand contains a true value, which is represented by any non-zero integer.
Issues a non-fatal failure if the verification fails.
check.expect_true(%arg0) : i32
Operands:link
Operand | Description |
---|---|
operand |
signless integer |