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
4886f3e8
Commit
4886f3e8
authored
Aug 16, 2018
by
Paul
Browse files
Formatting
parent
f4059729
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
26 deletions
+22
-26
src/onnx/perf_onnx.cpp
src/onnx/perf_onnx.cpp
+2
-2
src/program.cpp
src/program.cpp
+20
-24
No files found.
src/onnx/perf_onnx.cpp
View file @
4886f3e8
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
#include <migraph/generate.hpp>
#include <migraph/generate.hpp>
#include <migraph/verify.hpp>
#include <migraph/verify.hpp>
migraph
::
program
::
parameter_map
create_param_map
(
const
migraph
::
program
&
p
,
bool
gpu
=
true
)
migraph
::
program
::
parameter_map
create_param_map
(
const
migraph
::
program
&
p
,
bool
gpu
=
true
)
{
{
migraph
::
program
::
parameter_map
m
;
migraph
::
program
::
parameter_map
m
;
for
(
auto
&&
x
:
p
.
get_parameter_shapes
())
for
(
auto
&&
x
:
p
.
get_parameter_shapes
())
...
...
src/program.cpp
View file @
4886f3e8
...
@@ -313,19 +313,16 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
...
@@ -313,19 +313,16 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
eval
(
params
);
eval
(
params
);
// Run and time entire program
// Run and time entire program
double
total_acc
=
0
;
double
total_acc
=
0
;
for
(
std
::
size_t
i
=
0
;
i
<
n
;
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
n
;
i
++
)
{
{
total_acc
+=
time
<
milliseconds
>
([
&
]
{
total_acc
+=
time
<
milliseconds
>
([
&
]
{
eval
(
params
);
});
eval
(
params
);
});
}
}
std
::
unordered_map
<
const
instruction
*
,
double
>
ins_acc
;
std
::
unordered_map
<
const
instruction
*
,
double
>
ins_acc
;
// Fill the map
// Fill the map
generic_eval
(
*
this
,
this
->
impl
->
ctx
,
params
,
[
&
](
auto
&
ins
,
auto
)
{
generic_eval
(
ins_acc
[
std
::
addressof
(
ins
)]
=
0
;
*
this
,
this
->
impl
->
ctx
,
params
,
[
&
](
auto
&
ins
,
auto
)
{
ins_acc
[
std
::
addressof
(
ins
)]
=
0
;
});
});
// Run and time each instruction
// Run and time each instruction
for
(
std
::
size_t
i
=
0
;
i
<
n
;
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
n
;
i
++
)
{
{
generic_eval
(
*
this
,
this
->
impl
->
ctx
,
params
,
[
&
](
auto
&
ins
,
auto
f
)
{
generic_eval
(
*
this
,
this
->
impl
->
ctx
,
params
,
[
&
](
auto
&
ins
,
auto
f
)
{
ins_acc
[
std
::
addressof
(
ins
)]
+=
time
<
milliseconds
>
(
f
);
ins_acc
[
std
::
addressof
(
ins
)]
+=
time
<
milliseconds
>
(
f
);
...
@@ -333,21 +330,20 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
...
@@ -333,21 +330,20 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
}
}
// Run and time implicit overhead
// Run and time implicit overhead
double
overhead_acc
=
0
;
double
overhead_acc
=
0
;
for
(
std
::
size_t
i
=
0
;
i
<
n
;
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
n
;
i
++
)
{
{
overhead_acc
+=
time
<
milliseconds
>
([
&
]
{
overhead_acc
+=
time
<
milliseconds
>
(
generic_eval
(
*
this
,
this
->
impl
->
ctx
,
params
,
[](
auto
&&
...)
{});
[
&
]
{
generic_eval
(
*
this
,
this
->
impl
->
ctx
,
params
,
[](
auto
&&
...)
{});
});
});
}
}
double
total_time
=
total_acc
/
n
;
double
total_time
=
total_acc
/
n
;
double
overhead_time
=
overhead_acc
/
n
;
double
overhead_time
=
overhead_acc
/
n
;
double
overhead_percent
=
overhead_time
*
100.0
/
total_time
;
double
overhead_percent
=
overhead_time
*
100.0
/
total_time
;
double
total_instruction_time
=
0.0
;
double
total_instruction_time
=
0.0
;
for
(
auto
&&
p
:
ins_acc
)
for
(
auto
&&
p
:
ins_acc
)
total_instruction_time
+=
p
.
second
/
n
;
total_instruction_time
+=
p
.
second
/
n
;
double
calculate_overhead_time
=
total_time
-
total_instruction_time
;
double
calculate_overhead_time
=
total_time
-
total_instruction_time
;
double
calculate_overhead_percent
=
calculate_overhead_time
*
100.0
/
total_time
;
double
calculate_overhead_percent
=
calculate_overhead_time
*
100.0
/
total_time
;
print_program
(
os
,
*
this
,
[
&
](
auto
&
ins
,
auto
&&
)
{
print_program
(
os
,
*
this
,
[
&
](
auto
&
ins
,
auto
&&
)
{
os
<<
": "
<<
ins_acc
[
std
::
addressof
(
ins
)]
/
n
<<
"ms"
;
os
<<
": "
<<
ins_acc
[
std
::
addressof
(
ins
)]
/
n
<<
"ms"
;
...
@@ -355,10 +351,10 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
...
@@ -355,10 +351,10 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
os
<<
"Total time: "
<<
total_time
<<
"ms"
<<
std
::
endl
;
os
<<
"Total time: "
<<
total_time
<<
"ms"
<<
std
::
endl
;
os
<<
"Total instructions time: "
<<
total_instruction_time
<<
"ms"
<<
std
::
endl
;
os
<<
"Total instructions time: "
<<
total_instruction_time
<<
"ms"
<<
std
::
endl
;
os
<<
"Overhead time: "
<<
overhead_time
<<
"ms"
<<
", "
<<
calculate_overhead_time
<<
"ms"
<<
std
::
endl
;
os
<<
"Overhead time: "
<<
overhead_time
<<
"ms"
os
<<
"Overhead: "
<<
std
::
round
(
overhead_percent
)
<<
"%"
<<
", "
<<
std
::
round
(
calculate_overhead_
percent
)
<<
"
%
"
<<
std
::
endl
;
<<
", "
<<
calculate_overhead_
time
<<
"
ms
"
<<
std
::
endl
;
os
<<
"Overhead: "
<<
std
::
round
(
overhead_percent
)
<<
"%"
<<
", "
<<
std
::
round
(
calculate_overhead_percent
)
<<
"%"
<<
std
::
endl
;
}
}
bool
operator
==
(
const
program
&
x
,
const
program
&
y
)
{
return
to_string
(
x
)
==
to_string
(
y
);
}
bool
operator
==
(
const
program
&
x
,
const
program
&
y
)
{
return
to_string
(
x
)
==
to_string
(
y
);
}
...
...
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