Commit ae70a47c authored by Paul's avatar Paul
Browse files

Add dry run test

parent 009cf895
...@@ -105,6 +105,8 @@ struct program ...@@ -105,6 +105,8 @@ struct program
void debug_print(instruction_ref ins) const; void debug_print(instruction_ref ins) const;
void debug_print(const std::vector<instruction_ref>& inss) const; void debug_print(const std::vector<instruction_ref>& inss) const;
void dry_run(parameter_map params) const;
friend std::ostream& operator<<(std::ostream& os, const program& p); friend std::ostream& operator<<(std::ostream& os, const program& p);
friend bool operator==(const program& x, const program& y); friend bool operator==(const program& x, const program& y);
friend bool operator!=(const program& x, const program& y) { return !(x == y); } friend bool operator!=(const program& x, const program& y) { return !(x == y); }
......
...@@ -511,6 +511,12 @@ void program::debug_print(const std::vector<instruction_ref>& inss) const ...@@ -511,6 +511,12 @@ void program::debug_print(const std::vector<instruction_ref>& inss) const
std::cout << std::endl; std::cout << std::endl;
} }
void program::dry_run(std::unordered_map<std::string, argument> params) const
{
auto& ctx = this->impl->ctx;
generic_eval(*this, ctx, params, [](auto&&...) { return argument{}; });
}
bool operator==(const program& x, const program& y) { return to_string(x) == to_string(y); } bool operator==(const program& x, const program& y) { return to_string(x) == to_string(y); }
std::ostream& operator<<(std::ostream& os, const program& p) std::ostream& operator<<(std::ostream& os, const program& p)
......
...@@ -122,7 +122,14 @@ migraphx::argument run_gpu(migraphx::program& p) ...@@ -122,7 +122,14 @@ migraphx::argument run_gpu(migraphx::program& p)
m[x.first] = m[x.first] =
migraphx::gpu::to_gpu(migraphx::generate_argument(x.second, get_hash(x.first))); migraphx::gpu::to_gpu(migraphx::generate_argument(x.second, get_hash(x.first)));
} }
// Program should have an output parameter
EXPECT(bool{m.find("output") != m.end()}); EXPECT(bool{m.find("output") != m.end()});
// Ensure the program doesn't modify the context in a dry run
auto ctx = p.get_context();
assert(&ctx != &p.get_context());
EXPECT(is_shared(ctx, p.get_context()));
p.dry_run(m);
EXPECT(is_shared(ctx, p.get_context()));
return migraphx::gpu::from_gpu(p.eval(m)); return migraphx::gpu::from_gpu(p.eval(m));
} }
......
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