Skip to content

Commit 067b858

Browse files
authored
Merge pull request #13625 from wanghaoshuang/fix_warning_roi
Fix warning of roi perspective transform op
2 parents b37fe30 + 153d4f5 commit 067b858

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

paddle/fluid/operators/detection/roi_perspective_transform_op.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ bool in_quad(T x, T y, T roi_x[], T roi_y[]) {
104104
* a31 = (dx3 * dy2 - dx2 * dy3) / (dx1 * dy2 - dx2 * dy1) / (w - 1)
105105
* a32 = (dx1 * dy3 - dx3 * dy1) / (dx1 * dy2 - dx2 * dy1) / (h - 1)
106106
* a33 = 1
107-
*
108107
*/
109108
template <typename T>
110109
void get_transform_matrix(const int transformed_width,
@@ -260,8 +259,8 @@ class CPUROIPerspectiveTransformOpKernel : public framework::OpKernel<T> {
260259
roi2image.Resize({rois_num});
261260
int* roi2image_data = roi2image.mutable_data<int>(ctx.GetPlace());
262261
auto lod = rois->lod().back();
263-
for (int i = 0; i < lod.size() - 1; ++i) {
264-
for (int j = lod[i]; j < lod[i + 1]; ++j) {
262+
for (size_t i = 0; i < lod.size() - 1; ++i) {
263+
for (size_t j = lod[i]; j < lod[i + 1]; ++j) {
265264
roi2image_data[j] = i;
266265
}
267266
}
@@ -393,8 +392,8 @@ class CPUROIPerspectiveTransformGradOpKernel : public framework::OpKernel<T> {
393392
roi2image.Resize({rois_num});
394393
int* roi2image_data = roi2image.mutable_data<int>(ctx.GetPlace());
395394
auto lod = rois->lod().back();
396-
for (int i = 0; i < lod.size() - 1; ++i) {
397-
for (int j = lod[i]; j < lod[i + 1]; ++j) {
395+
for (size_t i = 0; i < lod.size() - 1; ++i) {
396+
for (size_t j = lod[i]; j < lod[i + 1]; ++j) {
398397
roi2image_data[j] = i;
399398
}
400399
}
@@ -404,7 +403,7 @@ class CPUROIPerspectiveTransformGradOpKernel : public framework::OpKernel<T> {
404403
for (int in_h = 0; in_h < in_height; ++in_h) {
405404
for (int in_w = 0; in_w < in_width; ++in_w) {
406405
T gradient = 0.0;
407-
for (int roi_idx = lod[n]; roi_idx < lod[n + 1]; ++roi_idx) {
406+
for (size_t roi_idx = lod[n]; roi_idx < lod[n + 1]; ++roi_idx) {
408407
const T* rois = rois_data + roi_idx * 8;
409408
T roi_x[4];
410409
T roi_y[4];

paddle/fluid/operators/detection/roi_perspective_transform_op.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ class CUDAROIPerspectiveTransformOpKernel : public framework::OpKernel<T> {
345345
roi2image.Resize({rois_num});
346346
int* roi2image_data = roi2image.mutable_data<int>(platform::CPUPlace());
347347
auto lod = rois->lod().back();
348-
for (int i = 0; i < lod.size() - 1; ++i) {
349-
for (int j = lod[i]; j < lod[i + 1]; ++j) {
348+
for (size_t i = 0; i < lod.size() - 1; ++i) {
349+
for (size_t j = lod[i]; j < lod[i + 1]; ++j) {
350350
roi2image_data[j] = i;
351351
}
352352
}
@@ -432,7 +432,7 @@ __global__ void RoiTransformGradKernel(
432432

433433
T gradient = 0.0;
434434
// Accumulate gradient over all RoIs that interpolated this element
435-
for (int roi_idx = lod[n]; roi_idx < lod[n + 1]; ++roi_idx) {
435+
for (size_t roi_idx = lod[n]; roi_idx < lod[n + 1]; ++roi_idx) {
436436
const T* rois = rois_data + roi_idx * 8;
437437
T roi_x[4];
438438
T roi_y[4];

0 commit comments

Comments
 (0)