Merged
Conversation
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR vectorizes the sigmoid operation to improve performance by removing the inefficient np.vectorize wrapper and implementing direct numpy array operations. The sigmoid function is commonly used and this change aims to make it faster.
Key Changes
- Refactored the
sigmoidfunction to operate directly on numpy arrays instead of scalar values - Removed
np.vectorizeusage from theSigmoidclass, which was a performance bottleneck - Removed the special case handling for scalar inputs (len(X.shape) == 0) as it's no longer needed
Comments suppressed due to low confidence (1)
onnx/reference/ops/op_sigmoid.py:25
- The dtype of the result is not being preserved. The result should be cast to match the input dtype. All similar operations in the codebase (e.g., op_exp.py, op_log.py, op_relu.py) use .astype(x.dtype) to preserve the input dtype. The return statement should ensure the result matches the input dtype.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
cbourjau
reviewed
Jan 6, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7556 +/- ##
=======================================
Coverage 55.24% 55.25%
=======================================
Files 515 515
Lines 32354 32349 -5
Branches 2897 2894 -3
=======================================
- Hits 17874 17873 -1
+ Misses 13688 13686 -2
+ Partials 792 790 -2 ☔ View full report in Codecov by Sentry. |
gramalingam
approved these changes
Jan 6, 2026
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.
Make it faster.