onnxruntime
0da10ef2 - Validate MatMulFpQ4 shape inputs (#32032)

Commit
1 day ago
Validate MatMulFpQ4 shape inputs (#32032) This pull request strengthens shape inference and input validation for the `MatMulFpQ4` operator and adds new unit tests to ensure invalid input shapes are properly rejected. The main focus is on improving error handling and making the code more robust against malformed inputs. **Shape inference and validation improvements:** * Added checks to ensure all relevant input tensors (`A`, `B`, and `B_shape`) have shapes before proceeding with shape inference in `matmulQ4ShapeInference` (`contrib_defs.cc`). * Improved validation for the `B` input to require it to be a 1-D tensor with a known, non-negative size, and for the `B_shape` input to require it to be a 1-D int64 tensor of length 2 (`contrib_defs.cc`). * Added a check to ensure the `B_shape` initializer contains exactly two int64 values before using its data (`contrib_defs.cc`). * Fixed the validation for the packed `B` tensor to correctly check its size against the expected pack size, removing an incorrect logical condition (`contrib_defs.cc`). **Unit test additions:** * Added new negative tests in `matmul_fpq4_test.cc` to verify that invalid input shapes for `B` and `B_shape` are properly rejected, including cases for scalar and short initializers.
Author
Parents
Loading