"doc/vscode:/vscode.git/clone" did not exist on "ffb1f7bf095bcf4b8e25383820053e2c8e92f5ee"
Commit 3d8c71fa authored by Paul's avatar Paul
Browse files

Format

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