Merge pull request #1635 from DaydreamCoding/patch-7

fix BF16 x86_64 Apple M1 failed
This commit is contained in:
jxt1234 2021-09-15 14:13:53 +08:00 committed by GitHub
commit bc355e84ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -30,6 +30,7 @@
#define LARGE_MEMORY 1024 * 1024 * 500
#ifdef MNN_SUPPORT_BF16
#include "bf16/BF16Backend.hpp"
#include "bf16/BF16Functions.hpp"
#endif
#ifdef MNN_USE_SSE
@ -106,7 +107,7 @@ Backend* CPURuntime::onCreate(const BackendConfig* config) const {
}
#endif
#ifdef MNN_SUPPORT_BF16
if (precision == BackendConfig::Precision_Low) {
if (precision == BackendConfig::Precision_Low && BF16Functions::get()) {
return new BF16Backend(this);
}
#endif

View File

@ -19,7 +19,7 @@ namespace MNN {
void registerBF16Ops();
static std::map<OpType, BF16Backend::BF16Creator*>* gInstance = nullptr;
// The Function Will be Called in init
extern void registerBF16Backend() {
void registerBF16Backend() {
gInstance = new std::map<OpType, BF16Backend::BF16Creator*>;
bool success = BF16Functions::init();
if (success) {

View File

@ -756,6 +756,8 @@ bool BF16Functions::init() {
gInstance->MNNPackForMatMul_B = _SSE_MNNPackForMatMul_B_BF16;
auto cpuFlags = libyuv::InitCpuFlags();
if (!(cpuFlags & libyuv::kCpuHasF16C)) {
delete gInstance;
gInstance = nullptr;
return false;
}
if (cpuFlags & libyuv::kCpuHasAVX2) {