Skip to content

Fix dynamic-shape parse failure in Softplus and Softsign - #5136

Open
zhihuidu-amd wants to merge 3 commits into
ROCm:developfrom
zhihuidu-amd:fix-softplus-softsign-dynamic-shape
Open

Fix dynamic-shape parse failure in Softplus and Softsign#5136
zhihuidu-amd wants to merge 3 commits into
ROCm:developfrom
zhihuidu-amd:fix-softplus-softsign-dynamic-shape

Conversation

@zhihuidu-amd

Copy link
Copy Markdown

parse_softplus and parse_softsign build their broadcast literal with

multibroadcast{"out_lens", args[0]->get_shape().lens()}

and shape::lens() throws for a dynamic shape, so parsing any ONNX model containing Softplus or Softsign aborts with

shape.cpp: lens: SHAPE: lens() called on a dynamic shape

as soon as an input dimension has min != max. A fixed dynamic dimension ({n,n}) does not reproduce it; a range as narrow as {95,96} does.

Both parsers now use add_common_op, whose documented purpose is exactly this ("use add_common_op() to match input sizes when inputs may be either static or dynamic"). parse_binary_op.cpp has the same multibroadcast pattern but guards it with an explicit MIGRAPHX_THROW, so these two were the outliers.

For static shapes the emitted graph is op-for-op identical; only the instruction order changes, since the broadcast is now inserted next to the add that consumes it rather than ahead of the exp/abs. The four existing softplus/softsign tests construct their expected program by hand and compare with EXPECT(p == prog), which is order-sensitive, so they are reordered to match. No behaviour change.

