"docs/vscode:/vscode.git/clone" did not exist on "57de7c6b5fb3fa99a386ee0500b25cdbf98eb1a2"
Unverified Commit 1898e3e5 authored by kahmed10's avatar kahmed10 Committed by GitHub
Browse files

Echo driver command (#2377)

parent a3cc2c7c
...@@ -59,6 +59,13 @@ namespace migraphx { ...@@ -59,6 +59,13 @@ namespace migraphx {
namespace driver { namespace driver {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
inline std::string get_version()
{
return "MIGraphX Version: " + std::to_string(MIGRAPHX_VERSION_MAJOR) + "." +
std::to_string(MIGRAPHX_VERSION_MINOR) + "." + std::to_string(MIGRAPHX_VERSION_PATCH) +
"." + MIGRAPHX_STRINGIZE(MIGRAPHX_VERSION_TWEAK);
}
struct loader struct loader
{ {
std::string model; std::string model;
...@@ -597,16 +604,6 @@ struct verify : command<verify> ...@@ -597,16 +604,6 @@ struct verify : command<verify>
} }
}; };
struct version : command<version>
{
void parse(const argument_parser&) {}
void run() const
{
std::cout << "MIGraphX Version: " << MIGRAPHX_VERSION_MAJOR << "." << MIGRAPHX_VERSION_MINOR
<< "." << MIGRAPHX_VERSION_PATCH << "." MIGRAPHX_VERSION_TWEAK << std::endl;
}
};
struct compile : command<compile> struct compile : command<compile>
{ {
compiler c; compiler c;
...@@ -759,16 +756,14 @@ struct main_command ...@@ -759,16 +756,14 @@ struct main_command
} }
void parse(argument_parser& ap) void parse(argument_parser& ap)
{ {
std::string version_str = "MIGraphX Version: " + std::to_string(MIGRAPHX_VERSION_MAJOR) + std::string version_str = get_version();
"." + std::to_string(MIGRAPHX_VERSION_MINOR) + "." +
std::to_string(MIGRAPHX_VERSION_PATCH) +
"." MIGRAPHX_VERSION_TWEAK;
ap(wrong_commands, {}, ap.metavar("<command>"), ap.append()); ap(wrong_commands, {}, ap.metavar("<command>"), ap.append());
ap(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()));
ap(nullptr, ap(nullptr,
{"-v", "--version"}, {"-v", "--version"},
ap.help("Show MIGraphX version"), ap.help("Show MIGraphX version"),
ap.show_help(version_str)); ap.show_help(version_str));
ap(nullptr, {"--ort-sha"}, ap.help("Show MIGraphX onnx runtime SHA"));
// Trim command off of exe name // Trim command off of exe name
ap.set_exe_name(ap.get_exe_name().substr(0, ap.get_exe_name().size() - 5)); ap.set_exe_name(ap.get_exe_name().substr(0, ap.get_exe_name().size() - 5));
...@@ -811,7 +806,6 @@ using namespace migraphx::driver; // NOLINT ...@@ -811,7 +806,6 @@ using namespace migraphx::driver; // NOLINT
int main(int argc, const char* argv[]) int main(int argc, const char* argv[])
{ {
std::vector<std::string> args(argv + 1, argv + argc); std::vector<std::string> args(argv + 1, argv + argc);
// no argument, print the help infomration by default // no argument, print the help infomration by default
if(args.empty()) if(args.empty())
{ {
...@@ -821,15 +815,27 @@ int main(int argc, const char* argv[]) ...@@ -821,15 +815,27 @@ int main(int argc, const char* argv[])
auto&& m = get_commands(); auto&& m = get_commands();
auto cmd = args.front(); auto cmd = args.front();
if(cmd == "ort-sha") if(cmd == "--ort-sha")
{ {
std::cout << MIGRAPHX_ORT_SHA1 << std::endl; std::cout << MIGRAPHX_ORT_SHA1 << std::endl;
return 0; return 0;
} }
if(cmd == "-v" or cmd == "--version")
{
std::cout << get_version() << std::endl;
return 0;
}
if(m.count(cmd) > 0) if(m.count(cmd) > 0)
{ {
m.at(cmd)(argv[0], {args.begin() + 1, args.end()}); std::string driver_invocation =
std::string(argv[0]) + " " + migraphx::to_string_range(args, " ");
std::cout << "Running [ " << get_version() << " ]: " << driver_invocation << std::endl;
m.at(cmd)(argv[0],
{args.begin() + 1, args.end()}); // run driver command found in commands map
std::cout << "[ " << get_version() << " ] Complete: " << driver_invocation << std::endl;
} }
else else
{ {
......
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