LCOV - code coverage report
Current view: top level - src/platform - platform_infos_def.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 93.8 % 272 255
Test Date: 2026-07-28 10:52:27 Functions: 100.0 % 37 37

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "platform/platform_infos_def.h"
      12              : #include "platform_infos_impl.h"
      13              : #include "platform_log.h"
      14              : #ifndef _OPEN_SOURCE_LLT_
      15              : #include "proto/platform_infos.pb.h"
      16              : #endif
      17              : #include "platform_infos_utils.h"
      18              : #include <unordered_set>
      19              : 
      20              : using std::map;
      21              : using std::string;
      22              : using std::vector;
      23              : using namespace std;
      24              : 
      25              : namespace fe {
      26              : using ProtoBufString = std::string;
      27              : #ifndef _OPEN_SOURCE_LLT_
      28              : using ProtoListDType = platform::tiling::ListDType;
      29              : using ProtoPlatformMap = platform::tiling::PlatformMap;
      30              : using ProtoBufStringVecMap = ascend_private::protobuf::Map<ProtoBufString, ProtoListDType>;
      31              : using ProtoBufStringMapMap = ascend_private::protobuf::Map<ProtoBufString, ProtoPlatformMap>;
      32              : #endif
      33              : 
      34          135 : bool PlatFormInfos::Init()
      35              : {
      36          135 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
      37          135 :     PF_MAKE_SHARED(platform_infos_impl_ = std::make_shared<PlatFormInfosImpl>(), return false);
      38          135 :     if (platform_infos_impl_ == nullptr) {
      39            0 :         return false;
      40              :     }
      41              : 
      42          135 :     return true;
      43          135 : }
      44              : 
      45              : #ifndef _OPEN_SOURCE_LLT_
      46              : static void GetVecMapInfoFromProtoBuf(
      47              :     ProtoBufStringVecMap* protoMap, std::map<std::string, std::vector<std::string>>& dstMap)
      48              : {
      49              :     for (auto mapIter = protoMap->begin(); mapIter != protoMap->end(); ++mapIter) {
      50              :         const std::string curMapKey = mapIter->first;
      51              :         PF_LOGD("curMapKey:%s", curMapKey.c_str());
      52              :         std::vector<std::string> tempVec;
      53              :         for (auto index = 0; index < mapIter->second.dtype_size(); index++) {
      54              :             tempVec.push_back(mapIter->second.dtype(index));
      55              :             PF_LOGD("insert value:%s", mapIter->second.dtype(index).c_str());
      56              :         }
      57              :         dstMap[curMapKey] = tempVec;
      58              :     }
      59              : }
      60              : 
      61              : static void GetMapMapInfoFromProtoBuf(
      62              :     ProtoBufStringMapMap* protoMap, std::map<std::string, std::map<std::string, std::string>>& dstMap)
      63              : {
      64              :     for (auto mapIter = protoMap->begin(); mapIter != protoMap->end(); ++mapIter) {
      65              :         const std::string curMapKey = mapIter->first;
      66              :         PF_LOGD("curMapKey:%s", curMapKey.c_str());
      67              :         std::map<std::string, std::string> tempMap;
      68              :         ProtoPlatformMap& protoTmpMap = mapIter->second;
      69              :         for (auto secondIter = protoTmpMap.platform_map().begin(); secondIter != protoTmpMap.platform_map().end();
      70              :              ++secondIter) {
      71              :             tempMap[secondIter->first] = secondIter->second;
      72              :             PF_LOGD("insert key:%s, value:%s", secondIter->first.c_str(), secondIter->second.c_str());
      73              :         }
      74              :         dstMap[curMapKey] = tempMap;
      75              :     }
      76              : }
      77              : #endif
      78              : 
      79          139 : map<string, vector<string>> PlatFormInfos::GetAICoreIntrinsicDtype()
      80              : {
      81          139 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
      82          139 :     if (platform_infos_impl_ == nullptr) {
      83            1 :         return map<string, vector<string>>();
      84              :     }
      85          138 :     return platform_infos_impl_->GetAICoreIntrinsicDtype();
      86          139 : }
      87              : 
      88           66 : map<string, vector<string>> PlatFormInfos::GetVectorCoreIntrinsicDtype()
      89              : {
      90           66 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
      91           66 :     if (platform_infos_impl_ == nullptr) {
      92            1 :         return map<string, vector<string>>();
      93              :     }
      94           65 :     return platform_infos_impl_->GetVectorCoreIntrinsicDtype();
      95           66 : }
      96              : 
      97           31 : bool PlatFormInfos::GetPlatformResWithOutLock(const string& label, const string& key, string& val)
      98              : {
      99           31 :     if (platform_infos_impl_ == nullptr) {
     100            0 :         return true;
     101              :     }
     102           31 :     return platform_infos_impl_->GetPlatformRes(label, key, val);
     103              : }
     104              : 
     105            2 : bool PlatFormInfos::GetPlatformRes(const string& label, const string& key, string& val)
     106              : {
     107            2 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     108            2 :     if (platform_infos_impl_ == nullptr) {
     109            1 :         return true;
     110              :     }
     111            1 :     return platform_infos_impl_->GetPlatformRes(label, key, val);
     112            2 : }
     113              : 
     114          157 : bool PlatFormInfos::GetPlatformResWithLock(const string& label, const string& key, string& val)
     115              : {
     116          157 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     117          157 :     if (platform_infos_impl_ == nullptr) {
     118            5 :         return true;
     119              :     }
     120          152 :     return platform_infos_impl_->GetPlatformRes(label, key, val);
     121          157 : }
     122              : 
     123            3 : bool PlatFormInfos::GetPlatformRes(const std::string& label, std::map<std::string, std::string>& res)
     124              : {
     125            3 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     126            3 :     if (platform_infos_impl_ == nullptr) {
     127            1 :         return true;
     128              :     }
     129            2 :     return platform_infos_impl_->GetPlatformRes(label, res);
     130            3 : }
     131              : 
     132            2 : bool PlatFormInfos::GetPlatformResWithLock(const std::string& label, std::map<std::string, std::string>& res)
     133              : {
     134            2 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     135            2 :     if (platform_infos_impl_ == nullptr) {
     136            1 :         return true;
     137              :     }
     138            1 :     return platform_infos_impl_->GetPlatformRes(label, res);
     139            2 : }
     140              : 
     141            3 : bool PlatFormInfos::GetPlatformResWithLock(std::map<std::string, std::map<std::string, std::string>>& res)
     142              : {
     143            3 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     144            3 :     if (platform_infos_impl_ == nullptr) {
     145            1 :         return true;
     146              :     }
     147            2 :     return platform_infos_impl_->GetPlatformRes(res);
     148            3 : }
     149              : 
     150           75 : void PlatFormInfos::SetAICoreIntrinsicDtype(map<string, vector<string>>& intrinsic_dtypes)
     151              : {
     152           75 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     153           75 :     if (platform_infos_impl_ == nullptr) {
     154            1 :         return;
     155              :     }
     156           74 :     platform_infos_impl_->SetAICoreIntrinsicDtype(intrinsic_dtypes);
     157           75 : }
     158              : 
     159           66 : void PlatFormInfos::SetVectorCoreIntrinsicDtype(map<string, vector<string>>& intrinsic_dtypes)
     160              : {
     161           66 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     162           66 :     if (platform_infos_impl_ == nullptr) {
     163            1 :         return;
     164              :     }
     165           65 :     platform_infos_impl_->SetVectorCoreIntrinsicDtype(intrinsic_dtypes);
     166           66 : }
     167              : 
     168           62 : void PlatFormInfos::SetFixPipeDtypeMap(const std::map<std::string, std::vector<std::string>>& fixpipe_dtype_map)
     169              : {
     170           62 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     171           62 :     if (platform_infos_impl_ == nullptr) {
     172            1 :         return;
     173              :     }
     174           61 :     platform_infos_impl_->SetFixPipeDtypeMap(fixpipe_dtype_map);
     175           62 : }
     176              : 
     177           13 : void PlatFormInfos::SetCoreNumByCoreType(const std::string& core_type)
     178              : {
     179           13 :     string core_num_str;
     180           13 :     string core_type_str;
     181              :     /*
     182              :     all core_types: NO_MIX(AIV,AIC)
     183              :                     MIX_AIV,MIX_AIC
     184              :                     MIX_AIC_AIV
     185              :                     MIX(customized for multi-kernelType)
     186              :     */
     187           26 :     std::unordered_set<string> vector_core_types = {"VectorCore", "AIV", "MIX_AIV", "MIX_VECTOR_CORE"};
     188           26 :     std::unordered_set<string> customized_types = {"MIX_AIC_AIV", "MIX_AIV", "MIX", "MIX_AICORE", "MIX_VECTOR_CORE"};
     189           13 :     if (vector_core_types.count(core_type) > 0) {
     190            7 :         core_type_str = "vector_core_cnt";
     191              :     } else {
     192            6 :         core_type_str = "ai_core_cnt";
     193              :     }
     194              : 
     195           13 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     196              :     try {
     197           13 :         (void)GetPlatformResWithOutLock("SoCInfo", core_type_str, core_num_str);
     198           26 :         core_num_ = core_num_str.empty() ? 0 : std::stoi(core_num_str.c_str());
     199           12 :         if (customized_types.count(core_type) > 0) {
     200            5 :             core_num_str.clear();
     201            5 :             core_type_str = "mix_vector_core_cnt";
     202            5 :             (void)GetPlatformResWithOutLock("SoCInfo", core_type_str, core_num_str);
     203           15 :             core_num_ = core_num_str.empty() ? core_num_ : std::stoi(core_num_str.c_str());
     204              :         }
     205            1 :     } catch (...) {
     206            1 :         PF_LOGW("Unable to load core_num[%s].", core_num_str.c_str());
     207            1 :     }
     208           13 :     PF_LOGD(
     209              :         "Set PlatFormInfos::core_num_ to %s: [%u], core_type: %s.", core_type_str.c_str(), core_num_,
     210              :         core_type.c_str());
     211           13 : }
     212              : 
     213            1 : void PlatFormInfos::SetCoreNum(const uint32_t& core_num)
     214              : {
     215            1 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     216            1 :     PF_LOGD("Set PlatFormInfos::core_num_ to %u.", core_num);
     217            1 :     core_num_ = core_num;
     218            1 : }
     219              : 
     220            3 : uint32_t PlatFormInfos::GetCoreNum() const
     221              : {
     222            3 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     223            3 :     PF_LOGD("Get PlatformInfos::core_num_=[%u].", core_num_);
     224            3 :     return core_num_;
     225            3 : }
     226              : 
     227            1 : uint32_t PlatFormInfos::GetCoreNumWithLock() const
     228              : {
     229            1 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     230            1 :     PF_LOGD("Get PlatformInfos::core_num_=[%u].", core_num_);
     231            1 :     return core_num_;
     232            1 : }
     233              : 
     234           13 : uint32_t PlatFormInfos::GetCoreNumByType(const std::string& core_type)
     235              : {
     236           26 :     std::unordered_set<string> vector_core_types = {"VectorCore", "AIV"};
     237           13 :     std::string core_type_str;
     238           13 :     if (vector_core_types.count(core_type) != 0) {
     239            6 :         core_type_str = "vector_core_cnt";
     240              :     } else {
     241            7 :         core_type_str = "ai_core_cnt";
     242              :     }
     243              : 
     244           13 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     245           13 :     std::string core_num_str;
     246           13 :     uint32_t core_num = 0;
     247              :     try {
     248           13 :         (void)GetPlatformResWithOutLock("SoCInfo", core_type_str, core_num_str);
     249           28 :         core_num = core_num_str.empty() ? 0 : std::stoi(core_num_str.c_str());
     250            1 :     } catch (...) {
     251            1 :         PF_LOGW("Unable to load core_num[%s].", core_num_str.c_str());
     252            1 :         return -1;
     253            1 :     }
     254           12 :     PF_LOGD("Get PlatFormInfos::core_num %u|%s, core_type %s", core_num, core_num_str.c_str(), core_type.c_str());
     255           12 :     return core_num;
     256           13 : }
     257              : 
     258           18 : void PlatFormInfos::GetLocalMemSize(const LocalMemType& mem_type, uint64_t& size)
     259              : {
     260           18 :     string size_str;
     261           18 :     switch (mem_type) {
     262            3 :         case LocalMemType::L0_A:
     263            9 :             (void)GetPlatformResWithLock("AICoreSpec", "l0_a_size", size_str);
     264            3 :             break;
     265            2 :         case LocalMemType::L0_B:
     266            6 :             (void)GetPlatformResWithLock("AICoreSpec", "l0_b_size", size_str);
     267            2 :             break;
     268            2 :         case LocalMemType::L0_C:
     269            6 :             (void)GetPlatformResWithLock("AICoreSpec", "l0_c_size", size_str);
     270            2 :             break;
     271            3 :         case LocalMemType::L1:
     272            9 :             (void)GetPlatformResWithLock("AICoreSpec", "l1_size", size_str);
     273            3 :             break;
     274            4 :         case LocalMemType::L2:
     275           12 :             (void)GetPlatformResWithLock("SoCInfo", "l2_size", size_str);
     276            4 :             break;
     277            3 :         case LocalMemType::UB:
     278            9 :             (void)GetPlatformResWithLock("AICoreSpec", "ub_size", size_str);
     279            3 :             break;
     280            1 :         case LocalMemType::HBM:
     281            3 :             (void)GetPlatformResWithLock("SoCInfo", "memory_size", size_str);
     282            1 :             break;
     283            0 :         default:
     284            0 :             break;
     285              :     }
     286           18 :     size = size_str.empty() ? 0 : std::atoll(size_str.c_str());
     287           18 : }
     288              : 
     289            8 : void PlatFormInfos::GetLocalMemBw(const LocalMemType& mem_type, uint64_t& bw_size)
     290              : {
     291            8 :     string bw_size_str;
     292            8 :     switch (mem_type) {
     293            3 :         case LocalMemType::L2:
     294            9 :             (void)GetPlatformResWithLock("AICoreMemoryRates", "l2_rate", bw_size_str);
     295            3 :             break;
     296            2 :         case LocalMemType::HBM:
     297            6 :             (void)GetPlatformResWithLock("AICoreMemoryRates", "ddr_rate", bw_size_str);
     298            2 :             break;
     299            3 :         default:
     300            3 :             break;
     301              :     }
     302            8 :     bw_size = bw_size_str.empty() ? 0 : std::atoll(bw_size_str.c_str());
     303            8 : }
     304              : 
     305          113 : std::map<std::string, std::vector<std::string>> PlatFormInfos::GetFixPipeDtypeMap()
     306              : {
     307          113 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     308          113 :     if (platform_infos_impl_ == nullptr) {
     309            0 :         return map<string, vector<string>>();
     310              :     }
     311          113 :     return platform_infos_impl_->GetFixPipeDtypeMap();
     312          113 : }
     313              : 
     314          752 : void PlatFormInfos::SetPlatformRes(const std::string& label, std::map<std::string, std::string>& res)
     315              : {
     316          752 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     317          752 :     if (platform_infos_impl_ == nullptr) {
     318            0 :         return;
     319              :     }
     320          752 :     platform_infos_impl_->SetPlatformRes(label, res);
     321          752 : }
     322              : 
     323            2 : void PlatFormInfos::SetPlatformResWithLock(const std::string& label, std::map<std::string, std::string>& res)
     324              : {
     325            2 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     326            2 :     if (platform_infos_impl_ == nullptr) {
     327            0 :         return;
     328              :     }
     329            2 :     platform_infos_impl_->SetPlatformRes(label, res);
     330            2 : }
     331              : 
     332            6 : bool PlatFormInfos::InitByInstance()
     333              : {
     334            6 :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     335            6 :     if (platform_infos_impl_ != nullptr) {
     336            4 :         return true;
     337              :     }
     338            2 :     static PlatFormInfosImplPtr platform_infos_impl_instance_ptr = nullptr;
     339            2 :     if (platform_infos_impl_instance_ptr == nullptr) {
     340            1 :         PF_MAKE_SHARED(platform_infos_impl_instance_ptr = std::make_shared<PlatFormInfosImpl>(), return false);
     341              :     }
     342              : 
     343            2 :     platform_infos_impl_ = platform_infos_impl_instance_ptr;
     344            2 :     return true;
     345            6 : }
     346              : 
     347            3 : std::string PlatFormInfos::SaveToBuffer()
     348              : {
     349              : #ifdef _OPEN_SOURCE_LLT_
     350            3 :     PF_LOGW("_OPEN_SOURCE_LLT_ is defined");
     351            6 :     return "";
     352              : #else
     353              :     platform::tiling::PlatformInfosDef platformInfosDef;
     354              :     for (const auto& iter : GetAICoreIntrinsicDtype()) {
     355              :         const auto& dtypes = iter.second;
     356              :         platform::tiling::ListDType listDtype;
     357              :         for (const auto& dtype : dtypes) {
     358              :             listDtype.add_dtype(dtype);
     359              :         }
     360              :         platformInfosDef.mutable_ai_core_intrinsic_dtype_map()->insert({iter.first, listDtype});
     361              :     }
     362              :     for (const auto& iter : GetVectorCoreIntrinsicDtype()) {
     363              :         const auto& dtypes = iter.second;
     364              :         platform::tiling::ListDType listDtype;
     365              :         for (const auto& dtype : dtypes) {
     366              :             listDtype.add_dtype(dtype);
     367              :         }
     368              :         platformInfosDef.mutable_vector_core_intrinsic_dtype_map()->insert({iter.first, listDtype});
     369              :     }
     370              :     for (const auto& iter : GetFixPipeDtypeMap()) {
     371              :         const auto& dtypes = iter.second;
     372              :         platform::tiling::ListDType listDtype;
     373              :         for (const auto& dtype : dtypes) {
     374              :             listDtype.add_dtype(dtype);
     375              :         }
     376              :         platformInfosDef.mutable_fixpipe_dtype_map()->insert({iter.first, listDtype});
     377              :     }
     378              : 
     379              :     std::map<std::string, std::map<std::string, std::string>> res;
     380              :     (void)GetPlatformResWithLock(res);
     381              :     for (const auto& iter : res) {
     382              :         platform::tiling::PlatformMap platformMap;
     383              :         for (const auto& info : iter.second) {
     384              :             platformMap.mutable_platform_map()->insert({info.first, info.second});
     385              :         }
     386              :         platformInfosDef.mutable_platform_res_map()->insert({iter.first, platformMap});
     387              :     }
     388              :     return platformInfosDef.SerializeAsString();
     389              : #endif
     390              : }
     391              : 
     392            5 : bool PlatFormInfos::LoadFromBuffer(const char* bufPtr, const size_t bufLen)
     393              : {
     394              : #ifdef _OPEN_SOURCE_LLT_
     395            5 :     return true;
     396              : #else
     397              :     if (platform_infos_impl_ == nullptr) {
     398              :         bool ret = InitByInstance();
     399              :         if (!ret) {
     400              :             PF_LOGE("PlatFormInfos init failed.");
     401              :             return false;
     402              :         }
     403              :     }
     404              :     platform::tiling::PlatformInfosDef platformDefInfos;
     405              :     bool parseRet = platformDefInfos.ParseFromArray(bufPtr, bufLen);
     406              :     if (!parseRet) {
     407              :         PF_LOGE("Parse proto failed.");
     408              :         return false;
     409              :     }
     410              :     std::map<std::string, std::vector<std::string>> aiCoreIntrinsicDtypesMap;
     411              :     std::map<std::string, std::vector<std::string>> aiVectorIntrinsicDtypesMap;
     412              :     std::map<std::string, std::map<std::string, std::string>> platformResMap;
     413              :     std::map<std::string, std::vector<std::string>> fixPipeDtypeMap;
     414              : 
     415              :     GetVecMapInfoFromProtoBuf(platformDefInfos.mutable_ai_core_intrinsic_dtype_map(), aiCoreIntrinsicDtypesMap);
     416              :     GetVecMapInfoFromProtoBuf(platformDefInfos.mutable_vector_core_intrinsic_dtype_map(), aiVectorIntrinsicDtypesMap);
     417              :     GetMapMapInfoFromProtoBuf(platformDefInfos.mutable_platform_res_map(), platformResMap);
     418              :     GetVecMapInfoFromProtoBuf(platformDefInfos.mutable_fixpipe_dtype_map(), fixPipeDtypeMap);
     419              : 
     420              :     std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
     421              :     platform_infos_impl_->SetAICoreIntrinsicDtype(aiCoreIntrinsicDtypesMap);
     422              :     platform_infos_impl_->SetVectorCoreIntrinsicDtype(aiVectorIntrinsicDtypesMap);
     423              :     for (auto iter = platformResMap.begin(); iter != platformResMap.end(); ++iter) {
     424              :         platform_infos_impl_->SetPlatformRes(iter->first, iter->second);
     425              :     }
     426              :     platform_infos_impl_->SetFixPipeDtypeMap(fixPipeDtypeMap);
     427              : 
     428              :     return true;
     429              : #endif
     430              : }
     431              : 
     432          159 : bool OptionalInfos::Init()
     433              : {
     434          159 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     435          159 :     PF_MAKE_SHARED(optional_infos_impl_ = std::make_shared<OptionalInfosImpl>(), return false);
     436          159 :     if (optional_infos_impl_ == nullptr) {
     437            0 :         return false;
     438              :     }
     439          159 :     return true;
     440          159 : }
     441              : 
     442          114 : string OptionalInfos::GetSocVersion()
     443              : {
     444          114 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     445          114 :     if (optional_infos_impl_ == nullptr) {
     446           14 :         return "";
     447              :     }
     448          107 :     return optional_infos_impl_->GetSocVersion();
     449          114 : }
     450              : 
     451            2 : string OptionalInfos::GetCoreType()
     452              : {
     453            2 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     454            2 :     if (optional_infos_impl_ == nullptr) {
     455            0 :         return "";
     456              :     }
     457            2 :     return optional_infos_impl_->GetCoreType();
     458            2 : }
     459              : 
     460            2 : uint32_t OptionalInfos::GetAICoreNum()
     461              : {
     462            2 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     463            2 :     if (optional_infos_impl_ == nullptr) {
     464            0 :         return 0;
     465              :     }
     466            2 :     return optional_infos_impl_->GetAICoreNum();
     467            2 : }
     468              : 
     469            2 : string OptionalInfos::GetL1FusionFlag()
     470              : {
     471            2 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     472            2 :     if (optional_infos_impl_ == nullptr) {
     473            0 :         return "";
     474              :     }
     475            2 :     return optional_infos_impl_->GetL1FusionFlag();
     476            2 : }
     477              : 
     478           86 : void OptionalInfos::SetFixPipeDtypeMap(const std::map<std::string, std::vector<std::string>>& fixpipe_dtype_map)
     479              : {
     480           86 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     481           86 :     if (optional_infos_impl_ == nullptr) {
     482            4 :         return;
     483              :     }
     484           82 :     optional_infos_impl_->SetFixPipeDtypeMap(fixpipe_dtype_map);
     485           86 : }
     486              : 
     487            2 : std::map<std::string, std::vector<std::string>> OptionalInfos::GetFixPipeDtypeMap()
     488              : {
     489            2 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     490            2 :     if (optional_infos_impl_ == nullptr) {
     491            0 :         return std::map<std::string, std::vector<std::string>>();
     492              :     }
     493            2 :     return optional_infos_impl_->GetFixPipeDtypeMap();
     494            2 : }
     495           51 : void OptionalInfos::SetSocVersion(string soc_version)
     496              : {
     497           51 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     498           51 :     if (optional_infos_impl_ == nullptr) {
     499            0 :         return;
     500              :     }
     501           51 :     optional_infos_impl_->SetSocVersion(soc_version);
     502           51 : }
     503              : 
     504            5 : void OptionalInfos::SetSocVersionWithLock(string soc_version)
     505              : {
     506            5 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     507            5 :     if (optional_infos_impl_ == nullptr) {
     508            0 :         return;
     509              :     }
     510            5 :     optional_infos_impl_->SetSocVersion(soc_version);
     511            5 : }
     512              : 
     513           41 : void OptionalInfos::SetCoreType(string core_type)
     514              : {
     515           41 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     516           41 :     if (optional_infos_impl_ == nullptr) {
     517            0 :         return;
     518              :     }
     519           41 :     optional_infos_impl_->SetCoreType(core_type);
     520           41 : }
     521              : 
     522           41 : void OptionalInfos::SetAICoreNum(uint32_t ai_core_num)
     523              : {
     524           41 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     525           41 :     if (optional_infos_impl_ == nullptr) {
     526            0 :         return;
     527              :     }
     528           41 :     optional_infos_impl_->SetAICoreNum(ai_core_num);
     529           41 : }
     530              : 
     531           41 : void OptionalInfos::SetL1FusionFlag(string l1_fusion_flag)
     532              : {
     533           41 :     std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
     534           41 :     if (optional_infos_impl_ == nullptr) {
     535            0 :         return;
     536              :     }
     537           41 :     optional_infos_impl_->SetL1FusionFlag(l1_fusion_flag);
     538           41 : }
     539              : 
     540              : } // namespace fe
        

Generated by: LCOV version 2.0-1