Adds softplus_dyn_test and softsign_dyn_test, which parse the existing .onnx fixtures with map_dyn_input_dims set to a non-fixed range - the case that fails today and had no coverage. They reuse the existing fixtures, and test/onnx/CMakeLists.txt globs parse/*.cpp, so no new data files or build changes are needed.

Motivation

Technical Details

Changelog Category

Add a CHANGELOG.md entry for any option other than Not Applicable

    • Added: New functionality.
    • Changed: Changes to existing functionality.
    • Removed: Functionality or support that has been removed. (Compared to a previous release)
    • Optimized: Component performance that has been optimized or improved.
    • Resolved Issues: Known issues from a previous version that have been resolved.
    • Not Applicable: This PR is not to be included in the changelog.

Follow the LLVM AI Tool Use Policy for contributions using AI.

parse_softplus and parse_softsign build their broadcast literal with

    multibroadcast{"out_lens", args[0]->get_shape().lens()}

and shape::lens() throws for a dynamic shape, so parsing any ONNX model
containing Softplus or Softsign aborts with

    shape.cpp: lens: SHAPE: lens() called on a dynamic shape

as soon as an input dimension has min != max. A fixed dynamic dimension
({n,n}) does not reproduce it; a range as narrow as {95,96} does.

Both parsers now use add_common_op, whose documented purpose is exactly
this ("use add_common_op() to match input sizes when inputs may be either
static or dynamic"). parse_binary_op.cpp has the same multibroadcast
pattern but guards it with an explicit MIGRAPHX_THROW, so these two were
the outliers.

For static shapes the emitted graph is op-for-op identical; only the
instruction order changes, since the broadcast is now inserted next to
the add that consumes it rather than ahead of the exp/abs. The four
existing softplus/softsign tests construct their expected program by
hand and compare with EXPECT(p == prog), which is order-sensitive, so
they are reordered to match. No behaviour change.

Adds softplus_dyn_test and softsign_dyn_test, which parse the existing
.onnx fixtures with map_dyn_input_dims set to a non-fixed range - the
case that fails today and had no coverage. They reuse the existing
fixtures, and test/onnx/CMakeLists.txt globs parse/*.cpp, so no new
data files or build changes are needed.
@zhihuidu-amd
zhihuidu-amd requested a review from causten as a code owner August 14, 2026 20:13
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Since this is an external pull request, a maintainer must review PR and add the "ok-to-test" label if it is approved for testing.

The licensing CI check requires every modified file to carry the current
year in its copyright stamp, and reported:

    8 Wrong year in license files

The two parsers were stamped 2015-2022 and the four existing tests
2015-2023; the two new tests inherited 2022 from the file they were
copied from. All eight now read 2015-2026.

Verified with the repository's own checker, tools/check_stamped.py, which
now reports that all files are properly stamped.

No functional change - this touches only the copyright line in each file.
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5136      +/-   ##
===========================================
+ Coverage    93.12%   93.13%   +0.01%     
===========================================
  Files          625      625              
  Lines        33162    33246      +84     
===========================================
+ Hits         30879    30961      +82     
- Misses        2283     2285       +2     
Files with missing lines Coverage Δ
src/onnx/parse_softplus.cpp 100.00% <100.00%> (ø)
src/onnx/parse_softsign.cpp 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhihuidu-amd

Copy link
Copy Markdown
Author

CI status after the latest push, in case it helps whoever picks this up: 17 checks pass, 3 fail, and I don't believe any of the three is caused by this change. Details so you can judge rather than take my word for it.

licensing — was a real failure, now fixed. The first push had the original copyright years (2015-2022 on the two parsers, 2015-2023 on the four existing tests), and the check correctly reported 8 Wrong year in license files. The second commit updates all eight to 2015-2026, verified with the repo's own tools/check_stamped.py ("Success: All files properly stamped"). That check is now green.

Jenkins — network failure in the status callback, not a build failure. The reported error is:

Error in sh step: curl -s -L ... "https://api.github.com/repos/ROCm/AMDMIGraphX/commits//status"
script returned exit code 6
curl exit 6 is "couldn't resolve host". Every Jenkins job that managed to report a verdict passed — All Targets Release, Clang ASAN, Clang libstdc++ Debug, HIP Clang Release, HIP Clang Static, HIP Clang Release Navi32 and Navi4x, MLIR Debug, Check image. HIP RTC Debug is the only one without a recorded result. On the previous head the same job failed while POSTing {"state":"success"}, which points the same way.

windows-gpu — Chocolatey could not serve Visual Studio Build Tools.

Failed to fetch results from V2 feed at 'https://community.chocolatey.org/api/v2/Packages(Id='visualstudio2022buildtools',...)'
##[error]Could not setup Developer Command Prompt: Microsoft Visual Studio not found
The runner never got a compiler installed, so nothing in this PR was built there.

security_gate — expected. Missing 'ok-to-test' label; BLOCKED, the standard gate for an external contributor. This is what mergeable_state: blocked reflects.

I'm deliberately not pushing empty commits to re-trigger CI, since a new commit drops the ok-to-test label and would only add churn. If a maintainer adds the label, the remaining jobs should re-run and the two infrastructure failures will most likely clear on their own.

One thing worth repeating from the PR description, since it is the weakest part of the evidence: the 827-test ONNX suite run was executed against tag rocm-7.2.0, not against develop. I could not rebuild on develop locally — it needs a newer rocm-cmake than the ROCm available to me (Unknown CMake command "rocm_add_version_resource"). I checked transfer by inspection instead: all six modified files are byte-identical between the two revisions, and add_common_op's implementation is unchanged. The develop CI here is therefore the first real test of this patch on this base, and I'd rather flag that than have it assumed.

@CharlieL7 CharlieL7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look OK. There are a lot of unnecessary comments throughout the PR that should be made more terse or removed. I added comments for a few of them but there are more. Please update the comments.
What is the model that is hitting Softplus or Softsign with dynamic shapes? Also what type of dynamic shape. Dynamic batch for example?

Comment thread src/onnx/parse_softsign.cpp Outdated
Comment thread src/onnx/parse_softplus.cpp Outdated
Comment thread test/onnx/parse/softplus_nd_test.cpp Outdated
Remove the explanatory comments CharlieL7 flagged and the others of the same
kind. No code changes - only comments were touched.

Kept: the two pre-existing formula comments that were in the parsers before
this PR, and one line per new regression test naming what regressed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants