optimize your design to manage quantization errors
quantization is the process of mapping continuous infinite values to a smaller set of discrete finite values. in the context of simulation and embedded computing, it is about approximating real-world values with a digital representation that introduces limits on the precision and range of a value. quantization introduces various sources of error in your algorithm, such as rounding errors, underflow or overflow, computational noise, and limit cycles. this results in numerical differences between the ideal system behavior and the computed numerical behavior.
to manage the effects of quantization, you need to choose the right data types to represent the real-world signals. you need to consider the precision, range, and scaling of the data type used to encode the signal, and also account for the non-linear cumulative effects of quantization on the numerical behavior of your algorithm. this cumulative effect is further exacerbated when you have constructs such as feedback loops.
why quantization matters
the process of converting a design for embedded hardware needs to take the quantization errors into account. quantization errors affect signal processing, wireless, control systems, fpga, asic, soc, deep learning, and other applications.
quantization in signal processing and wireless applications
in signal processing applications, quantization errors contribute to noise and degrade the (snr). the snr is measured in db and is generally described as x decibel reduction for each additional bit. in order to manage quantization noise and keep it at an acceptable level, you need to choose the right settings such as the data types and rounding modes.
quantization in control systems
when designing control systems, particularly for low-power microcontrollers, you can use integer or fixed-point arithmetic to balance real-time performance requirements with the low-power constraints. in such designs, you need to choose data types that accommodate the dynamic range and precision of the signals coming from input sensors while meeting the precision requirements for the output signals, all without running into numerical differences due to quantization.
quantization in fpga, asic, and soc development
converting a design from floating point to fixed point can help minimize power and resource consumption by reducing the fpga resource utilization, lowering power consumption, meeting latency requirements, etc. however, this conversion introduces quantization errors, and so you must budget the quantization noise appropriately when converting your designs.
quantization in deep learning
quantization for deep learning networks is an important step to help accelerate inference as well as to reduce memory and power consumption on embedded devices. scaled 8-bit integer quantization maintains the accuracy of the network while reducing the size of the network. this enables deployment to devices with smaller memory footprints, leaving more room for other algorithms and control logic.
quantization optimizations can be made when the targeted hardware (gpu, fpga, cpu) architecture is taken into consideration. this includes computing in integers, utilizing hardware accelerators, and fusing layers. the quantization step is an iterative process to achieve acceptable accuracy of the network.
see how to quantize, calibrate, and validate deep neural networks in matlab using a white-box approach to make tradeoffs between performance and accuracy, then deploy the quantized dnn to an embedded gpu and an fpga hardware board.
how quantization works
quantization errors are a cumulative effect of non-linear operations like rounding of the fractional part of a signal or overflow of the dynamic range of the signal. you can take quantization errors into account when converting a design for embedded hardware by observing the key signals or variables in your design and budgeting the quantization error so that the numerical difference is within acceptable tolerance.
quantization with matlab and simulink
with matlab and simulink, you can:
- explore and analyze the quantization error propagation
- automatically quantize your design to limited precision
- debug numerical differences that result from quantization
explore and analyze quantization errors
you can collect simulation data and statistics through automatic model-wide instrumentation. matlab visualizations of this data enable you to explore and analyze your designs to understand how your data type choices affect the underlying signal.
automatically quantize your design
you can quantize your design by selecting a specific data type, or you can iteratively explore different fixed-point data types. using a guided workflow, you can see the overall effect that quantization has on the numerical behavior of your system.
alternatively, you can solve the optimization problem and choose the optimal heterogenous data type configuration for your design that meets the tolerance constraints on the numerical behavior of your system.
learn more about fixed-point conversion:
debug numerical differences due to quantization
with matlab, you can identify, trace, and debug the sources of numerical issues due to quantization such as overflow, precision loss, and wasted range or precision in your design.
examples and how to
software reference
see also: filter design, motor control design with simulink, hardware design with matlab and simulink