Commit 3d4d0179 authored by Paul's avatar Paul
Browse files

Add run and compile command

parent e6174b8f
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <migraphx/config.hpp> #include <migraphx/config.hpp>
#include <migraphx/type_name.hpp> #include <migraphx/type_name.hpp>
#include <migraphx/stringutils.hpp>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
...@@ -20,10 +21,23 @@ inline auto& get_commands() ...@@ -20,10 +21,23 @@ inline auto& get_commands()
} }
template <class T> template <class T>
std::string command_name() std::string compute_command_name()
{ {
static const std::string& name = get_type_name<T>(); static const std::string& tname = get_type_name<T>();
return name.substr(name.rfind("::") + 2); 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> template <class T>
......
...@@ -122,6 +122,40 @@ struct verify : command<verify> ...@@ -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> struct perf : command<perf>
{ {
compiler c; compiler c;
......
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