Repository navigation
[Relax][ONNX] Support constant output_shape input in MaxUnpool - #21000
Open
cchung100m wants to merge 3 commits into
Open
cchung100m wants to merge 3 commits into
cchung100m wants to merge 3 commits into
Conversation
cchung100m
marked this pull request as ready for review
November 16, 2026 21:38
Contributor
Author
guan404ming
approved these changes
Nov 21, 2026
| data = np.array([[[[5.0, 6.0], [7.0, 8.0]]]], dtype="float32") | ||
| indices = np.array([[[[0, 3], [8, 15]]]], dtype="int64") | ||
|
|
||
| out_shape = [1, 1, 4, 4] |
Member
There was a problem hiding this comment.
This out_shape equals the inferred shape, so the test passes even if output_shape is ignored. Could we use the ONNX reference case and drop the None variant?
| for variant in [None, "initializer"]: | ||
| check_correctness(make_model(variant), inputs={"X": data}, opset=11) | ||
|
|
||
| from_onnx(make_model("initializer"), keep_params_in_input=True) |
Member
There was a problem hiding this comment.
check_correctness already uses keep_params_in_input=True. Maybe call from_onnx(make_model("initializer")) here to cover the default path from the issue?
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.
Hi Committers,
This PR fixes issue #20888. Any suggestions would be greatly appreciated.
Root Cause
The ONNX
MaxUnpoolconverter buildstotal_output_shapeas a NumPy array when the optional third inputoutput_shapeis absent. Whenoutput_shapeis provided, the converter assigned the Ralex expression directly: total_output_shape = output_shape That value is aGenericConst(or arelax.Varwhenkeep_params_in_input=True), not a NumPy array. The followingrelax.ShapeExpr(total_output_shape.tolist())then fails with: AttributeError: 'GenericConst' object has no attribute 'tolist'Solution
In the
output_shapebranch ofMaxUnpool._impl_v9:get_constant(output_shape, params), the same helper other converters (Reshape, Tile, Resize, ...) use to read constant inputs.int64NumPy array, so both paths produce the same type and.tolist()/ShapeExprwork unchanged.output_shapeis not a constant (e.g., a graph input), raise an explicitValueErrorinstead of an opaqueAttributeError, sinceShapeExprneeds static values.