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

fix(dnn/dtype): fix race condition in ParameterizedDType registry

GitOrigin-RevId: 85ca431b62c0a4083e1bc4d3a6b2534882105068
上级 5c29dffc
......@@ -3,6 +3,7 @@
#include <cmath>
#include <functional>
#include <mutex>
#include <unordered_map>
using namespace megdnn;
......@@ -64,6 +65,8 @@ typename ParameterizedDType<type_enum>::Trait* ParameterizedDType<
DTypeParam<SelfType>, std::unique_ptr<SelfType::Trait>, Hasher>
entries;
static DNN_MUTEX mtx;
MEGDNN_LOCK_GUARD(mtx);
auto it = entries.find(param);
if (it != entries.end()) {
return it->second.get();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册