Skip to content

Fix: Add tests checked that no casts are present #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions mlir/test/Dialect/Tosa/constant-add-opt.mlir
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// RUN: mlir-opt --split-input-file -verify-diagnostics --tosa-layerwise-constant-fold %s | FileCheck %s

// -----
// Float additions

// CHECK-LABEL: @add_fold_float
func.func @add_fold_float() -> tensor<4xf16> {
// CHECK: [[RES:]] ={{.*}}tosa.const{{.*}}-1.5{{.*}}e+02, 1.9{{.*}}e+00, 0.{{0*}}e+00, 5.{{0*}}e+00
// CHECK-NOT: tosa.cast
// CHECK-NOT: tosa.add
// CHECK: return [[RES]]
%0 = "tosa.const"() {value =
dense<[-17.4978, 4.9882, 0.0, -0.0]> :
Expand All @@ -23,7 +22,7 @@ func.func @add_fold_float() -> tensor<4xf16> {
// CHECK-LABEL: @add_fold_float_infinity_nan
func.func @add_fold_float_infinity_nan() -> tensor<6xf32> {
// CHECK: [[RES:]] ={{.*}}tosa.const{{.*}}0x7F800000, 0xFF800000, 0x7F800000, 0xFF800000, 0x7FC00000, 0x7FC00000
// CHECK-NOT: tosa.cast
// CHECK-NOT: tosa.add
// CHECK: return [[RES]]
%0 = "tosa.const"() {value =
dense<[0x7F800000, 0xFF800000, 0x7F800000, 0xFF800000, 0x7FC00000, 0x7F800000]> :
Expand All @@ -40,7 +39,7 @@ func.func @add_fold_float_infinity_nan() -> tensor<6xf32> {
// CHECK-LABEL: @add_fold_float_overflow
func.func @add_fold_float_overflow() -> tensor<2xf32> {
// CHECK: [[RES:]] ={{.*}}tosa.const{{.*}}0x7F800000, 0xFF800000
// CHECK-NOT: tosa.cast
// CHECK-NOT: tosa.add
// CHECK: return [[RES]]
%0 = "tosa.const"() {value =
dense<[3.1e+38, -3.1e+38]> :
Expand All @@ -60,7 +59,7 @@ func.func @add_fold_float_overflow() -> tensor<2xf32> {
// CHECK-LABEL: @add_fold_int
func.func @add_fold_int() -> tensor<4xi32> {
// CHECK: [[RES:]] ={{.*}}tosa.const{{.*}}-149, 1, 0, 5
// CHECK-NOT: tosa.cast
// CHECK-NOT: tosa.add
// CHECK: return [[RES]]
%0 = "tosa.const"() {value =
dense<[-17, 4, 0, 0]> :
Expand All @@ -77,7 +76,7 @@ func.func @add_fold_int() -> tensor<4xi32> {
// CHECK-LABEL: @add_fold_int_overflow
func.func @add_fold_int_overflow() -> tensor<4xi32> {
// CHECK: [[RES:]] ={{.*}}tosa.const{{.*}}2147483647, 2147483647, -2147483648, -2147483648
// CHECK-NOT: tosa.cast
// CHECK-NOT: tosa.add
// CHECK: return [[RES]]
%0 = "tosa.const"() {value =
dense<[2147483647, 2147483640, -2147483648, -2147483640]> :
Expand All @@ -97,7 +96,7 @@ func.func @add_fold_int_overflow() -> tensor<4xi32> {
// CHECK-LABEL: @add_fold_equal_args
func.func @add_fold_equal_args() -> tensor<3xi32> {
// CHECK: [[RES:]] ={{.*}}tosa.const{{.*}}-34, 8, 0
// CHECK-NOT: tosa.cast
// CHECK-NOT: tosa.add
// CHECK: return [[RES]]
%0 = "tosa.const"() {value =
dense<[-17, 4, 0]> :
Expand All @@ -113,7 +112,7 @@ func.func @add_fold_equal_args() -> tensor<3xi32> {
// CHECK-LABEL: @add_fold_int_broadcast_simple
func.func @add_fold_int_broadcast_simple() -> tensor<3xi32> {
// CHECK: [[RES:]] ={{.*}}tosa.const{{.*}}-29, -8, -12
// CHECK-NOT: tosa.cast
// CHECK-NOT: tosa.add
// CHECK: return [[RES]]
%0 = "tosa.const"() {value =
dense<[-17, 4, 0]> :
Expand All @@ -133,7 +132,7 @@ func.func @add_fold_int_broadcast_complex() -> tensor<3x3xi32> {
// CHECK-SAME{LITERAL}: [[-29, -10, -13],
// CHECK-SAME{LITERAL}: [-11, 8, 5],
// CHECK-SAME{LITERAL}: [7, 26, 23]]
// CHECK-NOT: tosa.cast
// CHECK-NOT: tosa.add
// CHECK: return [[RES]]
%0 = "tosa.const"() {value =
dense<[[-17], [1], [19]]> :
Expand Down
1 change: 0 additions & 1 deletion mlir/test/Dialect/Tosa/constant-cast-opt.mlir
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// RUN: mlir-opt --split-input-file -verify-diagnostics --tosa-layerwise-constant-fold %s | FileCheck %s

// -----
// Casts from float to int

// CHECK-LABEL: @cast_fold_f32_to_i1_all_none_zero
Expand Down