summaryrefslogtreecommitdiffstats
path: root/mlir/test/Dialect/QuantOps/canonicalize.mlir
blob: f9fc4fc466c52462d32016731b7f2278bf4b5c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// RUN: mlir-opt %s -split-input-file -pass-pipeline='func(canonicalize)' | FileCheck %s --dump-input=fail

// -----
// CHECK-LABEL: redundant_scast
func @redundant_scast() -> tensor<4xi8> {
  // CHECK-NEXT: constant dense<10> : tensor<4xi8>
  // CHECK-NEXT: return
  %cst = constant dense<5> : tensor<4xi8>
  %1 = "quant.scast"(%cst) : (tensor<4xi8>) -> tensor<4x!quant.uniform<u8:f32, 7.812500e-03:128>>
  %2 = "quant.scast"(%1) : (tensor<4x!quant.uniform<u8:f32, 7.812500e-03:128>>) -> tensor<4xi8>
  %3 = addi %2, %2 : tensor<4xi8>
  return %3 : tensor<4xi8>
}

// -----
// CHECK-LABEL: non_redundant_scast
func @non_redundant_scast() -> tensor<4x!quant.uniform<u8:f32, 7.812500e-03:128>> {
  // CHECK-NEXT: constant dense<5> : tensor<4xi8>
  // CHECK-NEXT: scast
  // CHECK-NEXT: return
  %cst = constant dense<5> : tensor<4xi8>
  %1 = "quant.scast"(%cst) : (tensor<4xi8>) -> tensor<4x!quant.uniform<u8:f32, 7.812500e-03:128>>
  return %1 : tensor<4x!quant.uniform<u8:f32, 7.812500e-03:128>>
}
OpenPOWER on IntegriCloud