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
697dcb06
Commit
697dcb06
authored
Jun 05, 2019
by
Paul
Browse files
Add perf command
parent
c1d2a665
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
1 deletion
+112
-1
src/driver/CMakeLists.txt
src/driver/CMakeLists.txt
+1
-1
src/driver/main.cpp
src/driver/main.cpp
+46
-0
src/driver/perf.cpp
src/driver/perf.cpp
+48
-0
src/driver/perf.hpp
src/driver/perf.hpp
+17
-0
No files found.
src/driver/CMakeLists.txt
View file @
697dcb06
add_executable
(
driver main.cpp verify.cpp
)
add_executable
(
driver main.cpp verify.cpp
perf.cpp
)
target_link_libraries
(
driver migraphx_cpu migraphx_onnx migraphx_tf
)
if
(
MIGRAPHX_ENABLE_GPU
)
target_link_libraries
(
driver migraphx_gpu
)
...
...
src/driver/main.cpp
View file @
697dcb06
#include "argument_parser.hpp"
#include "command.hpp"
#include "verify.hpp"
#include "perf.hpp"
#include <migraphx/tf.hpp>
#include <migraphx/onnx.hpp>
...
...
@@ -51,6 +52,30 @@ struct loader
}
};
struct
compiler
{
loader
l
;
bool
gpu
=
true
;
void
parse
(
argument_parser
&
ap
)
{
l
.
parse
(
ap
);
ap
(
gpu
,
{
"--gpu"
},
ap
.
help
(
"Compile on the gpu"
),
ap
.
set_value
(
true
));
ap
(
gpu
,
{
"--cpu"
},
ap
.
help
(
"Compile on the cpu"
),
ap
.
set_value
(
false
));
}
program
compile
()
{
auto
p
=
l
.
load
();
compile_program
(
p
,
gpu
);
return
p
;
}
auto
params
(
const
program
&
p
)
{
return
create_param_map
(
p
,
gpu
);
}
};
struct
read
:
command
<
read
>
{
loader
l
;
...
...
@@ -100,6 +125,27 @@ struct verify : command<verify>
}
};
struct
perf
:
command
<
perf
>
{
compiler
c
;
unsigned
n
=
100
;
void
parse
(
argument_parser
&
ap
)
{
c
.
parse
(
ap
);
ap
(
n
,
{
"--iterations"
,
"-n"
},
ap
.
help
(
"Number of iterations to run for perf report"
));
}
void
run
()
{
std
::
cout
<<
"Compiling ... "
<<
std
::
endl
;
auto
p
=
c
.
compile
();
std
::
cout
<<
"Allocating params ... "
<<
std
::
endl
;
auto
m
=
c
.
params
(
p
);
std
::
cout
<<
"Running performance report ... "
<<
std
::
endl
;
p
.
perf_report
(
std
::
cout
,
n
,
m
);
}
};
struct
main_command
{
static
std
::
string
get_command_help
()
...
...
src/driver/perf.cpp
0 → 100644
View file @
697dcb06
#include "perf.hpp"
#include <migraphx/cpu/target.hpp>
#include <migraphx/generate.hpp>
#ifdef HAVE_GPU
#include <migraphx/gpu/target.hpp>
#include <migraphx/gpu/hip.hpp>
#endif
namespace
migraphx
{
namespace
driver
{
inline
namespace
MIGRAPHX_INLINE_NS
{
program
::
parameter_map
create_param_map
(
const
program
&
p
,
bool
gpu
)
{
program
::
parameter_map
m
;
for
(
auto
&&
x
:
p
.
get_parameter_shapes
())
{
#ifdef HAVE_GPU
if
(
gpu
)
m
[
x
.
first
]
=
gpu
::
to_gpu
(
generate_argument
(
x
.
second
));
else
#endif
m
[
x
.
first
]
=
generate_argument
(
x
.
second
);
}
return
m
;
}
void
compile_program
(
program
&
p
,
bool
gpu
)
{
if
(
gpu
)
{
#ifdef HAVE_GPU
p
.
compile
(
gpu
::
target
{});
#else
MIGRAPHX_THROW
(
"Gpu not supported."
);
#endif
}
else
{
p
.
compile
(
cpu
::
target
{});
}
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace driver
}
// namespace migraphx
src/driver/perf.hpp
0 → 100644
View file @
697dcb06
#ifndef MIGRAPHX_GUARD_RTGLIB_PERF_HPP
#define MIGRAPHX_GUARD_RTGLIB_PERF_HPP
#include <migraphx/program.hpp>
namespace
migraphx
{
namespace
driver
{
inline
namespace
MIGRAPHX_INLINE_NS
{
program
::
parameter_map
create_param_map
(
const
program
&
p
,
bool
gpu
=
true
);
void
compile_program
(
program
&
p
,
bool
gpu
=
true
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace driver
}
// namespace migraphx
#endif
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