Repository navigation
Conversation
Implement ROperator_PRelu and its ONNX parser. The slope is unidirectionally broadcast to the shape of X as required since opset 7: instead of expanding the slope to the size of X, the generated loop computes the slope index from the strides of X, skipping the broadcast axes, e.g. tensor_slope[(id / 4) % 3] for a [1,3,2,2] input with the per-channel [3,1,1] slope exported by PyTorch's nn.PReLU. A slope that cannot be broadcast to X is rejected in Initialize(). Only float is supported for now. Add four model tests (same shape, last-axis, per-channel and single slope) and two parser tests checking the error for a non-broadcastable slope and that a per-channel slope is not expanded.
This branch has not been deployed
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.
This PR adds support for the ONNX
PReluoperator, which was still unchecked in the operator status list (#10360).Implementation
slopeis unidirectionally broadcast to the shape ofX, as required since opset 7. Instead of expanding the slope to the size ofX(which would turn e.g. a 64-element per-channel slope into a 1×64×112×112 weight tensor), the generated loop computes the slope index from the strides ofX, skipping the broadcast axes. For the per-channel[C,1,1]slope exported by PyTorch'snn.PReLU(C)on a[1,3,2,2]input this gives:A slope with the same shape as
Xis indexed byiddirectly and a single slope by0. A slope that cannot be broadcast toXis rejected inInitialize().Limitations
floatis supported for now.Tests
[5]), per-channel ([3,1,1]) and a single slope ([1]).Conv2d + nn.PReLU(4)model exported from PyTorch 2.14 goes through SOFIE and matches the PyTorch output exactly.