diff --git a/dnn/src/common/elemwise/opr_impl.cpp b/dnn/src/common/elemwise/opr_impl.cpp index ed994866c653b3baf6241b00ecb7853569c617c0..b5981b8c92b281f833ad3dad7c68f8326216c1c7 100644 --- a/dnn/src/common/elemwise/opr_impl.cpp +++ b/dnn/src/common/elemwise/opr_impl.cpp @@ -141,7 +141,10 @@ const ModeTrait& ModeTrait::from_mode(Mode mode) { #pragma message "elemwise mode stripped" #endif } - + megdnn_assert( + static_cast(mode) < traits.size(), + "Invalid elemwise mode in this version. " + "Maybe this version is too old, and you may need to update."); auto&& ret = traits.at(static_cast(mode)); #if !MEGDNN_ELEMWISE_MODE_ENABLE_ALL megdnn_assert(ret.arity); diff --git a/dnn/src/common/elemwise_multi_type/opr_impl.cpp b/dnn/src/common/elemwise_multi_type/opr_impl.cpp index f5bc9ec1432dd034099b97c572048948b1f94826..01acea164d9f913c051c2f7877d610446663d8c8 100644 --- a/dnn/src/common/elemwise_multi_type/opr_impl.cpp +++ b/dnn/src/common/elemwise_multi_type/opr_impl.cpp @@ -274,7 +274,10 @@ const ModeTrait& ModeTrait::from_mode(Mode mode) { SET(init_bool_unary_op, ISINF); #undef SET } - + megdnn_assert( + static_cast(mode) < traits.size(), + "Invalid elemwise multitype mode in this version. " + "Maybe this version is too old, and you may need to update."); return traits.at(static_cast(mode)); }