From b91a7a9d3073e4e38f659f4353dbf4eb0215d816 Mon Sep 17 00:00:00 2001 From: Xin Pan Date: Thu, 27 Dec 2018 09:41:18 +0800 Subject: [PATCH] clear operator changes test=develop --- paddle/fluid/framework/operator.cc | 50 ------------------------------ paddle/fluid/framework/operator.h | 8 ----- paddle/fluid/imperative/tracer.h | 1 - 3 files changed, 59 deletions(-) diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index dc365a954..d67782319 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -179,11 +179,6 @@ void OperatorBase::Run(const Scope& scope, const platform::Place& place) { VLOG(3) << place << " " << DebugStringEx(&scope); } -void OperatorBase::RunPrepared(const RuntimeContext& ctx, - const platform::Place& place) { - RunImplPrepared(ctx, place); -} - bool OperatorBase::HasInputs(const std::string& name) const { return inputs_.find(name) != inputs_.end(); } @@ -958,51 +953,6 @@ void OperatorWithKernel::RunImpl(const Scope& scope, } } -void OperatorWithKernel::RunImplPrepared(const RuntimeContext& ctx, - const platform::Place& place) const { - Scope dummy_scope; - platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance(); - auto* dev_ctx = pool.Get(place); - - // check if op[type] has kernel registered. - auto& all_op_kernels = AllOpKernels(); - auto kernels_iter = all_op_kernels.find(type_); - if (kernels_iter == all_op_kernels.end()) { - PADDLE_THROW( - "There are no kernels which are registered in the %s operator.", type_); - } - - OpKernelMap& kernels = kernels_iter->second; - - auto expected_kernel_key = this->GetExpectedKernelType( - ExecutionContext(*this, dummy_scope, *dev_ctx, ctx)); - VLOG(3) << "expected_kernel_key:" << expected_kernel_key; - - auto kernel_iter = kernels.find(expected_kernel_key); -#ifdef PADDLE_WITH_MKLDNN - // workaround for missing MKLDNN kernel when FLAGS_use_mkldnn env var is set - if (kernel_iter == kernels.end() && - expected_kernel_key.library_type_ == LibraryType::kMKLDNN) { - VLOG(3) << "missing MKLDNN kernel: fallbacking to PLAIN one"; - expected_kernel_key.library_type_ = LibraryType::kPlain; - expected_kernel_key.data_layout_ = DataLayout::kAnyLayout; - kernel_iter = kernels.find(expected_kernel_key); - } -#endif - if (kernel_iter == kernels.end()) { - PADDLE_THROW("op %s does not have kernel for %s", type_, - KernelTypeToString(expected_kernel_key)); - } - - if (!(expected_kernel_key.place_ == dev_ctx->GetPlace())) { - dev_ctx = pool.Get(expected_kernel_key.place_); - } - - RuntimeInferShapeContext infer_shape_ctx(*this, dummy_scope, ctx); - this->InferShape(&infer_shape_ctx); - kernel_iter->second(ExecutionContext(*this, dummy_scope, *dev_ctx, ctx)); -} - void OperatorWithKernel::TransferInplaceVarsBack( const Scope& scope, const std::vector& inplace_vars, const Scope& transfer_scope) const { diff --git a/paddle/fluid/framework/operator.h b/paddle/fluid/framework/operator.h index a6bdc0bfa..e2bedc60d 100644 --- a/paddle/fluid/framework/operator.h +++ b/paddle/fluid/framework/operator.h @@ -105,7 +105,6 @@ class OperatorBase { /// Executor will call this interface function to Run an op. // The implementation should be written at RunImpl void Run(const Scope& scope, const platform::Place& place); - void RunPrepared(const RuntimeContext& ctx, const platform::Place& place); // FIXME(typhoonzero): this is only used for recv_op to stop event_loop. virtual void Stop() {} @@ -172,11 +171,6 @@ class OperatorBase { void CheckAllInputOutputSet() const; virtual void RunImpl(const Scope& scope, const platform::Place& place) const = 0; - - virtual void RunImplPrepared(const RuntimeContext& ctx, - const platform::Place& place) const { - PADDLE_THROW("%s doesn't support RunPreparedImpl", Type()); - } }; class ExecutionContext { @@ -469,8 +463,6 @@ class OperatorWithKernel : public OperatorBase { // same. proto::VarType::Type IndicateDataType(const ExecutionContext& ctx) const; void RunImpl(const Scope& scope, const platform::Place& place) const final; - void RunImplPrepared(const RuntimeContext& ctx, - const platform::Place& place) const final; /** * Transfer data from scope to a transfered scope. If there is no data need to diff --git a/paddle/fluid/imperative/tracer.h b/paddle/fluid/imperative/tracer.h index 1f0c7b30b..c814da985 100644 --- a/paddle/fluid/imperative/tracer.h +++ b/paddle/fluid/imperative/tracer.h @@ -118,7 +118,6 @@ class Tracer { VLOG(3) << "tracer running " << op_desc->Type(); framework::RuntimeContext ctx(invars_map, outvars_map); - // op_base->RunPrepared(ctx, platform::CPUPlace()); // TODO(panyx0718): Cache p. framework::OperatorWithKernel* op_kernel = -- GitLab