From acd1aaea49e749a8d402bd6f744f2ca5f3de6020 Mon Sep 17 00:00:00 2001 From: wanghaoshuang Date: Thu, 12 Oct 2017 00:21:41 +0800 Subject: [PATCH] fix issues --- paddle/operators/seq_expand_op.cc | 3 +-- paddle/operators/seq_expand_op.h | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/paddle/operators/seq_expand_op.cc b/paddle/operators/seq_expand_op.cc index 894ba3f6b7..63b17a10f5 100644 --- a/paddle/operators/seq_expand_op.cc +++ b/paddle/operators/seq_expand_op.cc @@ -28,7 +28,7 @@ class SeqExpandOp : public framework::OperatorWithKernel { PADDLE_ENFORCE(ctx->HasInput("X"), "Input(X) of SeqExpandOp should not be null."); int repeat = ctx->Attrs().Get("repeat"); - DDim out_dim; + framework::DDim out_dim; if (repeat == 0) { PADDLE_ENFORCE( ctx->HasInput("Y"), @@ -38,7 +38,6 @@ class SeqExpandOp : public framework::OperatorWithKernel { } else { out_dim = ctx->GetInputDim("X"); out_dim[0] = out_dim[0] * repeat; - ctx->SetOutputDim("Out", y_dim); } PADDLE_ENFORCE(ctx->HasOutput("Out"), "Output(Out) of PadOp should not be null."); diff --git a/paddle/operators/seq_expand_op.h b/paddle/operators/seq_expand_op.h index 80076dc35f..0c399fe196 100644 --- a/paddle/operators/seq_expand_op.h +++ b/paddle/operators/seq_expand_op.h @@ -21,7 +21,6 @@ namespace paddle { namespace operators { using LoDTensor = framework::LoDTensor; -using LoD = paddle::framework::LoD; template class SeqExpandKernel : public framework::OpKernel { @@ -35,11 +34,11 @@ class SeqExpandKernel : public framework::OpKernel { if (repeat != 0) { if (x->lod().size() == 0) { - std::vector level0(x->dims()[0]); + std::vector level0; for (size_t i = 0; i <= x->dims()[0]; i++) { level0.push_back(i * repeat); } - const LoD out_lod; + framework::LoD out_lod; out_lod.push_back(level0); out->set_lod(out_lod); } @@ -55,14 +54,15 @@ class SeqExpandKernel : public framework::OpKernel { } } } - if (paddle::platform::CPUPlace() == Place) { + if (platform::is_cpu_place(context.GetPlace())) { for (int i = 0; i < out_dim[0]; ++i) { memcpy(out_data + element_len * i, x_data + element_len * cpy_map[i], sizeof(T) * element_len); } } else { for (int i = 0; i < out_dim[0]; ++i) { - hl_memcpy(out_data + element_len * i, x_data + element_len * cpy_map[i], + hl_memcpy(out_data + element_len * i, + const_cast(x_data) + element_len * cpy_map[i], sizeof(T) * element_len); } } -- GitLab