Skip to content

Tier-0: partition on dynamic shapes; materialize passthrough graph outputs - #88

Open
KenLagos wants to merge 1 commit into
mainfrom
dynamic_shape_partition_fusion
Open

Tier-0: partition on dynamic shapes; materialize passthrough graph outputs#88
KenLagos wants to merge 1 commit into
mainfrom
dynamic_shape_partition_fusion

Conversation

@KenLagos

Copy link
Copy Markdown
Collaborator

Restructure Tier-0 fusion so shape-static islands inside dynamic-shape graphs get fused, matching how ORT partitions detection/NMS models.

Refactor GetCapability into three phases:

  1. Resolve shapes to a fixpoint (graph-wide TryTranslateNodes forward propagation) before any claiming, so grouping can see recovered shapes.
  2. Shape-aware grouping in a single pass: dynamic shape is now a partition boundary alongside CPU-preferred / unsupported / no-translator, using the existing HasDynamicShape.
  3. Claim each resulting static group once.

Materialize a shape-only passthrough (Reshape/Squeeze/Unsqueeze/Flatten) as a real ELEMENT_WISE_IDENTITY in both Compile and TryCompilePartition when its output is a partition output, since an elided alias has no DML node to source its output edge. Mirrors ORT's DmlOperatorCopy.

Preserve true tensor rank through the fused-graph shape-reporting path so a scalar output is reported as [] rather than the 4D-padded [1,1,1,1], which changed downstream ONNX broadcast semantics. Three sites:

  • TranslateShapeOnly carries original_rank onto its output tensor.
  • Compile output_dims distinguishes a reported rank (incl. 0/scalar) from missing shape info via a rank_known flag.
  • ExportDims writes unpadded dims into resolved_shapes so a scalar does not round-trip back as rank 4.

…tputs

Restructure Tier-0 fusion so shape-static islands inside dynamic-shape
graphs get fused, matching how ORT partitions detection/NMS models.

Refactor GetCapability into three phases:
  1. Resolve shapes to a fixpoint (graph-wide TryTranslateNodes forward
     propagation) before any claiming, so grouping can see recovered shapes.
  2. Shape-aware grouping in a single pass: dynamic shape is now a partition
     boundary alongside CPU-preferred / unsupported / no-translator, using
     the existing HasDynamicShape.
  3. Claim each resulting static group once.

Materialize a shape-only passthrough (Reshape/Squeeze/Unsqueeze/Flatten) as
a real ELEMENT_WISE_IDENTITY in both Compile and TryCompilePartition when its
output is a partition output, since an elided alias has no DML node to source
its output edge. Mirrors ORT's DmlOperatorCopy.

Preserve true tensor rank through the fused-graph shape-reporting path so a
scalar output is reported as [] rather than the 4D-padded [1,1,1,1], which
changed downstream ONNX broadcast semantics. Three sites:
  - TranslateShapeOnly carries original_rank onto its output tensor.
  - Compile output_dims distinguishes a reported rank (incl. 0/scalar) from
    missing shape info via a rank_known flag.
  - ExportDims writes unpadded dims into resolved_shapes so a scalar does not
    round-trip back as rank 4.

Regression suite passes; small net perf gain overall.
@KenLagos KenLagos self-assigned this Aug 14, 2026
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.

1 participant