cache runtime_context#16002
cache runtime_context#16002luotao1 merged 15 commits intoPaddlePaddle:developfrom luotao1:runtime_context
Conversation
test=develop
test=develop
test=develop
test=develop
paddle/fluid/framework/scope.h
Outdated
|
|
||
| /// Find whether a variable in the current scope. | ||
| /// Return false if cannot find. | ||
| bool HasLocalVar(const std::string& name) const; |
There was a problem hiding this comment.
I want to use scope.parent()->HasLocalVar(kLocalExecScopeName) to replace scope->FindVar(kLocalExecScopeName) in this PR, but it seems that speedup is not obvious. I will remove it later.
There was a problem hiding this comment.
remove the used HasLocalVar function.
paddle/fluid/framework/operator.cc
Outdated
| // in the execution, RuntimeContext could be created only at the first | ||
| // iteration of the execution to save the elapsed time. | ||
| // Note that the Scope should not be the local scope, since local scope | ||
| // would be cleaned regularly. |
There was a problem hiding this comment.
making this default is dangerous because there is no restriction that global scope is not allowed to change.
There was a problem hiding this comment.
ca34c90 add runtime_context_cache_pass to do it, and making this default false in analysis_config of inference . @panyx0718 @Superjomn
There was a problem hiding this comment.
There are duplicated print enable_ir_optim before, see line74 and 75.
test=develop
test=develop
test=develop
|
Fails on TensorRT, the reason is that there are two more |
test=develop
|
|
@panyx0718 Could start review again since the latest commit passes all the CI except |
| VLOG(3) << "Applies Runtime Context Cache strategy."; | ||
| for (const Node* n : graph->Nodes()) { | ||
| if (n->IsOp()) { | ||
| n->Op()->SetAttr(kEnableRuntimeContext, true); |
There was a problem hiding this comment.
kEnableCacheRuntimeContext?
paddle/fluid/framework/operator.h
Outdated
|
|
||
| /// RuntimeContext is used to relate input/output names of Operator with | ||
| /// the corresponding variables in Scope. | ||
| /// If an Op has attribute kEnableRuntimeContext, it means that in a same Scope, |
|
Make the contexts member of the operator is much simpler, no need to make them attributes or the operators will have too many attributes, with the runtime attributes mixed with the algorithms'. Currently, the operator interface is over-implemented/designed, for inference, it should be much simpler, use MACRO to wrap them with the members? Do we really need to change the runtime context or infer shape context? suffer that complexity? |
I try this at first, but fail on ParallelExecutor unit-tests and distirbuted async unit-tests.
Do you mean use
The reason of changing runtime context is that cache it has a obvious speed up on small model of inference. Besides, we will cache kernel choose in #16004 @panyx0718 @Superjomn How do you think about using |
RuntimeContext is used to relate input/output names of Operator with the corresponding variables in Scope. Since the input/output names of Operator do not change in the execution, RuntimeContext could be created only at the first iteration of the execution to save the elapsed time.
In the inference of PyramidDNN (a small model):