Commit 90aca5c3 authored by Paul's avatar Paul
Browse files

Formatting

parent 37236428
...@@ -14,7 +14,7 @@ struct loader ...@@ -14,7 +14,7 @@ struct loader
{ {
std::string file; std::string file;
std::string type; std::string type;
bool is_nhwc = false; bool is_nhwc = false;
unsigned trim = 0; unsigned trim = 0;
void parse(argument_parser& ap) void parse(argument_parser& ap)
...@@ -43,9 +43,9 @@ struct loader ...@@ -43,9 +43,9 @@ struct loader
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);
if (trim > 0) if(trim > 0)
{ {
auto last = std::prev(p.end(), trim); auto last = std::prev(p.end(), trim);
p.remove_instructions(last, p.end()); p.remove_instructions(last, p.end());
} }
return p; return p;
...@@ -67,15 +67,19 @@ struct read : command<read> ...@@ -67,15 +67,19 @@ struct read : command<read>
struct verify : command<verify> struct verify : command<verify>
{ {
loader l; loader l;
double tolerance = 80; double tolerance = 80;
bool per_instruction = false; bool per_instruction = false;
bool reduce = false; bool reduce = false;
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.add(tolerance, {"--tolerance"}, ap.help("Tolerance for errors"));
ap.add(per_instruction, {"-i", "--per-instruction"}, ap.help("Verify each instruction"), ap.set_value(true)); ap.add(per_instruction,
ap.add(reduce, {"-r", "--reduce"}, ap.help("Reduce program and verify"), ap.set_value(true)); {"-i", "--per-instruction"},
ap.help("Verify each instruction"),
ap.set_value(true));
ap.add(
reduce, {"-r", "--reduce"}, ap.help("Reduce program and verify"), ap.set_value(true));
} }
void run() void run()
......
...@@ -41,8 +41,7 @@ argument run_gpu(program p) ...@@ -41,8 +41,7 @@ argument run_gpu(program p)
program::parameter_map m; program::parameter_map m;
for(auto&& x : p.get_parameter_shapes()) for(auto&& x : p.get_parameter_shapes())
{ {
m[x.first] = m[x.first] = gpu::to_gpu(generate_argument(x.second, get_hash(x.first)));
gpu::to_gpu(generate_argument(x.second, get_hash(x.first)));
} }
auto out = gpu::from_gpu(p.eval(m)); auto out = gpu::from_gpu(p.eval(m));
std::cout << p << std::endl; std::cout << p << std::endl;
...@@ -81,8 +80,7 @@ void verify_instructions(const program& prog, double tolerance) ...@@ -81,8 +80,7 @@ void verify_instructions(const program& prog, double tolerance)
if(arg->name() == "@literal") if(arg->name() == "@literal")
inputs.push_back(p.add_literal(arg->get_literal())); inputs.push_back(p.add_literal(arg->get_literal()));
else else
inputs.push_back( inputs.push_back(p.add_parameter(std::to_string(inputs.size()), arg->get_shape()));
p.add_parameter(std::to_string(inputs.size()), arg->get_shape()));
} }
p.add_instruction(ins.get_operator(), inputs); p.add_instruction(ins.get_operator(), inputs);
try try
...@@ -101,7 +99,7 @@ void verify_instructions(const program& prog, double tolerance) ...@@ -101,7 +99,7 @@ void verify_instructions(const program& prog, double tolerance)
void verify_reduced(program p, int n, double tolerance) void verify_reduced(program p, int n, double tolerance)
{ {
auto last = std::prev(p.end(), n + 1); auto last = std::prev(p.end(), n + 1);
p.remove_instructions(last, p.end()); p.remove_instructions(last, p.end());
std::cout << "Verify: " << std::endl; std::cout << "Verify: " << std::endl;
std::cout << p << std::endl; std::cout << p << std::endl;
...@@ -110,7 +108,7 @@ void verify_reduced(program p, int n, double tolerance) ...@@ -110,7 +108,7 @@ void verify_reduced(program p, int n, double tolerance)
void verify_reduced_program(program p, double tolerance) void verify_reduced_program(program p, double tolerance)
{ {
auto n = std::distance(p.begin(), p.end()); auto n = std::distance(p.begin(), p.end());
for(std::size_t i = 0; i < n; i++) for(std::size_t i = 0; i < n; i++)
{ {
verify_reduced(p, i, tolerance); verify_reduced(p, i, tolerance);
......
...@@ -13,7 +13,6 @@ void verify_program(const std::string& name, program p, double tolerance = 100); ...@@ -13,7 +13,6 @@ void verify_program(const std::string& name, program p, double tolerance = 100);
void verify_instructions(const program& prog, double tolerance = 80); void verify_instructions(const program& prog, double tolerance = 80);
void verify_reduced_program(program p, double tolerance = 80); void verify_reduced_program(program p, double tolerance = 80);
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace driver } // namespace driver
} // namespace migraphx } // namespace migraphx
......
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