Unverified Commit 0a9c18a5 authored by Paul Fultz II's avatar Paul Fultz II Committed by GitHub
Browse files

Add perf grouping (#841)


Co-authored-by: default avatarmvermeulen <5479696+mvermeulen@users.noreply.github.com>
parent ee79e9b7
......@@ -484,6 +484,14 @@ double common_average(const std::vector<double>& v)
return total / std::distance(v.begin() + n, v.end() - n);
}
std::string perf_group(const operation& op)
{
auto attr = op.attributes();
if(attr.contains("group"))
return attr.at("group").to<std::string>();
return op.name();
}
void program::perf_report(std::ostream& os, std::size_t n, parameter_map params) const
{
auto& ctx = this->impl->ctx;
......@@ -538,7 +546,7 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
for(auto&& p : ins_vec)
{
double avg = common_average(p.second);
op_times[p.first->name()] += avg;
op_times[perf_group(p.first->get_operator())] += avg;
total_instruction_time += avg;
}
double calculate_overhead_time = total_time - total_instruction_time;
......
......@@ -14,6 +14,8 @@ struct dnnl_binary : dnnl_op<dnnl_binary, dnnl::binary>
return pack_join(self.reflect_base(self, f), pack(f(self.algo, "algo")));
}
std::string group() const { return this->name() + "::" + algo; }
std::string name() const { return "dnnl::binary"; }
shape compute_shape(std::vector<shape> inputs) const
......
......@@ -17,6 +17,8 @@ struct dnnl_eltwise : dnnl_op<dnnl_eltwise, dnnl::eltwise_forward>
pack(f(self.algo, "algo"), f(self.alpha, "alpha"), f(self.beta, "beta")));
}
std::string group() const { return this->name() + "::" + algo; }
std::string name() const { return "dnnl::eltwise"; }
shape compute_shape(std::vector<shape> inputs) const
......
......@@ -74,6 +74,25 @@ struct dnnl_op : auto_register_op<Derived>
return reflect_base(self, f);
}
std::string group() const
{
const auto& self = static_cast<const Derived&>(*this);
return self.name();
}
value attributes() const
{
std::vector<std::string> names;
std::transform(post_ops.begin(), post_ops.end(), std::back_inserter(names), [](auto&& op) {
return op.algo;
});
const auto& self = static_cast<const Derived&>(*this);
auto g = self.group();
if(not names.empty())
g += "<" + join_strings(names, ",") + ">";
return {{"group", g}};
}
std::size_t get_extra_post_op_args() const
{
return std::count_if(post_ops.begin(), post_ops.end(), [](const auto& po) {
......
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