onnxruntime
f537be06 - Validate NCHWc binary input ranks (#33060)

Commit
38 days ago
Validate NCHWc binary input ranks (#33060) This pull request improves the robustness of the NCHWc optimizer by ensuring that binary operations are only transformed when all input tensors have the expected rank (number of dimensions). It also adds a new test to verify this behavior. **NCHWc optimizer robustness:** * Updated `TransformBinary` in `nchwc_transformer.cc` to check that all input tensors have the expected number of dimensions (`kNchwcDims`) before proceeding with transformation, preventing incorrect transformations on tensors with unexpected rank. * Fixed usage of shape variables in the dimension comparison logic to avoid referencing potentially uninitialized pointers. **Testing improvements:** * Added a new test case `BinaryInputsWithUnexpectedRankAreNotTransformed` in `nchwc_optimizer_test.cc` to ensure that binary operations with inputs of unexpected rank are not transformed by the optimizer. The test verifies that the `Add` operation remains in the graph when input ranks do not match expectations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Author
Parents
Loading