mirror of https://github.com/alibaba/MNN.git
Merge pull request #1635 from DaydreamCoding/patch-7
fix BF16 x86_64 Apple M1 failed
This commit is contained in:
commit
bc355e84ca
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue