Commit 3d8c71fa authored by Paul's avatar Paul
Browse files

Format

parent bfaec6b4
......@@ -7,13 +7,13 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
template<class T>
template <class T>
std::size_t hash_value(const T& v)
{
return std::hash<T>{}(v);
}
template<class T>
template <class T>
void hash_combine(std::size_t& seed, const T& v)
{
seed ^= hash_value(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
......@@ -22,4 +22,3 @@ void hash_combine(std::size_t& seed, const T& v)
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
#endif // MIGRAPHX_GUARD_MIGRAPHX_HASH_HPP
......@@ -483,20 +483,15 @@ struct value
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
namespace std {
template <>
struct hash<migraphx::value>
{
using argument_type = migraphx::value;
using result_type = std::size_t;
result_type operator()(const migraphx::value& x) const noexcept
{
return x.hash();
}
result_type operator()(const migraphx::value& x) const noexcept { return x.hash(); }
};
} // namespace std
#endif
......@@ -90,7 +90,7 @@ struct problem_cache
optional<value> get(const std::string& name, const value& problem) const
{
auto it = cache.find(create_key(name, problem));
if (it == cache.end())
if(it == cache.end())
return nullopt;
return it->second;
}
......@@ -184,7 +184,7 @@ struct compile_manager
problem_cache pc;
std::vector<compile_plan> cps;
template<class... Ts>
template <class... Ts>
void add_plan(Ts&&... xs)
{
cps.push_back({std::forward<Ts>(xs)...});
......@@ -213,9 +213,10 @@ struct compile_manager
}
// Remove compile_plan already executed
cps.erase(std::remove_if(cps.begin(), cps.end(), [](const auto& cp) {
return not cp.results.empty();
}), cps.end());
cps.erase(std::remove_if(cps.begin(),
cps.end(),
[](const auto& cp) { return not cp.results.empty(); }),
cps.end());
}
};
......
......@@ -341,8 +341,8 @@ struct ck_gemm_compiler : compiler<ck_gemm_compiler>
auto tuning_value = v.get("tuning_value", 4);
if(not v.contains("tuning_value"))
tuning_value = get_tuning_for({a_shape, b_shape, c_shape});
auto batch_count = get_batch_count(c_shape);
auto problem = create_problem(inputs, v);
auto batch_count = get_batch_count(c_shape);
auto problem = create_problem(inputs, v);
const auto include_header = problem.GetIncludeHeader();
const auto solutions = problem.GetSolutions(ctx.get_current_device().get_gfx_name());
......@@ -398,10 +398,11 @@ struct ck_gemm_compiler : compiler<ck_gemm_compiler>
return v;
}
compiler_replace compile(context& ctx, instruction_ref ins, const operation& op, const value& solution) const
compiler_replace
compile(context& ctx, instruction_ref ins, const operation& op, const value& solution) const
{
auto shapes = to_shapes(ins->inputs());
auto v = create_settings(ins, op);
auto shapes = to_shapes(ins->inputs());
auto v = create_settings(ins, op);
v["tuning_value"] = solution;
return {compile_op(ctx, shapes, v),
[=](module& m, instruction_ref ins2, const operation& code_object) {
......@@ -425,8 +426,7 @@ struct ck_gemm_compiler : compiler<ck_gemm_compiler>
auto solutions = problem.GetSolutions(ctx.get_current_device().get_gfx_name());
tc.solutions.resize(solutions.size());
std::iota(tc.solutions.begin(), tc.solutions.end(), 0);
std::vector<shape> gemm_shapes{
shapes[0], shapes[1], shapes.back()};
std::vector<shape> gemm_shapes{shapes[0], shapes[1], shapes.back()};
tc.problem = to_value(shapes);
return tc;
}
......
......@@ -520,7 +520,7 @@ std::ostream& operator<<(std::ostream& os, const value& d)
return os;
}
template<class T>
template <class T>
std::size_t value_hash(const std::string& key, const T& x)
{
std::size_t h = hash_value(key);
......@@ -530,14 +530,14 @@ std::size_t value_hash(const std::string& key, const T& x)
std::size_t value_hash(const std::string& key, const std::vector<value>& x)
{
std::size_t h = hash_value(key);
for(const auto& v:x)
for(const auto& v : x)
hash_combine(h, v);
return h;
}
std::size_t value_hash(const std::string& key, const value::binary& x)
{
std::size_t h = hash_value(key);
for(const auto& v:x)
for(const auto& v : x)
hash_combine(h, v);
return h;
}
......@@ -545,9 +545,7 @@ std::size_t value_hash(const std::string& key, const value::binary& x)
std::size_t value::hash() const
{
std::size_t h = 0;
this->visit_value([&](const auto& a) {
h = value_hash(this->get_key(), a);
});
this->visit_value([&](const auto& a) { h = value_hash(this->get_key(), a); });
return h;
}
......
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