1syntax = "proto3"; 2 3package mlir.quant; 4 5option cc_enable_arenas = true; 6 7// Represents the quantization parameters for a list of named tensors. 8message QuantizationInfo { 9 // min/max of the per axis value range. To quantize the value, the metadata 10 // of the target properties should be specified or read from the ops 11 // quantization specification. 12 message MinMax { 13 float min = 1; 14 float max = 2; 15 } 16 17 // Affine parameters to quantize the per axis value. The metadata of the 18 // target properties should be specified as well. 19 message AffineParams { 20 float scale = 1; 21 int32 zero_point = 2; 22 } 23 24 // Params to quantize the axis. Only one of the field can be used. 25 message PerAxisParams { 26 oneof params_oneof { 27 // min/max of the ranges. 28 MinMax min_max = 1; 29 30 // affine parameters to quantize the per axis value. 31 AffineParams affine_params = 2; 32 } 33 } 34 35 // The metadata defines the target properties. 36 message Metadata { 37 // Bit number of fixed-point data the target kernel supports. 38 int32 num_bits = 1; 39 // The quantized axis index if it is per-axis quantization. 40 int32 quantize_axis = 2; 41 // The minimum allowed value of the fixed-point data range. 42 // This can also be used to derive the sign of storage type. 43 int32 range_min = 3; 44 // The minimum allowed value of the fixed-point data range. 45 int32 range_max = 4; 46 } 47 48 // The quantization parameters for a named tensor. 49 message QuantParams { 50 // The tensor name has the following convention: 51 // tensor_name := op_name | op_name ’:’ port_number. 52 // If the op has only one port, op_name can be used. 53 // If the op has internal states, such as fused LSTM, the port_number should 54 // follow a predefined convention. 55 oneof name_oneof { 56 string name = 1; 57 58 // An regex can be used to match multiple tensors. 59 string name_regex = 2; 60 } 61 62 // The quantization parameters for the tensor. If it is for per-axis, the 63 // parameters should be defined for each axis, otherwise, if it is for 64 // per-tensor, this repeated field should only contain a single element. 65 repeated PerAxisParams params = 3; 66 67 // Metadata about the quantization parameters. 68 Metadata meta = 5; 69 } 70 71 // List of quantization parameters for tensors. 72 repeated QuantParams entries = 1; 73} 74