[ISSUE/BUG] TensorRT Crop Layer has different behavior comparing to Caffe Crop Layer

Provide details on the platforms you are using:
Linux distro and version: Ubuntu 16.04
GPU type: Titan V
nvidia driver version: 410.78
CUDA version: CUDA 10.130
CUDNN version: na
TensorRT version: 5.0.4

## Describe the problem

When use caffe parser to convert a caffe model to tensorrt engine, I found a discrepency in Crop Layer behavior, and this cause the ouptut of the TRT engine deviate from the original caffe model.

Crop layer are usually used after deconv, to crop the featuremap to fit the original feature map size, and in caffe the API has following usage:

layer {
  name: "crop"
  type: "Crop"
  bottom: "data"
  bottom: "ref"
  top: "crop"
  crop_param {
    axis: 2
    offset: 0
  }
}
  • bottom[0] (data): target feature map to be cropped
  • bottom[1] (ref): reference feature map, the shape will be used to crop the target feature map
  • top[0] (crop): the output feature map, which is part of blob.
  • axis = 2 means to apply crop on dims 2 and 3, i.e. Height and Width Dimension
  • offset = 0 means to align the crop starting from index = 0 on the target axis (in this case the spatial dimension)

So for a input feature map like

0   1   2   3
4   5   6   7
8   9   10  11
12  13  14  15

and a reference shape (1, 1, 2, 2), axis = 2, offset = 0, the Crop layer should produce the upper-left patch of the input feature map as below

0   1
4   5

However, when the model is coverted to TRT engine, the output is actually the following matrix (the lower-right patch of the original data).

10   11
14   15

So it seems that TRT crop layer has different behavior, in favor of last index instead of first index.

### Minimum case to reproduce

input: "data"
input_shape {
  dim: 1
  dim: 1
  dim: 4
  dim: 4
}

layer {
  name: "pool1"
  type: "Pooling"
  bottom: "data"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}

layer {
  name: "crop"
  type: "Crop"
  bottom: "data"
  bottom: "pool1"
  top: "crop"
  crop_param {
    axis: 2
    offset: 0
  }
}

Hello, we are reviewing and will keep you updated.

Hi,

We meet the same question. Is it normal?

Thanks.