onnxruntime
1b1d1e4d - Skip MatMulAdd reshaping for zero-sized dimensions (#33766)

Commit
8 days ago
Skip MatMulAdd reshaping for zero-sized dimensions (#33766) ### Description MatMulAddFusion inserts reshapes when converting non-matrix MatMul inputs to Gemm. For an input such as `[2, 0, 4]`, its `[0, 4]` reshape target copies the first input dimension instead of preserving the zero extent, so a valid empty MatMul + Add fails during execution. Skip the reshape-based fusion when the flattened row count, reduction dimension, or output column count is zero. Ordinary nonempty fusion and the rank-2 path are unchanged. The regression tests cover zero M/K/N, rank-1/3/4 inputs, and opsets 7/13/14/18, with nonempty controls that still fuse. ### Motivation and Context Fixes #33245. Validation on Windows x64, Release CPU build: - The empty-dimension regression fails before the fix and passes after it; nonempty controls pass in both versions. - All 35 MatMulAddFusion/ReshapeFusion tests pass. - GraphTransformationTests: 453 passed, 33 skipped, one failure in `SimplifiedLayerNormFusionPreservesIntegerToFloatCastEpsilon`, also reproduced on the unmodified base commit `b5fe413d`. - Lintrunner and `git diff --check` pass.
Author
Parents
Loading