提交 4098ba29 编写于 作者: L luotao1

reduce hasAttr elapsed time in RunImpl

test=develop
上级 f89a9c5d
...@@ -884,6 +884,8 @@ void OperatorWithKernel::RunImpl(const Scope& scope, ...@@ -884,6 +884,8 @@ void OperatorWithKernel::RunImpl(const Scope& scope,
// result of HasAttr. // result of HasAttr.
if (!enable_cache_runtime_context && HasAttr(kEnableCacheRuntimeContext)) if (!enable_cache_runtime_context && HasAttr(kEnableCacheRuntimeContext))
enable_cache_runtime_context = true; enable_cache_runtime_context = true;
if (!enable_cache_expected_kernel && HasAttr(kEnableCacheExpectedKernel))
enable_cache_expected_kernel = true;
if (!all_kernels_must_compute_runtime_shape && if (!all_kernels_must_compute_runtime_shape &&
HasAttr(kAllKernelsMustComputeRuntimeShape)) HasAttr(kAllKernelsMustComputeRuntimeShape))
all_kernels_must_compute_runtime_shape = true; all_kernels_must_compute_runtime_shape = true;
...@@ -906,7 +908,7 @@ void OperatorWithKernel::RunImpl(const Scope& scope, ...@@ -906,7 +908,7 @@ void OperatorWithKernel::RunImpl(const Scope& scope,
platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance(); platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance();
auto* dev_ctx = pool.Get(place); auto* dev_ctx = pool.Get(place);
if (!HasAttr(kEnableCacheExpectedKernel) || !kernel_type_) { if (!enable_cache_expected_kernel || !kernel_type_) {
ChooseKernel(*runtime_ctx, scope, place); ChooseKernel(*runtime_ctx, scope, place);
} }
......
...@@ -507,6 +507,7 @@ class OperatorWithKernel : public OperatorBase { ...@@ -507,6 +507,7 @@ class OperatorWithKernel : public OperatorBase {
mutable std::unique_ptr<RuntimeContext> runtime_ctx_; mutable std::unique_ptr<RuntimeContext> runtime_ctx_;
mutable const Scope* pre_scope_ = nullptr; mutable const Scope* pre_scope_ = nullptr;
mutable bool enable_cache_runtime_context = false; mutable bool enable_cache_runtime_context = false;
mutable bool enable_cache_expected_kernel = false;
mutable bool all_kernels_must_compute_runtime_shape = false; mutable bool all_kernels_must_compute_runtime_shape = false;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册