Visitar URL original
[Optimizer] Fold Shape -> {Slice, Gather} -> Concat -> Reshape · Issue #2736 · microsoft/onnxscript · GitHub
Skip to content

[Optimizer] Fold Shape -> {Slice, Gather} -> Concat -> Reshape #2736

Description

In Shape -> {Slice, Gather} -> Concat -> Reshape, when the dynamic axis coming from Shape is a single axis and the rest of the dimensions are not -1, we can replace the shape for Reshape to have a static -1 axis, and eliminate the nodes for dynamic shape evaluation.

Activity

  1. P-Mahi10 commented on Jan 14, 2026

    @P-Mahi10

    Hi, I’m planning to work on this and will submit a PR.

  2. OYCN commented on Jun 24, 2026

    @OYCN

    On our side, we handle the Shape -> {Slice, Gather} -> {AnyOp} -> Concat -> Reshape pattern using the following passes, as long as there is only one dynamic dimension.

    One thing worth noting is that the {AnyOp} stage is often present in real-world models, so supporting it can significantly improve the coverage of this optimization.

    PassManager:
      `const_folding & shape_inference` 
      `fuse_shape_gather`,
      `fuse_shape_slice`,
      `const_folding & shape_inference ` 
      `fuse_concat_reshape`,
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions