Validate Resize scale counts before copying (#32722)
This pull request improves the validation logic for the `scales` input
in the `Upsample` and `Resize` operators and adds new tests to ensure
correct error handling when the number of elements in `scales` does not
match the expected rank. The changes enforce stricter input validation
and expand test coverage for these edge cases.
**Input validation improvements:**
* Refactored the validation logic in `UpsampleBase`
(`onnxruntime/core/providers/cpu/tensor/upsamplebase.h`) to ensure that
the number of elements in the `scales` input matches the tensor rank
(when `axes` is not provided) or the number of axes (when `axes` is
provided), and moved the resizing and copying of `scales` after
validation.
[[1]](diffhunk://#diff-af2a5df3321843b2a5a1dab773b49f4627645d5c9cc9c02c54dc46b254b5bd39L596-R614)
[[2]](diffhunk://#diff-af2a5df3321843b2a5a1dab773b49f4627645d5c9cc9c02c54dc46b254b5bd39L622)
**Test coverage enhancements:**
* Added a test to `resize_op_test.cc`
(`ResizeOpTest.Scales_CountMismatch_13`) that verifies the operator
fails when the `scales` input size does not match the tensor rank,
ensuring the correct error message is returned.
* Added a test to `upsample_op_test.cc`
(`UpsampleOpTest.UpsampleOpScalesCountMismatch_opset9`) that checks for
failure when the `scales` input size does not match the expected rank,
validating that the error is properly handled and reported.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>