Improve checks in concat_slice_elimination against optional attrs and unsqueeze_elimination against invalid model (#27638)
This pull request introduces improvements to the
`concat_slice_elimination` and `unsqueeze_elimination` optimizer passes,
focusing on correctness, robustness, and code clarity. The changes
include enhanced handling of optional Slice operator attributes,
stricter validation of axes and steps, and improved error handling for
invalid model inputs.
Improvements to `concat_slice_elimination`:
* Materialized default values for optional `axes` and `steps` in the
Slice operator, ensuring safe indexing and alignment with ONNX defaults.
(`onnxruntime/core/optimizer/concat_slice_elimination.cc`)
* Refined the fusion pattern to only allow `starts.size() == 1`,
clarifying the scope of the optimization and preventing incorrect
fusions. (`onnxruntime/core/optimizer/concat_slice_elimination.cc`)
* Added `<numeric>` include to support new code using `std::iota`.
(`onnxruntime/core/optimizer/concat_slice_elimination.cc`)
Improvements to `unsqueeze_elimination`:
* Added validation for axes values, including range checks and detection
of duplicate axes, returning errors for invalid models instead of
silently proceeding.
(`onnxruntime/core/optimizer/unsqueeze_elimination.cc`)
* Added `core/providers/common.h` include for utility functions used in
validation. (`onnxruntime/core/optimizer/unsqueeze_elimination.cc`)