Skip to content

onnxruntime optimizers fails #22512

Closed

Description

Describe the issue

The attached model succeeds when onnxruntime optimization are disabled, and fails when all of them are.

  File "onnxruntime/capi/onnxruntime_inference_collection.py", line 491, in _create_inference_session
    sess.initialize_session(providers, provider_options, disabled_optimizers)
onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Node (MatMulBnFusion_Gemm) Op (Gemm) [ShapeInferenceError] First input does not have rank 2

model_levit_128-onnx_dynamo-ir-d0rt0.zip

To reproduce

import onnxruntime
onnxruntime.InferenceSession("<model.onnx>", providers=["CUDAExecutionProvider", "CPUExecutionProvider"])

Urgency

No response

Platform

Linux

OS Version

ubuntu-22.04

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

7880342

ONNX Runtime API

Python

Architecture

X64

Execution Provider

CUDA

Execution Provider Library Version

CUDA 11.8

Activity

  1. xadupre commented on Nov 6, 2024

    @xadupre
    MemberAuthor

    The issue is here: https://github.com/microsoft/onnxruntime/blob/main/onnxruntime/core/optimizer/matmul_bn_fusion.cc#L207. A Gemm operator is introduced to fuse Add(MatMul(X,Y), Z) into Gemm(X,Y,Z). In my case, it fails because rank(X) == 3 and rank(Y) == 2 which is not allowed by this kernel.

  2. added a commit that references this issue on Nov 11, 2024
    1f3b675
  3. added a commit that references this issue on Dec 2, 2024
    eec92d1
  4. added 2 commits that reference this issue on Dec 11, 2024
    3d0b366
    1df1f04
  5. added a commit that references this issue on Jun 22, 2025
    9e15cc4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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