@@ -43,10 +43,14 @@ static inline void CheckScoreSizes(OpKernelContext* context, int num_boxes,
4343 const Tensor& scores) {
4444 // The shape of 'scores' is [num_boxes]
4545 OP_REQUIRES (context, scores.dims () == 1 ,
46- errors::InvalidArgument (" scores must be 1-D" ,
47- scores.shape ().DebugString ()));
48- OP_REQUIRES (context, scores.dim_size (0 ) == num_boxes,
49- errors::InvalidArgument (" scores has incompatible shape" ));
46+ errors::InvalidArgument (
47+ " scores must be 1-D" , scores.shape ().DebugString (),
48+ " (Shape must be rank 1 but is rank " , scores.dims (), " )" ));
49+ OP_REQUIRES (
50+ context, scores.dim_size (0 ) == num_boxes,
51+ errors::InvalidArgument (" scores has incompatible shape (Dimensions must "
52+ " be equal, but are " ,
53+ num_boxes, " and " , scores.dim_size (0 ), " )" ));
5054}
5155
5256static inline void ParseAndCheckOverlapSizes (OpKernelContext* context,
@@ -67,11 +71,14 @@ static inline void ParseAndCheckBoxSizes(OpKernelContext* context,
6771 const Tensor& boxes, int * num_boxes) {
6872 // The shape of 'boxes' is [num_boxes, 4]
6973 OP_REQUIRES (context, boxes.dims () == 2 ,
70- errors::InvalidArgument (" boxes must be 2-D" ,
71- boxes.shape ().DebugString ()));
74+ errors::InvalidArgument (
75+ " boxes must be 2-D" , boxes.shape ().DebugString (),
76+ " (Shape must be rank 2 but is rank " , boxes.dims (), " )" ));
7277 *num_boxes = boxes.dim_size (0 );
7378 OP_REQUIRES (context, boxes.dim_size (1 ) == 4 ,
74- errors::InvalidArgument (" boxes must have 4 columns" ));
79+ errors::InvalidArgument (" boxes must have 4 columns (Dimension "
80+ " must be 4 but is " ,
81+ boxes.dim_size (1 ), " )" ));
7582}
7683
7784static inline void CheckCombinedNMSScoreSizes (OpKernelContext* context,
@@ -670,12 +677,16 @@ class NonMaxSuppressionV3Op : public OpKernel {
670677 OP_REQUIRES (
671678 context, TensorShapeUtils::IsScalar (max_output_size.shape ()),
672679 errors::InvalidArgument (" max_output_size must be 0-D, got shape " ,
673- max_output_size.shape ().DebugString ()));
680+ max_output_size.shape ().DebugString (),
681+ " (Shape must be rank 0 but is " , " rank " ,
682+ max_output_size.dims (), " )" ));
674683 // iou_threshold: scalar
675684 const Tensor& iou_threshold = context->input (3 );
676685 OP_REQUIRES (context, TensorShapeUtils::IsScalar (iou_threshold.shape ()),
677686 errors::InvalidArgument (" iou_threshold must be 0-D, got shape " ,
678- iou_threshold.shape ().DebugString ()));
687+ iou_threshold.shape ().DebugString (),
688+ " (Shape must be rank 0 but is rank " ,
689+ iou_threshold.dims (), " )" ));
679690 const T iou_threshold_val = iou_threshold.scalar <T>()();
680691 OP_REQUIRES (context,
681692 iou_threshold_val >= static_cast <T>(0.0 ) &&
0 commit comments