Skip to content

NHWC layout transformation skips layout-sensitive ops when input rank is unavailable in dynamic-shape models #27912

@alex-spacemit

Description

@alex-spacemit

Describe the issue

Summary

For NHWC-capable execution providers, layout transformation in ONNX Runtime currently depends too heavily on input tensor shape information to determine rank for layout-sensitive operators. In complex dynamic-shape models, input rank is often unavailable from ValueInfo during optimization, causing layout transformation analysis to skip eligible nodes even when their spatial rank could be derived from operator attributes.

Problem

The current behavior is too restrictive for convolution and pooling related operators. For ops such as Conv, ConvTranspose, MaxPool, and AveragePool, the spatial rank is often already encoded in attributes like kernel_shape, strides, dilations, pads, output_padding, or output_shape. However, when input rank is missing from ValueInfo, layout transformation cannot proceed and the node is skipped.

This makes NHWC conversion fragile for models with dynamic or partially inferred shapes, where shape information is commonly incomplete during optimization.

Affected operators

  • Conv
  • ConvTranspose
  • ConvInteger
  • QLinearConv
  • FusedConv
  • AveragePool
  • LpPool
  • MaxPool
  • MaxUnpool
  • QLinearAveragePool

To reproduce

#27908 I’ve tried to resolve this via this PR

Urgency

No response

Platform

Linux

OS Version

24.04

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

318a251

ONNX Runtime API

C++

Architecture

X64

Execution Provider

Other / Unknown

Execution Provider Library Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions