Commit 929b48d0 authored by Umang Yadav's avatar Umang Yadav
Browse files

changes to print cpp

parent 1d9f7deb
...@@ -114,7 +114,7 @@ struct module_impl ...@@ -114,7 +114,7 @@ struct module_impl
const operation& get_operation(instruction_ref ins) { return ins->get_operator(); } const operation& get_operation(instruction_ref ins) { return ins->get_operator(); }
module::module(const std::string& name) : impl(std::make_unique<module_impl>()) module::module(const std::string& name) :impl(std::make_unique<module_impl>())
{ {
impl->name = name; impl->name = name;
} }
...@@ -165,7 +165,7 @@ void module::assign(const module& m) ...@@ -165,7 +165,7 @@ void module::assign(const module& m)
auto order = any_cast<builtin::param>(ins->get_operator()).order; auto order = any_cast<builtin::param>(ins->get_operator()).order;
auto s = ins->get_shape(); auto s = ins->get_shape();
copy_ins = impl->insert(impl->instructions.end(), copy_ins = impl->insert(impl->instructions.end(),
{builtin::param{name, order}, std::move(s), {}}); {builtin::param{name, order}, std::move(s), {}});
impl->nparams++; impl->nparams++;
} }
else if(ins->name() == "@outline") else if(ins->name() == "@outline")
...@@ -800,8 +800,10 @@ static std::string cpp_var_name(const std::string& name) ...@@ -800,8 +800,10 @@ static std::string cpp_var_name(const std::string& name)
{ {
std::string prefix = "x_"; std::string prefix = "x_";
if(not contains(name, "@")) if(not contains(name, "@"))
prefix = "p_"; {
return to_c_id(prefix + replace_string(name, ":", "_module_")); return to_c_id(name);
}
return to_c_id(prefix + name);
} }
static void print_py_op(std::ostream& os, const operation& op) static void print_py_op(std::ostream& os, const operation& op)
...@@ -825,8 +827,11 @@ static void print_make_op(std::ostream& os, const operation& op) ...@@ -825,8 +827,11 @@ static void print_make_op(std::ostream& os, const operation& op)
auto v = op.to_value(); auto v = op.to_value();
if(not v.empty()) if(not v.empty())
{ {
os << "migraphx::make_json_op(" << enclose_name(op.name()); os << "migraphx::make_op(" << enclose_name(op.name());
os << ", " << enclose_name(to_json_string(v)); auto rname = "{" + replace_string(to_json_string(v), "\"", "\\\"") + "}";
rname = replace_string(rname, ":", ", ");
rname = replace_string(rname, "\\", "");
os << ", " << rname;
} }
else else
{ {
......
...@@ -1032,7 +1032,7 @@ void program::print_cpp(std::ostream& os) const ...@@ -1032,7 +1032,7 @@ void program::print_cpp(std::ostream& os) const
os << "migraphx::program p;\n"; os << "migraphx::program p;\n";
for(auto& mod : vec_modules) for(auto& mod : vec_modules)
{ {
std::string var_name = "m" + mod->name(); std::string var_name = mod->name();
os << "migraphx::module_ref " << var_name << " = "; os << "migraphx::module_ref " << var_name << " = ";
if(mod->name() == "main") if(mod->name() == "main")
os << "p.get_main_module();"; os << "p.get_main_module();";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment