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
90aca5c3
Commit
90aca5c3
authored
Jun 05, 2019
by
Paul
Browse files
Formatting
parent
37236428
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
src/driver/main.cpp
src/driver/main.cpp
+13
-9
src/driver/verify.cpp
src/driver/verify.cpp
+4
-6
src/driver/verify.hpp
src/driver/verify.hpp
+0
-1
No files found.
src/driver/main.cpp
View file @
90aca5c3
...
@@ -14,7 +14,7 @@ struct loader
...
@@ -14,7 +14,7 @@ struct loader
{
{
std
::
string
file
;
std
::
string
file
;
std
::
string
type
;
std
::
string
type
;
bool
is_nhwc
=
false
;
bool
is_nhwc
=
false
;
unsigned
trim
=
0
;
unsigned
trim
=
0
;
void
parse
(
argument_parser
&
ap
)
void
parse
(
argument_parser
&
ap
)
...
@@ -43,9 +43,9 @@ struct loader
...
@@ -43,9 +43,9 @@ struct loader
p
=
parse_onnx
(
file
);
p
=
parse_onnx
(
file
);
else
if
(
type
==
"tf"
)
else
if
(
type
==
"tf"
)
p
=
parse_tf
(
file
,
is_nhwc
);
p
=
parse_tf
(
file
,
is_nhwc
);
if
(
trim
>
0
)
if
(
trim
>
0
)
{
{
auto
last
=
std
::
prev
(
p
.
end
(),
trim
);
auto
last
=
std
::
prev
(
p
.
end
(),
trim
);
p
.
remove_instructions
(
last
,
p
.
end
());
p
.
remove_instructions
(
last
,
p
.
end
());
}
}
return
p
;
return
p
;
...
@@ -67,15 +67,19 @@ struct read : command<read>
...
@@ -67,15 +67,19 @@ struct read : command<read>
struct
verify
:
command
<
verify
>
struct
verify
:
command
<
verify
>
{
{
loader
l
;
loader
l
;
double
tolerance
=
80
;
double
tolerance
=
80
;
bool
per_instruction
=
false
;
bool
per_instruction
=
false
;
bool
reduce
=
false
;
bool
reduce
=
false
;
void
parse
(
argument_parser
&
ap
)
void
parse
(
argument_parser
&
ap
)
{
{
l
.
parse
(
ap
);
l
.
parse
(
ap
);
ap
.
add
(
tolerance
,
{
"--tolerance"
},
ap
.
help
(
"Tolerance for errors"
));
ap
.
add
(
tolerance
,
{
"--tolerance"
},
ap
.
help
(
"Tolerance for errors"
));
ap
.
add
(
per_instruction
,
{
"-i"
,
"--per-instruction"
},
ap
.
help
(
"Verify each instruction"
),
ap
.
set_value
(
true
));
ap
.
add
(
per_instruction
,
ap
.
add
(
reduce
,
{
"-r"
,
"--reduce"
},
ap
.
help
(
"Reduce program and verify"
),
ap
.
set_value
(
true
));
{
"-i"
,
"--per-instruction"
},
ap
.
help
(
"Verify each instruction"
),
ap
.
set_value
(
true
));
ap
.
add
(
reduce
,
{
"-r"
,
"--reduce"
},
ap
.
help
(
"Reduce program and verify"
),
ap
.
set_value
(
true
));
}
}
void
run
()
void
run
()
...
...
src/driver/verify.cpp
View file @
90aca5c3
...
@@ -41,8 +41,7 @@ argument run_gpu(program p)
...
@@ -41,8 +41,7 @@ argument run_gpu(program p)
program
::
parameter_map
m
;
program
::
parameter_map
m
;
for
(
auto
&&
x
:
p
.
get_parameter_shapes
())
for
(
auto
&&
x
:
p
.
get_parameter_shapes
())
{
{
m
[
x
.
first
]
=
m
[
x
.
first
]
=
gpu
::
to_gpu
(
generate_argument
(
x
.
second
,
get_hash
(
x
.
first
)));
gpu
::
to_gpu
(
generate_argument
(
x
.
second
,
get_hash
(
x
.
first
)));
}
}
auto
out
=
gpu
::
from_gpu
(
p
.
eval
(
m
));
auto
out
=
gpu
::
from_gpu
(
p
.
eval
(
m
));
std
::
cout
<<
p
<<
std
::
endl
;
std
::
cout
<<
p
<<
std
::
endl
;
...
@@ -81,8 +80,7 @@ void verify_instructions(const program& prog, double tolerance)
...
@@ -81,8 +80,7 @@ void verify_instructions(const program& prog, double tolerance)
if
(
arg
->
name
()
==
"@literal"
)
if
(
arg
->
name
()
==
"@literal"
)
inputs
.
push_back
(
p
.
add_literal
(
arg
->
get_literal
()));
inputs
.
push_back
(
p
.
add_literal
(
arg
->
get_literal
()));
else
else
inputs
.
push_back
(
inputs
.
push_back
(
p
.
add_parameter
(
std
::
to_string
(
inputs
.
size
()),
arg
->
get_shape
()));
p
.
add_parameter
(
std
::
to_string
(
inputs
.
size
()),
arg
->
get_shape
()));
}
}
p
.
add_instruction
(
ins
.
get_operator
(),
inputs
);
p
.
add_instruction
(
ins
.
get_operator
(),
inputs
);
try
try
...
@@ -101,7 +99,7 @@ void verify_instructions(const program& prog, double tolerance)
...
@@ -101,7 +99,7 @@ void verify_instructions(const program& prog, double tolerance)
void
verify_reduced
(
program
p
,
int
n
,
double
tolerance
)
void
verify_reduced
(
program
p
,
int
n
,
double
tolerance
)
{
{
auto
last
=
std
::
prev
(
p
.
end
(),
n
+
1
);
auto
last
=
std
::
prev
(
p
.
end
(),
n
+
1
);
p
.
remove_instructions
(
last
,
p
.
end
());
p
.
remove_instructions
(
last
,
p
.
end
());
std
::
cout
<<
"Verify: "
<<
std
::
endl
;
std
::
cout
<<
"Verify: "
<<
std
::
endl
;
std
::
cout
<<
p
<<
std
::
endl
;
std
::
cout
<<
p
<<
std
::
endl
;
...
@@ -110,7 +108,7 @@ void verify_reduced(program p, int n, double tolerance)
...
@@ -110,7 +108,7 @@ void verify_reduced(program p, int n, double tolerance)
void
verify_reduced_program
(
program
p
,
double
tolerance
)
void
verify_reduced_program
(
program
p
,
double
tolerance
)
{
{
auto
n
=
std
::
distance
(
p
.
begin
(),
p
.
end
());
auto
n
=
std
::
distance
(
p
.
begin
(),
p
.
end
());
for
(
std
::
size_t
i
=
0
;
i
<
n
;
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
n
;
i
++
)
{
{
verify_reduced
(
p
,
i
,
tolerance
);
verify_reduced
(
p
,
i
,
tolerance
);
...
...
src/driver/verify.hpp
View file @
90aca5c3
...
@@ -13,7 +13,6 @@ void verify_program(const std::string& name, program p, double tolerance = 100);
...
@@ -13,7 +13,6 @@ void verify_program(const std::string& name, program p, double tolerance = 100);
void
verify_instructions
(
const
program
&
prog
,
double
tolerance
=
80
);
void
verify_instructions
(
const
program
&
prog
,
double
tolerance
=
80
);
void
verify_reduced_program
(
program
p
,
double
tolerance
=
80
);
void
verify_reduced_program
(
program
p
,
double
tolerance
=
80
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace driver
}
// namespace driver
}
// namespace migraphx
}
// namespace migraphx
...
...
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