From 136b1f428b1ca62cd74f7f33c6e0f947732d6728 Mon Sep 17 00:00:00 2001 From: HongyuJia Date: Fri, 30 Sep 2022 16:55:10 +0800 Subject: [PATCH] opt GetExpectedKernelType code of fill_constant_op (#46667) --- paddle/fluid/operators/fill_constant_op.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/paddle/fluid/operators/fill_constant_op.cc b/paddle/fluid/operators/fill_constant_op.cc index 4c63b9969f..85aadcb07a 100644 --- a/paddle/fluid/operators/fill_constant_op.cc +++ b/paddle/fluid/operators/fill_constant_op.cc @@ -70,11 +70,12 @@ class FillConstantOp : public framework::OperatorWithKernel { framework::OpKernelType GetExpectedKernelType( const framework::ExecutionContext &ctx) const override { - framework::OpKernelType kt = framework::OpKernelType( - framework::proto::VarType::Type(ctx.Attr("dtype")), - ctx.GetPlace()); - // TODO(zyfncg) The force_cpu and place_type are conflicted, it's a issue - // lefted before, and we may merge them in the future. + auto input_data_type = + framework::proto::VarType::Type(ctx.Attr("dtype")); + framework::OpKernelType kt = + framework::OpKernelType(input_data_type, ctx.GetPlace()); + // TODO(zyfncg) The force_cpu and place_type are conflicted, it's an issue + // left before, and we may merge them in the future. // In order to invoke new fill_constant kernel, the place of OpKernelType // will be setted by force_cpu and place_type here. if (ctx.Attr("force_cpu")) { @@ -104,9 +105,6 @@ class FillConstantOp : public framework::OperatorWithKernel { } #ifdef PADDLE_WITH_MKLDNN - auto input_data_type = - framework::proto::VarType::Type(ctx.Attr("dtype")); - if (this->CanMKLDNNBeUsed(ctx, input_data_type)) { return framework::OpKernelType(input_data_type, ctx.GetPlace(), -- GitLab