From 52167a8d2852b7867ed30c707da8ca8dd31a015a Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Wed, 22 Mar 2023 17:24:49 +0800 Subject: [PATCH] fix(dnn/dtype): fix race condition in ParameterizedDType registry GitOrigin-RevId: 85ca431b62c0a4083e1bc4d3a6b2534882105068 --- dnn/src/common/dtype.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dnn/src/common/dtype.cpp b/dnn/src/common/dtype.cpp index 708a95106..f8126339d 100644 --- a/dnn/src/common/dtype.cpp +++ b/dnn/src/common/dtype.cpp @@ -3,6 +3,7 @@ #include #include +#include #include using namespace megdnn; @@ -64,6 +65,8 @@ typename ParameterizedDType::Trait* ParameterizedDType< DTypeParam, std::unique_ptr, Hasher> entries; + static DNN_MUTEX mtx; + MEGDNN_LOCK_GUARD(mtx); auto it = entries.find(param); if (it != entries.end()) { return it->second.get(); -- GitLab