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_infos_impl.h"
12 :
13 : using namespace std;
14 :
15 : namespace fe {
16 :
17 138 : std::map<std::string, std::vector<std::string>> PlatFormInfosImpl::GetAICoreIntrinsicDtype()
18 : {
19 138 : return ai_core_intrinsic_dtype_map_;
20 : }
21 :
22 65 : std::map<std::string, std::vector<std::string>> PlatFormInfosImpl::GetVectorCoreIntrinsicDtype()
23 : {
24 65 : return vector_core_intrinsic_dtype_map_;
25 : }
26 :
27 19 : PlatFormInfosImpl::PlatFormInfosImpl(const PlatFormInfosImpl& platform_infos_impl)
28 : {
29 19 : ai_core_intrinsic_dtype_map_ = platform_infos_impl.ai_core_intrinsic_dtype_map_;
30 19 : vector_core_intrinsic_dtype_map_ = platform_infos_impl.vector_core_intrinsic_dtype_map_;
31 19 : platform_res_map_ = platform_infos_impl.platform_res_map_;
32 19 : fixpipe_dtype_map_ = platform_infos_impl.fixpipe_dtype_map_;
33 19 : }
34 :
35 0 : PlatFormInfosImpl& PlatFormInfosImpl::operator=(const PlatFormInfosImpl& platform_infos_impl)
36 : {
37 0 : if (this != &platform_infos_impl) {
38 0 : ai_core_intrinsic_dtype_map_ = platform_infos_impl.ai_core_intrinsic_dtype_map_;
39 0 : vector_core_intrinsic_dtype_map_ = platform_infos_impl.vector_core_intrinsic_dtype_map_;
40 0 : platform_res_map_ = platform_infos_impl.platform_res_map_;
41 0 : fixpipe_dtype_map_ = platform_infos_impl.fixpipe_dtype_map_;
42 : }
43 0 : return *this;
44 : }
45 :
46 184 : bool PlatFormInfosImpl::GetPlatformRes(const std::string& label, const std::string& key, std::string& val)
47 : {
48 184 : auto it_label = platform_res_map_.find(label);
49 184 : if (it_label == platform_res_map_.end()) {
50 6 : return false;
51 : }
52 178 : auto it_key = it_label->second.find(key);
53 178 : if (it_key == it_label->second.end()) {
54 14 : return false;
55 : }
56 :
57 164 : val = it_key->second;
58 164 : return true;
59 : }
60 :
61 3 : bool PlatFormInfosImpl::GetPlatformRes(const std::string& label, std::map<std::string, std::string>& res)
62 : {
63 3 : auto it_label = platform_res_map_.find(label);
64 3 : if (it_label == platform_res_map_.end()) {
65 1 : return false;
66 : }
67 :
68 2 : res = it_label->second;
69 2 : return true;
70 : }
71 :
72 2 : bool PlatFormInfosImpl::GetPlatformRes(std::map<std::string, std::map<std::string, std::string>>& res)
73 : {
74 2 : res = platform_res_map_;
75 2 : return true;
76 : }
77 :
78 74 : void PlatFormInfosImpl::SetAICoreIntrinsicDtype(std::map<std::string, std::vector<std::string>>& intrinsic_dtypes)
79 : {
80 74 : ai_core_intrinsic_dtype_map_ = intrinsic_dtypes;
81 74 : }
82 :
83 65 : void PlatFormInfosImpl::SetVectorCoreIntrinsicDtype(std::map<std::string, std::vector<std::string>>& intrinsic_dtypes)
84 : {
85 65 : vector_core_intrinsic_dtype_map_ = intrinsic_dtypes;
86 65 : }
87 :
88 754 : void PlatFormInfosImpl::SetPlatformRes(const std::string& label, std::map<std::string, std::string>& res)
89 : {
90 754 : platform_res_map_[label] = res;
91 754 : }
92 :
93 61 : void PlatFormInfosImpl::SetFixPipeDtypeMap(const std::map<std::string, std::vector<std::string>>& fixpipe_dtype_map)
94 : {
95 61 : fixpipe_dtype_map_ = fixpipe_dtype_map;
96 61 : }
97 :
98 113 : std::map<std::string, std::vector<std::string>> PlatFormInfosImpl::GetFixPipeDtypeMap() { return fixpipe_dtype_map_; }
99 :
100 107 : std::string OptionalInfosImpl::GetSocVersion() { return soc_version_; }
101 :
102 2 : std::string OptionalInfosImpl::GetCoreType() { return core_type_; }
103 :
104 2 : uint32_t OptionalInfosImpl::GetAICoreNum() { return ai_core_num_; }
105 :
106 2 : std::string OptionalInfosImpl::GetL1FusionFlag() { return l1_fusion_flag_; }
107 :
108 56 : void OptionalInfosImpl::SetSocVersion(std::string soc_version) { soc_version_ = soc_version; }
109 :
110 82 : void OptionalInfosImpl::SetFixPipeDtypeMap(const std::map<std::string, std::vector<std::string>>& fixpipe_dtype_map)
111 : {
112 82 : fixpipe_dtype_map_ = fixpipe_dtype_map;
113 82 : }
114 :
115 2 : std::map<std::string, std::vector<std::string>> OptionalInfosImpl::GetFixPipeDtypeMap() { return fixpipe_dtype_map_; }
116 :
117 41 : void OptionalInfosImpl::SetCoreType(string core_type) { core_type_ = core_type; }
118 :
119 41 : void OptionalInfosImpl::SetAICoreNum(uint32_t ai_core_num) { ai_core_num_ = ai_core_num; }
120 :
121 41 : void OptionalInfosImpl::SetL1FusionFlag(string l1_fusion_flag) { l1_fusion_flag_ = l1_fusion_flag; }
122 :
123 : } // namespace fe
|