add runtime symbol resolution op#5085
Open
shivadbhavsar wants to merge 9 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new resolve_sym_expr runtime operator to evaluate symbolic dimension expressions from concrete runtime dimension values, enabling dynamic-shape lowering patterns (e.g., feeding symbolic slice bounds as runtime inputs).
Changes:
- Added
op::resolve_sym_expr(reflected attributesexprs/symbols) that returns a tuple of evaluated int64 scalars. - Added reference and shape tests for
resolve_sym_expr, plus an integration-style ref test demonstrating use with dynamic multi-inputslice. - Registered the new operator in the build system.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/include/migraphx/op/resolve_sym_expr.hpp |
New operator implementation for runtime symbol expression evaluation. |
src/CMakeLists.txt |
Registers resolve_sym_expr in register_migraphx_ops(). |
test/ref/resolve_sym_expr.cpp |
New ref tests covering single/multi-symbol evaluation behavior. |
test/op_shape_test.cpp |
New shape tests (valid shape + bad input arity) for the operator. |
test/ref/slice.cpp |
New ref test demonstrating resolve_sym_expr feeding a runtime slice bound. |
Check flagged results 🔆 * No develop baseline was found for this PR's branch point; compared against the latest available develop run instead. |
|
pfultz2
reviewed
Jul 22, 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.
Motivation
For dynamic shapes, the runtime needs to be able to evaluate symbols using concrete input dimensions to be able to compute dynamic ops (eg. slice)
Technical Details
Attributes (
std::vector<sym::expr>, reflected directly):expressions— symbolic expressions to evaluate.Inputs: one tensor whose original compile-time shape contains the referenced root symbols as direct dimensions.
At runtime, each direct symbolic dimension is bound to the corresponding concrete input lens:
Output: one packed
int64vector of shape{expressions.size()}. Elementiiseval(expressions[i]), unclamped.Implementation:
compute_shaperequires one input, verifies every referenced root symbol appears as a direct input dimension, and returnsint64_type, {expressions.size()}.computereads the original input shape fromdyn_output::input_shapesand the concrete dimensions from the runtime argument shape.eval_uint.Restriction: compound input dimensions are not inverted. For example, an input dimension
N/2cannot be used to recoverN;Nmust appear directly on an input axis.Example:
expressions=[N, H/2, W/2], compile-time input{N,3,H,W}, runtime input{7,3,10,12}→[7,5,6].Usage
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot ApplicableFollow the LLVM AI Tool Use Policy for contributions using AI.