23 lines · plain
1// RUN: mlir-opt %s --test-fold-type-converting-op --split-input-file | FileCheck %s2 3// CHECK-LABEL: @test_fold_unary_op_f32_to_si32(4func.func @test_fold_unary_op_f32_to_si32() -> tensor<4x2xsi32> {5 // CHECK-NEXT: %[[POSITIVE_ONE:.*]] = arith.constant dense<1> : tensor<4x2xsi32>6 // CHECK-NEXT: return %[[POSITIVE_ONE]] : tensor<4x2xsi32>7 %operand = arith.constant dense<5.1> : tensor<4x2xf32>8 %sign = test.sign %operand : (tensor<4x2xf32>) -> tensor<4x2xsi32>9 return %sign : tensor<4x2xsi32>10}11 12// -----13 14// CHECK-LABEL: @test_fold_binary_op_f32_to_i1(15func.func @test_fold_binary_op_f32_to_i1() -> tensor<8xi1> {16 // CHECK-NEXT: %[[FALSE:.*]] = arith.constant dense<false> : tensor<8xi1>17 // CHECK-NEXT: return %[[FALSE]] : tensor<8xi1>18 %lhs = arith.constant dense<5.1> : tensor<8xf32>19 %rhs = arith.constant dense<4.2> : tensor<8xf32>20 %less_than = test.less_than %lhs, %rhs : (tensor<8xf32>, tensor<8xf32>) -> tensor<8xi1>21 return %less_than : tensor<8xi1>22}23