Commit de62b8ac authored by Paul's avatar Paul
Browse files

Formatting

parent c20d0fc2
...@@ -89,9 +89,7 @@ struct argument_parser ...@@ -89,9 +89,7 @@ struct argument_parser
static auto nargs(unsigned n = 1) static auto nargs(unsigned n = 1)
{ {
return [=](auto&&, auto& arg) { return [=](auto&&, auto& arg) { arg.nargs = n; };
arg.nargs = n;
};
} }
template <class F> template <class F>
...@@ -135,7 +133,7 @@ struct argument_parser ...@@ -135,7 +133,7 @@ struct argument_parser
{ {
std::cout << std::endl; std::cout << std::endl;
std::string prefix = " "; std::string prefix = " ";
if (arg.flags.empty()) if(arg.flags.empty())
{ {
std::cout << prefix; std::cout << prefix;
std::cout << arg.metavar; std::cout << arg.metavar;
...@@ -185,16 +183,14 @@ struct argument_parser ...@@ -185,16 +183,14 @@ struct argument_parser
std::unordered_map<std::string, unsigned> keywords; std::unordered_map<std::string, unsigned> keywords;
for(auto&& arg : arguments) for(auto&& arg : arguments)
{ {
for(auto&& flag:arg.flags) for(auto&& flag : arg.flags)
keywords[flag] = arg.nargs + 1; keywords[flag] = arg.nargs + 1;
} }
auto arg_map = generic_parse(args, [&](std::string x) { auto arg_map = generic_parse(args, [&](std::string x) { return keywords[x]; });
return keywords[x];
});
for(auto&& arg : arguments) for(auto&& arg : arguments)
{ {
auto flags = arg.flags; auto flags = arg.flags;
if (flags.empty()) if(flags.empty())
flags = {""}; flags = {""};
for(auto&& flag : arg.flags) for(auto&& flag : arg.flags)
{ {
...@@ -223,18 +219,17 @@ struct argument_parser ...@@ -223,18 +219,17 @@ struct argument_parser
{ {
flag = x; flag = x;
result[flag]; // Ensure the flag exists result[flag]; // Ensure the flag exists
if (k == 1) if(k == 1)
flag = ""; flag = "";
else if (k == 2) else if(k == 2)
clear = true; clear = true;
else else
clear = false; clear = false;
} }
else else
{ {
result[flag].push_back(x); result[flag].push_back(x);
if (clear) if(clear)
flag = ""; flag = "";
clear = false; clear = false;
} }
......
...@@ -26,15 +26,15 @@ std::string command_name() ...@@ -26,15 +26,15 @@ std::string command_name()
return name.substr(name.rfind("::") + 2); return name.substr(name.rfind("::") + 2);
} }
template<class T> template <class T>
void run_command(std::vector<std::string> args, bool add_help=false) 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.add(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;
x.run(); x.run();
} }
...@@ -43,9 +43,7 @@ template <class T> ...@@ -43,9 +43,7 @@ template <class T>
int auto_register_command() int auto_register_command()
{ {
auto& m = get_commands(); auto& m = get_commands();
m[command_name<T>()] = [](std::vector<std::string> args) { m[command_name<T>()] = [](std::vector<std::string> args) { run_command<T>(args, true); };
run_command<T>(args, true);
};
return 0; return 0;
} }
......
...@@ -21,22 +21,23 @@ struct loader ...@@ -21,22 +21,23 @@ struct loader
ap.add(type, {"--onnx"}, ap.help("Load as onnx"), ap.set_value("onnx")); ap.add(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.add(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.add(is_nhwc, {"--nhwc"}, ap.help("Treat tensorflow format as nhwc"), ap.set_value(true));
ap.add(is_nhwc, {"--nchw"}, ap.help("Treat tensorflow format as nchw"), ap.set_value(false)); ap.add(
is_nhwc, {"--nchw"}, ap.help("Treat tensorflow format as nchw"), ap.set_value(false));
} }
program load() program load()
{ {
program p; program p;
if (type.empty()) if(type.empty())
{ {
if (ends_with(file, ".onnx")) if(ends_with(file, ".onnx"))
type = "onnx"; type = "onnx";
else else
type = "tf"; type = "tf";
} }
if (type == "onnx") if(type == "onnx")
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);
return p; return p;
} }
...@@ -45,10 +46,7 @@ struct loader ...@@ -45,10 +46,7 @@ struct loader
struct read : command<read> struct read : command<read>
{ {
loader l; loader l;
void parse(argument_parser& ap) void parse(argument_parser& ap) { l.parse(ap); }
{
l.parse(ap);
}
void run() void run()
{ {
......
...@@ -24,8 +24,9 @@ using bool_c = std::integral_constant<bool, B>; ...@@ -24,8 +24,9 @@ using bool_c = std::integral_constant<bool, B>;
#define MIGRAPHX_REQUIRES(...) class = void #define MIGRAPHX_REQUIRES(...) class = void
#else #else
#define MIGRAPHX_REQUIRES(...) \ #define MIGRAPHX_REQUIRES(...) \
bool MIGRAPHX_REQUIRES_VAR()=true, \ bool MIGRAPHX_REQUIRES_VAR() = true, \
typename std::enable_if<(MIGRAPHX_REQUIRES_VAR() && (migraphx::and_<__VA_ARGS__>{})), int>::type = 0 typename std::enable_if<(MIGRAPHX_REQUIRES_VAR() && (migraphx::and_<__VA_ARGS__>{})), \
int>::type = 0
#endif #endif
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment