You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add BiasGelu, Erfgelu and SkipLayerNormalization fusions (#2222)
This pull request introduces new fusion patterns and enhancements to the
ONNXScript rewriter module, focusing on optimization and test coverage
improvements. The key changes include adding support for `BiasGelu` and
additional `ErfGelu` patterns, extending `SkipLayerNormalization` to
handle bias addition, and updating test utilities for better accuracy
validation.
### New fusion patterns:
* **BiasGelu Fusion**: Added a new fusion pattern for `BiasGelu`
operations, including its implementation in
`onnxscript/rewriter/ort_fusions/bias_gelu.py` and integration into the
`fuse_xformers` pipeline. A corresponding unit test was added to
validate the functionality.
[[1]](diffhunk://#diff-bae885e012eac8fcd8bb223ffcd1ad12032d9567274c47c96e3bc7359976f201R1-R22)
[[2]](diffhunk://#diff-7ed8fc913d266194ed4adf06143954a9f5c0b5170ac6a813faf09b1159899394R16-R18)
[[3]](diffhunk://#diff-7ed8fc913d266194ed4adf06143954a9f5c0b5170ac6a813faf09b1159899394R90)
[[4]](diffhunk://#diff-d86ef6d0ede3ff678737083487de1363cf2e9b79b0bcb93cb76db343c0a9e450R1-R52)
* **ErfGelu Enhancements**: Introduced a second pattern for `ErfGelu`
fusion and refactored the corresponding implementation. The file was
renamed from `erfgelu.py` to `ort_fusions/erfgelu.py` for consistency.
[[1]](diffhunk://#diff-5b7be33fd11491135b99b58bfb5caad2458fde98364c99875dfd8739cb38ec2eL5-R9)
[[2]](diffhunk://#diff-5b7be33fd11491135b99b58bfb5caad2458fde98364c99875dfd8739cb38ec2eR22-R36)
[[3]](diffhunk://#diff-7ed8fc913d266194ed4adf06143954a9f5c0b5170ac6a813faf09b1159899394R16-R18)
[[4]](diffhunk://#diff-7ed8fc913d266194ed4adf06143954a9f5c0b5170ac6a813faf09b1159899394R70)
### Enhancements to existing fusions:
* **SkipLayerNormalization with Bias**: Extended the
`SkipLayerNormalization` fusion to support an additional bias term. This
includes new patterns and rewrite rules in
`onnxscript/rewriter/ort_fusions/skip_normalization.py`.
### Test utility updates:
* **Tolerance Adjustment**: Increased the relative and absolute
tolerances in `assert_allclose` to `1e-3` for better handling of
numerical discrepancies in tests.
0 commit comments