Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix EinsumHelper::ParseEquation to avoid uninitialized accesses.
EinsumHelper::ParseEquation is supposed to return true or false in
input_has_ellipsis and output_has_ellipsis to indicate whether there is
ellipsis in the inputs and output. Previously, when there is no ellipsis in the
inputs or output, the routine doesn't assign false to the variables. This
change initializes the two variables with false to fix the problem.
PiperOrigin-RevId: 391772004
Change-Id: I17b6c88aadef4131470378e48cced054bf252e86
  • Loading branch information
bixia1 authored and tensorflower-gardener committed Aug 19, 2021
1 parent a81f78d commit f09caa5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tensorflow/core/kernels/linalg/einsum_op_impl.h
Expand Up @@ -153,6 +153,7 @@ struct EinsumHelper {
input_has_ellipsis->resize(num_inputs);
for (int i = 0; i < num_inputs; ++i) {
input_label_counts->at(i).resize(num_labels);
input_has_ellipsis->at(i) = false;
for (const int label : input_labels->at(i)) {
if (label != kEllipsisLabel)
input_label_counts->at(i)[label] += 1;
Expand All @@ -161,6 +162,7 @@ struct EinsumHelper {
}
}
output_label_counts->resize(num_labels);
*output_has_ellipsis = false;
for (const int label : *output_labels) {
if (label != kEllipsisLabel)
output_label_counts->at(label) += 1;
Expand Down

0 comments on commit f09caa5

Please sign in to comment.