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
f0c57f28
Commit
f0c57f28
authored
Jun 05, 2019
by
Paul
Browse files
Shortedn call to add args
parent
90aca5c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
src/driver/argument_parser.hpp
src/driver/argument_parser.hpp
+2
-2
src/driver/command.hpp
src/driver/command.hpp
+1
-1
src/driver/main.cpp
src/driver/main.cpp
+10
-10
No files found.
src/driver/argument_parser.hpp
View file @
f0c57f28
...
@@ -62,7 +62,7 @@ struct argument_parser
...
@@ -62,7 +62,7 @@ struct argument_parser
};
};
template
<
class
T
,
class
...
Fs
>
template
<
class
T
,
class
...
Fs
>
void
add
(
T
&
x
,
std
::
vector
<
std
::
string
>
flags
,
Fs
...
fs
)
void
operator
()
(
T
&
x
,
std
::
vector
<
std
::
string
>
flags
,
Fs
...
fs
)
{
{
arguments
.
push_back
({
flags
,
[
&
](
auto
&&
,
const
std
::
vector
<
std
::
string
>&
params
)
{
arguments
.
push_back
({
flags
,
[
&
](
auto
&&
,
const
std
::
vector
<
std
::
string
>&
params
)
{
if
(
params
.
empty
())
if
(
params
.
empty
())
...
@@ -77,7 +77,7 @@ struct argument_parser
...
@@ -77,7 +77,7 @@ struct argument_parser
}
}
template
<
class
...
Fs
>
template
<
class
...
Fs
>
void
add
(
std
::
nullptr_t
x
,
std
::
vector
<
std
::
string
>
flags
,
Fs
...
fs
)
void
operator
()
(
std
::
nullptr_t
x
,
std
::
vector
<
std
::
string
>
flags
,
Fs
...
fs
)
{
{
arguments
.
push_back
({
flags
});
arguments
.
push_back
({
flags
});
...
...
src/driver/command.hpp
View file @
f0c57f28
...
@@ -32,7 +32,7 @@ void run_command(std::vector<std::string> args, bool add_help = false)
...
@@ -32,7 +32,7 @@ void run_command(std::vector<std::string> args, bool add_help = false)
T
x
;
T
x
;
argument_parser
ap
;
argument_parser
ap
;
if
(
add_help
)
if
(
add_help
)
ap
.
add
(
nullptr
,
{
"-h"
,
"--help"
},
ap
.
help
(
"Show help"
),
ap
.
show_help
());
ap
(
nullptr
,
{
"-h"
,
"--help"
},
ap
.
help
(
"Show help"
),
ap
.
show_help
());
x
.
parse
(
ap
);
x
.
parse
(
ap
);
if
(
ap
.
parse
(
args
))
if
(
ap
.
parse
(
args
))
return
;
return
;
...
...
src/driver/main.cpp
View file @
f0c57f28
...
@@ -19,13 +19,13 @@ struct loader
...
@@ -19,13 +19,13 @@ struct loader
void
parse
(
argument_parser
&
ap
)
void
parse
(
argument_parser
&
ap
)
{
{
ap
.
add
(
file
,
{},
ap
.
metavar
(
"<input file>"
));
ap
(
file
,
{},
ap
.
metavar
(
"<input file>"
));
ap
.
add
(
type
,
{
"--onnx"
},
ap
.
help
(
"Load as onnx"
),
ap
.
set_value
(
"onnx"
));
ap
(
type
,
{
"--onnx"
},
ap
.
help
(
"Load as onnx"
),
ap
.
set_value
(
"onnx"
));
ap
.
add
(
type
,
{
"--tf"
},
ap
.
help
(
"Load as tensorflow"
),
ap
.
set_value
(
"tf"
));
ap
(
type
,
{
"--tf"
},
ap
.
help
(
"Load as tensorflow"
),
ap
.
set_value
(
"tf"
));
ap
.
add
(
is_nhwc
,
{
"--nhwc"
},
ap
.
help
(
"Treat tensorflow format as nhwc"
),
ap
.
set_value
(
true
));
ap
(
is_nhwc
,
{
"--nhwc"
},
ap
.
help
(
"Treat tensorflow format as nhwc"
),
ap
.
set_value
(
true
));
ap
.
add
(
ap
(
is_nhwc
,
{
"--nchw"
},
ap
.
help
(
"Treat tensorflow format as nchw"
),
ap
.
set_value
(
false
));
is_nhwc
,
{
"--nchw"
},
ap
.
help
(
"Treat tensorflow format as nchw"
),
ap
.
set_value
(
false
));
ap
.
add
(
trim
,
{
"--trim"
,
"-t"
},
ap
.
help
(
"Trim instructions from the end"
));
ap
(
trim
,
{
"--trim"
,
"-t"
},
ap
.
help
(
"Trim instructions from the end"
));
}
}
program
load
()
program
load
()
...
@@ -73,12 +73,12 @@ struct verify : command<verify>
...
@@ -73,12 +73,12 @@ struct verify : command<verify>
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
(
tolerance
,
{
"--tolerance"
},
ap
.
help
(
"Tolerance for errors"
));
ap
.
add
(
per_instruction
,
ap
(
per_instruction
,
{
"-i"
,
"--per-instruction"
},
{
"-i"
,
"--per-instruction"
},
ap
.
help
(
"Verify each instruction"
),
ap
.
help
(
"Verify each instruction"
),
ap
.
set_value
(
true
));
ap
.
set_value
(
true
));
ap
.
add
(
ap
(
reduce
,
{
"-r"
,
"--reduce"
},
ap
.
help
(
"Reduce program and verify"
),
ap
.
set_value
(
true
));
reduce
,
{
"-r"
,
"--reduce"
},
ap
.
help
(
"Reduce program and verify"
),
ap
.
set_value
(
true
));
}
}
...
@@ -113,7 +113,7 @@ struct main_command
...
@@ -113,7 +113,7 @@ struct main_command
}
}
void
parse
(
argument_parser
&
ap
)
void
parse
(
argument_parser
&
ap
)
{
{
ap
.
add
(
nullptr
,
{
"-h"
,
"--help"
},
ap
.
help
(
"Show help"
),
ap
.
show_help
(
get_command_help
()));
ap
(
nullptr
,
{
"-h"
,
"--help"
},
ap
.
help
(
"Show help"
),
ap
.
show_help
(
get_command_help
()));
}
}
void
run
()
{}
void
run
()
{}
...
...
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