Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
5f8d091d
Commit
5f8d091d
authored
May 05, 2018
by
Paul
Browse files
Use stream operator
parent
301b84e3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
15 deletions
+16
-15
include/rtg/program.hpp
include/rtg/program.hpp
+2
-2
onnx/read_onnx.cpp
onnx/read_onnx.cpp
+2
-2
src/program.cpp
src/program.cpp
+12
-11
No files found.
include/rtg/program.hpp
View file @
5f8d091d
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include <rtg/builtin.hpp>
#include <rtg/builtin.hpp>
#include <rtg/instruction_ref.hpp>
#include <rtg/instruction_ref.hpp>
#include <algorithm>
#include <algorithm>
#include <iostream>
namespace
rtg
{
namespace
rtg
{
...
@@ -47,8 +48,7 @@ struct program
...
@@ -47,8 +48,7 @@ struct program
literal
eval
(
std
::
unordered_map
<
std
::
string
,
argument
>
params
)
const
;
literal
eval
(
std
::
unordered_map
<
std
::
string
,
argument
>
params
)
const
;
// TODO: Change to stream operator
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
program
&
p
);
void
print
()
const
;
bool
has_instruction
(
instruction_ref
ins
)
const
;
bool
has_instruction
(
instruction_ref
ins
)
const
;
...
...
onnx/read_onnx.cpp
View file @
5f8d091d
...
@@ -304,9 +304,9 @@ int main(int argc, char const* argv[])
...
@@ -304,9 +304,9 @@ int main(int argc, char const* argv[])
}
}
catch
(...)
catch
(...)
{
{
parser
.
prog
.
print
()
;
std
::
cout
<<
parser
.
prog
<<
std
::
endl
;
throw
;
throw
;
}
}
parser
.
prog
.
print
()
;
std
::
cout
<<
parser
.
prog
<<
std
::
endl
;
}
}
}
}
src/program.cpp
View file @
5f8d091d
...
@@ -87,12 +87,12 @@ literal program::eval(std::unordered_map<std::string, argument> params) const
...
@@ -87,12 +87,12 @@ literal program::eval(std::unordered_map<std::string, argument> params) const
return
literal
{
result
.
get_shape
(),
result
.
data
()};
return
literal
{
result
.
get_shape
(),
result
.
data
()};
}
}
void
program
::
print
()
const
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
program
&
p
)
{
{
std
::
unordered_map
<
const
instruction
*
,
std
::
string
>
names
;
std
::
unordered_map
<
const
instruction
*
,
std
::
string
>
names
;
int
count
=
0
;
int
count
=
0
;
for
(
auto
&
ins
:
impl
->
instructions
)
for
(
auto
&
ins
:
p
.
impl
->
instructions
)
{
{
std
::
string
var_name
=
"@"
+
std
::
to_string
(
count
);
std
::
string
var_name
=
"@"
+
std
::
to_string
(
count
);
if
(
starts_with
(
ins
.
op
.
name
(),
"@param"
))
if
(
starts_with
(
ins
.
op
.
name
(),
"@param"
))
...
@@ -100,16 +100,16 @@ void program::print() const
...
@@ -100,16 +100,16 @@ void program::print() const
var_name
=
ins
.
op
.
name
().
substr
(
7
);
var_name
=
ins
.
op
.
name
().
substr
(
7
);
}
}
s
td
::
cout
<<
var_name
<<
" = "
;
o
s
<<
var_name
<<
" = "
;
s
td
::
cout
<<
ins
.
op
.
name
();
o
s
<<
ins
.
op
.
name
();
if
(
ins
.
op
.
name
()
==
"@literal"
)
if
(
ins
.
op
.
name
()
==
"@literal"
)
{
{
if
(
ins
.
lit
.
get_shape
().
elements
()
>
10
)
if
(
ins
.
lit
.
get_shape
().
elements
()
>
10
)
s
td
::
cout
<<
"{ ... }"
;
o
s
<<
"{ ... }"
;
else
else
s
td
::
cout
<<
"{"
<<
ins
.
lit
<<
"}"
;
o
s
<<
"{"
<<
ins
.
lit
<<
"}"
;
}
}
if
(
!
ins
.
arguments
.
empty
())
if
(
!
ins
.
arguments
.
empty
())
...
@@ -117,20 +117,21 @@ void program::print() const
...
@@ -117,20 +117,21 @@ void program::print() const
char
delim
=
'('
;
char
delim
=
'('
;
for
(
auto
&&
arg
:
ins
.
arguments
)
for
(
auto
&&
arg
:
ins
.
arguments
)
{
{
assert
(
this
->
has_instruction
(
arg
)
&&
"Instruction not found"
);
assert
(
p
.
has_instruction
(
arg
)
&&
"Instruction not found"
);
s
td
::
cout
<<
delim
<<
names
.
at
(
std
::
addressof
(
*
arg
));
o
s
<<
delim
<<
names
.
at
(
std
::
addressof
(
*
arg
));
delim
=
','
;
delim
=
','
;
}
}
s
td
::
cout
<<
")"
;
o
s
<<
")"
;
}
}
s
td
::
cout
<<
" -> "
<<
ins
.
result
;
o
s
<<
" -> "
<<
ins
.
result
;
s
td
::
cout
<<
std
::
endl
;
o
s
<<
std
::
endl
;
names
.
emplace
(
std
::
addressof
(
ins
),
var_name
);
names
.
emplace
(
std
::
addressof
(
ins
),
var_name
);
count
++
;
count
++
;
}
}
return
os
;
}
}
}
// namespace rtg
}
// namespace rtg
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