Open
Conversation
Implement the Gelu operator for the SOFIE inference engine with ONNX Opset 20 specifications. Port of root-project/root#20876. The implementation uses the exact Gelu formula: y = 0.5 * x * (1+ erf( x / sqrt(2))) Uses compile-time hexfloat constants for 1/sqrt(2) and 0.5 to ensure bit-exact reproducibility. Updates RModelParser_ONNX to register the Gelu operator node. It explicitly rejects the approximate attribute (tanh approximation) as it is not yet supported.
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#20876 to the standalone SOFIE repository, following the upstream-first development workflow.
What this adds
ROperator_GELU— Exact CDF-based GELU implementation (ONNX Opset 20)ParseGelu.cxx— ONNX parser registration following the standalone parser file patternapproximate="tanh"attribute with a clear errorPrecision
Uses C++17 hexadecimal floating-point constants (
0x1.6a09e667f3bcdp-1for 1/√2) instead of runtime division to guarantee bit-exact reproducibility across platforms.Formula
Testing
A comprehensive GTest validation suite (
TestSofieGELU.cxx) exists in the ROOT PR (root-project/root#20876) covering:std::cmathdependency checkTests can be adapted for the standalone SOFIE test infrastructure if needed.
Files changed
src/SOFIE_core/inc/SOFIE/ROperator_GELU.hxxsrc/SOFIE_parsers/src/ParseGelu.cxxsrc/SOFIE_parsers/src/RModelParser_ONNX.cxxsrc/SOFIE_parsers/CMakeLists.txtsrc/SOFIE_core/CMakeLists.txt