You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Kernel] Fix bug in Einsum implementation when a lone operand had a reduction operation (#27225)
### Description
When the lone operand had a reduction operation in Einsum, there was a
mis-management in the shape which led to a mis-match in terms of the
subscript indices in the output as deciphered from the Einsum equation
and the rank of the candidate output being produced after the reduction
operation which caused issues while finalizing the output of the Einsum
op.
This change fixes the bug and adds a test
### Motivation and Context
Resolve#18654
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@@ -419,9 +427,9 @@ Status EinsumTypedComputeProcessor<T>::Run() {
419
427
// Keep processing each input pair-wise
420
428
for (int input = 1; input < num_inputs; ++input) {
421
429
TensorShapeVector reduced_dims;
422
-
reduced_dims.reserve(onnxruntime::narrow<size_t>(num_subscript_labels)); // num_subscript_labels is the upper bound. No harm in over-reserving by a small margin.
423
-
for (int64_t dim = 0; dim < num_subscript_labels; ++dim) {
424
-
if (mapped_indices_to_last_input_index[onnxruntime::narrow<size_t>(dim)] == input) {
430
+
reduced_dims.reserve(num_subscript_labels); // num_subscript_labels is the upper bound. No harm in over-reserving by a small margin.
431
+
for (size_t dim = 0; dim < num_subscript_labels; ++dim) {
432
+
if (mapped_indices_to_last_input_index[dim] == input) {
425
433
// This is the last input we are seeing this dimension (and it doesn't occur in the output), so reduce along the dimension
0 commit comments