From e051bba0056053303071caa51849fa9a514015a4 Mon Sep 17 00:00:00 2001 From: Huihuang Zheng Date: Wed, 13 Oct 2021 14:37:03 +0800 Subject: [PATCH] Remove RunFromCinn in PE because We Will Call CinnRunner in Compute of SubgraphOp (#36385) Remove RunFromCinn method in PE because We Will Call CinnRunner in Compute method of SubgraphOp --- paddle/fluid/framework/parallel_executor.cc | 36 --------------------- paddle/fluid/framework/parallel_executor.h | 5 --- paddle/fluid/pybind/pybind.cc | 12 ------- python/paddle/fluid/executor.py | 14 ++------ 4 files changed, 2 insertions(+), 65 deletions(-) diff --git a/paddle/fluid/framework/parallel_executor.cc b/paddle/fluid/framework/parallel_executor.cc index 3b80e9c786..d19ac0b65f 100644 --- a/paddle/fluid/framework/parallel_executor.cc +++ b/paddle/fluid/framework/parallel_executor.cc @@ -34,7 +34,6 @@ limitations under the License. */ #include "paddle/fluid/framework/ir/memory_optimize_pass/memory_optimization_var_info.h" #include "paddle/fluid/framework/ir/memory_optimize_pass/reference_count_pass_helper.h" #include "paddle/fluid/framework/ir/multi_devices_graph_pass/set_reader_device_info_utils.h" -#include "paddle/fluid/framework/paddle2cinn/cinn_runner.h" #include "paddle/fluid/framework/variable_helper.h" #include "paddle/fluid/platform/cuda_graph_with_memory_pool.h" #include "paddle/fluid/platform/event.h" @@ -44,7 +43,6 @@ limitations under the License. */ #include "paddle/fluid/platform/cuda_device_guard.h" #endif -DECLARE_bool(use_cinn); DECLARE_double(eager_delete_tensor_gb); #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) @@ -945,40 +943,6 @@ void ParallelExecutor::RunWithoutFetch( member_->executor_->Run(/*fetch_tensors*/ {}, /*return_merged*/ false); } -FetchResultType ParallelExecutor::RunFromCinn( - const std::unordered_map &feed_tensors, - const std::vector &fetch_names) { - // Feed tensor to scope, now only support 1 scope - // TODO(zhhsplendid): handle multiple scope - size_t scope_id = 0; - std::map cinn_input_tensors; - for (auto &name_tensor_pair : feed_tensors) { - bool is_persistable = member_->IsPersistable(name_tensor_pair.first); - if (!is_persistable) { - member_->SetSkipMemoryReuse(scope_id, name_tensor_pair.first); - } - Scope *feed_scope = is_persistable ? member_->local_scopes_[scope_id] - : member_->local_exec_scopes_[scope_id]; - Variable *feed_var = feed_scope->Var(name_tensor_pair.first); - LoDTensor *trg = feed_var->GetMutable(); - trg->ShareDataWith(name_tensor_pair.second); - trg->set_lod(name_tensor_pair.second.lod()); - - cinn_input_tensors[name_tensor_pair.first] = trg; - } - - // TODO(zhhsplendid): get correct API after CINN API is ready - // now only return empty fetch result; - std::shared_ptr cinn_runner = - paddle2cinn::CinnRunner::GetInstance(); - - cinn_runner->Run(Graph(), member_->local_exec_scopes_[scope_id], - &cinn_input_tensors); - - paddle::framework::FetchResultType fetches = FetchList(fetch_names.size()); - return fetches; -} - void ParallelExecutor::SkipMemoryReuse( size_t scope_idx, const std::vector &skip_vars) { for (auto &var_name : skip_vars) { diff --git a/paddle/fluid/framework/parallel_executor.h b/paddle/fluid/framework/parallel_executor.h index f908ce3f01..78774f0489 100644 --- a/paddle/fluid/framework/parallel_executor.h +++ b/paddle/fluid/framework/parallel_executor.h @@ -14,7 +14,6 @@ limitations under the License. */ #pragma once -#include #include #include #include @@ -93,10 +92,6 @@ class ParallelExecutor { void RunWithoutFetch(const std::vector &skip_eager_vars); - FetchResultType RunFromCinn( - const std::unordered_map &feed_tensors, - const std::vector &fetch_names); - void ResetOpHandleScopeMapOfGraphs( const std::unordered_map &scope_map); diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index 80350abb4f..f58c2a5db3 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -3293,18 +3293,6 @@ All parameter, weight, gradient are variables in Paddle. BOOST_GET(paddle::framework::FetchUnmergedList, ret))); } }) - .def("run_from_cinn", - [](ParallelExecutor &self, - const std::unordered_map &feed_tensors, - const std::vector &fetch_names) -> py::object { - paddle::framework::FetchResultType ret; - { - pybind11::gil_scoped_release release; - ret = self.RunFromCinn(feed_tensors, fetch_names); - } - return py::cast( - std::move(BOOST_GET(paddle::framework::FetchList, ret))); - }) .def("device_count", &ParallelExecutor::DeviceCount); BindFleetWrapper(&m); diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index bea5b29eca..17f8a7291a 100644 --- a/python/paddle/fluid/executor.py +++ b/python/paddle/fluid/executor.py @@ -24,7 +24,7 @@ from .wrapped_decorator import signature_safe_contextmanager import six from .data_feeder import convert_dtype from .framework import Program, default_main_program, Variable, Operator -from .framework import convert_np_dtype_to_dtype_, get_flags +from .framework import convert_np_dtype_to_dtype_ from . import core from . import unique_name from . import compiler @@ -1016,17 +1016,8 @@ class Executor(object): if need_check_feed: check_feed_shape_type(var, feed_tensor, exe.device_count()) feed_tensor_dict[feed_name] = feed_tensor + exe.feed_and_split_tensor_into_local_scopes(feed_tensor_dict) - #TODO(zhhsplendid): handle other feed data format case for CINN - use_cinn = get_flags("FLAGS_use_cinn")["FLAGS_use_cinn"] - if use_cinn: - fetch_var_names = list(map(_to_name_str, fetch_list)) - fetch_tensors = exe.run_from_cinn( - feed_tensor_dict, fetch_var_names)._move_to_list() - return as_numpy( - fetch_tensors) if return_numpy else fetch_tensors - else: - exe.feed_and_split_tensor_into_local_scopes(feed_tensor_dict) elif isinstance(feed, list) or isinstance(feed, tuple): res = list() for i, each in enumerate(feed): @@ -1047,7 +1038,6 @@ class Executor(object): res_dict[feed_name] = tensor res.append(res_dict) - use_cinn = get_flags("FLAGS_use_cinn")["FLAGS_use_cinn"] exe.feed_tensors_into_local_scopes(res) if hasattr(program._program, 'lr_sheduler'): -- GitLab