• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifdef ENABLE_ARM
17 #include <string>
18 #ifndef MINDSPORE_LITE_SRC_CPU_INFO_H
19 #define MINDSPORE_LITE_SRC_CPU_INFO_H
20 namespace mindspore::lite {
21 #ifndef MS_COMPILE_IOS
22 #define ARM_CPU_IMPLEMENTER_MASK UINT32_C(0xFF000000)
23 #define ARM_CPU_PART_MASK UINT32_C(0x0000FFF0)
24 #define ARM_CPU_IMPLEMENTER_OFFSET 24
25 #define ARM_CPU_PART_OFFSET 4
26 typedef struct AndroidCpuInfo {
27   uint32_t cpu_implementer = 0;
28   uint32_t cpu_part = 0;
29   std::string hardware = "";
30 } AndroidCpuInfo;
31 #endif
32 
33 class CpuInfo {
34  public:
35   CpuInfo() = default;
36   virtual ~CpuInfo() = default;
37   bool ArmIsSupportFp16();
38 
39  private:
40 #ifndef MS_COMPILE_IOS
41   uint32_t StringToDigit(const std::string &str);
42   uint32_t ParseArmCpuPart(const std::string &suffix);
43   uint32_t MidrSetImplementer(uint32_t implementer);
44   uint32_t MidrSetPart(uint32_t part);
45   uint32_t ParseArmCpuImplementer(const std::string &suffix);
46   void GetArmProcCpuInfo(AndroidCpuInfo *android_cpu_info);
47   uint32_t midr_ = 0;
48   AndroidCpuInfo android_cpu_info_;
49 #endif
50   bool fp16_flag_ = false;
51 };
52 }  // namespace mindspore::lite
53 #endif  // MINDSPORE_LITE_SRC_CPU_INFO_H
54 #endif
55