未验证 提交 05b9ea50 编写于 作者: W wanghuancoder 提交者: GitHub

Use separate uniquename in op_function_impl.h, test=develop (#33189)

上级 4cf01462
...@@ -176,7 +176,7 @@ std::set<std::string> inplace_op_duplicable_ins_set = { ...@@ -176,7 +176,7 @@ std::set<std::string> inplace_op_duplicable_ins_set = {
// clang-format off // clang-format off
const char* OUT_INITIALIZER_TEMPLATE = const char* OUT_INITIALIZER_TEMPLATE =
R"({"%s", {std::shared_ptr<imperative::VarBase>(new imperative::VarBase(tracer->GenerateUniqueName()))}})"; R"({"%s", {std::shared_ptr<imperative::VarBase>(new imperative::VarBase("auto_"+std::to_string(VarBaseUniqueNameID++)+"_"))}})";
const char* OUT_DUPLICABLE_INITIALIZER_TEMPLATE = R"({"%s", ConstructDuplicableOutput(%s)})"; const char* OUT_DUPLICABLE_INITIALIZER_TEMPLATE = R"({"%s", ConstructDuplicableOutput(%s)})";
const char* INPUT_INITIALIZER_TEMPLATE = R"({"%s", {%s}})"; const char* INPUT_INITIALIZER_TEMPLATE = R"({"%s", {%s}})";
...@@ -258,12 +258,11 @@ R"( ...@@ -258,12 +258,11 @@ R"(
ConstructAttrMapFromPyArgs("%s", %d, &attrs, args); ConstructAttrMapFromPyArgs("%s", %d, &attrs, args);
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
auto tracer = imperative::GetCurrentTracer();
%s %s
imperative::NameVarBaseMap outs = %s; imperative::NameVarBaseMap outs = %s;
imperative::NameVarBaseMap ins = %s; imperative::NameVarBaseMap ins = %s;
%s %s
tracer->TraceOp("%s", ins, outs, attrs, {%s}); imperative::GetCurrentTracer()->TraceOp("%s", ins, outs, attrs, {%s});
return %s; return %s;
} }
})"; })";
...@@ -588,7 +587,8 @@ int main(int argc, char* argv[]) { ...@@ -588,7 +587,8 @@ int main(int argc, char* argv[]) {
out << "namespace py = pybind11;" out << "namespace py = pybind11;"
<< "\n"; << "\n";
out << "namespace paddle {\n" out << "namespace paddle {\n"
<< "namespace pybind {\n"; << "namespace pybind {\n\n";
out << "std::atomic<int> VarBaseUniqueNameID{0};\n";
out << paddle::string::join_strings(std::get<0>(op_funcs), '\n'); out << paddle::string::join_strings(std::get<0>(op_funcs), '\n');
out << "\n\n"; out << "\n\n";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册