Commit 18273046 authored by Paul's avatar Paul
Browse files

Allow putting inputs in the settings

parent d11ec237
...@@ -36,7 +36,7 @@ struct compile_op : action<compile_op> ...@@ -36,7 +36,7 @@ struct compile_op : action<compile_op>
static void apply(const parser& p, const value& v) static void apply(const parser& p, const value& v)
{ {
context ctx; context ctx;
auto inputs = p.parse_shapes(v.at("inputs")); auto inputs = p.get_inputs(v);
auto op = gpu::compile_op(v.at("name").to<std::string>(), ctx, inputs, v); auto op = gpu::compile_op(v.at("name").to<std::string>(), ctx, inputs, v);
auto [host_time, device_time] = time_op(ctx, op, inputs, p.get(v, "iterations", 100)); auto [host_time, device_time] = time_op(ctx, op, inputs, p.get(v, "iterations", 100));
std::cout << op << ": " << host_time << "ms"; std::cout << op << ": " << host_time << "ms";
......
...@@ -53,6 +53,8 @@ struct parser ...@@ -53,6 +53,8 @@ struct parser
std::vector<shape> parse_shapes(const value& v) const; std::vector<shape> parse_shapes(const value& v) const;
std::vector<shape> get_inputs(const value& v) const;
void load_settings(const value& v); void load_settings(const value& v);
static void process(const value& v); static void process(const value& v);
......
...@@ -55,6 +55,11 @@ std::vector<shape> parser::parse_shapes(const value& v) const ...@@ -55,6 +55,11 @@ std::vector<shape> parser::parse_shapes(const value& v) const
return result; return result;
} }
std::vector<shape> parser::get_inputs(const value& v) const
{
return parse_shapes(get(v, "inputs", value{}));
}
void parser::load_settings(const value& v) void parser::load_settings(const value& v)
{ {
if(v.contains("settings")) if(v.contains("settings"))
......
...@@ -36,7 +36,7 @@ struct run_op : action<run_op> ...@@ -36,7 +36,7 @@ struct run_op : action<run_op>
static void apply(const parser& p, const value& v) static void apply(const parser& p, const value& v)
{ {
context ctx; context ctx;
auto inputs = p.parse_shapes(v.at("inputs")); auto inputs = p.get_inputs(v);
auto name = v.at("name").to<std::string>(); auto name = v.at("name").to<std::string>();
if(not contains(name, "::")) if(not contains(name, "::"))
name = "gpu::" + name; name = "gpu::" + name;
......
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