message: check if boxes have logical coordinates (different than a line or a point)
diff: @@ -39,6 +39,17 @@ namespace {
  typedef Eigen::ThreadPoolDevice CPUDevice;
  +// This function checks that all boxes have coherant ccordinates
  +template <typename T>
  +bool CheckBoxesCoordinates(const Tensor& boxes, int num_boxes){
  + typename TTypes<T, 2>::ConstTensor boxes_data = boxes.tensor<T, 2>();
  + for(int i=0; i<num_boxes; ++i){
  + if(boxes_data(i, 0) == boxes_data(i, 2) || boxes_data(i, 1) == boxes_data(i, 3))
  + return (false);
  + }
  + return (true);
  +}
  +
  static inline void CheckScoreSizes(OpKernelContext* context, int num_boxes,
  const Tensor& scores) {
  // The shape of 'scores' is [num_boxes]
  @@ -522,6 +533,8 @@ class NonMaxSuppressionOp : public OpKernel {
  int num_boxes = 0;
  ParseAndCheckBoxSizes(context, boxes, &num_boxes);
  CheckScoreSizes(context, num_boxes, scores);
  + // check if the boxes have logical coordinates
  + OP_REQUIRES(context, CheckBoxesCoordinates<float>(boxes, num_boxes), errors::InvalidArgument("boxes coordinates shouldn't have x1=x2 or y1=y2"));
  if (!context->status().ok()) {
  return;
  }
  @@ -569,6 +582,8 @@ class NonMaxSuppressionV2Op : public OpKernel {
  int num_boxes = 0;
  ParseAndCheckBoxSizes(context, boxes, &num_boxes);
  CheckScoreSizes(context, num_boxes, scores);
  + // check if the boxes have logical coordinates
  + OP_REQUIRES(context, CheckBoxesCoordinates<T>(boxes, num_boxes), errors::InvalidArgument("boxes coordinates shouldn't have x1=x2 or y1=y2"));
  if (!context->status().ok()) {
  return;
  }
  @@ -620,6 +635,8 @@ class NonMaxSuppressionV3Op : public OpKernel {
  int num_boxes = 0;
  ParseAndCheckBoxSizes(context, boxes, &num_boxes);
  CheckScoreSizes(context, num_boxes, scores);
  + // check if the boxes have logical coordinates
  + OP_REQUIRES(context, CheckBoxesCoordinates<T>(boxes, num_boxes), errors::InvalidArgument("boxes coordinates shouldn't have x1=x2 or y1=y2"));
  if (!context->status().ok()) {
  return;
  }
  @@ -674,6 +691,8 @@ class NonMaxSuppressionV4Op : public OpKernel {
  int num_boxes = 0;
  ParseAndCheckBoxSizes(context, boxes, &num_boxes);
  CheckScoreSizes(context, num_boxes, scores);
  + // check if the boxes have logical coordinates
  + OP_REQUIRES(context, CheckBoxesCoordinates<T>(boxes, num_boxes), errors::InvalidArgument("boxes coordinates shouldn't have x1=x2 or y1=y2"));
  if (!context->status().ok()) {
  return;
  }
  