diff --git a/paddle/fluid/operators/lod_reset_op.cc b/paddle/fluid/operators/lod_reset_op.cc index baa709b9e493095f2bc310e0f07ad3fd39718c70..94483bc7f4cd87316c20b3280520dfb633e2bf86 100644 --- a/paddle/fluid/operators/lod_reset_op.cc +++ b/paddle/fluid/operators/lod_reset_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include "paddle/fluid/operators/lod_reset_op.h" #include +#include namespace paddle { namespace operators { @@ -50,6 +51,14 @@ class LoDResetOp : public framework::OperatorWithKernel { OperatorWithKernel::IndicateVarDataType(ctx, "X"), ctx.device_context()); } + + framework::OpKernelType GetKernelTypeForVar( + const std::string &var_name, const framework::Tensor &tensor, + const framework::OpKernelType &expected_kernel_type) const override { + return framework::OpKernelType(expected_kernel_type.data_type_, + expected_kernel_type.place_, + tensor.layout()); + } }; class LoDResetOpVarTypeInference : public framework::VarTypeInference { diff --git a/paddle/fluid/operators/lod_reset_op.h b/paddle/fluid/operators/lod_reset_op.h index d827f2a2ebbe99183b801ab1b9787c69a924c293..7677fa2251f0b2fefe84f5baa0eb2763fbae21c1 100644 --- a/paddle/fluid/operators/lod_reset_op.h +++ b/paddle/fluid/operators/lod_reset_op.h @@ -45,7 +45,7 @@ class LoDResetKernel : public framework::OpKernel { return; // early return, since lod already set } else { auto* lod = lod_t->data(); - if (platform::is_gpu_place(ctx.GetPlace())) { + if (platform::is_gpu_place(lod_t->place())) { framework::Tensor lod_cpu; framework::TensorCopySync(*lod_t, platform::CPUPlace(), &lod_cpu); lod = lod_cpu.data();