!19125 [LITE][iOS] fp16
Merge pull request !19125 from yefeng/128-ios_fp16
This commit is contained in:
commit
de2e37a4ee
|
@ -14,16 +14,39 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#ifdef ENABLE_ARM
|
||||
#ifndef MS_COMPILE_IOS
|
||||
#include "src/cpu_info.h"
|
||||
#include <sys/auxv.h>
|
||||
#include <asm/hwcap.h>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <fstream>
|
||||
#include "src/common/log_adapter.h"
|
||||
#include "nnacl/nnacl_utils.h"
|
||||
|
||||
#ifndef MS_COMPILE_IOS
|
||||
#include <sys/auxv.h>
|
||||
#include <asm/hwcap.h>
|
||||
#else
|
||||
#include <mach/mach.h>
|
||||
#include <mach/machine.h>
|
||||
#include <mach/thread_act.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#include "TargetConditionals.h"
|
||||
#ifndef CPUFAMILY_ARM_HURRICANE
|
||||
#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
|
||||
#endif
|
||||
#ifndef CPUFAMILY_ARM_MONSOON_MISTRAL
|
||||
#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
|
||||
#endif
|
||||
#ifndef CPUFAMILY_ARM_VORTEX_TEMPEST
|
||||
#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
|
||||
#endif
|
||||
#ifndef CPUFAMILY_ARM_LIGHTNING_THUNDER
|
||||
#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
|
||||
#endif
|
||||
#ifndef CPUFAMILY_ARM_FIRESTORM_ICESTORM
|
||||
#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
|
||||
#endif
|
||||
#endif
|
||||
namespace mindspore::lite {
|
||||
#ifndef MS_COMPILE_IOS
|
||||
uint32_t CpuInfo::MidrSetPart(uint32_t part) {
|
||||
return ((part << ARM_CPU_PART_OFFSET) & ARM_CPU_PART_MASK) | (midr_ & ~ARM_CPU_PART_MASK);
|
||||
}
|
||||
|
@ -101,9 +124,17 @@ void CpuInfo::GetArmProcCpuInfo(AndroidCpuInfo *android_cpu_info) {
|
|||
}
|
||||
infile.close();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CpuInfo::ArmIsSupportFp16() {
|
||||
#ifdef MS_COMPILE_IOS
|
||||
unsigned int value = 0;
|
||||
size_t len = sizeof(value);
|
||||
sysctlbyname("hw.cpufamily", &value, &len, NULL, 0);
|
||||
if (value == CPUFAMILY_ARM_MONSOON_MISTRAL || value == CPUFAMILY_ARM_VORTEX_TEMPEST ||
|
||||
value == CPUFAMILY_ARM_LIGHTNING_THUNDER || value == CPUFAMILY_ARM_FIRESTORM_ICESTORM) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
#ifdef ENABLE_ARM32
|
||||
|
@ -149,4 +180,3 @@ bool CpuInfo::ArmIsSupportFp16() {
|
|||
}
|
||||
} // namespace mindspore::lite
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#ifdef ENABLE_ARM
|
||||
#ifndef MS_COMPILE_IOS
|
||||
#include <string>
|
||||
#ifndef MINDSPORE_LITE_SRC_CPU_INFO_H
|
||||
#define MINDSPORE_LITE_SRC_CPU_INFO_H
|
||||
namespace mindspore::lite {
|
||||
#ifndef MS_COMPILE_IOS
|
||||
#define ARM_CPU_IMPLEMENTER_MASK UINT32_C(0xFF000000)
|
||||
#define ARM_CPU_PART_MASK UINT32_C(0x0000FFF0)
|
||||
#define ARM_CPU_IMPLEMENTER_OFFSET 24
|
||||
|
@ -28,25 +28,27 @@ typedef struct AndroidCpuInfo {
|
|||
uint32_t cpu_part = 0;
|
||||
std::string hardware = "";
|
||||
} AndroidCpuInfo;
|
||||
#endif
|
||||
|
||||
class CpuInfo {
|
||||
public:
|
||||
CpuInfo() = default;
|
||||
virtual ~CpuInfo() = default;
|
||||
void GetArmProcCpuInfo(AndroidCpuInfo *android_cpu_info);
|
||||
uint32_t ParseArmCpuImplementer(const std::string &suffix);
|
||||
uint32_t ParseArmCpuPart(const std::string &suffix);
|
||||
uint32_t MidrSetPart(uint32_t part);
|
||||
uint32_t MidrSetImplementer(uint32_t implementer);
|
||||
bool ArmIsSupportFp16();
|
||||
uint32_t StringToDigit(const std::string &str);
|
||||
|
||||
private:
|
||||
bool fp16_flag_ = false;
|
||||
#ifndef MS_COMPILE_IOS
|
||||
uint32_t StringToDigit(const std::string &str);
|
||||
uint32_t ParseArmCpuPart(const std::string &suffix);
|
||||
uint32_t MidrSetImplementer(uint32_t implementer);
|
||||
uint32_t MidrSetPart(uint32_t part);
|
||||
uint32_t ParseArmCpuImplementer(const std::string &suffix);
|
||||
void GetArmProcCpuInfo(AndroidCpuInfo *android_cpu_info);
|
||||
uint32_t midr_ = 0;
|
||||
AndroidCpuInfo android_cpu_info_;
|
||||
#endif
|
||||
bool fp16_flag_ = false;
|
||||
};
|
||||
} // namespace mindspore::lite
|
||||
#endif // MINDSPORE_LITE_SRC_CPU_INFO_H
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue