From 9301d3b5ea9e48f2335160bc7cdaafa111720477 Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Sun, 24 Sep 2017 22:03:50 -0700 Subject: [PATCH] add namespace and reduce warning --- paddle/operators/crop_op.h | 6 +++--- paddle/operators/multiplex_op.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/paddle/operators/crop_op.h b/paddle/operators/crop_op.h index 2f40c0590..ac3aeaf41 100644 --- a/paddle/operators/crop_op.h +++ b/paddle/operators/crop_op.h @@ -38,10 +38,10 @@ class CropKernel : public framework::OpKernel { auto out_stride = framework::stride(out->dims()); auto offsets = context.Attr>("offsets"); PADDLE_ENFORCE_EQ( - x->dims().size(), offsets.size(), + x->dims().size(), static_cast(offsets.size()), "Offsets size should be equal to dimension size of input tensor."); int64_t offset = 0; - for (int i = 0; i < offsets.size(); ++i) { + for (size_t i = 0; i < offsets.size(); ++i) { offset += (x_stride[i] * offsets[i]); } StridedMemcpy(context.device_context(), x_data + offset, x_stride, @@ -57,7 +57,7 @@ void CropGradFunction(const framework::ExecutionContext& context) { d_x->mutable_data(context.GetPlace()); auto offsets = context.Attr>("offsets"); Eigen::array, D> paddings; - for (int i = 0; i < D; ++i) { + for (size_t i = 0; i < D; ++i) { paddings[i].first = offsets[i]; paddings[i].second = d_x->dims()[i] - d_out->dims()[i] - offsets[i]; } diff --git a/paddle/operators/multiplex_op.h b/paddle/operators/multiplex_op.h index 44e8e0c19..98466426b 100644 --- a/paddle/operators/multiplex_op.h +++ b/paddle/operators/multiplex_op.h @@ -37,7 +37,7 @@ class MultiplexCPUKernel : public framework::OpKernel { Place place = boost::get(ctx.GetPlace()); for (auto i = 0; i < rows; i++) { int k = (int)index[i] + 1; - PADDLE_ENFORCE_LT(k, ins.size(), + PADDLE_ENFORCE_LT(static_cast(k), ins.size(), "index exceeds the number of candidate tensors."); memory::Copy(place, out->data() + i * cols, place, ins[k]->data() + i * cols, cols * sizeof(T)); @@ -74,5 +74,5 @@ class MultiplexGradCPUKernel : public framework::OpKernel { } } }; -} -} +} // namespace operators +} // namespace paddle -- GitLab