!21139 Delete unused code

Merge pull request !21139 from zhangzhaoju/master_del_unuse_api
This commit is contained in:
i-robot 2021-07-31 06:41:07 +00:00 committed by Gitee
commit c575776584
3 changed files with 1 additions and 34 deletions

View File

@ -2888,22 +2888,6 @@ void PynativeExecutor::Sync() {
}
}
void PynativeExecutor::EnterConstruct(const py::object &cell) {
if (py_top_cell_ != nullptr) {
return;
}
py_top_cell_ = cell.ptr();
MS_LOG(DEBUG) << "Enter construct process.";
}
void PynativeExecutor::LeaveConstruct(const py::object &cell) {
if (py_top_cell_ != cell.ptr()) {
return;
}
py_top_cell_ = nullptr;
MS_LOG(DEBUG) << "Leave construct process.";
}
REGISTER_PYBIND_DEFINE(PynativeExecutor_, ([](const py::module *m) {
(void)py::class_<PynativeExecutor, std::shared_ptr<PynativeExecutor>>(*m, "PynativeExecutor_")
.def_static("get_instance", &PynativeExecutor::GetInstance, "PynativeExecutor get_instance.")
@ -2919,10 +2903,6 @@ REGISTER_PYBIND_DEFINE(PynativeExecutor_, ([](const py::module *m) {
.def("__call__", &PynativeExecutor::Run, "pynative executor run grad graph.")
.def("set_graph_phase", &PynativeExecutor::set_graph_phase, "pynative set graph phase")
.def("set_grad_flag", &PynativeExecutor::set_grad_flag, py::arg("flag") = py::bool_(false),
"Executor set grad flag.")
.def("enter_construct", &PynativeExecutor::EnterConstruct,
"Do something before enter construct function.")
.def("leave_construct", &PynativeExecutor::LeaveConstruct,
"Do something after leave construct function.");
"Executor set grad flag.");
}));
} // namespace mindspore::pynative

View File

@ -347,9 +347,6 @@ class PynativeExecutor : public std::enable_shared_from_this<PynativeExecutor> {
~PynativeExecutor() = default;
PynativeExecutor(const PynativeExecutor &) = delete;
PynativeExecutor &operator=(const PynativeExecutor &) = delete;
void EnterConstruct(const py::object &cell);
void LeaveConstruct(const py::object &cell);
GradExecutorPtr grad_executor() const;
ForwardExecutorPtr forward_executor() const;
@ -380,12 +377,6 @@ class PynativeExecutor : public std::enable_shared_from_this<PynativeExecutor> {
static std::mutex instance_lock_;
static ForwardExecutorPtr forward_executor_;
static GradExecutorPtr grad_executor_;
// The pointer of top python Cell object, which is always the network(inherit class Cell) ran in python test script,
// such as Resnet50(Cell),LeNet(Cell).This pointer is used to distinguish temporary primitives from global
// primitives to control memory release. Global primitives are always created in top cell's '__init__' function and
// temporary primitives are always created in other place.Temporary primitives will be released after executing top
// cell's 'construct' function but global primitives will not.
PyObject *py_top_cell_{nullptr};
};
using PynativeExecutorPtr = std::shared_ptr<PynativeExecutor>;

View File

@ -337,13 +337,9 @@ class Cell(Cell_):
def run_construct(self, cast_inputs, kwargs):
if self.enable_hook:
_pynative_exec.enter_construct(self)
output = self._hook_construct(*cast_inputs, **kwargs)
_pynative_exec.leave_construct(self)
else:
_pynative_exec.enter_construct(self)
output = self.construct(*cast_inputs, **kwargs)
_pynative_exec.leave_construct(self)
return output
def _check_construct_args(self, *inputs, **kwargs):