未验证 提交 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) {
.def("_get_program_desc_tracer",
&imperative::Tracer::GetProgramDescTracer,
py::return_value_policy::reference)
.def("_generate_unique_name", &imperative::Tracer::GenerateUniqueName,
py::arg("key") = "tmp")
.def("trace",
[](imperative::Tracer &self, const std::string &type,
const PyNameVarBaseMap &ins, const PyNameVarBaseMap &outs,
......
......@@ -232,8 +232,7 @@ GenerateOpFunctions(const std::string& module_name) {
}
std::string function_args = "";
if (input_args == "") {
function_args =
paddle::string::Sprintf(FUNCTION_ARGS_NO_INPUT, input_args);
function_args = FUNCTION_ARGS_NO_INPUT;
} else {
function_args = paddle::string::Sprintf(FUNCTION_ARGS, input_args);
}
......
......@@ -119,11 +119,14 @@ def generate(key):
# would save model in static graph mode, and load it in dygraph
# 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):
from .framework import in_dygraph_mode
from .framework import in_dygraph_mode, _dygraph_tracer
if in_dygraph_mode():
key = "tmp"
return _dygraph_tracer()._generate_unique_name()
return generator(key)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册