[Mlir-commits] [mlir] [mlir][arith] Add more canonicalization and integration tests coverage (PR #92272)
Andrzej Warzyński
llvmlistbot at llvm.org
Fri Jun 28 06:46:12 PDT 2024
banach-space wrote:
> Sorry for dropping the ball on this one last few weeks!
Not at all - life gets busy 😅 Thanks for getting back to this!
> I don't understand what this means fully - would you be able to give an example to clarify a bit further?
Sure. I was trying to suggest a strategy for selecting edge cases to test. Once a strategy is in place, it is easy to be consistent. And consistency makes things easy to review and maintain.
As a specific example, for `arith.addi`, I would test 2 edge cases:
1. "Normal values" (e.g. `10 + 20`) - this should "just work" ™️ (technically speaking, this would be more like a sanity check rather than an edge case)
2. Values that would lead to overflows (e.g. `INT_MAX + 1`, `INT_MIN - 1`)
This could be tested as follows (pseudo MLIR):
```mlir
func.func @add_i32(%arg_0: i32, %arg_1: i32) -> i32 {
%res = arith.addi %arg_0 : i32, i32
return %res : i32
}
%res_i32_30 = func.call @add_i32(10, 20)
// CHECK: 30
vector.print %res_i32_30
%res_i32_min = func.call @add_i32(INT_MAX, 1)
// CHECK: -2147483648
vector.print %res_i32_min
```
If you were to test FP operations, I'd add another edge case:
3. Operations on `nan` and `inf` values.
Now, I am not asking you to cover all cases. However, please try to make it easy to:
* identify what edge cases are currently tested (through descriptive function and variable names)
* extend your tests with more edge cases (by e.g. making things re-usable).
https://github.com/llvm/llvm-project/pull/92272
More information about the Mlir-commits
mailing list