Function arm_elementwise_sub_f32

Function Documentation

arm_cmsis_nn_status arm_elementwise_sub_f32(const float32_t *input_1_vect, const float32_t *input_2_vect, float32_t *output, float32_t out_activation_min, float32_t out_activation_max, int32_t block_size)

Elementwise subtract with optional output clamp.

NaN propagates through the clamp (TensorFlow Lite semantics): a quiet NaN in either input operand, or a NaN produced by the arithmetic itself (such as Inf - Inf for subtract), yields a NaN at that output element. This holds at every optimization level, on the toolchains this project gates (see the Testing & Verification guide, docs/guides/verification.md), including the shipped -Ofast (CMSIS_OPTIMIZATION_LEVEL in the top-level CMakeLists.txt): the clamp classifies NaN on the integer bit pattern of the value rather than with a floating-point compare, and the -ffinite-math-only that -Ofast implies grants no license to fold integer arithmetic. Verified by host execution and by disassembly on gated Arm GNU Toolchain 14.3.Rel1 (where the unguarded form demonstrably folds) and 13.x/15.x and armclang 6.23; ATfE unexamined — cross-toolchain on-target execution is #340’s scope. See issues #333 and #334. Only the NaN-ness of the element is guaranteed, not a particular NaN payload. Infinities that are not NaN still clamp to the activation bounds (and pass through unchanged under the +/-INFINITY “no clamp” idiom).

Parameters:
  • input_1_vect[in] Pointer to the first input vector (minuend).

  • input_2_vect[in] Pointer to the second input vector (subtrahend).

  • output[out] Pointer to the output vector.

  • out_activation_min[in] Minimum output clamp value.

  • out_activation_max[in] Maximum output clamp value.

  • block_size[in] Number of elements to process.

Returns:

ARM_CMSIS_NN_SUCCESS on success or ARM_CMSIS_NN_ARG_ERROR on invalid arguments.