⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@AdityaDRathore
Copy link

This Pull Request

This PR implements the HardSwish operator for the SOFIE engine. This operator is required for supporting MobileNetV3 architectures.

Note on Dependency:
This PR is stacked on top of PR #20933 (HardSigmoid). It includes the commits from that PR. The unique changes for this PR are contained in the HardSwish operator files.

Changes or fixes:

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

    • Implementation Strategy: Inline code generation. Does not instantiate HardSigmoid to minimize function overhead.
    • Optimization: Uses std::fmax and std::fmin with bit-exact hexfloat constants:
      • 0x1.5555555555555p-3f (approx 1/6)
      • 0x1p-1f (0.5)
      • 0x0p+0f and 0x1p+0f (Clamp bounds)
    • Parsing: Updated RModelParser_ONNX to register HardSwish (Opset 14 compliant).
  • Validation: Added TestSofieHardSwish GTest suite.

    • Verified bit-exact hexfloat emission in generated C++ code.
    • Verified numerical correctness against reference math: x * max(0, min(1, x/6 + 0.5)).
    • Verified split-topology generation for debuggability (float h = ...).

Checklist:

  • tested changes locally ( TestSofieHardSwish passing )
  • updated the docs ( not necessary for internal operator )

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.
The SOFIE inference engine lacks the 'HardSwish' operator, which is a critical activation function for MobileNetV3 and other modern lightweight architectures (ONNX Opset 14).

- Implemented `TMVA::Experimental::SOFIE::ROperator_HardSwish` as a standalone inline operator.

- Utilized `std::fmax` and `std::fmin` with strict hexfloat constants (1/6 and 0.5) to ensure AVX optimization and prevent double-precision promotion.

- Registered the operator in `RModelParser_ONNX` with an inline lambda.

- Added comprehensive unit tests (`TestSofieHardSwish`) verifying numerical correctness and generated code topology.
@AdityaDRathore
Copy link
Author

This branch is built on top of feature/sofie-hardsigmoid (PR #20933). Please focus review on ROperator_HardSwish.hxx and TestSofieHardSwish.cxx.

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.

1 participant