From: Evan Shelhamer Date: Fri, 15 Apr 2016 05:16:07 +0000 (-0700) Subject: [fix] CropLayer: check dimension bounds only for cropped dimensions X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=75b0d40a856dda87f2e0de77b2c6626753e1e231;p=platform%2Fupstream%2Fcaffe.git [fix] CropLayer: check dimension bounds only for cropped dimensions check only the dimensions to be cropped for compatible sizes and offsets --- diff --git a/src/caffe/layers/crop_layer.cpp b/src/caffe/layers/crop_layer.cpp index e81bdd7..849208f 100644 --- a/src/caffe/layers/crop_layer.cpp +++ b/src/caffe/layers/crop_layer.cpp @@ -61,12 +61,11 @@ void CropLayer::Reshape(const vector*>& bottom, // following axis crop_offset = param.offset(i - start_axis); } + // check that the crop and offset are within the dimension bounds + CHECK_GE(bottom[0]->shape(i) - crop_offset, bottom[1]->shape(i)) + << "the crop for dimension " << i << " is out-of-bounds with " + << "size " << bottom[1]->shape(i) << " and offset " << crop_offset; } - // Check that the image we are cropping minus the margin is bigger - // than the destination image. - CHECK_GE(bottom[0]->shape(i) - crop_offset, - bottom[1]->shape(i)) - << "invalid crop parameters in dimension: " << i; // Now set new size and offsets new_shape[i] = new_size; offsets[i] = crop_offset;