Commit e45e0216 authored by umangyadav's avatar umangyadav
Browse files

formatting

parent aff10174
...@@ -61,7 +61,9 @@ struct program ...@@ -61,7 +61,9 @@ struct program
instruction_ref validate() const; instruction_ref validate() const;
void compile(const target& t, compile_options options = compile_options{}, std::string ir_dump_path="passes"); void compile(const target& t,
compile_options options = compile_options{},
std::string ir_dump_path = "passes");
bool is_compiled() const; bool is_compiled() const;
......
...@@ -19,24 +19,27 @@ struct tracer ...@@ -19,24 +19,27 @@ struct tracer
template <class... Ts> template <class... Ts>
void operator()(const std::string& program_name, const Ts&... xs) void operator()(const std::string& program_name, const Ts&... xs)
{ {
if(this->enabled()) { if(this->enabled())
{
fs::path dir_path = fs::current_path() / this->dump_dir; fs::path dir_path = fs::current_path() / this->dump_dir;
if(not fs::exists(dir_path)) { if(not fs::exists(dir_path))
{
fs::create_directories(dir_path); fs::create_directories(dir_path);
} }
fs::path ir_file_path = dir_path / (std::to_string(this->counter++)+"_"+program_name+".mxr"); fs::path ir_file_path =
dir_path / (std::to_string(this->counter++) + "_" + program_name + ".mxr");
std::ofstream ofs(ir_file_path); std::ofstream ofs(ir_file_path);
swallow{ofs<<xs...}; swallow{ofs << xs...};
ofs<<std::endl; ofs << std::endl;
ofs.close(); ofs.close();
} }
} }
std::string dump_dir; std::string dump_dir;
private: private:
uint counter; uint counter;
}; };
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -83,7 +83,7 @@ module& get_module(module_pass_manager& mpm) { return mpm.get_module(); } ...@@ -83,7 +83,7 @@ module& get_module(module_pass_manager& mpm) { return mpm.get_module(); }
void run_passes(module& mod, const std::vector<pass>& passes, tracer trace) void run_passes(module& mod, const std::vector<pass>& passes, tracer trace)
{ {
if(enabled(MIGRAPHX_TRACE_PASSES{})) if(enabled(MIGRAPHX_TRACE_PASSES{}))
trace = tracer{mod.name()+"_passes"}; trace = tracer{mod.name() + "_passes"};
for(const auto& p : passes) for(const auto& p : passes)
{ {
module_pm{&mod, nullptr, &trace}.run_pass(p); module_pm{&mod, nullptr, &trace}.run_pass(p);
...@@ -101,9 +101,10 @@ void run_passes(program& prog, const std::vector<pass>& passes, tracer trace) ...@@ -101,9 +101,10 @@ void run_passes(program& prog, const std::vector<pass>& passes, tracer trace)
auto mods = prog.get_modules(); auto mods = prog.get_modules();
for(const auto& mod : reverse(mods)) for(const auto& mod : reverse(mods))
{ {
if(!module_tracer_map.count(mod->name())) { if(!module_tracer_map.count(mod->name()))
{
module_tracer_map[mod->name()] = module_trace; module_tracer_map[mod->name()] = module_trace;
module_tracer_map[mod->name()].dump_dir += "/"+mod->name(); module_tracer_map[mod->name()].dump_dir += "/" + mod->name();
} }
if(mod->bypass()) if(mod->bypass())
continue; continue;
......
...@@ -144,7 +144,7 @@ void program::compile(const target& t, compile_options options, std::string ir_d ...@@ -144,7 +144,7 @@ void program::compile(const target& t, compile_options options, std::string ir_d
this->impl->target_name = t.name(); this->impl->target_name = t.name();
this->impl->ctx = t.get_context(); this->impl->ctx = t.get_context();
if(enabled(MIGRAPHX_TRACE_COMPILE{})) if(enabled(MIGRAPHX_TRACE_COMPILE{}))
options.trace = tracer{t.name()+"_"+ir_dump_path}; options.trace = tracer{t.name() + "_" + ir_dump_path};
options.trace("input_program", *this); options.trace("input_program", *this);
......
...@@ -41,7 +41,7 @@ inline void compile_check(migraphx::program& p, const migraphx::target& t, bool ...@@ -41,7 +41,7 @@ inline void compile_check(migraphx::program& p, const migraphx::target& t, bool
std::stringstream ss; std::stringstream ss;
migraphx::compile_options options; migraphx::compile_options options;
if(show_trace) if(show_trace)
options.trace = migraphx::tracer{t.name()+"_passes"}; options.trace = migraphx::tracer{t.name() + "_passes"};
p.compile(t, options); p.compile(t, options);
if(shapes.size() != p.get_output_shapes().size()) if(shapes.size() != p.get_output_shapes().size())
{ {
......
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