summaryrefslogtreecommitdiff
path: root/mlir/test/Dialect/Quant/Bytecode/types.mlir
blob: 8c79b757eeb19a7b67197b7aadea32d9fbaba93c (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// RUN: mlir-opt -emit-bytecode %s | mlir-opt | FileCheck %s

//===----------------------------------------------------------------------===//
// AnyQuantized
//===----------------------------------------------------------------------===//

// CHECK-LABEL: parseAnyFullySpecified
module @parseAnyFullySpecified attributes {
  // CHECK: bytecode.test = !quant.any<i8<-8:7>:f32>
  bytecode.test = !quant.any<i8<-8:7>:f32>
} {}

// CHECK-LABEL: parseAnyNoExpressedType
module @parseAnyNoExpressedType attributes {
  // CHECK: bytecode.test = !quant.any<i8<-8:7>>
  bytecode.test = !quant.any<i8<-8:7>>
} {}

// CHECK-LABEL: parseAnyOnlyStorageType
module @parseAnyOnlyStorageType attributes {
  // CHECK: bytecode.test = !quant.any<i8<-8:7>>
  bytecode.test = !quant.any<i8<-8:7>>
} {}

//===----------------------------------------------------------------------===//
// CalibratedQuantized
//===----------------------------------------------------------------------===//

// CHECK-LABEL: parseCalibrated
module @parseCalibrated attributes {
  // CHECK: !quant.calibrated<f32<-0.998:1.232100e+00>>
  bytecode.test = !quant.calibrated<f32<-0.998:1.2321>>
} {}

//===----------------------------------------------------------------------===//
// UniformQuantized
//===----------------------------------------------------------------------===//

// CHECK-LABEL: parseUniformPerLayer
module @parseUniformPerLayer attributes {
  // CHECK: !quant.uniform<i8<-8:7>:f32, 9.987200e-01:127>
  bytecode.test = !quant.uniform<i8<-8:7>:f32, 9.987200e-01:127>
} {}

//===----------------------------------------------------------------------===//
// UniformQuantizedPerAxis
//===----------------------------------------------------------------------===//

// CHECK-LABEL: parseUniformPerAxisScaleZero
module @parseUniformPerAxisScaleZero attributes {
  // CHECK: !quant.uniform<u8:f32:1, {2.000000e+02:-120,9.987200e-01:127}>
  bytecode.test = !quant.uniform<u8:f32:1, {2.000000e+02:-120,9.987200e-01:127}>
} {}

// CHECK-LABEL: parseUniformPerAxisScaleNoZero
module @parseUniformPerAxisScaleNoZero attributes {
  // CHECK: !quant.uniform<i8:f32:1, {2.000000e+02,9.987200e-01}>
  bytecode.test = !quant.uniform<i8:f32:1, {2.0e+2,0.99872}>
} {}

// CHECK-LABEL: parseUniformPerAxisMixed
module @parseUniformPerAxisMixed attributes {
  // CHECK: !quant.uniform<i8:f32:1, {2.000000e+02,9.987200e-01:120}>
  bytecode.test = !quant.uniform<i8:f32:1, {2.0e+2,0.99872:120}>
} {}

//===----------------------------------------------------------------------===//
// UniformQuantizedSubChannel
//===----------------------------------------------------------------------===//

// CHECK-LABEL: parseUniformSubChannel
module @parseUniformSubChannel attributes {
  // CHECK: !quant.uniform<i8:f32:{0:1, 1:2}, {{\{}}{2.000000e+00:10, 3.000000e+00:20}, {4.000000e+00:30, 5.000000e+00:40}}>
  bytecode.test = !quant.uniform<i8:f32:{0:1, 1:2}, {{2.0:10, 3.0:20}, {4.0:30, 5.0:40}}>
} {}