Skip to content

Modification of the elemwise.hpp

Context

An inconsistency has been identified in the computation logic of the QAdd block (addition, multiplication, and bit shifting) between aidge_core and aidge_export_cpp when running an 8-bit quantized model.

See related issue: aidge_quantization#88 (moved)

The behavior observed in aidge_core appears to be correct, as it aligns with the C++ standard. According to the standard ([ISO/IEC 14882], e.g. §7.6.1/2 in C++17), arithmetic operations involving integer types smaller than int (e.g., int8_t) must be implicitly promoted to int before the operation is evaluated.

However, this implicit promotion was not being enforced in aidge_export_cpp, resulting in potential overflows during intermediate computations.

To ensure consistent and standards-compliant behavior across both components, an explicit type promotion to int32_t has been added in elementwise.hpp during arithmetic operations.

Modified files

  • elementwise.hpp: Enforced explicit promotion to int32_t for intermediate arithmetic operations to prevent overflow in quantized models.

Merge request reports

Loading