From e76b601b35b628303583f1b05ad766ff66c38ab7 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Wed, 24 Nov 2021 19:01:16 +0800 Subject: [PATCH] [new-exec] support skipping infershape (#37510) --- .../new_executor/interpretercore_util.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/framework/new_executor/interpretercore_util.cc b/paddle/fluid/framework/new_executor/interpretercore_util.cc index fe4d1546ea1..98799e049df 100644 --- a/paddle/fluid/framework/new_executor/interpretercore_util.cc +++ b/paddle/fluid/framework/new_executor/interpretercore_util.cc @@ -305,11 +305,18 @@ void build_op_func_list(const platform::Place& place, RuntimeContext runtime_context({}, {}); runtime_context.inputs.swap(ins_map); runtime_context.outputs.swap(outs_map); - InterpretercoreInferShapeContext infer_shape_ctx(*op, runtime_context); - // TODO(Aurelius84): In case of control flow ops, they are NOT inheritted - // from OperatorWithKernel. - static_cast(op)->InferShape( - &infer_shape_ctx); + + // see OperatorWithKernel::RunImpl in operator.cc for why + if (!(op->HasAttr(kAllKernelsMustComputeRuntimeShape) && + op->Attr(kAllKernelsMustComputeRuntimeShape))) { + InterpretercoreInferShapeContext infer_shape_ctx(*op, runtime_context); + // TODO(Aurelius84): In case of control flow ops, they are NOT + // inheritted + // from OperatorWithKernel. + static_cast(op)->InferShape( + &infer_shape_ctx); + } + auto kernels_iter = all_op_kernels.find(op->Type()); PADDLE_ENFORCE_NE( kernels_iter, all_op_kernels.end(), -- GitLab