Skip to content

Commit 40037f4

Browse files
authored
Merge pull request #16 from Xilinx/tina.tosareciprocaloverunderflowtest
Add over-/underflow tests for reciprocal folding
2 parents 6b18842 + 63a7ed5 commit 40037f4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

mlir/test/Dialect/Tosa/constant-reciproc-opt.mlir

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ func.func @reciprocal_div_neg_infinity() -> tensor<f32> {
7373
return %1 : tensor<f32>
7474
}
7575

76+
// CHECK-LABEL: @reciprocal_div_underflow
77+
func.func @reciprocal_div_underflow() -> tensor<2xf16> {
78+
// CHECK: [[RES:]] ={{.*}}tosa.const{{.*}}-0.{{0*}}e+00, 0.{{0*}}e+00
79+
// CHECK-NOT: tosa.reciprocal
80+
// CHECK: return [[RES]]
81+
%0 = "tosa.const"() {value = dense<[-6.0e+15, 6.0e+15]> : tensor<2xf16>} : () -> tensor<2xf16>
82+
%1 = "tosa.reciprocal"(%0) : (tensor<2xf16>) -> tensor<2xf16>
83+
return %1 : tensor<2xf16>
84+
}
85+
86+
// CHECK-LABEL: @reciprocal_div_overflow
87+
func.func @reciprocal_div_overflow() -> tensor<2xf16> {
88+
// CHECK: [[RES:]] ={{.*}}tosa.const{{.*}}0x7C00, 0xFC00
89+
// CHECK-NOT: tosa.reciprocal
90+
// CHECK: return [[RES]]
91+
%0 = "tosa.const"() {value = dense<[0.0000001, -0.0000001]> : tensor<2xf16>} : () -> tensor<2xf16>
92+
%1 = "tosa.reciprocal"(%0) : (tensor<2xf16>) -> tensor<2xf16>
93+
return %1 : tensor<2xf16>
94+
}
95+
7696
// CHECK-LABEL: @reciprocal_no_fold
7797
// The folding optimization works only intra-procedurally, so we won't be able
7898
// to fold anything here

0 commit comments

Comments
 (0)