Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
929b48d0
Commit
929b48d0
authored
Oct 18, 2023
by
Umang Yadav
Browse files
changes to print cpp
parent
1d9f7deb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
src/module.cpp
src/module.cpp
+11
-6
src/program.cpp
src/program.cpp
+1
-1
No files found.
src/module.cpp
View file @
929b48d0
...
@@ -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
;
}
}
...
@@ -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
{
{
...
...
src/program.cpp
View file @
929b48d0
...
@@ -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();"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment