Skip to content

Commit

Permalink
[new-exec] support skipping infershape (#37510)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqiu authored Nov 24, 2021
1 parent c5e857d commit e76b601
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions paddle/fluid/framework/new_executor/interpretercore_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<const framework::OperatorWithKernel*>(op)->InferShape(
&infer_shape_ctx);

// see OperatorWithKernel::RunImpl in operator.cc for why
if (!(op->HasAttr(kAllKernelsMustComputeRuntimeShape) &&
op->Attr<bool>(kAllKernelsMustComputeRuntimeShape))) {
InterpretercoreInferShapeContext infer_shape_ctx(*op, runtime_context);
// TODO(Aurelius84): In case of control flow ops, they are NOT
// inheritted
// from OperatorWithKernel.
static_cast<const framework::OperatorWithKernel*>(op)->InferShape(
&infer_shape_ctx);
}

auto kernels_iter = all_op_kernels.find(op->Type());
PADDLE_ENFORCE_NE(
kernels_iter, all_op_kernels.end(),
Expand Down

0 comments on commit e76b601

Please sign in to comment.