Skip to content

Add dynamic shape support for ONNX Conv to Linalg lowering#3388

Open
kimm240 wants to merge 2 commits intoonnx:mainfrom
kimm240:feature/conv-dynamic
Open

Add dynamic shape support for ONNX Conv to Linalg lowering#3388
kimm240 wants to merge 2 commits intoonnx:mainfrom
kimm240:feature/conv-dynamic

Conversation

@kimm240
Copy link
Contributor

@kimm240 kimm240 commented Feb 10, 2026

Changes

  • Added IndexExprBuilderForLinalg
  • Integrated ShapeHelper for dynamic shape computation
  • Enhanced tensor::EmptyOp creation

Testing

  • Added conv_dynamic test case in test/mlir/conversion/onnx_to_linalg/NN/Conv.mlir
    • Tests dynamic input shapes: tensor<?x3x?x?xf32>
    • Verifies dynamic output shapes: tensor<?x2x?x?xf32>
    • Checks that tensor.dim, affine.apply, and tensor.empty with dynamic sizes are generated correctly

Example

Before (static only):

func.func @conv(%arg0: tensor<1x3x5x5xf32>, %arg1: tensor<2x3x3x3xf32>)
    -> tensor<1x2x3x3xf32> {
  %0 = tensor.empty() : tensor<1x2x3x3xf32>
  // ...
}

After (dynamic support):

func.func @conv(%arg0: tensor<?x3x?x?xf32>, %arg1: tensor<2x3x3x3xf32>)
    -> tensor<?x2x?x?xf32> {
  %dim0 = tensor.dim %arg0, %c0 : tensor<?x3x?x?xf32>
  %dim2 = tensor.dim %arg0, %c2 : tensor<?x3x?x?xf32>
  %out_h = affine.apply #map(%dim2)
  %dim3 = tensor.dim %arg0, %c3 : tensor<?x3x?x?xf32>
  %out_w = affine.apply #map1(%dim2, %dim3)
  %0 = tensor.empty(%dim0, %out_h, %out_w) : tensor<?x2x?x?xf32>
  // ...
}

Related

Hyun Gyu Kim added 2 commits February 10, 2026 11:12
1
Signed-off-by: Hyun Gyu Kim <kimm240@telepix.net>
Signed-off-by: Hyun Gyu Kim <kimm240@telepix.net>
@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

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