Skip to content

Commit

Permalink
Adding new quantileType types to mlir test (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
sartil authored Nov 19, 2024
1 parent 86a70d6 commit 0d11450
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
6 changes: 3 additions & 3 deletions mlir/lib/Dialect/Quant/IR/TypeParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,10 @@ static void printStorageType(QuantizedType type, DialectAsmPrinter &out) {
static void printQuantileType(Type quantileType, DialectAsmPrinter &out) {
if (auto intType = llvm::dyn_cast<IntegerType>(quantileType)) {
const unsigned storageTypeWidth = intType.getWidth();
if (intType.isSigned()) {
out << ":i" << storageTypeWidth;
} else {
if (intType.isUnsigned()) {
out << ":u" << storageTypeWidth;
} else {
out << ":i" << storageTypeWidth;
}
} else if (quantileType.isa<Float8E5M2Type>()) {
out << ":f8E5M2";
Expand Down
22 changes: 20 additions & 2 deletions mlir/test/Dialect/Quant/Bytecode/types.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,30 @@ module @parseUniformPerAxisMixed attributes {
// QuantileQuantized
//===----------------------------------------------------------------------===//

// CHECK-LABEL: parseQuantilePerLayer
module @parseQuantilePerLayer attributes {
// CHECK-LABEL: parseQuantilePerLayerFp16
module @parseQuantilePerLayerFp16 attributes {
// CHECK: !quant.quantile<u8:f16:f32, {-1.000000e+00,-0.99219999999999997,-0.98429999999999995,-9.765000e-01,-9.686000e-01,-0.96079999999999998,-9.529000e-01,-9.451000e-01,-9.373000e-01,-9.294000e-01,-0.92159999999999997,-0.91369999999999995,-9.059000e-01,-8.980000e-01,-8.902000e-01,-8.824000e-01,-8.745000e-01,-8.667000e-01,-8.588000e-01,-8.510000e-01,-0.84309999999999996,-8.353000e-01,-8.275000e-01,-8.196000e-01,-8.118000e-01,-8.039000e-01,-7.961000e-01,-7.882000e-01,-0.78039999999999998,-7.725000e-01,-7.647000e-01,-7.569000e-01,-7.490000e-01,-7.412000e-01,-7.333000e-01,-7.255000e-01,-7.176000e-01,-7.098000e-01,-0.70199999999999996,-6.941000e-01,-6.863000e-01,-6.784000e-01,-6.706000e-01,-6.627000e-01,-6.549000e-01,-6.471000e-01,-0.63919999999999999,-0.63139999999999996,-6.235000e-01,-6.157000e-01,-6.078000e-01,-6.000000e-01,-5.922000e-01,-5.843000e-01,-5.765000e-01,-5.686000e-01,-5.608000e-01,-5.529000e-01,-5.451000e-01,-5.373000e-01,-5.294000e-01,-5.216000e-01,-5.137000e-01,-5.059000e-01,-4.980000e-01,-4.902000e-01,-4.824000e-01,-4.745000e-01,-4.667000e-01,-4.588000e-01,-4.510000e-01,-4.431000e-01,-4.353000e-01,-4.275000e-01,-4.196000e-01,-4.118000e-01,-4.039000e-01,-3.961000e-01,-3.882000e-01,-3.804000e-01,-3.725000e-01,-3.647000e-01,-3.569000e-01,-3.490000e-01,-3.412000e-01,-3.333000e-01,-3.255000e-01,-3.176000e-01,-3.098000e-01,-3.020000e-01,-2.941000e-01,-2.863000e-01,-2.784000e-01,-2.706000e-01,-2.627000e-01,-2.549000e-01,-2.471000e-01,-2.392000e-01,-2.314000e-01,-2.235000e-01,-2.157000e-01,-2.078000e-01,-2.000000e-01,-1.922000e-01,-1.843000e-01,-1.765000e-01,-1.686000e-01,-1.608000e-01,-1.529000e-01,-1.451000e-01,-1.373000e-01,-1.294000e-01,-1.216000e-01,-1.137000e-01,-1.059000e-01,-9.800000e-02,-9.020000e-02,-8.240000e-02,-0.074499999999999997,-0.066699999999999995,-5.880000e-02,-5.100000e-02,-4.310000e-02,-3.530000e-02,-2.750000e-02,-1.960000e-02,-1.180000e-02,-3.900000e-03,3.900000e-03,1.180000e-02,1.960000e-02,2.750000e-02,3.530000e-02,4.310000e-02,5.100000e-02,5.880000e-02,0.066699999999999995,0.074499999999999997,8.240000e-02,9.020000e-02,9.800000e-02,1.059000e-01,1.137000e-01,1.216000e-01,1.294000e-01,1.373000e-01,1.451000e-01,1.529000e-01,1.608000e-01,1.686000e-01,1.765000e-01,1.843000e-01,1.922000e-01,2.000000e-01,2.078000e-01,2.157000e-01,2.235000e-01,2.314000e-01,2.392000e-01,2.471000e-01,2.549000e-01,2.627000e-01,2.706000e-01,2.784000e-01,2.863000e-01,2.941000e-01,3.020000e-01,3.098000e-01,3.176000e-01,3.255000e-01,3.333000e-01,3.412000e-01,3.490000e-01,3.569000e-01,3.647000e-01,3.725000e-01,3.804000e-01,3.882000e-01,3.961000e-01,4.039000e-01,4.118000e-01,4.196000e-01,4.275000e-01,4.353000e-01,4.431000e-01,4.510000e-01,4.588000e-01,4.667000e-01,4.745000e-01,4.824000e-01,4.902000e-01,4.980000e-01,5.059000e-01,5.137000e-01,5.216000e-01,5.294000e-01,5.373000e-01,5.451000e-01,5.529000e-01,5.608000e-01,5.686000e-01,5.765000e-01,5.843000e-01,5.922000e-01,6.000000e-01,6.078000e-01,6.157000e-01,6.235000e-01,0.63139999999999996,0.63919999999999999,6.471000e-01,6.549000e-01,6.627000e-01,6.706000e-01,6.784000e-01,6.863000e-01,6.941000e-01,0.70199999999999996,7.098000e-01,7.176000e-01,7.255000e-01,7.333000e-01,7.412000e-01,7.490000e-01,7.569000e-01,7.647000e-01,7.725000e-01,0.78039999999999998,7.882000e-01,7.961000e-01,8.039000e-01,8.118000e-01,8.196000e-01,8.275000e-01,8.353000e-01,0.84309999999999996,8.510000e-01,8.588000e-01,8.667000e-01,8.745000e-01,8.824000e-01,8.902000e-01,8.980000e-01,9.059000e-01,0.91369999999999995,0.92159999999999997,9.294000e-01,9.373000e-01,9.451000e-01,9.529000e-01,0.96079999999999998,9.686000e-01,9.765000e-01,0.98429999999999995,0.99219999999999997,1.000000e+00}:9.987200e-01:127>
bytecode.test = !quant.quantile<u8:f16:f32, {-1.0000,-0.9922,-0.9843,-0.9765,-0.9686,-0.9608,-0.9529,-0.9451,-0.9373,-0.9294,-0.9216,-0.9137,-0.9059,-0.8980,-0.8902,-0.8824,-0.8745,-0.8667,-0.8588,-0.8510,-0.8431,-0.8353,-0.8275,-0.8196,-0.8118,-0.8039,-0.7961,-0.7882,-0.7804,-0.7725,-0.7647,-0.7569,-0.7490,-0.7412,-0.7333,-0.7255,-0.7176,-0.7098,-0.7020,-0.6941,-0.6863,-0.6784,-0.6706,-0.6627,-0.6549,-0.6471,-0.6392,-0.6314,-0.6235,-0.6157,-0.6078,-0.6000,-0.5922,-0.5843,-0.5765,-0.5686,-0.5608,-0.5529,-0.5451,-0.5373,-0.5294,-0.5216,-0.5137,-0.5059,-0.4980,-0.4902,-0.4824,-0.4745,-0.4667,-0.4588,-0.4510,-0.4431,-0.4353,-0.4275,-0.4196,-0.4118,-0.4039,-0.3961,-0.3882,-0.3804,-0.3725,-0.3647,-0.3569,-0.3490,-0.3412,-0.3333,-0.3255,-0.3176,-0.3098,-0.3020,-0.2941,-0.2863,-0.2784,-0.2706,-0.2627,-0.2549,-0.2471,-0.2392,-0.2314,-0.2235,-0.2157,-0.2078,-0.2000,-0.1922,-0.1843,-0.1765,-0.1686,-0.1608,-0.1529,-0.1451,-0.1373,-0.1294,-0.1216,-0.1137,-0.1059,-0.0980,-0.0902,-0.0824,-0.0745,-0.0667,-0.0588,-0.0510,-0.0431,-0.0353,-0.0275,-0.0196,-0.0118,-0.0039,0.0039,0.0118,0.0196,0.0275,0.0353,0.0431,0.0510,0.0588,0.0667,0.0745,0.0824,0.0902,0.0980,0.1059,0.1137,0.1216,0.1294,0.1373,0.1451,0.1529,0.1608,0.1686,0.1765,0.1843,0.1922,0.2000,0.2078,0.2157,0.2235,0.2314,0.2392,0.2471,0.2549,0.2627,0.2706,0.2784,0.2863,0.2941,0.3020,0.3098,0.3176,0.3255,0.3333,0.3412,0.3490,0.3569,0.3647,0.3725,0.3804,0.3882,0.3961,0.4039,0.4118,0.4196,0.4275,0.4353,0.4431,0.4510,0.4588,0.4667,0.4745,0.4824,0.4902,0.4980,0.5059,0.5137,0.5216,0.5294,0.5373,0.5451,0.5529,0.5608,0.5686,0.5765,0.5843,0.5922,0.6000,0.6078,0.6157,0.6235,0.6314,0.6392,0.6471,0.6549,0.6627,0.6706,0.6784,0.6863,0.6941,0.7020,0.7098,0.7176,0.7255,0.7333,0.7412,0.7490,0.7569,0.7647,0.7725,0.7804,0.7882,0.7961,0.8039,0.8118,0.8196,0.8275,0.8353,0.8431,0.8510,0.8588,0.8667,0.8745,0.8824,0.8902,0.8980,0.9059,0.9137,0.9216,0.9294,0.9373,0.9451,0.9529,0.9608,0.9686,0.9765,0.9843,0.9922,1.0000}:9.987200e-01:127>
} {}

// CHECK-LABEL: parseQuantilePerLayerBf16
module @parseQuantilePerLayerBf16 attributes {
// CHECK: !quant.quantile<i4:bf16:f32, {-1.000000e+00,-8.000000e-01,-0.69999999999999996,-6.000000e-01,-5.000000e-01,-4.000000e-01,-3.000000e-01,0.000000e+00,1.000000e-01,2.000000e-01,3.000000e-01,4.000000e-01,5.000000e-01,6.000000e-01,0.69999999999999996,1.000000e+00}:9.987200e-01:127>
bytecode.test = !quant.quantile<i4:bf16:f32, {-1.000000e+00,-8.000000e-01,-0.69999999999999996,-6.000000e-01,-5.000000e-01,-4.000000e-01,-3.000000e-01,0.000000e+00,1.000000e-01,2.000000e-01,3.000000e-01,4.000000e-01,5.000000e-01,6.000000e-01,0.69999999999999996,1.000000e+00}:9.987200e-01:127>
} {}

// CHECK-LABEL: parseQuantilePerLayerI8
module @parseQuantilePerLayerI8 attributes {
// CHECK: !quant.quantile<u4:i8:f32, {-8.000000e+00,-7.000000e+00,-6.000000e+00,-5.000000e+00,-4.000000e+00,-3.000000e+00,-2.000000e+00,-1.000000e+00,0.000000e+00,1.000000e+00,2.000000e+00,3.000000e+00,4.000000e+00,5.000000e+00,6.000000e+00,7.000000e+00}:9.987200e-01:127>
bytecode.test = !quant.quantile<u4:i8:f32, {-8.000000e+00,-7.000000e+00,-6.000000e+00,-5.000000e+00,-4.000000e+00,-3.000000e+00,-2.000000e+00,-1.000000e+00,0.000000e+00,1.000000e+00,2.000000e+00,3.000000e+00,4.000000e+00,5.000000e+00,6.000000e+00,7.000000e+00}:9.987200e-01:127>
} {}

// CHECK-LABEL: parseQuantilePerLayerU8
module @parseQuantilePerLayerU8 attributes {
// CHECK: !quant.quantile<i4:u8:f32, {0.000000e+00,1.000000e+00,2.000000e+00,3.000000e+00,4.000000e+00,5.000000e+00,6.000000e+00,7.000000e+00,8.000000e+00,9.000000e+00,1.000000e+01,1.100000e+01,1.200000e+01,1.300000e+01,1.400000e+01,1.500000e+01}:9.987200e-01:127>
bytecode.test = !quant.quantile<i4:u8:f32, {0.000000e+00,1.000000e+00,2.000000e+00,3.000000e+00,4.000000e+00,5.000000e+00,6.000000e+00,7.000000e+00,8.000000e+00,9.000000e+00,1.000000e+01,1.100000e+01,1.200000e+01,1.300000e+01,1.400000e+01,1.500000e+01}:9.987200e-01:127>
} {}

//===----------------------------------------------------------------------===//
// QuantileQuantizedPerAxis
//===----------------------------------------------------------------------===//
Expand Down

0 comments on commit 0d11450

Please sign in to comment.