Skip to content

Commit 8023bc7

Browse files
author
baiyfbupt
committed
fix index
1 parent 4d2a2e7 commit 8023bc7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

paddle/fluid/operators/roi_pool_op.cu

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ __global__ void GPUROIPoolForward(
3838
int index = blockIdx.x * blockDim.x + threadIdx.x;
3939
int offset = blockDim.x * gridDim.x;
4040
for (size_t i = index; i < nthreads; i += offset) {
41-
int pw = index % pooled_width;
42-
int ph = (index / pooled_width) % pooled_height;
43-
int c = (index / pooled_width / pooled_height) % channels;
44-
int n = index / pooled_width / pooled_height / channels;
41+
int pw = i % pooled_width;
42+
int ph = (i / pooled_width) % pooled_height;
43+
int c = (i / pooled_width / pooled_height) % channels;
44+
int n = i / pooled_width / pooled_height / channels;
4545

4646
const int64_t* offset_input_rois = input_rois + n * kROISize;
4747
int roi_batch_ind = roi_batch_id_data[n];
@@ -65,7 +65,6 @@ __global__ void GPUROIPoolForward(
6565
int wend = static_cast<int>(ceil(static_cast<double>(pw + 1) *
6666
static_cast<double>(roi_width) /
6767
static_cast<double>(pooled_width)));
68-
6968
hstart = min(max(hstart + roi_start_h, 0), height);
7069
hend = min(max(hend + roi_start_h, 0), height);
7170
wstart = min(max(wstart + roi_start_w, 0), width);
@@ -85,9 +84,9 @@ __global__ void GPUROIPoolForward(
8584
}
8685
}
8786
}
88-
output_data[index] = maxval;
87+
output_data[i] = maxval;
8988
if (argmax_data) {
90-
argmax_data[index] = maxidx;
89+
argmax_data[i] = maxidx;
9190
}
9291
}
9392
}
@@ -144,6 +143,7 @@ class GPUROIPoolOpKernel : public framework::OpKernel<T> {
144143
int width = in_dims[3];
145144

146145
int rois_num = rois->dims()[0];
146+
147147
if (rois_num == 0) return;
148148

149149
int output_size = out->numel();

0 commit comments

Comments
 (0)