未验证 提交 5cccc69f 编写于 作者: L Leo Chen 提交者: GitHub

update name generator, test=develop (#24048)

* update name generator, test=develop

* use c++ unique name generator, test=develop
上级 da803415
...@@ -741,6 +741,8 @@ void BindImperative(py::module *m_ptr) { ...@@ -741,6 +741,8 @@ void BindImperative(py::module *m_ptr) {
.def("_get_program_desc_tracer", .def("_get_program_desc_tracer",
&imperative::Tracer::GetProgramDescTracer, &imperative::Tracer::GetProgramDescTracer,
py::return_value_policy::reference) py::return_value_policy::reference)
.def("_generate_unique_name", &imperative::Tracer::GenerateUniqueName,
py::arg("key") = "tmp")
.def("trace", .def("trace",
[](imperative::Tracer &self, const std::string &type, [](imperative::Tracer &self, const std::string &type,
const PyNameVarBaseMap &ins, const PyNameVarBaseMap &outs, const PyNameVarBaseMap &ins, const PyNameVarBaseMap &outs,
......
...@@ -232,8 +232,7 @@ GenerateOpFunctions(const std::string& module_name) { ...@@ -232,8 +232,7 @@ GenerateOpFunctions(const std::string& module_name) {
} }
std::string function_args = ""; std::string function_args = "";
if (input_args == "") { if (input_args == "") {
function_args = function_args = FUNCTION_ARGS_NO_INPUT;
paddle::string::Sprintf(FUNCTION_ARGS_NO_INPUT, input_args);
} else { } else {
function_args = paddle::string::Sprintf(FUNCTION_ARGS, input_args); function_args = paddle::string::Sprintf(FUNCTION_ARGS, input_args);
} }
......
...@@ -120,10 +120,13 @@ def generate(key): ...@@ -120,10 +120,13 @@ def generate(key):
# mode. Therefore, we keep the variable name of Parameter currently. # mode. Therefore, we keep the variable name of Parameter currently.
# #
# Please fix me if a better method is found. # Please fix me if a better method is found.
#
# NOTE(zhiqiu): use c++ unique_name_generator in dygraph mode,
# in order to keep name consistency.
def generate_with_ignorable_key(key): def generate_with_ignorable_key(key):
from .framework import in_dygraph_mode from .framework import in_dygraph_mode, _dygraph_tracer
if in_dygraph_mode(): if in_dygraph_mode():
key = "tmp" return _dygraph_tracer()._generate_unique_name()
return generator(key) return generator(key)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册