1// RUN: mlir-opt %s -split-input-file -pass-pipeline='func(canonicalize)' | FileCheck %s 2 3// ----- 4// CHECK-LABEL: redundant_scast 5func @redundant_scast() -> tensor<4xi8> { 6 // CHECK-NEXT: constant dense<10> : tensor<4xi8> 7 // CHECK-NEXT: return 8 %cst = constant dense<5> : tensor<4xi8> 9 %1 = "quant.scast"(%cst) : (tensor<4xi8>) -> tensor<4x!quant.uniform<u8:f32, 7.812500e-03:128>> 10 %2 = "quant.scast"(%1) : (tensor<4x!quant.uniform<u8:f32, 7.812500e-03:128>>) -> tensor<4xi8> 11 %3 = addi %2, %2 : tensor<4xi8> 12 return %3 : tensor<4xi8> 13} 14 15// ----- 16// CHECK-LABEL: non_redundant_scast 17func @non_redundant_scast() -> tensor<4x!quant.uniform<u8:f32, 7.812500e-03:128>> { 18 // CHECK-NEXT: constant dense<5> : tensor<4xi8> 19 // CHECK-NEXT: scast 20 // CHECK-NEXT: return 21 %cst = constant dense<5> : tensor<4xi8> 22 %1 = "quant.scast"(%cst) : (tensor<4xi8>) -> tensor<4x!quant.uniform<u8:f32, 7.812500e-03:128>> 23 return %1 : tensor<4x!quant.uniform<u8:f32, 7.812500e-03:128>> 24} 25