/** * Copyright 2019-2020 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. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef PLATFORM_INFO_H #define PLATFORM_INFO_H #include #include #include #include "platform_info_def.h" using std::map; using std::string; using std::vector; namespace fe { class PlatformInfoManager { public: PlatformInfoManager(const PlatformInfoManager &) = delete; PlatformInfoManager &operator=(const PlatformInfoManager &) = delete; static PlatformInfoManager &Instance(); uint32_t InitializePlatformInfo(); uint32_t Finalize(); uint32_t GetPlatformInfo(const string SoCVersion, PlatformInfo &platformInfo, OptionalInfo &optiCompilationInfo); uint32_t GetPlatformInfoWithOutSocVersion(PlatformInfo &platformInfo, OptionalInfo &optiCompilationInfo); void SetOptionalCompilationInfo(OptionalInfo &optiCompilationInfo); private: PlatformInfoManager(); ~PlatformInfoManager(); uint32_t LoadIniFile(string iniFileRealPath); void Trim(string &str); uint32_t LoadConfigFile(string realPath); string RealPath(const std::string &path); string GetSoFilePath(); void ParseVersion(map &versionMap, string &socVersion, PlatformInfo &platformInfoTemp); void ParseSocInfo(map &socInfoMap, PlatformInfo &platformInfoTemp); void ParseCubeOfAICoreSpec(map &aiCoreSpecMap, PlatformInfo &platformInfoTemp); void ParseBufferOfAICoreSpec(map &aiCoreSpecMap, PlatformInfo &platformInfoTemp); void ParseUBOfAICoreSpec(map &aiCoreSpecMap, PlatformInfo &platformInfoTemp); void ParseUnzipOfAICoreSpec(map &aiCoreSpecMap, PlatformInfo &platformInfoTemp); void ParseAICoreSpec(map &aiCoreSpecMap, PlatformInfo &platformInfoTemp); void ParseBufferOfAICoreMemoryRates(map &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); void ParseAICoreMemoryRates(map &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); void ParseUBOfAICoreMemoryRates(map &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); void ParseAICoreintrinsicDtypeMap(map &aiCoreintrinsicDtypeMap, PlatformInfo &platformInfoTemp); void ParseVectorCoreSpec(map &vectorCoreSpecMap, PlatformInfo &platformInfoTemp); void ParseVectorCoreMemoryRates(map &vectorCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); void ParseVectorCoreintrinsicDtypeMap(map &vectorCoreintrinsicDtypeMap, PlatformInfo &platformInfoTemp); uint32_t ParsePlatformInfoFromStrToStruct(map> &contentInfoMap, string &socVersion, PlatformInfo &platformInfoTemp); uint32_t AssemblePlatformInfoVector(map> &contentInfoMap); private: bool initFlag_; map platformInfoMap_; OptionalInfo optiCompilationInfo_; }; } // namespace fe #endif