feat: Add HardSigmoid, HardSwish, and stabilized Softplus operators#13
Open
AdityaDRathore wants to merge 1 commit intoML4EP:devfrom
Open
feat: Add HardSigmoid, HardSwish, and stabilized Softplus operators#13AdityaDRathore wants to merge 1 commit intoML4EP:devfrom
AdityaDRathore wants to merge 1 commit intoML4EP:devfrom
Conversation
Port of root-project/root#20933, #20944, and #21092. - HardSigmoid: stateful operator with alpha/beta attributes (ONNX Opset 6+) - HardSwish: inline generation with split topology (ONNX Opset 14) - Softplus: numerical stability fix using log1p and threshold at 20.0f All use hexfloat constants for bit-exact reproducibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of root-project/root#20933, root-project/root#20944, and root-project/root#21092 to the standalone SOFIE repository.
HardSigmoid (ONNX Opset 6+)
ROperator_HardSigmoid— Stateful operator with configurablealphaandbetaattributesy = max(0, min(1, alpha * x + beta))(defaults: α=0.2, β=0.5)std::fmax/std::fminwith hexfloat clamp constants for AVX mappingHardSwish (ONNX Opset 14)
ROperator_HardSwish— Inline code generation (does not instantiate HardSigmoid)y = x * max(0, min(1, x/6 + 0.5))hfor debuggability0x1.5555555555555p-3ffor exact 1/6 representationSoftplus (Numerical Stability Fix)
std::log(std::exp(x) + 1)forx > 88.72y = (x >= 20.0) ? x : std::log1p(std::exp(x))0x1.4000000000000p+4ffor cross-platform exactnesskSoftplustoEBasicUnaryOperatorenum andGetStdLibs()Testing
Comprehensive GTest suites exist in the ROOT PRs covering:
Tests can be adapted for the standalone SOFIE test infrastructure if needed.
Files changed
src/SOFIE_core/inc/SOFIE/ROperator_HardSigmoid.hxxsrc/SOFIE_core/inc/SOFIE/ROperator_HardSwish.hxxsrc/SOFIE_core/inc/SOFIE/ROperator_BasicUnary.hxxkSoftplussrc/SOFIE_parsers/src/ParseHardSigmoid.cxxsrc/SOFIE_parsers/src/ParseHardSwish.cxxsrc/SOFIE_parsers/src/ParseBasicUnary.cxxParseSoftplussrc/SOFIE_parsers/src/RModelParser_ONNX.cxxsrc/SOFIE_parsers/CMakeLists.txtsrc/SOFIE_core/CMakeLists.txt