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
3d4d0179
Commit
3d4d0179
authored
Jun 05, 2019
by
Paul
Browse files
Add run and compile command
parent
e6174b8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
src/driver/command.hpp
src/driver/command.hpp
+17
-3
src/driver/main.cpp
src/driver/main.cpp
+34
-0
No files found.
src/driver/command.hpp
View file @
3d4d0179
...
...
@@ -5,6 +5,7 @@
#include <migraphx/config.hpp>
#include <migraphx/type_name.hpp>
#include <migraphx/stringutils.hpp>
#include <unordered_map>
#include <vector>
...
...
@@ -20,10 +21,23 @@ inline auto& get_commands()
}
template
<
class
T
>
std
::
string
command_name
()
std
::
string
compute_
command_name
()
{
static
const
std
::
string
&
name
=
get_type_name
<
T
>
();
return
name
.
substr
(
name
.
rfind
(
"::"
)
+
2
);
static
const
std
::
string
&
tname
=
get_type_name
<
T
>
();
auto
name
=
tname
.
substr
(
tname
.
rfind
(
"::"
)
+
2
);
if
(
ends_with
(
name
,
"_command"
))
name
=
name
.
substr
(
0
,
name
.
size
()
-
8
);
if
(
ends_with
(
name
,
"_cmd"
))
name
=
name
.
substr
(
0
,
name
.
size
()
-
4
);
return
name
;
}
template
<
class
T
>
const
std
::
string
&
command_name
()
{
static
const
std
::
string
&
name
=
compute_command_name
<
T
>
();
return
name
;
}
template
<
class
T
>
...
...
src/driver/main.cpp
View file @
3d4d0179
...
...
@@ -122,6 +122,40 @@ struct verify : command<verify>
}
};
struct
compile
:
command
<
compile
>
{
compiler
c
;
void
parse
(
argument_parser
&
ap
)
{
c
.
parse
(
ap
);
}
void
run
()
{
std
::
cout
<<
"Compiling ... "
<<
std
::
endl
;
auto
p
=
c
.
compile
();
std
::
cout
<<
p
<<
std
::
endl
;
}
};
struct
run_cmd
:
command
<
run_cmd
>
{
compiler
c
;
void
parse
(
argument_parser
&
ap
)
{
c
.
parse
(
ap
);
}
void
run
()
{
std
::
cout
<<
"Compiling ... "
<<
std
::
endl
;
auto
p
=
c
.
compile
();
std
::
cout
<<
"Allocating params ... "
<<
std
::
endl
;
auto
m
=
c
.
params
(
p
);
std
::
cout
<<
p
<<
std
::
endl
;
}
};
struct
perf
:
command
<
perf
>
{
compiler
c
;
...
...
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