Fix FPE issue in external Eigen source code issue with `tf.raw_ops.SparseMatMul`.
PiperOrigin-RevId: 370992919
Change-Id: Icfb276fef5fb40928b27c3e44608d2aca72c9fd7
diff --git a/tensorflow/core/kernels/sparse_matmul_op.cc b/tensorflow/core/kernels/sparse_matmul_op.cc
index f574785..a02afaf 100644
--- a/tensorflow/core/kernels/sparse_matmul_op.cc
+++ b/tensorflow/core/kernels/sparse_matmul_op.cc
@@ -1039,6 +1039,10 @@
if (transpose_b) {
// TODO(agarwal): avoid transposing the matrix here and directly handle
// transpose in CreateDenseSlices.
+ OP_REQUIRES(ctx, right->dim_size(0) != 0,
+ errors::InvalidArgument("b has an entry 0 in it's shape."));
+ OP_REQUIRES(ctx, right->dim_size(1) != 0,
+ errors::InvalidArgument("b has an entry 0 in it's shape."));
right_tr.reset(
new Tensor(right->dtype(),
TensorShape({right->dim_size(1), right->dim_size(0)})));