File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
tensorflow/core/kernels/linalg Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,9 @@ class MatrixDiagPartOp : public OpKernel {
7373 errors::InvalidArgument (
7474 " diag_index must be a scalar or vector, received shape: " ,
7575 diag_index.shape ().DebugString ()));
76+ OP_REQUIRES (context, diag_index.NumElements () > 0 ,
77+ errors::InvalidArgument (
78+ " Expected diag_index to have at least 1 element" ));
7679 lower_diag_index = diag_index.flat <int32>()(0 );
7780 upper_diag_index = lower_diag_index;
7881 if (TensorShapeUtils::IsVector (diag_index.shape ())) {
@@ -179,6 +182,9 @@ class MatrixDiagOp : public OpKernel {
179182 errors::InvalidArgument (
180183 " diag_index must be a scalar or vector, received shape: " ,
181184 diag_index.shape ().DebugString ()));
185+ OP_REQUIRES (context, diag_index.NumElements () > 0 ,
186+ errors::InvalidArgument (
187+ " Expected diag_index to have at least 1 element" ));
182188 lower_diag_index = diag_index.flat <int32>()(0 );
183189 upper_diag_index = lower_diag_index;
184190 if (TensorShapeUtils::IsVector (diag_index.shape ())) {
You can’t perform that action at this time.
0 commit comments