diff --git a/paddle/fluid/pybind/op_function_generator.cc b/paddle/fluid/pybind/op_function_generator.cc index bab4ac36353b863e7f3686aea3568ac5c9a61654..6278a23cea6440569dc7c52e6525d58d9075ef89 100644 --- a/paddle/fluid/pybind/op_function_generator.cc +++ b/paddle/fluid/pybind/op_function_generator.cc @@ -176,7 +176,7 @@ std::set inplace_op_duplicable_ins_set = { // clang-format off const char* OUT_INITIALIZER_TEMPLATE = - R"({"%s", {std::shared_ptr(new imperative::VarBase(tracer->GenerateUniqueName()))}})"; + R"({"%s", {std::shared_ptr(new imperative::VarBase("auto_"+std::to_string(VarBaseUniqueNameID++)+"_"))}})"; const char* OUT_DUPLICABLE_INITIALIZER_TEMPLATE = R"({"%s", ConstructDuplicableOutput(%s)})"; const char* INPUT_INITIALIZER_TEMPLATE = R"({"%s", {%s}})"; @@ -258,12 +258,11 @@ R"( ConstructAttrMapFromPyArgs("%s", %d, &attrs, args); { py::gil_scoped_release release; - auto tracer = imperative::GetCurrentTracer(); %s imperative::NameVarBaseMap outs = %s; imperative::NameVarBaseMap ins = %s; %s - tracer->TraceOp("%s", ins, outs, attrs, {%s}); + imperative::GetCurrentTracer()->TraceOp("%s", ins, outs, attrs, {%s}); return %s; } })"; @@ -588,7 +587,8 @@ int main(int argc, char* argv[]) { out << "namespace py = pybind11;" << "\n"; out << "namespace paddle {\n" - << "namespace pybind {\n"; + << "namespace pybind {\n\n"; + out << "std::atomic VarBaseUniqueNameID{0};\n"; out << paddle::string::join_strings(std::get<0>(op_funcs), '\n'); out << "\n\n";