diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.c b/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.c index a7ddd8e52fd..929ac6d9345 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.c +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.c @@ -92,26 +92,26 @@ int IntelX86CpuInfoInit(void) { return NNACL_OK; } -bool IntelX86InstructionSetSupportCheck(void) { +X86CpuInfoErrorCodeEnum IntelX86InstructionSetSupportCheck(void) { if (IntelX86CpuInfoInit() != NNACL_OK) { - return false; + return X86CPUINFO_PLATFORM_ERR; } #ifdef ENABLE_AVX512 if (!X86_Avx512_Support()) { - return false; + return X86CPUINFO_AVX512_ERR; } #endif #ifdef ENABLE_AVX if (!X86_Avx_Support()) { - return false; + return X86CPUINFO_AVX_ERR; } #endif #ifdef ENABLE_SSE if (!X86_Sse_Support()) { - return false; + return X86CPUINFO_SSE_ERR; } #endif - return true; + return X86CPUINFO_OK; } diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.h b/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.h index 59af9e09d3d..04d062317dd 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.h +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/ms_simd_cpu_info.h @@ -23,13 +23,22 @@ extern "C" { #endif +typedef enum X86CpuInfoErrorCodeEnum { + X86CPUINFO_OK = 0, + X86CPUINFO_PLATFORM_ERR = 1, + X86CPUINFO_AVX512_ERR, + X86CPUINFO_AVX_ERR, + X86CPUINFO_SSE_ERR, + X86CPUINFO_END = 9999 +} X86CpuInfoErrorCodeEnum; + const bool X86_Fma_Support(void); const bool X86_Sse_Support(void); const bool X86_Avx_Support(void); const bool X86_Avx512_Support(void); bool IsIntelX86Platform(void); -bool IntelX86InstructionSetSupportCheck(void); +X86CpuInfoErrorCodeEnum IntelX86InstructionSetSupportCheck(void); int IntelX86CpuInfoInit(void); diff --git a/mindspore/lite/src/cpu_info.h b/mindspore/lite/src/cpu_info.h index 7d766757219..d383921d87a 100644 --- a/mindspore/lite/src/cpu_info.h +++ b/mindspore/lite/src/cpu_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2021 Huawei Technologies Co., Ltd + * Copyright 2021-2022 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,13 +22,24 @@ #endif inline bool PlatformInstructionSetSupportCheck() { - bool flag = true; - #if defined(ENABLE_AVX512) || defined(ENABLE_AVX) - flag = IntelX86InstructionSetSupportCheck(); + auto ret = IntelX86InstructionSetSupportCheck(); + if (ret == X86CPUINFO_PLATFORM_ERR) { + MS_LOG(WARNING) << "This is not intel platform."; + return true; + } else if (ret == X86CPUINFO_AVX512_ERR) { + MS_LOG(ERROR) << "This is avx512 version, but the platform don't support avx512 instruction."; + return false; + } else if (ret == X86CPUINFO_AVX_ERR) { + MS_LOG(ERROR) << "This is avx version, but the platform don't support avx instruction."; + return false; + } else if (ret == X86CPUINFO_SSE_ERR) { + MS_LOG(ERROR) << "This is sse version, but the platform don't support sse instruction."; + return false; + } #endif - return flag; + return true; } #ifdef ENABLE_ARM diff --git a/mindspore/lite/src/cxx_api/model_pool/model_parallel_runner.cc b/mindspore/lite/src/cxx_api/model_pool/model_parallel_runner.cc index dec973b8c99..0c65f69dba0 100644 --- a/mindspore/lite/src/cxx_api/model_pool/model_parallel_runner.cc +++ b/mindspore/lite/src/cxx_api/model_pool/model_parallel_runner.cc @@ -16,9 +16,13 @@ #include "include/api/model_parallel_runner.h" #include "src/cxx_api/model_pool/model_pool.h" #include "src/common/log_adapter.h" +#include "src/cpu_info.h" namespace mindspore { Status ModelParallelRunner::Init(const std::string &model_path, const std::shared_ptr &runner_config) { + if (!PlatformInstructionSetSupportCheck()) { + return kLiteNotSupport; + } model_pool_ = std::make_shared(); if (model_pool_ == nullptr) { MS_LOG(ERROR) << "model pool is nullptr.";