diff --git a/tensorflow/core/kernels/sparse_dense_binary_op_shared.cc b/tensorflow/core/kernels/sparse_dense_binary_op_shared.cc index ac48202ada2..3a6b66302f7 100644 --- a/tensorflow/core/kernels/sparse_dense_binary_op_shared.cc +++ b/tensorflow/core/kernels/sparse_dense_binary_op_shared.cc @@ -88,12 +88,11 @@ class SparseDenseBinaryOpShared : public OpKernel { const auto rhs_dims = BCast::FromShape(dense_t->shape()); BCast b(lhs_dims, rhs_dims, false); // false for keeping the same num dims. - // True iff (size(lhs) > size(rhs)), or (sizes equal, lhs cwise rhs). + // True iff (size(lhs) >= size(rhs)) and all dims in lhs is smaller or equal to dims in rhs (from right to left). auto VecGreaterEq = [](ArraySlice lhs, ArraySlice rhs) { - if (lhs.size() > rhs.size()) return true; if (lhs.size() < rhs.size()) return false; - for (size_t i = 0; i < lhs.size(); ++i) { - if (lhs[i] < rhs[i]) return false; + for (size_t i = 0; i < rhs.size(); ++i) { + if (lhs[lhs.size() - 1 - i] < rhs[rhs.size() - 1 - i]) return false; } return true; };