diff --git a/paddle/framework/scope.cc b/paddle/framework/scope.cc index 522f0f9f9e80a..af08b2ab816f6 100644 --- a/paddle/framework/scope.cc +++ b/paddle/framework/scope.cc @@ -16,7 +16,6 @@ limitations under the License. */ #include // for unique_ptr #include // for call_once -#include #include "glog/logging.h" #include "paddle/framework/threadpool.h" #include "paddle/string/printf.h" @@ -77,19 +76,6 @@ const Scope* Scope::FindScope(const Variable* var) const { } return (parent_ == nullptr) ? nullptr : parent_->FindScope(var); } - -void Scope::EraseVars(std::vector& var_names) { - std::set var_set(var_names.begin(), var_names.end()); - for (auto it = vars_.begin(); it != vars_.end();) { - if (var_set.find(it->first) != var_set.end()) { - delete it->second; - it = vars_.erase(it); - } else { - ++it; - } - } -} - void Scope::DropKids() { for (Scope* s : kids_) delete s; kids_.clear(); diff --git a/paddle/framework/scope.h b/paddle/framework/scope.h index 79608bc495b15..a1da81cc7977d 100644 --- a/paddle/framework/scope.h +++ b/paddle/framework/scope.h @@ -65,8 +65,6 @@ class Scope { /// Drop all kids scopes belonged to this scope. void DropKids(); - void EraseVars(std::vector& var_names); - // enumerate all the variables current contains. std::vector LocalVarNames() const; diff --git a/paddle/operators/delete_var_op.cc b/paddle/operators/delete_var_op.cc deleted file mode 100644 index 6909c7b2c52af..0000000000000 --- a/paddle/operators/delete_var_op.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -#include "paddle/framework/op_registry.h" -#include "paddle/framework/operator.h" - -namespace paddle { -namespace operators { -class DeleteVarOp : public framework::OperatorBase { - public: - DeleteVarOp(const std::string &type, const framework::VariableNameMap &inputs, - const framework::VariableNameMap &outputs, - const framework::AttributeMap &attrs) - : OperatorBase(type, inputs, outputs, attrs) {} - void Run(const framework::Scope &scope, - const platform::Place &place) const override { - // get device context from pool - platform::DeviceContextPool &pool = platform::DeviceContextPool::Instance(); - auto &dev_ctx = *pool.Get(place); - dev_ctx.Wait(); - - auto delete_var_names = Inputs("X"); - const_cast(scope).EraseVars(delete_var_names); - } -}; - -class DeleteVarOpInfoMaker : public framework::OpProtoAndCheckerMaker { - public: - DeleteVarOpInfoMaker(OpProto *proto, OpAttrChecker *op_checker) - : OpProtoAndCheckerMaker(proto, op_checker) { - AddInput("X", "The input of delete op").AsDuplicable(); - AddComment(R"DOC( -Delete Operator. - -It should not be configured by users directly. - -)DOC"); - } -}; - -} // namespace operators -} // namespace paddle - -REGISTER_OPERATOR(delete_var, paddle::operators::DeleteVarOp, - paddle::framework::EmptyGradOpMaker, - paddle::operators::DeleteVarOpInfoMaker); diff --git a/python/paddle/v2/fluid/memory_optimization_transpiler.py b/python/paddle/v2/fluid/memory_optimization_transpiler.py index 7acb006d231f3..2b00923f5e85e 100644 --- a/python/paddle/v2/fluid/memory_optimization_transpiler.py +++ b/python/paddle/v2/fluid/memory_optimization_transpiler.py @@ -195,10 +195,6 @@ def check_var_validity(block_desc, x, is_forward): for var_name in can_optimize: self.pool.append((var_name, self._find_var( block_desc, var_name, is_forward).shape())) - var_names = [x[0] for x in self.pool] - op_desc = self.current_block_desc.append_op() - op_desc.set_type("delete_var") - op_desc.set_input("X", var_names) def get_cfgs(input_program):