提交 d1adc9a2 编写于 作者: M Megvii Engine Team

fix(dnn): fix opencl algo search

GitOrigin-RevId: 25997d0ef168769b18f06434b32a99739f857bb0
上级 368c1860
......@@ -155,7 +155,15 @@ public:
template <typename T>
static T deserialize_read_pod(const std::string& data, size_t offset = 0) {
T ret = *reinterpret_cast<const T*>(&data[offset]);
T ret;
//! A pointer to an object or incomplete type may be converted to a
//! pointer to a different object or incomplete type. If the resulting
//! pointer is not correctly aligned for the pointed-to type, the
//! behavior is undefined.
//!
//! so here we should use memcpy instead of
//! *reinterpret_cast<const T*>(&data[offset]);
memcpy(&ret, data.data() + offset, sizeof(T));
return ret;
}
......
......@@ -48,10 +48,10 @@ typename Opr::AlgoBase* get_algorithm_or_construct(Opr* opr, Args&&... args) {
if (set.valid()) {
return opr->algo_pack().construct_and_get_algo(set.desc);
} else {
ret = opr->get_algorithm_info_heuristic(
std::forward<Args>(args)..., std::numeric_limits<size_t>::max(),
false);
return opr->get_algo_from_desc(ret.desc);
return static_cast<typename Opr::AlgoBase*>(
opr->get_algorithm_heuristic(std::forward<Args>(args)...,
std::numeric_limits<size_t>::max(),
false));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册