提交 74578a96 编写于 作者: Q Qiao Longfei 提交者: GitHub

Merge pull request #4356 from jacquesqiao/fix-namespace

add namespace and reduce warning
...@@ -38,10 +38,10 @@ class CropKernel : public framework::OpKernel { ...@@ -38,10 +38,10 @@ class CropKernel : public framework::OpKernel {
auto out_stride = framework::stride(out->dims()); auto out_stride = framework::stride(out->dims());
auto offsets = context.Attr<std::vector<int>>("offsets"); auto offsets = context.Attr<std::vector<int>>("offsets");
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(
x->dims().size(), offsets.size(), x->dims().size(), static_cast<int64_t>(offsets.size()),
"Offsets size should be equal to dimension size of input tensor."); "Offsets size should be equal to dimension size of input tensor.");
int64_t offset = 0; 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]); offset += (x_stride[i] * offsets[i]);
} }
StridedMemcpy<T>(context.device_context(), x_data + offset, x_stride, StridedMemcpy<T>(context.device_context(), x_data + offset, x_stride,
...@@ -57,7 +57,7 @@ void CropGradFunction(const framework::ExecutionContext& context) { ...@@ -57,7 +57,7 @@ void CropGradFunction(const framework::ExecutionContext& context) {
d_x->mutable_data<T>(context.GetPlace()); d_x->mutable_data<T>(context.GetPlace());
auto offsets = context.Attr<std::vector<int>>("offsets"); auto offsets = context.Attr<std::vector<int>>("offsets");
Eigen::array<std::pair<int, int>, D> paddings; Eigen::array<std::pair<int, int>, D> paddings;
for (int i = 0; i < D; ++i) { for (size_t i = 0; i < D; ++i) {
paddings[i].first = offsets[i]; paddings[i].first = offsets[i];
paddings[i].second = d_x->dims()[i] - d_out->dims()[i] - offsets[i]; paddings[i].second = d_x->dims()[i] - d_out->dims()[i] - offsets[i];
} }
......
...@@ -37,7 +37,7 @@ class MultiplexCPUKernel : public framework::OpKernel { ...@@ -37,7 +37,7 @@ class MultiplexCPUKernel : public framework::OpKernel {
Place place = boost::get<Place>(ctx.GetPlace()); Place place = boost::get<Place>(ctx.GetPlace());
for (auto i = 0; i < rows; i++) { for (auto i = 0; i < rows; i++) {
int k = (int)index[i] + 1; int k = (int)index[i] + 1;
PADDLE_ENFORCE_LT(k, ins.size(), PADDLE_ENFORCE_LT(static_cast<size_t>(k), ins.size(),
"index exceeds the number of candidate tensors."); "index exceeds the number of candidate tensors.");
memory::Copy(place, out->data<T>() + i * cols, place, memory::Copy(place, out->data<T>() + i * cols, place,
ins[k]->data<T>() + i * cols, cols * sizeof(T)); ins[k]->data<T>() + i * cols, cols * sizeof(T));
...@@ -74,5 +74,5 @@ class MultiplexGradCPUKernel : public framework::OpKernel { ...@@ -74,5 +74,5 @@ class MultiplexGradCPUKernel : public framework::OpKernel {
} }
} }
}; };
} } // namespace operators
} } // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册