Skip to content

Conversation

@AdityaDRathore
Copy link

This Pull Request

This PR implements the HardSigmoid operator for the SOFIE (System for Optimized Fast Inference code Emit) engine. This is a standalone operator implementation compliant with the ONNX specification (Opset 6+).
The implementation is critical for supporting MobileNetV3 architectures (also for the HardSwish activation).

Changes or fixes:

  • New Operator: Implemented TMVA::Experimental::SOFIE::ROperator_HardSigmoid.

    • Optimization: It uses std::fmax and std::fmin with specific hexfloat constants (0x0p+0f, 0x1p+0f) to ensure the compiler emits pure AVX MAXSS/MINSS instructions without intermediate double-precision conversions.
      It Enforces f-suffix on alpha and beta coefficients to prevent implicit promotion to double during inference.
      Updated RModelParser_ONNX to correctly parse alpha and beta attributes (defaults are set to 0.2, 0.5).
  • Validation: Added a new unit test suite TestSofieHardSigmoid.

    • Verified numerical correctness against SciPy reference values (Golden Data).
    • Verified code generation structure to ensure AVX-friendly constants are emitted.

    Checklist:

  • tested changes locally (TestSofieHardSigmoid passing)
  • updated the docs (if necessary)

This PR fixes # (No specific issue linked, strictly feature addition)

cc: @guitargeek @moneta @devajithvs @bellenot

Implemented the HardSigmoid operator (ONNX opset 6+) for Project SOFIE.

This operator is a prerequisite for supporting MobileNetV3 architectures
(specifically for the HardSwish activation).

Implemented in `ROperator_HardSigmoid`.

- Uses hexfloat constants (`0x0p+0f`, `0x1p+0f`) for clamp bounds to ensure
  bit-exact reproducibility and prevent implicit double-precision promotion.

- Attributes `alpha` and `beta` are strictly handled as floats to avoid
  `CVTSS2SD` overhead in the generated inference loop.

- Added GTest suite `TestSofieHardSigmoid` validating numerical correctness against SciPy  data and verifying AVX-friendly code generation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants