已合并
feat: add SoC-specific ATT performance model #2490
feat: add SoC-specific ATT performance model #2490
已合并
zhang_shengjie创建于 23 天前
共 217 个文件变更+2716-412
@@ -14,6 +14,7 @@
14#include <numeric>14#include <numeric>
15#include "common/checker.h"15#include "common/checker.h"
16#include "base/att_const_values.h"16#include "base/att_const_values.h"
17+#include "api_perf_register/soc_perf_config.h"
17 18 
18using namespace af::sym;19using namespace af::sym;
19namespace att {20namespace att {
@@ -1172,7 +1173,22 @@ Perf GetPerfFunc(const std::string &op_type) {
1172}1173}
1173 1174 
1174AscendCPerf GetAscendCPerfFunc(const std::string &op_type) {1175AscendCPerf GetAscendCPerfFunc(const std::string &op_type) {
1175- return EvalCosts::Instance().GetAscendCFunc(op_type);1176+ AscendCPerf default_func = EvalCosts::Instance().GetAscendCFunc(op_type);
1177+ if (default_func == nullptr) {
1178+ return nullptr;
1179+ }
1180+ 
1181+ SocPerfTarget target;
1182+ bool required = false;
1183+ if (ReadSocPerfTarget(target) != af::SUCCESS || RequiresFullSocVersion(target.npu_arch, required) != af::SUCCESS ||
1184+ !required) {
1185+ return default_func;
1186+ }
1187+ AscendCPerf selected_func = nullptr;
1188+ if (ResolveSocAscendCPerf(target, op_type, default_func, selected_func) != af::SUCCESS) {
1189+ return nullptr;
1190+ }
1191+ return selected_func;
1176}1192}
1177 1193 
1178EvalCosts &EvalCosts::Instance() {1194EvalCosts &EvalCosts::Instance() {
@@ -0,0 +1,534 @@
1+/**
2+ * Copyright (c) 2026 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 "soc_perf_config.h"
12+#include "common/platform_context.h"
13+#include "common_utils.h"
14+#include "api_perf_factory.h"
15+#include "ascendc_api_perf.h"
16+ 
17+#include <cmath>
18+#include <mutex>
19+#include <set>
20+ 
21+namespace att {
22+namespace {
23+const char kProbeApiName[] = "Abs";
24+const char kV2RegisterKey[] = "V2";
25+const char kModelParamsKey[] = "model_params";
26+const char kModelTypeKey[] = "model_type";
27+const char kLoadStoreFuncModel[] = "LoadStoreFunc";
28+const char kLoadUbStrideModel[] = "LoadUbStride";
29+const std::set<std::string> kForbiddenRecordFields = {"data_type_size", "block_count_idx"};
30+ 
31+struct SocPerfCacheEntry {
32+ SocPerfConfig config;
33+ std::string base_json;
34+ std::shared_ptr<const Json> params;
35+};
36+ 
37+std::mutex g_soc_perf_cache_mutex;
38+std::map<SocPerfKey, std::shared_ptr<const SocPerfCacheEntry>> g_soc_perf_cache;
39+std::mutex g_soc_api_params_baseline_mutex;
40+std::map<std::string, std::weak_ptr<const Json>> g_soc_api_params_baseline_cache;
41+std::mutex g_soc_ascir_registration_keys_mutex;
42+std::map<std::string, std::set<std::string>> g_soc_ascir_registration_keys_cache;
43+ 
44+af::Status GetProbeParamTable(const std::string &npu_arch, const PerfParamTable *&param_table) {
45+ param_table = nullptr;
46+ if (npu_arch.empty()) {
47+ return af::FAILED;
48+ }
49+ 
50+ const auto asc_ir_att_impl = af::ascir::AscirRegistry::GetInstance().GetIrAttImpl(npu_arch, kProbeApiName);
51+ if (asc_ir_att_impl == nullptr) {
52+ return af::FAILED;
53+ }
54+ const auto api_perf_name = ge::PtrToPtr<void, ge::char_t>(asc_ir_att_impl->GetApiPerf());
55+ if (api_perf_name == nullptr) {
56+ return af::FAILED;
57+ }
58+ auto api_perf = ApiPerfFactory::Instance().Create(api_perf_name);
59+ if (api_perf == nullptr) {
60+ return af::FAILED;
61+ }
62+ param_table = api_perf->GetPerfParam();
63+ return param_table == nullptr ? af::FAILED : af::SUCCESS;
64+}
65+ 
66+af::Status GetBaselineJson(const SocPerfTarget &target, const std::string *&base_json) {
67+ base_json = nullptr;
68+ const PerfParamTable *param_table = nullptr;
69+ if (GetProbeParamTable(target.npu_arch, param_table) != af::SUCCESS) {
70+ return af::FAILED;
71+ }
72+ base_json = param_table->GetAscendCApiPerfTable();
73+ return base_json == nullptr ? af::FAILED : af::SUCCESS;
74+}
75+ 
76+af::Status ParseJsonObject(const std::string &json_str, Json &json) {
77+ json = Json::object();
78+ try {
79+ json = Json::parse(json_str);
80+ } catch (const nlohmann::json::exception &) {
81+ return af::FAILED;
82+ }
83+ return json.is_object() ? af::SUCCESS : af::FAILED;
84+}
85+ 
86+bool IsFiniteFloat(const Json &value) {
87+ return value.is_number() && std::isfinite(static_cast<float>(value.get<double>()));
88+}
89+ 
90+bool IsZeroFloat(const Json &value) {
91+ const float actual = static_cast<float>(value.get<double>());
92+ return std::fpclassify(actual) == FP_ZERO;
93+}
94+ 
95+af::Status ValidateRecord(const Json &override_record, const Json &baseline_record, const std::string &model_type) {
96+ if (!override_record.is_object() || !baseline_record.is_object()) {
97+ return af::FAILED;
98+ }
99+ 
100+ std::set<std::string> baseline_fields;
@@ -0,0 +1,63 @@
1+/**
2+ * Copyright (c) 2026 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+#ifndef ATT_SOC_PERF_CONFIG_H_
12+#define ATT_SOC_PERF_CONFIG_H_
13+ 
14+#include <map>
15+#include <memory>
16+#include <string>
17+#include <utility>
18+ 
19+#include <nlohmann/json.hpp>
20+ 
21+#include "api_perf.h"
22+#include "ge_common_af/ge_api_error_codes_af.h"
23+ 
24+namespace att {
25+using Json = nlohmann::json;
26+ 
27+struct SocPerfTarget {
28+ std::string npu_arch;
29+ std::string soc_version;
30+};
31+ 
32+using SocPerfKey = std::pair<std::string, std::string>;
33+ 
34+struct SocPerfConfig {
35+ Json api_param_overrides = Json::object();
36+ std::map<std::string, std::string> ascir_model_overrides;
37+ std::map<std::string, std::string> ascendc_model_overrides;
38+};
39+ 
40+using SocPerfConfigs = std::map<SocPerfKey, SocPerfConfig>;
41+ 
42+const SocPerfConfigs &GetBuiltinSocPerfConfigs();
43+ 
44+af::Status ReadSocPerfTarget(SocPerfTarget &target);
45+af::Status RequiresFullSocVersion(const std::string &npu_arch, bool &required);
46+af::Status ValidateSocPerfEntry();
47+af::Status ValidateSocPerfConfig(const SocPerfTarget &target, const SocPerfConfigs &configs);
48+af::Status ValidateSocPerfConfig(const SocPerfTarget &target);
49+af::Status GetSocApiParams(const SocPerfTarget &target, const std::string &base_json, const SocPerfConfigs &configs,
50+ std::shared_ptr<const Json> &params);
51+af::Status GetSocApiParams(const SocPerfTarget &target, const std::string &base_json,
52+ std::shared_ptr<const Json> &params);
53+af::Status ResolveSocAscIrPerf(const SocPerfTarget &target, const std::string &api_registration_key, Perf default_func,
54+ Perf &selected_func, const SocPerfConfigs &configs);
55+af::Status ResolveSocAscIrPerf(const SocPerfTarget &target, const std::string &api_registration_key, Perf default_func,
56+ Perf &selected_func);
57+af::Status ResolveSocAscendCPerf(const SocPerfTarget &target, const std::string &api_registration_key,
58+ AscendCPerf default_func, AscendCPerf &selected_func, const SocPerfConfigs &configs);
59+af::Status ResolveSocAscendCPerf(const SocPerfTarget &target, const std::string &api_registration_key,
60+ AscendCPerf default_func, AscendCPerf &selected_func);
61+} // namespace att
62+ 
63+#endif // ATT_SOC_PERF_CONFIG_H_
@@ -0,0 +1,19 @@
1+/**
2+ * Copyright (c) 2026 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 "soc_perf_config.h"
12+ 
13+namespace att {
14+const SocPerfConfigs &GetBuiltinSocPerfConfigs() {
15+ // Only SoC-specific differences belong here; registered V2 architectures keep their baseline by default.
16+ static const SocPerfConfigs configs;
17+ return configs;
18+}
19+} // namespace att
@@ -14,6 +14,7 @@
14#include "api_perf_register/perf_param.h"14#include "api_perf_register/perf_param.h"
15#include "api_perf_register/api_perf_factory.h"15#include "api_perf_register/api_perf_factory.h"
16#include "api_perf_register/ascendc_api_perf.h"16#include "api_perf_register/ascendc_api_perf.h"
17+#include "api_perf_register/soc_perf_config.h"
17#include "utils/node_expr_id.h"18#include "utils/node_expr_id.h"
18 19 
19namespace att {20namespace att {
@@ -383,6 +384,25 @@ const PerfParamTable *GetParamPerfTable() {
383 return api_perf->GetPerfParam();384 return api_perf->GetPerfParam();
384}385}
385 386 
387+static af::Status IsSocPerfTarget(const SocPerfTarget &target, bool &is_soc_perf_target) {
388+ is_soc_perf_target = false;
389+ return RequiresFullSocVersion(target.npu_arch, is_soc_perf_target);
390+}
391+ 
392+static af::Status GetTargetApiParams(const SocPerfTarget &target, std::shared_ptr<const Json> &params) {
393+ const auto asc_ir_att_impl = af::ascir::AscirRegistry::GetInstance().GetIrAttImpl(target.npu_arch, kDefaultApi);
394+ GE_ASSERT_NOTNULL(asc_ir_att_impl);
395+ const auto api_perf_name = ge::PtrToPtr<void, ge::char_t>(asc_ir_att_impl->GetApiPerf());
396+ GE_ASSERT_NOTNULL(api_perf_name);
397+ auto api_perf = ApiPerfFactory::Instance().Create(api_perf_name);
398+ GE_ASSERT_NOTNULL(api_perf);
399+ const auto param_table = api_perf->GetPerfParam();
400+ GE_ASSERT_NOTNULL(param_table);
401+ const auto ascend_api_perf_table = param_table->GetAscendCApiPerfTable();
402+ GE_ASSERT_NOTNULL(ascend_api_perf_table);
403+ return GetSocApiParams(target, *ascend_api_perf_table, params);
404+}
405+ 
386void UpdateContinuousIdx(size_t idx, const std::vector<Expr> &strides, const std::vector<Expr> &repeats,406void UpdateContinuousIdx(size_t idx, const std::vector<Expr> &strides, const std::vector<Expr> &repeats,
387 std::vector<bool> &is_continuous) {407 std::vector<bool> &is_continuous) {
388 size_t cur = idx - 1UL;408 size_t cur = idx - 1UL;
@@ -560,8 +580,39 @@ af::Status GetOpHeadCost(Expr &head_cost) {
560 return af::SUCCESS;580 return af::SUCCESS;
561}581}
562 582 
583+static std::unique_ptr<ApiPerf> CreateSocApiPerf(const SocPerfTarget &target, const std::string &node_type) {
584+ const auto asc_ir_att_impl = af::ascir::AscirRegistry::GetInstance().GetIrAttImpl(target.npu_arch, node_type);
585+ if (asc_ir_att_impl == nullptr) {
586+ return nullptr;
587+ }
588+ const auto api_perf_name = ge::PtrToPtr<void, ge::char_t>(asc_ir_att_impl->GetApiPerf());
589+ auto api_perf = api_perf_name == nullptr ? ApiPerfFactory::Instance().Create(node_type)
590+ : ApiPerfFactory::Instance().Create(api_perf_name);
591+ if (api_perf == nullptr) {
592+ return nullptr;
593+ }
594+ 
595+ Perf selected_func = nullptr;
596+ if (ResolveSocAscIrPerf(target, api_perf->GetApiName(), api_perf->GetPerfFunc(), selected_func) != af::SUCCESS) {
597+ return nullptr;
598+ }
599+ return std::make_unique<ApiPerf>(api_perf->GetApiName(), selected_func, api_perf->GetMicroPerfFunc(),
600+ api_perf->GetPerfParam(), api_perf->GetTilingScheduleConfigTable());
601+}
602+ 
563std::unique_ptr<ApiPerf> GetApiPerf(const std::string &node_type) {603std::unique_ptr<ApiPerf> GetApiPerf(const std::string &node_type) {
564 GELOGD("Begin to get api name for node[%s]", node_type.c_str());604 GELOGD("Begin to get api name for node[%s]", node_type.c_str());
605+ SocPerfTarget target;
606+ if (ReadSocPerfTarget(target) == af::SUCCESS) {
607+ bool is_soc_perf_target = false;
608+ if (IsSocPerfTarget(target, is_soc_perf_target) != af::SUCCESS) {
609+ return nullptr;
610+ }
611+ if (is_soc_perf_target) {
612+ return CreateSocApiPerf(target, node_type);
613+ }
614+ }
615+ 
565 const auto asc_ir_att_impl = ascgen_utils::GetAscIrAttImpl(node_type);616 const auto asc_ir_att_impl = ascgen_utils::GetAscIrAttImpl(node_type);
566 GE_ASSERT_NOTNULL(asc_ir_att_impl, "Get ascir att impl failed, node_type[%s]", node_type.c_str());617 GE_ASSERT_NOTNULL(asc_ir_att_impl, "Get ascir att impl failed, node_type[%s]", node_type.c_str());
567 const auto api_perf_name = ge::PtrToPtr<void, ge::char_t>(asc_ir_att_impl->GetApiPerf());618 const auto api_perf_name = ge::PtrToPtr<void, ge::char_t>(asc_ir_att_impl->GetApiPerf());
@@ -572,18 +623,10 @@ std::unique_ptr<ApiPerf> GetApiPerf(const std::string &node_type) {
572 return ApiPerfFactory::Instance().Create(node_type);623 return ApiPerfFactory::Instance().Create(node_type);
573}624}
574 625 
575-af::Status GetPerf(const NodePerfInfo &node_perf_info, Expr &res) {626+static af::Status CalculatePerfFromParams(const NodePerfInfo &node_perf_info, const Json &params_data, Expr &res) {
576- std::string optype = node_perf_info.optype;627+ const std::string optype = node_perf_info.optype;
577- std::string input_dtype = node_perf_info.input_dtype;628+ const std::string input_dtype = node_perf_info.input_dtype;
578- std::string output_dtype = node_perf_info.output_dtype;629+ const std::string output_dtype = node_perf_info.output_dtype;
579- GELOGD("GetPerf: optype=[%s], input_dtype=[%s], output_dtype=[%s], block_count_idx=%d", optype.c_str(),
580- input_dtype.c_str(), output_dtype.c_str(), node_perf_info.block_count_idx);
581- const auto perf_table = GetParamPerfTable();
582- GE_ASSERT_NOTNULL(perf_table);
583- const auto ascend_api_perf_table = perf_table->GetAscendCApiPerfTable();
584- GE_ASSERT_NOTNULL(ascend_api_perf_table);
585- Json params_data;
586- GE_ASSERT_SUCCESS(StringToJson(*ascend_api_perf_table, params_data));
587 const auto &opt_type_param = params_data.find(optype);630 const auto &opt_type_param = params_data.find(optype);
588 GE_ASSERT_TRUE(opt_type_param != params_data.end(), "Optype[%s] not found! json: %s", optype.c_str(),631 GE_ASSERT_TRUE(opt_type_param != params_data.end(), "Optype[%s] not found! json: %s", optype.c_str(),
589 params_data.dump().c_str());632 params_data.dump().c_str());
@@ -616,6 +659,30 @@ af::Status GetPerf(const NodePerfInfo &node_perf_info, Expr &res) {
616 return af::SUCCESS;659 return af::SUCCESS;
617}660}
618 661 
662+af::Status GetPerf(const NodePerfInfo &node_perf_info, Expr &res) {
663+ GELOGD("GetPerf: optype=[%s], input_dtype=[%s], output_dtype=[%s], block_count_idx=%d", node_perf_info.optype.c_str(),
664+ node_perf_info.input_dtype.c_str(), node_perf_info.output_dtype.c_str(), node_perf_info.block_count_idx);
665+ 
666+ SocPerfTarget target;
667+ std::shared_ptr<const Json> soc_params;
668+ if (ReadSocPerfTarget(target) == af::SUCCESS) {
669+ bool is_soc_perf_target = false;
670+ GE_ASSERT_SUCCESS(IsSocPerfTarget(target, is_soc_perf_target));
671+ if (is_soc_perf_target) {
672+ GE_ASSERT_SUCCESS(GetTargetApiParams(target, soc_params));
673+ return CalculatePerfFromParams(node_perf_info, *soc_params, res);
674+ }
675+ }
676+ 
677+ const auto perf_table = GetParamPerfTable();
678+ GE_ASSERT_NOTNULL(perf_table);
679+ const auto ascend_api_perf_table = perf_table->GetAscendCApiPerfTable();
680+ GE_ASSERT_NOTNULL(ascend_api_perf_table);
681+ Json params_data;
682+ GE_ASSERT_SUCCESS(StringToJson(*ascend_api_perf_table, params_data));
683+ return CalculatePerfFromParams(node_perf_info, params_data, res);
684+}
685+ 
619inline void FilterStridesAndRepeats(const std::vector<Expr> &strides, const std::vector<Expr> &repeats,686inline void FilterStridesAndRepeats(const std::vector<Expr> &strides, const std::vector<Expr> &repeats,
620 std::vector<Expr> &filtered_strides, // 输出:过滤后的strides687 std::vector<Expr> &filtered_strides, // 输出:过滤后的strides
621 std::vector<Expr> &filtered_repeats // 输出:过滤后的repeats688 std::vector<Expr> &filtered_repeats // 输出:过滤后的repeats
@@ -16,6 +16,7 @@
16#include "common/checker.h"16#include "common/checker.h"
17#include "api_perf_register/utils/vf_perf_utils.h"17#include "api_perf_register/utils/vf_perf_utils.h"
18#include "api_perf_register/utils/api_perf_utils.h"18#include "api_perf_register/utils/api_perf_utils.h"
19+#include "api_perf_register/soc_perf_config.h"
19#include "api_perf_register/api_perf_factory.h"20#include "api_perf_register/api_perf_factory.h"
20#include "utils/node_expr_id.h"21#include "utils/node_expr_id.h"
21#include "graph/compute_graph.h"22#include "graph/compute_graph.h"
@@ -23,6 +24,13 @@
23namespace att {24namespace att {
24namespace {25namespace {
25constexpr int32_t kMaxRecursiveNum = 10;26constexpr int32_t kMaxRecursiveNum = 10;
27+bool IsV35SocPerfTarget() {
28+ SocPerfTarget target;
29+ bool required = false;
30+ return ReadSocPerfTarget(target) == af::SUCCESS && RequiresFullSocVersion(target.npu_arch, required) == af::SUCCESS &&
31+ required;
32+}
33+ 
26std::string GetContribDescription(const std::string &pipe_type, const std::string &contrib_suffix) {34std::string GetContribDescription(const std::string &pipe_type, const std::string &contrib_suffix) {
27 if (contrib_suffix == "core_contrib") {35 if (contrib_suffix == "core_contrib") {
28 return pipe_type + " core contribution = node API perf * core exe time";36 return pipe_type + " core contribution = node API perf * core exe time";
@@ -435,6 +443,9 @@ af::Status PipePerfExpr::GetNodePerf(const NodeInfo &node, std::map<PipeType, Ex
435 node_unit.c_str());443 node_unit.c_str());
436 444 
437 if (perf_func(inputs, outputs, node, perf_res) != af::SUCCESS) {445 if (perf_func(inputs, outputs, node, perf_res) != af::SUCCESS) {
446+ if (IsV35SocPerfTarget()) {
447+ return af::FAILED;
448+ }
438 GELOGW("Perf func failed for node[%s, %s], perf_res may be incomplete.", node.name.c_str(), node.node_type.c_str());449 GELOGW("Perf func failed for node[%s, %s], perf_res may be incomplete.", node.name.c_str(), node.node_type.c_str());
439 }450 }
440 GELOGD("node[%s, %s] perf res: {%s}", node.name.c_str(), node.node_type.c_str(), perf_res.ToString().c_str());451 GELOGD("node[%s, %s] perf res: {%s}", node.name.c_str(), node.node_type.c_str(), perf_res.ToString().c_str());
@@ -22,6 +22,7 @@
22#include "nlohmann/json.hpp"22#include "nlohmann/json.hpp"
23#include "util/base_types_printer.h"23#include "util/base_types_printer.h"
24#include "util/duration.h"24#include "util/duration.h"
25+#include "api_perf_register/soc_perf_config.h"
25#include "api_tiling_gen/gen_api_tiling.h"26#include "api_tiling_gen/gen_api_tiling.h"
26#include "base/att_const_values.h"27#include "base/att_const_values.h"
27#include "util/thread_local_context.h"28#include "util/thread_local_context.h"
@@ -187,6 +188,7 @@ af::Status RefreshCommonUbExprContext(const af::AscGraph &graph, ModelInfo &mode
187static af::Status GenerateSingleModelInfoWithContext(const af::AscGraph &graph, ModelInfo &model_info,188static af::Status GenerateSingleModelInfoWithContext(const af::AscGraph &graph, ModelInfo &model_info,
188 TuningSpacePtr &tuning_space, const uint32_t tiling_case_id,189 TuningSpacePtr &tuning_space, const uint32_t tiling_case_id,
189 bool is_cv_ub_fusion) {190 bool is_cv_ub_fusion) {
191+ GE_ASSERT_SUCCESS(ValidateSocPerfEntry(), "Validate SoC performance target failed.");
190 GELOGI("[DFX]Begin to generate model info for graph %s of tiling case id %u", graph.GetName().c_str(),192 GELOGI("[DFX]Begin to generate model info for graph %s of tiling case id %u", graph.GetName().c_str(),
191 tiling_case_id);193 tiling_case_id);
192 DURATION_GUARD(DurationType::DURATION_GEN_MODEL_INFO);194 DURATION_GUARD(DurationType::DURATION_GEN_MODEL_INFO);
@@ -223,6 +225,7 @@ af::Status CheckKeyValid(const std::vector<af::AscGraph> &graph_list) {
223}225}
224 226 
225af::Status GenerateModelInfo(const std::vector<af::AscGraph> &graph_list, std::vector<ModelInfo> &model_info_list) {227af::Status GenerateModelInfo(const std::vector<af::AscGraph> &graph_list, std::vector<ModelInfo> &model_info_list) {
228+ GE_ASSERT_SUCCESS(ValidateSocPerfEntry(), "Validate SoC performance target failed.");
226 GE_ASSERT_SUCCESS(CheckKeyValid(graph_list));229 GE_ASSERT_SUCCESS(CheckKeyValid(graph_list));
227 uint32_t tiling_key = 0U;230 uint32_t tiling_key = 0U;
228 for (auto &graph : graph_list) {231 for (auto &graph : graph_list) {
@@ -421,12 +424,14 @@ static af::Status GenerateModelInfoWithContext(const std::vector<af::AscGraph> &
421 424 
422af::Status GenerateModelInfo(const std::vector<af::AscGraph> &graph_list, std::vector<ModelInfo> &model_info_list,425af::Status GenerateModelInfo(const std::vector<af::AscGraph> &graph_list, std::vector<ModelInfo> &model_info_list,
423 const std::map<std::string, std::string> &options, bool enable_group_parallel) {426 const std::map<std::string, std::string> &options, bool enable_group_parallel) {
427+ GE_ASSERT_SUCCESS(ValidateSocPerfEntry(), "Validate SoC performance target failed.");
424 return GenerateModelInfo(graph_list, model_info_list, options, enable_group_parallel, false);428 return GenerateModelInfo(graph_list, model_info_list, options, enable_group_parallel, false);
425}429}
426 430 
427af::Status GenerateModelInfo(const std::vector<af::AscGraph> &graph_list, std::vector<ModelInfo> &model_info_list,431af::Status GenerateModelInfo(const std::vector<af::AscGraph> &graph_list, std::vector<ModelInfo> &model_info_list,
428 const std::map<std::string, std::string> &options, bool enable_group_parallel,432 const std::map<std::string, std::string> &options, bool enable_group_parallel,
429 bool enable_gather_reduce_penalty) {433 bool enable_gather_reduce_penalty) {
434+ GE_ASSERT_SUCCESS(ValidateSocPerfEntry(), "Validate SoC performance target failed.");
430 return GenerateModelInfoWithContext(graph_list, model_info_list, options, enable_group_parallel,435 return GenerateModelInfoWithContext(graph_list, model_info_list, options, enable_group_parallel,
431 {enable_gather_reduce_penalty, false});436 {enable_gather_reduce_penalty, false});
432}437}
@@ -576,6 +581,7 @@ af::Status ProcessAndSetScheduleGroupInfo(const std::vector<std::vector<af::AscG
576af::Status GetModelInfoMap(const ascir::FusedScheduledResult &schedule_results,581af::Status GetModelInfoMap(const ascir::FusedScheduledResult &schedule_results,
577 const std::map<std::string, std::string> &options,582 const std::map<std::string, std::string> &options,
578 FusedParsedScheduleResult &out_all_model_infos) {583 FusedParsedScheduleResult &out_all_model_infos) {
584+ GE_ASSERT_SUCCESS(ValidateSocPerfEntry(), "Validate SoC performance target failed.");
579 std::vector<std::vector<std::vector<std::vector<af::AscGraph>>>> all_graphs_lists;585 std::vector<std::vector<std::vector<std::vector<af::AscGraph>>>> all_graphs_lists;
580 std::map<std::string, std::string> all_graph_score_funcs;586 std::map<std::string, std::string> all_graph_score_funcs;
581 GE_ASSERT_SUCCESS(GetAllSubImplGraphs(schedule_results, all_graphs_lists, all_graph_score_funcs));587 GE_ASSERT_SUCCESS(GetAllSubImplGraphs(schedule_results, all_graphs_lists, all_graph_score_funcs));
@@ -22,6 +22,7 @@
22#include "common/ge_common/debug/log.h"22#include "common/ge_common/debug/log.h"
23#include "codegen_infershape.h"23#include "codegen_infershape.h"
24#include "common/platform_context.h"24#include "common/platform_context.h"
25+#include "gen_model_info/api_perf_register/soc_perf_config.h"
25#include "graph/ascendc_ir/utils/asc_graph_utils.h"26#include "graph/ascendc_ir/utils/asc_graph_utils.h"
26 27 
27using namespace codegen;28using namespace codegen;
@@ -390,6 +391,7 @@ Status Codegen::Generate(const ascir::FusedScheduledResult &fused_schedule_resul
390// inductor路径仍返回单个host_tiling字符串,通过注释marker保留拆分边界391// inductor路径仍返回单个host_tiling字符串,通过注释marker保留拆分边界
391Status Codegen::GenerateForInductor(const ascir::FusedScheduledResult &fused_schedule_result,392Status Codegen::GenerateForInductor(const ascir::FusedScheduledResult &fused_schedule_result,
392 CodegenResult &result) const {393 CodegenResult &result) const {
394+ GE_CHK_STATUS_RET(att::ValidateSocPerfEntry(), "Validate SoC performance target failed");
393 if (tiling_lib_.ShouldFallbackPgo(fused_schedule_result)) {395 if (tiling_lib_.ShouldFallbackPgo(fused_schedule_result)) {
394 GELOGW("Tiling key count exceeds 10000, fallback to non-PGO Inductor codegen");396 GELOGW("Tiling key count exceeds 10000, fallback to non-PGO Inductor codegen");
395 Codegen fallback(*this);397 Codegen fallback(*this);
@@ -428,6 +430,7 @@ Status Codegen::GenerateForInductor(const ascir::FusedScheduledResult &fused_sch
428 430 
429Status Codegen::Generate(const std::map<std::string, std::string> &shape_info,431Status Codegen::Generate(const std::map<std::string, std::string> &shape_info,
430 const ascir::FusedScheduledResult &fused_schedule_result, CodegenResult &result) const {432 const ascir::FusedScheduledResult &fused_schedule_result, CodegenResult &result) const {
433+ GE_CHK_STATUS_RET(att::ValidateSocPerfEntry(), "Validate SoC performance target failed");
431 GE_CHK_STATUS_RET(GenerateKernel(fused_schedule_result, result.kernel, false), "Codegen generate kernel failed");434 GE_CHK_STATUS_RET(GenerateKernel(fused_schedule_result, result.kernel, false), "Codegen generate kernel failed");
432 result.tiling_data = GenerateTilingData(fused_schedule_result, false);435 result.tiling_data = GenerateTilingData(fused_schedule_result, false);
433 std::map<std::string, std::string> tiling_file_name_to_content;436 std::map<std::string, std::string> tiling_file_name_to_content;
@@ -446,6 +449,7 @@ std::string Codegen::GenerateTilingData(const ascir::FusedScheduledResult &fused
446 449 
447Status Codegen::GenerateTilingForInductor(const ascir::FusedScheduledResult &fused_schedule_result,450Status Codegen::GenerateTilingForInductor(const ascir::FusedScheduledResult &fused_schedule_result,
448 std::map<std::string, std::string> &tiling_file_name_to_content) const {451 std::map<std::string, std::string> &tiling_file_name_to_content) const {
452+ GE_CHK_STATUS_RET(att::ValidateSocPerfEntry(), "Validate SoC performance target failed");
449 tiling_file_name_to_content = this->tiling_lib_.GenerateForInductor(fused_schedule_result);453 tiling_file_name_to_content = this->tiling_lib_.GenerateForInductor(fused_schedule_result);
450 for (const auto &pair : tiling_file_name_to_content) {454 for (const auto &pair : tiling_file_name_to_content) {
451 GE_CHK_BOOL_RET_STATUS(pair.second != ascgen_utils::INVALID_TILING, af::FAILED, "tilings(%s) is invalid",455 GE_CHK_BOOL_RET_STATUS(pair.second != ascgen_utils::INVALID_TILING, af::FAILED, "tilings(%s) is invalid",
@@ -465,6 +469,7 @@ Status Codegen::GenerateTiling(const ascir::FusedScheduledResult &fused_schedule
465 const std::map<std::string, std::string> &shape_info, const std::string &pgo_dir,469 const std::map<std::string, std::string> &shape_info, const std::string &pgo_dir,
466 const std::string &core_num,470 const std::string &core_num,
467 std::map<std::string, std::string> &tiling_file_name_to_content) const {471 std::map<std::string, std::string> &tiling_file_name_to_content) const {
472+ GE_CHK_STATUS_RET(att::ValidateSocPerfEntry(), "Validate SoC performance target failed");
468 tiling_file_name_to_content = this->tiling_lib_.Generate(fused_schedule_result, shape_info, pgo_dir, core_num);473 tiling_file_name_to_content = this->tiling_lib_.Generate(fused_schedule_result, shape_info, pgo_dir, core_num);
469 for (const auto &pair : tiling_file_name_to_content) {474 for (const auto &pair : tiling_file_name_to_content) {
470 GE_CHK_BOOL_RET_STATUS(pair.second != ascgen_utils::INVALID_TILING, af::FAILED, "tilings(%s) is invalid",475 GE_CHK_BOOL_RET_STATUS(pair.second != ascgen_utils::INVALID_TILING, af::FAILED, "tilings(%s) is invalid",
@@ -20,6 +20,7 @@ const char *kAICoreSpec = "AICoreSpec";
20const char *kVectorCoreCnt = "vector_core_cnt";20const char *kVectorCoreCnt = "vector_core_cnt";
21const char *kUbSize = "ub_size";21const char *kUbSize = "ub_size";
22const char *kL2Size = "l2_size";22const char *kL2Size = "l2_size";
23+std::string g_full_soc_version;
23 24 
24bool ParseInt64(const char *value, const char *key_name, int64_t &result) {25bool ParseInt64(const char *value, const char *key_name, int64_t &result) {
25 try {26 try {
@@ -41,6 +42,7 @@ std::mutex PlatformContext::mutex_;
41 42 
42void PlatformContext::SetPlatform(const std::string &platform_name) {43void PlatformContext::SetPlatform(const std::string &platform_name) {
43 std::lock_guard<std::mutex> lg(mutex_);44 std::lock_guard<std::mutex> lg(mutex_);
45+ g_full_soc_version.clear();
44 if (!platform_name.empty()) {46 if (!platform_name.empty()) {
45 platform_info_.soc_ver = platform_name;47 platform_info_.soc_ver = platform_name;
46 initialized_ = true;48 initialized_ = true;
@@ -50,6 +52,7 @@ void PlatformContext::SetPlatform(const std::string &platform_name) {
50 52 
51void PlatformContext::SetPlatformInfo(const PlatformInfo &platform_info) {53void PlatformContext::SetPlatformInfo(const PlatformInfo &platform_info) {
52 std::lock_guard<std::mutex> lg(mutex_);54 std::lock_guard<std::mutex> lg(mutex_);
55+ g_full_soc_version.clear();
53 if (platform_info.ub_size > 0) {56 if (platform_info.ub_size > 0) {
54 ub_size_override_ = platform_info.ub_size;57 ub_size_override_ = platform_info.ub_size;
55 has_ub_size_override_ = true;58 has_ub_size_override_ = true;
@@ -62,6 +65,50 @@ void PlatformContext::SetPlatformInfo(const PlatformInfo &platform_info) {
62 }65 }
63}66}
64 67 
68+af::Status PlatformContext::SetPlatformTarget(const PlatformInfo &platform_info, const std::string &soc_version) {
69+ if (platform_info.soc_ver.empty() && !soc_version.empty()) {
70+ return af::FAILED;
71+ }
72+ 
73+ std::lock_guard<std::mutex> lg(mutex_);
74+ g_full_soc_version.clear();
75+ if (platform_info.ub_size > 0) {
76+ ub_size_override_ = platform_info.ub_size;
77+ has_ub_size_override_ = true;
78+ }
79+ if (!platform_info.soc_ver.empty()) {
80+ platform_info_ = platform_info;
81+ g_full_soc_version = soc_version;
82+ initialized_ = true;
83+ return af::SUCCESS;
84+ }
85+ 
86+ initialized_ = false;
87+ return af::SUCCESS;
88+}
89+ 
90+af::Status PlatformContext::GetPlatformTarget(std::string &npu_arch, std::string &soc_version) {
91+ npu_arch.clear();
92+ soc_version.clear();
93+ if (!initialized_) {
94+ g_full_soc_version.clear();
95+ GE_ASSERT_SUCCESS(Initialize(), "Failed to init platform info.");
96+ }
97+ std::lock_guard<std::mutex> lg(mutex_);
98+ npu_arch = platform_info_.soc_ver;
99+ soc_version = g_full_soc_version;
100+ return af::SUCCESS;
101+}
102+ 
103+void PlatformContext::Reset() {
104+ std::lock_guard<std::mutex> lg(mutex_);
105+ initialized_ = false;
106+ platform_info_ = PlatformInfo{};
107+ g_full_soc_version.clear();
108+ ub_size_override_ = 0;
109+ has_ub_size_override_ = false;
110+}
111+ 
65void PlatformContext::SetUbSizeOverride(int64_t ub_size) {112void PlatformContext::SetUbSizeOverride(int64_t ub_size) {
66 std::lock_guard<std::mutex> lg(mutex_);113 std::lock_guard<std::mutex> lg(mutex_);
67 ub_size_override_ = ub_size;114 ub_size_override_ = ub_size;
@@ -83,6 +130,7 @@ af::Status PlatformContext::Initialize() {
83 if (initialized_) {130 if (initialized_) {
84 return af::SUCCESS;131 return af::SUCCESS;
85 }132 }
133+ g_full_soc_version.clear();
86 char soc_version[kSocStrMaxLen] = {};134 char soc_version[kSocStrMaxLen] = {};
87 auto res = rtGetSocSpec("version", "NpuArch", soc_version, kSocStrMaxLen);135 auto res = rtGetSocSpec("version", "NpuArch", soc_version, kSocStrMaxLen);
88 GE_ASSERT_TRUE(res == RT_ERROR_NONE, "Failed to get npu arch str.");136 GE_ASSERT_TRUE(res == RT_ERROR_NONE, "Failed to get npu arch str.");
@@ -1566,6 +1566,8 @@ PyMethodDef UtilsMethods[] = {
1566 "report durations"},1566 "report durations"},
1567 {"set_platform", reinterpret_cast<PyCFunction>(pyascir::UtilsSetPlatform), METH_VARARGS,1567 {"set_platform", reinterpret_cast<PyCFunction>(pyascir::UtilsSetPlatform), METH_VARARGS,
1568 "set platform for platform context"},1568 "set platform for platform context"},
1569+ {"requires_full_soc_version", reinterpret_cast<PyCFunction>(pyascir::UtilsRequiresFullSocVersion), METH_VARARGS,
1570+ "check whether npu arch requires full soc version"},
1569 {NULL}};1571 {NULL}};
1570 1572 
1571PyMethodDef AscirMethods[] = {{"Max", SizeExprMax, METH_VARARGS, "Return the maximum of two SizeExpr values"},1573PyMethodDef AscirMethods[] = {{"Max", SizeExprMax, METH_VARARGS, "Return the maximum of two SizeExpr values"},
@@ -17,6 +17,7 @@
17#include "common/ge_common/debug/log.h"17#include "common/ge_common/debug/log.h"
18#include "attribute_group/attr_group_shape_env.h"18#include "attribute_group/attr_group_shape_env.h"
19#include "common/platform_context.h"19#include "common/platform_context.h"
20+#include "gen_model_info/api_perf_register/soc_perf_config.h"
20 21 
21#include "pyascir_types.h"22#include "pyascir_types.h"
22#include "ascgen_log.h"23#include "ascgen_log.h"
@@ -202,7 +203,8 @@ PyObject *UtilsSetPlatform(const PyObject *self_pyobject, PyObject *args, const
202 const char *platform = nullptr;203 const char *platform = nullptr;
203 long long vector_core_num = 0;204 long long vector_core_num = 0;
204 long long ub_size = 0;205 long long ub_size = 0;
205- if (PyArg_ParseTuple(args, "sLL", &platform, &vector_core_num, &ub_size) == kPythonFail) {206+ const char *soc_version = nullptr;
207+ if (PyArg_ParseTuple(args, "sLL|s", &platform, &vector_core_num, &ub_size, &soc_version) == kPythonFail) {
206 return PyErr_Format(PyExc_TypeError, "UtilsSetPlatform param parse failed, expected string, long, long");208 return PyErr_Format(PyExc_TypeError, "UtilsSetPlatform param parse failed, expected string, long, long");
207 }209 }
208 PY_ASSERT_NOTNULL(platform);210 PY_ASSERT_NOTNULL(platform);
@@ -210,7 +212,28 @@ PyObject *UtilsSetPlatform(const PyObject *self_pyobject, PyObject *args, const
210 platform_info.soc_ver = std::string(platform);212 platform_info.soc_ver = std::string(platform);
211 platform_info.aiv_num = static_cast<int64_t>(vector_core_num);213 platform_info.aiv_num = static_cast<int64_t>(vector_core_num);
212 platform_info.ub_size = static_cast<int64_t>(ub_size);214 platform_info.ub_size = static_cast<int64_t>(ub_size);
213- ge::PlatformContext::GetInstance().SetPlatformInfo(platform_info);215+ const std::string full_soc_version = (soc_version == nullptr) ? std::string() : std::string(soc_version);
216+ if (ge::PlatformContext::GetInstance().SetPlatformTarget(platform_info, full_soc_version) != af::SUCCESS) {
217+ return PyErr_Format(PyExc_RuntimeError, "UtilsSetPlatform failed: npu arch and soc version are inconsistent");
218+ }
214 Py_RETURN_NONE;219 Py_RETURN_NONE;
215}220}
221+ 
222+PyObject *UtilsRequiresFullSocVersion(const PyObject *self_pyobject, PyObject *args, const PyObject *kwds) {
223+ (void)self_pyobject;
224+ (void)kwds;
225+ const char *npu_arch = nullptr;
226+ if (PyArg_ParseTuple(args, "s", &npu_arch) == kPythonFail) {
227+ return PyErr_Format(PyExc_TypeError, "UtilsRequiresFullSocVersion param parse failed, expected string");
228+ }
229+ 
230+ bool required = false;
231+ if (att::RequiresFullSocVersion(std::string(npu_arch), required) != af::SUCCESS) {
232+ return PyErr_Format(PyExc_RuntimeError, "invalid npu arch: %s", npu_arch);
233+ }
234+ if (required) {
235+ Py_RETURN_TRUE;
236+ }
237+ Py_RETURN_FALSE;
238+}
216} // namespace pyascir239} // namespace pyascir
@@ -24,6 +24,7 @@ PyObject *UtilsDeserialize(PyObject *self_pyobject, PyObject *args, PyObject *kw
24PyObject *UtilsDurationRecord(PyObject *self_pyobject, PyObject *args, PyObject *kwds);24PyObject *UtilsDurationRecord(PyObject *self_pyobject, PyObject *args, PyObject *kwds);
25PyObject *UtilsReportDurations(PyObject *self_pyobject, PyObject *args, PyObject *kwds);25PyObject *UtilsReportDurations(PyObject *self_pyobject, PyObject *args, PyObject *kwds);
26PyObject *UtilsSetPlatform(const PyObject *self_pyobject, PyObject *args, const PyObject *kwds);26PyObject *UtilsSetPlatform(const PyObject *self_pyobject, PyObject *args, const PyObject *kwds);
27+PyObject *UtilsRequiresFullSocVersion(const PyObject *self_pyobject, PyObject *args, const PyObject *kwds);
27} // namespace pyascir28} // namespace pyascir
28 29 
29#endif30#endif
@@ -19,6 +19,7 @@
19#include "ascgen_log.h"19#include "ascgen_log.h"
20#include "ascir/meta/asc_graph_dumper_context.h"20#include "ascir/meta/asc_graph_dumper_context.h"
21#include "common_utils.h"21#include "common_utils.h"
22+#include "gen_model_info/api_perf_register/soc_perf_config.h"
22 23 
23namespace pyascir {24namespace pyascir {
24namespace {25namespace {
@@ -258,6 +259,9 @@ PyObject *Autofuser::AutofuseBackend(PyObject *self, PyObject *args, PyObject *k
258 if (PyArg_ParseTuple(args, "O", &graph_obj) == kPythonFail) {259 if (PyArg_ParseTuple(args, "O", &graph_obj) == kPythonFail) {
259 return PyErr_Format(PyExc_ValueError, "autofuse input args error");260 return PyErr_Format(PyExc_ValueError, "autofuse input args error");
260 }261 }
262+ if (att::ValidateSocPerfEntry() != af::SUCCESS) {
263+ return PyErr_Format(PyExc_RuntimeError, "Invalid SoC performance target");
264+ }
261 265 
262 ascir::FusedScheduledResult fused_schedule_result;266 ascir::FusedScheduledResult fused_schedule_result;
263 267 
@@ -284,11 +288,13 @@ PyObject *Autofuser::AutofuseBackend(PyObject *self, PyObject *args, PyObject *k
284 288 
285 codegen::CodegenResult result;289 codegen::CodegenResult result;
286 try {290 try {
287- if (self_->codegen->GenerateForInductor(fused_schedule_result, result) != af::SUCCESS) {291+ const auto ret = self_->codegen->GenerateForInductor(fused_schedule_result, result);
288- GELOGE(af::FAILED, "Codegen generate kernel failed");292+ if (ret != af::SUCCESS) {
293+ return PyErr_Format(PyExc_RuntimeError, "Codegen generate kernel failed");
289 }294 }
290 } catch (const std::runtime_error &e) {295 } catch (const std::runtime_error &e) {
291 GELOGE(af::FAILED, "Caught a runtime_error: %s", e.what());296 GELOGE(af::FAILED, "Caught a runtime_error: %s", e.what());
297+ return PyErr_Format(PyExc_RuntimeError, "Codegen generate kernel failed: %s", e.what());
292 }298 }
293 299 
294 return Py_BuildValue("sss", result.tiling_data.c_str(), result.tiling.c_str(), result.kernel.c_str());300 return Py_BuildValue("sss", result.tiling_data.c_str(), result.tiling.c_str(), result.kernel.c_str());
@@ -572,6 +572,26 @@ def get_codegen_compile_context():
572 )572 )
573 573 
574 574 
575+def _set_platform_from_compile_target(codegen_context):
576+ npu_arch = get_soc_spec("NpuArch")
577+ if not npu_arch:
578+ raise RuntimeError("NpuArch is empty in compile target")
579+ 
580+ requires_full_soc_version = ascir.utils.requires_full_soc_version(npu_arch)
581+ soc_version = ""
582+ if requires_full_soc_version:
583+ soc_version = get_soc_spec("SOC_VERSION") or ""
584+ 
585+ ub_size = int(get_soc_spec("ub_size"))
586+ ascir.utils.set_platform(
587+ npu_arch,
588+ codegen_context.static_compile_vector_core_num,
589+ ub_size,
590+ soc_version,
591+ )
592+ return npu_arch
593+ 
594+ 
575def log_core_limit_info(codegen_context):595def log_core_limit_info(codegen_context):
576 CommonUtility.print_compile_log(596 CommonUtility.print_compile_log(
577 "",597 "",
@@ -2858,18 +2878,12 @@ def asc_codegen_compile(*args, **kwargs):
2858 log_core_limit_info(codegen_context)2878 log_core_limit_info(codegen_context)
2859 2879 
2860 # 设置 platform 到 context2880 # 设置 platform 到 context
2861- npu_arch = get_soc_spec("NpuArch")2881+ npu_arch = _set_platform_from_compile_target(codegen_context)
2862- if npu_arch:2882+ CommonUtility.print_compile_log(
2863- ascir.utils.set_platform(2883+ "",
2864- npu_arch,2884+ f"Set platform from get_soc_spec: {npu_arch}",
2865- codegen_context.static_compile_vector_core_num,2885+ AscendCLogLevel.LOG_DEBUG,
2866- int(get_soc_spec("ub_size")),2886+ )
2867- )
2868- CommonUtility.print_compile_log(
2869- "",
2870- f"Set platform from get_soc_spec: {npu_arch}",
2871- AscendCLogLevel.LOG_DEBUG,
2872- )
2873 2887 
2874 CommonUtility.print_compile_log(2888 CommonUtility.print_compile_log(
2875 "",2889 "",
@@ -37,20 +37,16 @@ class PlatformContext {
37 37 
38 void SetPlatformInfo(const PlatformInfo &platform_info);38 void SetPlatformInfo(const PlatformInfo &platform_info);
39 39 
40+ af::Status SetPlatformTarget(const PlatformInfo &platform_info, const std::string &soc_version);
41+ 
42+ af::Status GetPlatformTarget(std::string &npu_arch, std::string &soc_version);
43+ 
40 void SetUbSizeOverride(int64_t ub_size);44 void SetUbSizeOverride(int64_t ub_size);
41 45 
42 // 获取当前 platform 字符串46 // 获取当前 platform 字符串
43 af::Status GetCurrentPlatformString(std::string &platform_name);47 af::Status GetCurrentPlatformString(std::string &platform_name);
44 48 
45- void Reset() {49+ void Reset();
46- initialized_ = false;
47- platform_info_.soc_ver = "";
48- platform_info_.aiv_num = 0;
49- platform_info_.ub_size = 0;
50- platform_info_.l2_size = 0;
51- ub_size_override_ = 0;
52- has_ub_size_override_ = false;
53- }
54 50 
55 af::Status GetPlatformInfo(PlatformInfo &platform_info);51 af::Status GetPlatformInfo(PlatformInfo &platform_info);
56 52 
@@ -287,6 +287,9 @@ file(GLOB SOURCES
287 )287 )
288 288 
289 289 
290+list(REMOVE_ITEM SOURCES ${ATT_DIR}/gen_model_info/api_perf_register/soc_perf_config_data.cpp)
291+list(APPEND SOURCES ${CODE_ROOT_DIR}/tests/common/att/soc_perf_test_config.cpp)
292+ 
290add_library(att SHARED293add_library(att SHARED
291 ${SOURCES}294 ${SOURCES}
292)295)
@@ -500,6 +503,9 @@ else ()
500 unified_dlog503 unified_dlog
501 )504 )
502endif ()505endif ()
506+if (TARGET pyautofuse_runtime_error_tiling)
507+ add_dependencies(pyautofuse pyautofuse_runtime_error_tiling)
508+endif ()
503if (ENABLE_OPEN_SRC)509if (ENABLE_OPEN_SRC)
504 target_compile_options(att PRIVATE -g --coverage -fprofile-arcs -ftest-coverage)510 target_compile_options(att PRIVATE -g --coverage -fprofile-arcs -ftest-coverage)
505 target_compile_options(optimize PRIVATE -g --coverage -fprofile-arcs -ftest-coverage)511 target_compile_options(optimize PRIVATE -g --coverage -fprofile-arcs -ftest-coverage)
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "soc_perf_test_config.h"
12+ 
13+namespace att {
14+const SocPerfConfigs &GetBuiltinSocPerfConfigs() {
15+ return soc_perf_test::GetSocPerfTestConfigs();
16+}
17+} // namespace att
@@ -0,0 +1,76 @@
1+/**
2+ * Copyright (c) 2026 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+#ifndef ATT_SOC_PERF_TEST_CONFIG_H_
12+#define ATT_SOC_PERF_TEST_CONFIG_H_
13+ 
14+#include <utility>
15+#include "base/att_const_values.h"
16+#include "common/platform_context.h"
17+#include "gen_model_info/api_perf_register/soc_perf_config.h"
18+#include "graph/ascendc_ir/ascir_registry.h"
19+ 
20+namespace att {
21+namespace soc_perf_test {
22+inline constexpr char kV35NpuArch[] = "5102";
23+inline constexpr char kV35AltNpuArch[] = "3510";
24+inline constexpr char kSocA[] = "SOC_A";
25+inline constexpr char kSocB[] = "SOC_B";
26+inline constexpr char kSocEmpty[] = "SOC_EMPTY";
27+inline constexpr char kRegisteredNpuArch[] = "SocPerfRegisteredV2Arch";
28+ 
29+inline void RegisterSocPerfTestArchitecture() {
30+ for (const std::string &api : {std::string("Abs"), kDefaultApi}) {
31+ const auto &api_def = af::ascir::AscirRegistry::GetInstance().GetAll().at(api);
32+ api_def.AddSocImpl(
33+ {kRegisteredNpuArch},
34+ {[api] { return af::ascir::AscirRegistry::GetInstance().GetIrAttImpl(kV35AltNpuArch, api); }, nullptr, {}});
35+ }
36+}
37+ 
38+inline af::Status SetSocPerfTestPlatform(const std::string &npu_arch, const std::string &soc_version) {
39+ ge::PlatformInfo platform_info;
40+ platform_info.soc_ver = npu_arch;
41+ platform_info.aiv_num = 48;
42+ platform_info.ub_size = 245760;
43+ return ge::PlatformContext::GetInstance().SetPlatformTarget(platform_info, soc_version);
44+}
45+ 
46+inline Json MakeApiOverride(float k, float b) {
47+ Json api_override = Json::object();
48+ api_override["Abs"]["model_params"]["float16tofloat16"] = {{"k", k}, {"b", b}};
49+ return api_override;
50+}
51+ 
52+inline const SocPerfConfigs &GetSocPerfTestConfigs() {
53+ static const SocPerfConfigs configs = [] {
54+ SocPerfConfigs result;
55+ SocPerfConfig soc_a;
56+ soc_a.api_param_overrides = MakeApiOverride(1.0F, 10.0F);
57+ soc_a.ascir_model_overrides = {{"AbsV2", "ExpV2"}, {"SelectV2", "ExpV2"}, {"Tanh", "ExpV2"}};
58+ soc_a.ascendc_model_overrides = {{"LoadV2", "StoreV2"}};
59+ result.emplace(SocPerfKey{kV35NpuArch, kSocA}, soc_a);
60+ result.emplace(SocPerfKey{kV35AltNpuArch, kSocA}, soc_a);
61+ 
62+ SocPerfConfig soc_b;
63+ soc_b.api_param_overrides = MakeApiOverride(2.0F, 20.0F);
64+ soc_b.ascir_model_overrides = {{"AbsV2", "AbsV2"}};
65+ soc_b.ascendc_model_overrides = {{"LoadV2", "LoadV2"}};
66+ result.emplace(SocPerfKey{kV35NpuArch, kSocB}, soc_b);
67+ result.emplace(SocPerfKey{kV35NpuArch, kSocEmpty}, SocPerfConfig{});
68+ result.emplace(SocPerfKey{kV35AltNpuArch, kSocEmpty}, SocPerfConfig{});
69+ return result;
70+ }();
71+ return configs;
72+}
73+} // namespace soc_perf_test
74+} // namespace att
75+ 
76+#endif // ATT_SOC_PERF_TEST_CONFIG_H_
@@ -0,0 +1,30 @@
1+/**
2+ * Copyright (c) 2026 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+ * the CANN Open Software License Agreement Version 2.0 (the "License"). You may not use this file except in
5+ * compliance with the License. You may obtain a copy of the License at
6+ *
7+ * http://www.huawei.com
8+ *
9+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
10+ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11+ * See the License for the specific language governing permissions and limitations under the License.
12+ */
13+ 
14+#include <map>
15+#include <stdexcept>
16+#include <string>
17+ 
18+namespace ascir {
19+struct FusedScheduledResult;
20+}
21+ 
22+extern "C" bool CodegenTiling(const std::string &op_name, const ascir::FusedScheduledResult &fused_schedule_result,
23+ std::map<std::string, std::string> &options,
24+ std::map<std::string, std::string> &tiling_func) {
25+ (void)op_name;
26+ (void)fused_schedule_result;
27+ (void)options;
28+ (void)tiling_func;
29+ throw std::runtime_error("pyautofuse runtime error test");
30+}
@@ -20,6 +20,7 @@
20#include "codegen.h"20#include "codegen.h"
21#include "common_utils.h"21#include "common_utils.h"
22#include "common/platform_context.h"22#include "common/platform_context.h"
23+#include "../../../common/att/soc_perf_test_config.h"
23#include "optimize.h"24#include "optimize.h"
24#include "runtime_stub.h"25#include "runtime_stub.h"
25#include "share_graph.h"26#include "share_graph.h"
@@ -36,6 +37,9 @@ class TestBackendInductorMatmulElemwiseE2e : public testing::Test {
36 ge::PlatformContext::GetInstance().Reset();37 ge::PlatformContext::GetInstance().Reset();
37 auto stub_v2 = std::make_shared<ge::RuntimeStubV2Common>();38 auto stub_v2 = std::make_shared<ge::RuntimeStubV2Common>();
38 ge::RuntimeStub::SetInstance(stub_v2);39 ge::RuntimeStub::SetInstance(stub_v2);
40+ ASSERT_EQ(
41+ att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35AltNpuArch, att::soc_perf_test::kSocEmpty),
42+ af::SUCCESS);
39 }43 }
40 44 
41 void TearDown() override {45 void TearDown() override {
@@ -12,6 +12,8 @@
12#define AUTOFUSE_RUNTIME_STUB_H12#define AUTOFUSE_RUNTIME_STUB_H
13#include <cstring>13#include <cstring>
14#include_next <runtime_stub.h>14#include_next <runtime_stub.h>
15+#include "../../common/att/soc_perf_test_config.h"
16+ 
15namespace af {17namespace af {
16using ge::RuntimeStub;18using ge::RuntimeStub;
17class RuntimeStubV2 : public ge::RuntimeStub {19class RuntimeStubV2 : public ge::RuntimeStub {
@@ -25,6 +27,14 @@ class RuntimeStubV2 : public ge::RuntimeStub {
25 return ge::CopyRuntimeSocSpecValue(label, key, val, maxLen, ge::RuntimeSocSpecDefaults{"3510", "0"});27 return ge::CopyRuntimeSocSpecValue(label, key, val, maxLen, ge::RuntimeSocSpecDefaults{"3510", "0"});
26 }28 }
27};29};
30+ 
31+inline void InstallV35SocPerfRuntimeStub() {
32+ ge::RuntimeStub::SetInstance(std::make_shared<RuntimeStubV2>());
33+ if (att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35AltNpuArch, att::soc_perf_test::kSocEmpty) !=
34+ af::SUCCESS) {
35+ ge::RuntimeStub::Reset();
36+ }
37+}
28} // namespace af38} // namespace af
29 39 
30#endif // AUTOFUSE_RUNTIME_STUB_H40#endif // AUTOFUSE_RUNTIME_STUB_H
@@ -64,6 +64,7 @@ target_link_directories(att_ut PRIVATE ${ASCEND_INSTALL_LIB_PATH})
64target_include_directories(att_ut PRIVATE64target_include_directories(att_ut PRIVATE
65 ${TOP_DIR}/tests/ut/att/testcase65 ${TOP_DIR}/tests/ut/att/testcase
66 ${TOP_DIR}/tests/ut/att/utils66 ${TOP_DIR}/tests/ut/att/utils
67+ ${TOP_DIR}/tests/common/att
67 ${TOP_DIR}/tests/common/stub68 ${TOP_DIR}/tests/common/stub
68 ${TOP_DIR}/tests/ut/att/testcase/gen_model_info69 ${TOP_DIR}/tests/ut/att/testcase/gen_model_info
69 ${TOP_DIR}/tests/ut/att/testcase/gen_model_info/core70 ${TOP_DIR}/tests/ut/att/testcase/gen_model_info/core
@@ -25,6 +25,7 @@
25#include "transpose_base_type.h"25#include "transpose_base_type.h"
26#include "graph_construct_utils.h"26#include "graph_construct_utils.h"
27#include "common/platform_context.h"27#include "common/platform_context.h"
28+#include "soc_perf_test_config.h"
28 29 
29using namespace att;30using namespace att;
30using att::test::CombineTilings;31using att::test::CombineTilings;
@@ -717,12 +718,12 @@ TEST_F(TestGenModelInfo, ModelInfoParserForV2TransposeWithoutApiTilingTypeName)
717 af::AscGraph graph("graph");718 af::AscGraph graph("graph");
718 ASSERT_EQ(af::ascir::cg::BuildTransposeAscendGraph(graph, {1, 0, 2}), af::SUCCESS);719 ASSERT_EQ(af::ascir::cg::BuildTransposeAscendGraph(graph, {1, 0, 2}), af::SUCCESS);
719 graphs.emplace_back(graph);720 graphs.emplace_back(graph);
720- ge::PlatformContext::GetInstance().SetPlatform("3510");721+ ASSERT_EQ(soc_perf_test::SetSocPerfTestPlatform(soc_perf_test::kV35AltNpuArch, soc_perf_test::kSocEmpty),
722+ af::SUCCESS);
721 const auto &tiling_data_name = graph.GetName() + "TilingData";723 const auto &tiling_data_name = graph.GetName() + "TilingData";
722- EXPECT_EQ(GenerateModelInfo(graphs, model_info_list, {{kTilingDataTypeName, tiling_data_name}}), af::SUCCESS);724+ EXPECT_NE(GenerateModelInfo(graphs, model_info_list, {{kTilingDataTypeName, tiling_data_name}}), af::SUCCESS);
723 ge::PlatformContext::GetInstance().Reset();725 ge::PlatformContext::GetInstance().Reset();
724- ASSERT_EQ(model_info_list.size(), 1);726+ EXPECT_TRUE(model_info_list.empty());
725- EXPECT_TRUE(model_info_list[0].node_name_to_api_code.empty());
726}727}
727 728 
728TEST_F(TestGenModelInfo, Pad) {729TEST_F(TestGenModelInfo, Pad) {
@@ -14,6 +14,7 @@
14#include "test_fa_ascir_graph.h"14#include "test_fa_ascir_graph.h"
15#include "base/att_const_values.h"15#include "base/att_const_values.h"
16#include "common/platform_context.h"16#include "common/platform_context.h"
17+#include "soc_perf_test_config.h"
17#define private public18#define private public
18#include "expr_gen/generate_tiling_expr.h"19#include "expr_gen/generate_tiling_expr.h"
19#include "parser/ascend_graph_parser.h"20#include "parser/ascend_graph_parser.h"
@@ -146,7 +147,7 @@ ascir::FusedScheduledResult BuildGatherReduceScheduleResult(const af::AscGraph &
146 147 
147af::Status GenerateGatherReduceModelInfos(const bool enable_group_parallel, const bool gather_as_load,148af::Status GenerateGatherReduceModelInfos(const bool enable_group_parallel, const bool gather_as_load,
148 FusedParsedScheduleResult &model_infos) {149 FusedParsedScheduleResult &model_infos) {
149- ge::PlatformContext::GetInstance().SetPlatform("5102");150+ GE_ASSERT_SUCCESS(soc_perf_test::SetSocPerfTestPlatform(soc_perf_test::kV35NpuArch, soc_perf_test::kSocEmpty));
150 af::AscGraph gather_graph("gather_graph");151 af::AscGraph gather_graph("gather_graph");
151 af::AscGraph reduce_graph("reduce_graph");152 af::AscGraph reduce_graph("reduce_graph");
152 if (af::ascir::cg::BuildGatherAscendGraphND(gather_graph) != af::SUCCESS ||153 if (af::ascir::cg::BuildGatherAscendGraphND(gather_graph) != af::SUCCESS ||
@@ -166,7 +167,7 @@ af::Status GenerateGatherReduceModelInfos(const bool enable_group_parallel, cons
166}167}
167 168 
168af::Status GenerateReduceOnlyModelInfos(const size_t group_count, FusedParsedScheduleResult &model_infos) {169af::Status GenerateReduceOnlyModelInfos(const size_t group_count, FusedParsedScheduleResult &model_infos) {
169- ge::PlatformContext::GetInstance().SetPlatform("5102");170+ GE_ASSERT_SUCCESS(soc_perf_test::SetSocPerfTestPlatform(soc_perf_test::kV35NpuArch, soc_perf_test::kSocEmpty));
170 af::AscGraph reduce_graph("reduce_graph");171 af::AscGraph reduce_graph("reduce_graph");
171 if (GraphConstructUtils::BuildConcatGroupAscendGraphS0S1ReduceMultiTiling(reduce_graph) != af::SUCCESS) {172 if (GraphConstructUtils::BuildConcatGroupAscendGraphS0S1ReduceMultiTiling(reduce_graph) != af::SUCCESS) {
172 return af::FAILED;173 return af::FAILED;
@@ -22,6 +22,7 @@
22#include "schedule_result.h"22#include "schedule_result.h"
23#include "runtime_stub.h"23#include "runtime_stub.h"
24#include "platform_context.h"24#include "platform_context.h"
25+#include "../../common/att/soc_perf_test_config.h"
25#include "ascgraph_info_complete.h"26#include "ascgraph_info_complete.h"
26#if defined(FALSE)27#if defined(FALSE)
27#pragma push_macro("FALSE")28#pragma push_macro("FALSE")
@@ -162,6 +163,43 @@ uint64_t StableSourceHash(const std::string &source) {
162}163}
163 164 
164using autofuse::tests::ScopedAutofusePgoFlag;165using autofuse::tests::ScopedAutofusePgoFlag;
166+ 
167+bool g_soc_codegen_func_called = false;
168+ 
169+bool SuccessSocCodegenFunc(const std::string &op_name, const ascir::FusedScheduledResult &fused_schedule_result,
170+ std::map<std::string, std::string> &options,
171+ std::map<std::string, std::string> &tiling_file_name_to_content, bool is_inductor_scene) {
172+ (void)op_name;
173+ (void)fused_schedule_result;
174+ (void)options;
175+ (void)tiling_file_name_to_content;
176+ (void)is_inductor_scene;
177+ g_soc_codegen_func_called = true;
178+ return true;
179+}
180+ 
181+class ScopedSocPlatformState {
182+ public:
183+ ScopedSocPlatformState() {
184+ has_state_ = ge::PlatformContext::GetInstance().GetPlatformInfo(saved_info_) == af::SUCCESS;
185+ std::string npu_arch;
186+ has_state_ =
187+ has_state_ && ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, saved_soc_) == af::SUCCESS;
188+ }
189+ 
190+ ~ScopedSocPlatformState() {
191+ if (has_state_) {
192+ (void)ge::PlatformContext::GetInstance().SetPlatformTarget(saved_info_, saved_soc_);
193+ return;
194+ }
195+ ge::PlatformContext::GetInstance().Reset();
196+ }
197+ 
198+ private:
199+ bool has_state_{false};
200+ ge::PlatformInfo saved_info_{};
201+ std::string saved_soc_;
202+};
165} // namespace203} // namespace
166 204 
167namespace {205namespace {
@@ -1161,6 +1199,9 @@ class TestCodegenTiling : public testing::Test, public codegen::TilingLib {
1161 void SetUp() override {1199 void SetUp() override {
1162 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_DEBUG, 0);1200 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_DEBUG, 0);
1163 ge::PlatformContext::GetInstance().Reset();1201 ge::PlatformContext::GetInstance().Reset();
1202+ ASSERT_EQ(
1203+ att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35NpuArch, att::soc_perf_test::kSocEmpty),
1204+ af::SUCCESS);
1164 ge::RuntimeStub::SetInstance(std::make_shared<ge::RuntimeStubV2Common>());1205 ge::RuntimeStub::SetInstance(std::make_shared<ge::RuntimeStubV2Common>());
1165 }1206 }
1166 void TearDown() override {1207 void TearDown() override {
@@ -1329,6 +1370,51 @@ TEST_F(TestCodegenTiling, DynamicShapeCacheKeyGuardsCapacityAndPreservesSymbolOr
1329 EXPECT_LT(second_symbol, set_size);1370 EXPECT_LT(second_symbol, set_size);
1330}1371}
1331 1372 
1373+TEST_F(TestCodegenTiling, GenerateForInductorValidatesSocTargetBeforeTilingCodegen) {
1374+ const ScopedSocPlatformState platform_state_guard;
1375+ ge::PlatformContext::GetInstance().SetPlatform("UnknownArch");
1376+ codegen::Codegen codegen(codegen::CodegenOptions{});
1377+ codegen.tiling_lib_.codegen_func_ = SuccessSocCodegenFunc;
1378+ const auto fused_schedule_result = this->GenBasicFusedScheduleResult({}, af::Symbol(64));
1379+ 
1380+ codegen::CodegenResult result;
1381+ g_soc_codegen_func_called = false;
1382+ EXPECT_NE(codegen.GenerateForInductor(fused_schedule_result, result), af::SUCCESS);
1383+ EXPECT_FALSE(g_soc_codegen_func_called);
1384+ EXPECT_TRUE(result.tiling_data.empty());
1385+ EXPECT_TRUE(result.tiling.empty());
1386+ EXPECT_TRUE(result.kernel.empty());
1387+ 
1388+ ge::PlatformInfo platform_info;
1389+ platform_info.soc_ver = "5102";
1390+ platform_info.aiv_num = 1;
1391+ platform_info.ub_size = 262144;
1392+ ASSERT_EQ(ge::PlatformContext::GetInstance().SetPlatformTarget(platform_info, "SOC_EMPTY"), af::SUCCESS);
1393+ result = codegen::CodegenResult{};
1394+ g_soc_codegen_func_called = false;
1395+ EXPECT_EQ(codegen.GenerateForInductor(fused_schedule_result, result), af::SUCCESS);
1396+ EXPECT_TRUE(g_soc_codegen_func_called);
1397+}
1398+ 
1399+TEST_F(TestCodegenTiling, GenerateTilingAcceptsV2ArchitecturesUnknownSocAndLegacyTarget) {
1400+ const ScopedSocPlatformState platform_state_guard;
1401+ codegen::Codegen codegen(codegen::CodegenOptions{});
1402+ codegen.tiling_lib_.codegen_func_ = SuccessSocCodegenFunc;
1403+ const auto schedule_result = this->GenBasicFusedScheduleResult({}, af::Symbol(64));
1404+ for (const std::string &npu_arch : {"3510", "5102", "9201", "9202"}) {
1405+ for (const std::string &soc : {std::string("SOC_UNREGISTERED"), std::string()}) {
1406+ ASSERT_EQ(att::soc_perf_test::SetSocPerfTestPlatform(npu_arch, soc), af::SUCCESS);
1407+ if (soc.empty()) {
1408+ ge::PlatformContext::GetInstance().SetPlatform(npu_arch);
1409+ }
1410+ std::map<std::string, std::string> tiling_files;
1411+ g_soc_codegen_func_called = false;
1412+ EXPECT_EQ(codegen.GenerateTiling(schedule_result, {}, "", "0", tiling_files), af::SUCCESS);
1413+ EXPECT_TRUE(g_soc_codegen_func_called);
1414+ }
1415+ }
1416+}
1417+ 
1332class RuntimeStubWithFullSocName : public ge::RuntimeStubV2Common {1418class RuntimeStubWithFullSocName : public ge::RuntimeStubV2Common {
1333 public:1419 public:
1334 const char *aclrtGetSocName() override {1420 const char *aclrtGetSocName() override {
@@ -10,13 +10,29 @@
10 10 
11#include <gtest/gtest.h>11#include <gtest/gtest.h>
12 12 
13+#define private public
13#include "common/platform_context.h"14#include "common/platform_context.h"
15+#undef private
14#include "tests/depends/runtime/src/runtime_stub.h"16#include "tests/depends/runtime/src/runtime_stub.h"
15 17 
18+namespace {
19+class RuntimeSocSpecFailStub : public ge::RuntimeStub {
20+ public:
21+ rtError_t rtGetSocSpec(const char *label, const char *key, char *val, const uint32_t maxLen) override {
22+ (void)label;
23+ (void)key;
24+ (void)val;
25+ (void)maxLen;
26+ return -1;
27+ }
28+};
29+} // namespace
30+ 
16class PlatformContextTest : public testing::Test {31class PlatformContextTest : public testing::Test {
17 protected:32 protected:
18 void TearDown() override {33 void TearDown() override {
19 ge::PlatformContext::GetInstance().Reset();34 ge::PlatformContext::GetInstance().Reset();
35+ ge::RuntimeStub::Reset();
20 }36 }
21};37};
22 38 
@@ -87,3 +103,123 @@ TEST_F(PlatformContextTest, GetPlatformInfoInitializesUbSizeFromRuntime) {
87 EXPECT_EQ(actual.aiv_num, 48);103 EXPECT_EQ(actual.aiv_num, 48);
88 EXPECT_EQ(actual.ub_size, 245760);104 EXPECT_EQ(actual.ub_size, 245760);
89}105}
106+ 
107+TEST_F(PlatformContextTest, SetPlatformTargetStoresAndGetDualFields) {
108+ ge::PlatformContext::GetInstance().Reset();
109+ ge::PlatformInfo platform_info;
110+ platform_info.soc_ver = "5102";
111+ platform_info.aiv_num = 48;
112+ platform_info.ub_size = 245760;
113+ EXPECT_EQ(ge::PlatformContext::GetInstance().SetPlatformTarget(platform_info, "MC62CM12AA"), af::SUCCESS);
114+ 
115+ std::string npu_arch;
116+ std::string soc_version;
117+ EXPECT_EQ(ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, soc_version), af::SUCCESS);
118+ EXPECT_EQ(npu_arch, "5102");
119+ EXPECT_EQ(soc_version, "MC62CM12AA");
120+}
121+ 
122+TEST_F(PlatformContextTest, SetPlatformTargetUpdatesUbSizeOverride) {
123+ ge::PlatformContext::GetInstance().Reset();
124+ ge::PlatformInfo old_info;
125+ old_info.ub_size = 4096;
126+ ge::PlatformContext::GetInstance().SetPlatformInfo(old_info);
127+ 
128+ int64_t ub_size = 0;
129+ ASSERT_TRUE(ge::PlatformContext::GetInstance().TryGetUbSizeOverride(ub_size));
130+ ASSERT_EQ(ub_size, 4096);
131+ 
132+ ge::PlatformInfo new_info;
133+ new_info.soc_ver = "5102";
134+ new_info.ub_size = 262144;
135+ ASSERT_EQ(ge::PlatformContext::GetInstance().SetPlatformTarget(new_info, "MC62CM12AA"), af::SUCCESS);
136+ EXPECT_TRUE(ge::PlatformContext::GetInstance().TryGetUbSizeOverride(ub_size));
137+ EXPECT_EQ(ub_size, 262144);
138+}
139+ 
140+TEST_F(PlatformContextTest, InitializeKeepsExplicitFullSocVersion) {
141+ ge::PlatformContext::GetInstance().Reset();
142+ ge::PlatformInfo platform_info;
143+ platform_info.soc_ver = "5102";
144+ platform_info.aiv_num = 48;
145+ platform_info.ub_size = 262144;
146+ ASSERT_EQ(ge::PlatformContext::GetInstance().SetPlatformTarget(platform_info, "MC62CM12AA"), af::SUCCESS);
147+ ASSERT_EQ(ge::PlatformContext::GetInstance().Initialize(), af::SUCCESS);
148+ 
149+ std::string npu_arch;
150+ std::string soc_version;
151+ EXPECT_EQ(ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, soc_version), af::SUCCESS);
152+ EXPECT_EQ(npu_arch, "5102");
153+ EXPECT_EQ(soc_version, "MC62CM12AA");
154+}
155+ 
156+TEST_F(PlatformContextTest, OldSetPlatformClearsFullSocVersion) {
157+ ge::PlatformContext::GetInstance().Reset();
158+ ge::PlatformInfo platform_info;
159+ platform_info.soc_ver = "5102";
160+ EXPECT_EQ(ge::PlatformContext::GetInstance().SetPlatformTarget(platform_info, "MC62CM12AA"), af::SUCCESS);
161+ 
162+ ge::PlatformContext::GetInstance().SetPlatform("3510");
163+ std::string npu_arch;
164+ std::string soc_version;
165+ EXPECT_EQ(ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, soc_version), af::SUCCESS);
166+ EXPECT_EQ(npu_arch, "3510");
167+ EXPECT_EQ(soc_version, "");
168+}
169+ 
170+TEST_F(PlatformContextTest, OldSetPlatformInfoWithEmptySocVerClearsFullSocVersion) {
171+ ge::PlatformContext::GetInstance().Reset();
172+ ge::PlatformInfo platform_info;
173+ platform_info.soc_ver = "5102";
174+ platform_info.ub_size = 245760;
175+ EXPECT_EQ(ge::PlatformContext::GetInstance().SetPlatformTarget(platform_info, "MC62CM12AA"), af::SUCCESS);
176+ 
177+ ge::PlatformInfo empty_arch;
178+ empty_arch.ub_size = 245760;
179+ ge::PlatformContext::GetInstance().SetPlatformInfo(empty_arch);
180+ std::string npu_arch;
181+ std::string soc_version;
182+ EXPECT_EQ(ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, soc_version), af::SUCCESS);
183+ EXPECT_EQ(npu_arch, "5102");
184+ EXPECT_EQ(soc_version, "");
185+}
186+ 
187+TEST_F(PlatformContextTest, ResetClearsFullSocVersion) {
188+ ge::PlatformContext::GetInstance().Reset();
189+ ge::PlatformInfo platform_info;
190+ platform_info.soc_ver = "5102";
191+ EXPECT_EQ(ge::PlatformContext::GetInstance().SetPlatformTarget(platform_info, "MC62CM12AA"), af::SUCCESS);
192+ ge::PlatformContext::GetInstance().Reset();
193+ 
194+ std::string npu_arch;
195+ std::string soc_version;
196+ EXPECT_EQ(ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, soc_version), af::SUCCESS);
197+ EXPECT_EQ(npu_arch, "2201");
198+ EXPECT_EQ(soc_version, "");
199+}
200+ 
201+TEST_F(PlatformContextTest, SetPlatformTargetRejectsFullSocVersionWithoutNpuArch) {
202+ ge::PlatformContext::GetInstance().Reset();
203+ ge::PlatformInfo platform_info;
204+ platform_info.soc_ver = "5102";
205+ EXPECT_EQ(ge::PlatformContext::GetInstance().SetPlatformTarget(platform_info, "MC62CM12AA"), af::SUCCESS);
206+ 
207+ ge::PlatformInfo empty_arch;
208+ EXPECT_NE(ge::PlatformContext::GetInstance().SetPlatformTarget(empty_arch, "MC62CM12AA"), af::SUCCESS);
209+ std::string npu_arch;
210+ std::string soc_version;
211+ EXPECT_EQ(ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, soc_version), af::SUCCESS);
212+ EXPECT_EQ(npu_arch, "5102");
213+ EXPECT_EQ(soc_version, "MC62CM12AA");
214+}
215+ 
216+TEST_F(PlatformContextTest, InitializeFailureDoesNotExposeFullSocVersion) {
217+ ge::PlatformContext::GetInstance().Reset();
218+ ge::RuntimeStub::SetInstance(std::make_shared<RuntimeSocSpecFailStub>());
219+ 
220+ std::string npu_arch = "stale_arch";
221+ std::string soc_version = "stale_soc";
222+ EXPECT_NE(ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, soc_version), af::SUCCESS);
223+ EXPECT_EQ(npu_arch, "");
224+ EXPECT_EQ(soc_version, "");
225+}
@@ -20,6 +20,7 @@
20#include "e2e_common.h"20#include "e2e_common.h"
21#include "platform_context.h"21#include "platform_context.h"
22#include "autofuse_config/auto_fuse_config.h"22#include "autofuse_config/auto_fuse_config.h"
23+#include "../../common/att/soc_perf_test_config.h"
23#include "../../common/att/common_gen_utils.h"24#include "../../common/att/common_gen_utils.h"
24 25 
25using namespace ascir;26using namespace ascir;
@@ -35,6 +36,9 @@ class E2E_LoadAbsStore : public ::testing::Test {
35 36 
36 void SetUp() override {37 void SetUp() override {
37 ge::PlatformContext::GetInstance().Reset();38 ge::PlatformContext::GetInstance().Reset();
39+ ASSERT_EQ(
40+ att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35NpuArch, att::soc_perf_test::kSocEmpty),
41+ af::SUCCESS);
38 }42 }
39};43};
40 44 
@@ -46,6 +46,7 @@
46#include "optimize/graph_pass/pass_utils.h"46#include "optimize/graph_pass/pass_utils.h"
47#include "common/autofuse_backend_spec_api.h"47#include "common/autofuse_backend_spec_api.h"
48#include "autoschedule/alignment_handler.h"48#include "autoschedule/alignment_handler.h"
49+#include "../../common/att/soc_perf_test_config.h"
49#include "../../v35/ut/optimize/runtime_stub.h"50#include "../../v35/ut/optimize/runtime_stub.h"
50 51 
51using namespace af;52using namespace af;
@@ -501,7 +502,9 @@ TEST_F(TestOptimizer, V2ArangeStoreOptimizeProducesSingletonVectorFunc) {
501 502 
502TEST_F(TestOptimizer, V2HighRankArangeOptimizeAndCodegenOuterFor) {503TEST_F(TestOptimizer, V2HighRankArangeOptimizeAndCodegenOuterFor) {
503 SetUpV2RuntimeStub();504 SetUpV2RuntimeStub();
504- ge::PlatformContext::GetInstance().SetPlatform("3510");505+ ASSERT_EQ(
506+ att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35AltNpuArch, att::soc_perf_test::kSocEmpty),
507+ af::SUCCESS);
505 af::AscGraph graph("high_rank_arange_pipeline");508 af::AscGraph graph("high_rank_arange_pipeline");
506 std::vector<af::Expression> sizes;509 std::vector<af::Expression> sizes;
507 std::vector<af::AxisId> axes;510 std::vector<af::AxisId> axes;
@@ -729,7 +732,9 @@ class Int64ArangeConsumerCodegenTest : public TestOptimizer,
729 732 
730TEST_P(Int64ArangeConsumerCodegenTest, GeneratesInt64ConsumerWithoutNarrowing) {733TEST_P(Int64ArangeConsumerCodegenTest, GeneratesInt64ConsumerWithoutNarrowing) {
731 SetUpV2RuntimeStub();734 SetUpV2RuntimeStub();
732- ge::PlatformContext::GetInstance().SetPlatform("3510");735+ ASSERT_EQ(
736+ att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35AltNpuArch, att::soc_perf_test::kSocEmpty),
737+ af::SUCCESS);
733 const auto &test_case = GetParam();738 const auto &test_case = GetParam();
734 auto graph = CreateArangeConsumerGraph("int64_consumer", test_case.consumer, af::ops::One, af::DT_INT64);739 auto graph = CreateArangeConsumerGraph("int64_consumer", test_case.consumer, af::ops::One, af::DT_INT64);
735 ::ascir::FusedScheduledResult scheduled;740 ::ascir::FusedScheduledResult scheduled;
@@ -778,7 +783,9 @@ INSTANTIATE_TEST_SUITE_P(
778 783 
779TEST_F(TestOptimizer, V2ScalarVectorFuncPreservesRootScalarThroughCodegen) {784TEST_F(TestOptimizer, V2ScalarVectorFuncPreservesRootScalarThroughCodegen) {
780 SetUpV2RuntimeStub();785 SetUpV2RuntimeStub();
781- ge::PlatformContext::GetInstance().SetPlatform("3510");786+ ASSERT_EQ(
787+ att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35AltNpuArch, att::soc_perf_test::kSocEmpty),
788+ af::SUCCESS);
782 af::AscGraph graph("scalar_vf_regression");789 af::AscGraph graph("scalar_vf_regression");
783 const auto size = graph.CreateSizeVar("size");790 const auto size = graph.CreateSizeVar("size");
784 const auto axis = graph.CreateAxis("axis", size);791 const auto axis = graph.CreateAxis("axis", size);
@@ -1,9 +1,14 @@
1find_package(Python3 REQUIRED COMPONENTS Interpreter Development)1find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
2 2 
3file(GLOB_RECURSE CODEGEN_TEST_SRCS CONFIGURE_DEPENDS "*.cpp")3file(GLOB_RECURSE CODEGEN_TEST_SRCS CONFIGURE_DEPENDS "*.cpp")
4+add_library(pyautofuse_runtime_error_tiling SHARED
5+ ${CMAKE_CURRENT_SOURCE_DIR}/../../common/py_module/pyautofuse_runtime_error_tiling.cpp)
6+set_target_properties(pyautofuse_runtime_error_tiling PROPERTIES
7+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../..)
4add_library(test_py_module OBJECT8add_library(test_py_module OBJECT
5 ${CODEGEN_TEST_SRCS}9 ${CODEGEN_TEST_SRCS}
6)10)
11+add_dependencies(test_py_module pyautofuse_runtime_error_tiling)
7target_link_options(test_py_module PRIVATE12target_link_options(test_py_module PRIVATE
8 -Wl,--no-as-needed13 -Wl,--no-as-needed
9)14)
@@ -10,6 +10,8 @@
10 10 
11#include "gtest/gtest.h"11#include "gtest/gtest.h"
12 12 
13+#include <string>
14+ 
13#include "ascendc_ir.h"15#include "ascendc_ir.h"
14#include "graph/ascendc_ir/utils/asc_graph_utils.h"16#include "graph/ascendc_ir/utils/asc_graph_utils.h"
15#include "ascir_ops.h"17#include "ascir_ops.h"
@@ -17,20 +19,127 @@
17#include "pyascir.h"19#include "pyascir.h"
18#include "pyascir_types.h"20#include "pyascir_types.h"
19#include "pyascir_common_utils.h"21#include "pyascir_common_utils.h"
22+#include "common/platform_context.h"
20 23 
21class TestPyModule : public testing::Test {24class TestPyModule : public testing::Test {
22 protected:25 protected:
23- virtual void SetUp() {26+ static PyObject *pyautofuse_module_;
27+ 
28+ static void SetUpTestSuite() {
24 Py_Initialize();29 Py_Initialize();
25- PyInit_pyautofuse();30+ pyautofuse_module_ = PyInit_pyautofuse();
26- PyInit_ascir();
27 }31 }
28 32 
29- virtual void TearDown() {33+ static void TearDownTestSuite() {
34+ Py_XDECREF(pyautofuse_module_);
35+ pyautofuse_module_ = nullptr;
30 Py_Finalize();36 Py_Finalize();
31 }37 }
32};38};
33 39 
40+PyObject *TestPyModule::pyautofuse_module_ = nullptr;
41+ 
42+TEST_F(TestPyModule, UtilsSetPlatformKeepsLegacyThreeArguments) {
43+ PyObject *args = Py_BuildValue("(sLL)", "5102", 48, 245760);
44+ ASSERT_NE(args, nullptr);
45+ 
46+ PyObject *result = pyascir::UtilsSetPlatform(nullptr, args, nullptr);
47+ EXPECT_NE(result, nullptr);
48+ Py_DECREF(result);
49+ Py_DECREF(args);
50+ 
51+ std::string npu_arch;
52+ std::string soc_version;
53+ EXPECT_EQ(ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, soc_version), af::SUCCESS);
54+ EXPECT_EQ(npu_arch, "5102");
55+ EXPECT_EQ(soc_version, "");
56+ ge::PlatformContext::GetInstance().Reset();
57+}
58+ 
59+TEST_F(TestPyModule, UtilsSetPlatformAcceptsFullSocVersion) {
60+ PyObject *args = Py_BuildValue("(sLLs)", "5102", 48, 245760, "MC62CM12AA");
61+ ASSERT_NE(args, nullptr);
62+ 
63+ PyObject *result = pyascir::UtilsSetPlatform(nullptr, args, nullptr);
64+ EXPECT_NE(result, nullptr);
65+ Py_DECREF(result);
66+ Py_DECREF(args);
67+ 
68+ std::string npu_arch;
69+ std::string soc_version;
70+ EXPECT_EQ(ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, soc_version), af::SUCCESS);
71+ EXPECT_EQ(npu_arch, "5102");
72+ EXPECT_EQ(soc_version, "MC62CM12AA");
73+ ge::PlatformContext::GetInstance().Reset();
74+}
75+ 
76+TEST_F(TestPyModule, UtilsSetPlatformRejectsFullSocVersionWithoutNpuArch) {
77+ PyObject *valid_args = Py_BuildValue("(sLLs)", "5102", 48, 245760, "MC62CM12AA");
78+ ASSERT_NE(valid_args, nullptr);
79+ PyObject *result = pyascir::UtilsSetPlatform(nullptr, valid_args, nullptr);
80+ EXPECT_NE(result, nullptr);
81+ Py_DECREF(result);
82+ Py_DECREF(valid_args);
83+ 
84+ PyObject *invalid_args = Py_BuildValue("(sLLs)", "", 48, 245760, "MC62CM12AA");
85+ ASSERT_NE(invalid_args, nullptr);
86+ result = pyascir::UtilsSetPlatform(nullptr, invalid_args, nullptr);
87+ EXPECT_EQ(result, nullptr);
88+ PyErr_Clear();
89+ Py_DECREF(invalid_args);
90+ 
91+ std::string npu_arch;
92+ std::string soc_version;
93+ EXPECT_EQ(ge::PlatformContext::GetInstance().GetPlatformTarget(npu_arch, soc_version), af::SUCCESS);
94+ EXPECT_EQ(npu_arch, "5102");
95+ EXPECT_EQ(soc_version, "MC62CM12AA");
96+ ge::PlatformContext::GetInstance().Reset();
97+}
98+ 
99+TEST_F(TestPyModule, AutofuseBackendRejectsUnknownArchBeforeGraphValidation) {
100+ ge::PlatformContext::GetInstance().SetPlatform("UnknownArch");
101+ ASSERT_NE(pyautofuse_module_, nullptr);
102+ PyObject *options_type = PyObject_GetAttrString(pyautofuse_module_, "AutofuserOptions");
103+ ASSERT_NE(options_type, nullptr);
104+ PyObject *options = PyObject_CallObject(options_type, nullptr);
105+ ASSERT_NE(options, nullptr);
106+ PyObject *autofuser_type = PyObject_GetAttrString(pyautofuse_module_, "Autofuser");
107+ ASSERT_NE(autofuser_type, nullptr);
108+ PyObject *autofuser = PyObject_CallFunctionObjArgs(autofuser_type, options, NULL);
109+ ASSERT_NE(autofuser, nullptr);
110+ PyObject *method = PyObject_GetAttrString(autofuser, "autofuse_backend");
111+ ASSERT_NE(method, nullptr);
112+ PyObject *args = Py_BuildValue("(O)", Py_None);
113+ ASSERT_NE(args, nullptr);
114+ 
115+ PyObject *result = PyObject_CallObject(method, args);
116+ EXPECT_EQ(result, nullptr);
117+ ASSERT_TRUE(PyErr_Occurred());
118+ 
119+ PyObject *exc_type = nullptr;
120+ PyObject *exc_value = nullptr;
121+ PyObject *exc_traceback = nullptr;
122+ PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
123+ ASSERT_NE(exc_value, nullptr);
124+ PyObject *message_obj = PyObject_Str(exc_value);
125+ ASSERT_NE(message_obj, nullptr);
126+ const std::string message = PyUnicode_AsUTF8(message_obj);
127+ EXPECT_NE(message.find("Invalid SoC performance target"), std::string::npos) << message;
128+ 
129+ Py_XDECREF(message_obj);
130+ Py_XDECREF(exc_traceback);
131+ Py_XDECREF(exc_value);
132+ Py_XDECREF(exc_type);
133+ Py_XDECREF(result);
134+ Py_XDECREF(args);
135+ Py_XDECREF(method);
136+ Py_XDECREF(autofuser);
137+ Py_XDECREF(autofuser_type);
138+ Py_XDECREF(options);
139+ Py_XDECREF(options_type);
140+ ge::PlatformContext::GetInstance().Reset();
141+}
142+ 
34TEST_F(TestPyModule, DISABLED_UtilsDeserialize_symbol_source_info) {143TEST_F(TestPyModule, DISABLED_UtilsDeserialize_symbol_source_info) {
35 PyObject *args = PyTuple_New(2);144 PyObject *args = PyTuple_New(2);
36 PyObject *kwds = PyDict_New();145 PyObject *kwds = PyDict_New();
@@ -665,7 +665,7 @@ class TestStaticShapeCompileHasattrCheck:
665 asc_codegen_compile_module,665 asc_codegen_compile_module,
666 "get_soc_spec",666 "get_soc_spec",
667 lambda key: {667 lambda key: {
668- "NpuArch": "Ascend910",668+ "NpuArch": "2201",
669 "vector_core_cnt": 8,669 "vector_core_cnt": 8,
670 "ub_size": 1024,670 "ub_size": 1024,
671 }.get(key),671 }.get(key),
@@ -676,7 +676,8 @@ class TestStaticShapeCompileHasattrCheck:
676 lambda unused, message, level: log_messages.append((message, level)),676 lambda unused, message, level: log_messages.append((message, level)),
677 )677 )
678 asc_codegen_compile_module.ascir.utils = SimpleNamespace(678 asc_codegen_compile_module.ascir.utils = SimpleNamespace(
679- set_platform=lambda *args: set_platform_calls.append(args)679+ set_platform=lambda *args, **kwargs: set_platform_calls.append(args),
680+ requires_full_soc_version=lambda npu_arch: False,
680 )681 )
681 monkeypatch.setattr(682 monkeypatch.setattr(
682 asc_codegen_compile_module,683 asc_codegen_compile_module,
@@ -686,7 +687,7 @@ class TestStaticShapeCompileHasattrCheck:
686 687 
687 asc_codegen_compile_module.asc_codegen_compile("kernel")688 asc_codegen_compile_module.asc_codegen_compile("kernel")
688 689 
689- assert ("Ascend910", 4, 1024) in set_platform_calls690+ assert ("2201", 4, 1024, "") in set_platform_calls
690 assert compile_calls[0]["vector_core_num"] == "4"691 assert compile_calls[0]["vector_core_num"] == "4"
691 assert any(692 assert any(
692 "vector_core_num=4, vector_core_num_limited=4" in message693 "vector_core_num=4, vector_core_num_limited=4" in message
@@ -0,0 +1,139 @@
1+# -*- coding: utf-8 -*-
2+# -----------------------------------------------------------------------------------------------------------
3+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
4+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5+# CANN Open Software License Agreement Version 2.0 (the "License").
6+# Please refer to the License for details. You may not use this file except in compliance with the License.
7+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9+# See LICENSE in the root of the software repository for the full text of the License.
10+# -----------------------------------------------------------------------------------------------------------
11+ 
12+import sys
13+import types
14+ 
15+import pytest
16+ 
17+from autofuse.pyautofuse import ascir
18+from compile_test_utils import load_asc_codegen_compile_module
19+ 
20+ 
21+def test_requires_full_soc_version_uses_registered_architecture():
22+ assert ascir.utils.requires_full_soc_version("2201") is False
23+ assert ascir.utils.requires_full_soc_version("5102") is True
24+ with pytest.raises(RuntimeError, match="invalid npu arch"):
25+ ascir.utils.requires_full_soc_version("3102")
26+ 
27+ 
28+class FakeSocUtils:
29+ def __init__(self, required):
30+ self.required = required
31+ self.set_platform_calls = []
32+ 
33+ @staticmethod
34+ def requires_full_soc_version(npu_arch):
35+ return npu_arch in {"3510", "5102", "9201", "9202"}
36+ 
37+ def set_platform(self, npu_arch, vector_core_num, ub_size, soc_version=""):
38+ self.set_platform_calls.append(
39+ (npu_arch, vector_core_num, ub_size, soc_version)
40+ )
41+ 
42+ 
43+def _make_context(module):
44+ extra_params = {"compute_graph": "", "symbol_source_info": ""}
45+ return module.CodegenCompileContext(extra_params, 1, 1, 0, 8)
46+ 
47+ 
48+def test_compile_target_passes_full_soc_version_for_v35(monkeypatch):
49+ with load_asc_codegen_compile_module() as loaded:
50+ module = loaded
51+ queried = []
52+ values = {"NpuArch": "5102", "SOC_VERSION": "MC62CM12AA", "ub_size": "245760"}
53+ 
54+ def fake_get_soc_spec(key):
55+ queried.append(key)
56+ return values[key]
57+ 
58+ fake_utils = FakeSocUtils(True)
59+ monkeypatch.setattr(module, "get_soc_spec", fake_get_soc_spec)
60+ monkeypatch.setattr(module, "ascir", types.SimpleNamespace(utils=fake_utils))
61+ 
62+ module._set_platform_from_compile_target(_make_context(module))
63+ 
64+ assert queried == ["NpuArch", "SOC_VERSION", "ub_size"]
65+ assert fake_utils.set_platform_calls == [("5102", 8, 245760, "MC62CM12AA")]
66+ 
67+ 
68+def test_compile_target_does_not_query_full_soc_version_for_v2(monkeypatch):
69+ with load_asc_codegen_compile_module() as loaded:
70+ module = loaded
71+ queried = []
72+ values = {"NpuArch": "2201", "ub_size": "245760"}
73+ 
74+ def fake_get_soc_spec(key):
75+ queried.append(key)
76+ return values[key]
77+ 
78+ fake_utils = FakeSocUtils(False)
79+ monkeypatch.setattr(module, "get_soc_spec", fake_get_soc_spec)
80+ monkeypatch.setattr(module, "ascir", types.SimpleNamespace(utils=fake_utils))
81+ 
82+ module._set_platform_from_compile_target(_make_context(module))
83+ 
84+ assert "SOC_VERSION" not in queried
85+ assert fake_utils.set_platform_calls == [("2201", 8, 245760, "")]
86+ 
87+ 
88+@pytest.mark.parametrize("npu_arch", ["3510", "5102", "9201", "9202"])
89+def test_compile_target_keeps_v2_baseline_without_full_soc_version(
90+ monkeypatch, npu_arch
91+):
92+ with load_asc_codegen_compile_module() as loaded:
93+ module = loaded
94+ values = {"NpuArch": npu_arch, "ub_size": "245760"}
95+ monkeypatch.setattr(module, "get_soc_spec", lambda key: values.get(key))
96+ fake_utils = FakeSocUtils(True)
97+ monkeypatch.setattr(module, "ascir", types.SimpleNamespace(utils=fake_utils))
98+ 
99+ assert (
100+ module._set_platform_from_compile_target(_make_context(module)) == npu_arch
101+ )
102+ assert fake_utils.set_platform_calls == [(npu_arch, 8, 245760, "")]
103+ 
104+ 
105+def test_compile_target_is_set_before_graph_compile(monkeypatch, tmpdir):
106+ with load_asc_codegen_compile_module() as loaded:
107+ module = loaded
108+ events = []
109+ values = {"NpuArch": "5102", "SOC_VERSION": "MC62CM12AA", "ub_size": "245760"}
110+ fake_utils = FakeSocUtils(True)
111+ 
112+ def fake_set_platform(*args, **kwargs):
113+ events.append(("set_platform",) + args)
114+ 
115+ def fake_compute_graph_compile(*args, **kwargs):
116+ events.append("compute_graph_compile")
117+ 
118+ fake_utils.set_platform = fake_set_platform
119+ monkeypatch.setattr(module, "get_soc_spec", lambda key: values[key])
120+ monkeypatch.setattr(module, "ascir", types.SimpleNamespace(utils=fake_utils))
121+ monkeypatch.setattr(
122+ module, "get_codegen_compile_context", lambda: _make_context(module)
123+ )
124+ monkeypatch.setattr(module, "compute_graph_compile", fake_compute_graph_compile)
125+ monkeypatch.setattr(module, "get_current_build_config", lambda key: str(tmpdir))
126+ monkeypatch.setattr(module, "is_valid_path", lambda value: True)
127+ monkeypatch.setattr(module.AscendCLogLevel, "LOG_INFO", "info", raising=False)
128+ monkeypatch.setitem(
129+ sys.modules,
130+ "autofuse.compile_adapter",
131+ types.SimpleNamespace(get_debug_flag=lambda: False),
132+ )
133+ 
134+ module.asc_codegen_compile("kernel")
135+ 
136+ assert events == [
137+ ("set_platform", "5102", 8, 245760, "MC62CM12AA"),
138+ "compute_graph_compile",
139+ ]
@@ -16,6 +16,7 @@ import time
16import os16import os
17import shutil17import shutil
18import sys18import sys
19+from pathlib import Path
19from autofuse.pyautofuse import ascir, Autofuser, AutofuserOptions, Schedule, CodeGen20from autofuse.pyautofuse import ascir, Autofuser, AutofuserOptions, Schedule, CodeGen
20 21 
21try:22try:
@@ -25,6 +26,13 @@ except ImportError:
25from ascir import Max, Min, Mod26from ascir import Max, Min, Mod
26 27 
27PYF_PATH = os.path.dirname(os.path.realpath(__file__))28PYF_PATH = os.path.dirname(os.path.realpath(__file__))
29+RUNTIME_ERROR_TILING_LIB = (
30+ Path(__file__).resolve().parents[4]
31+ / "build"
32+ / "autofuse"
33+ / "tests"
34+ / "libpyautofuse_runtime_error_tiling.so"
35+)
28 36 
29ascir.utils.set_platform("2201", 1, 245760)37ascir.utils.set_platform("2201", 1, 245760)
30 38 
@@ -175,7 +183,7 @@ class TestAscir:
175 183 
176 @staticmethod184 @staticmethod
177 def test_index_expr_and_arange_api():185 def test_index_expr_and_arange_api():
178- ascir.utils.set_platform("3510", 1, 245760)186+ ascir.utils.set_platform("3510", 1, 245760, "SOC_EMPTY")
179 try:187 try:
180 graph = ascir.HintGraph("index_expr_arange_api")188 graph = ascir.HintGraph("index_expr_arange_api")
181 size = graph.create_size("size")189 size = graph.create_size("size")
@@ -692,6 +700,23 @@ class TestAutofuseLoadAbsStore:
692 hint_graph = self.construct_graph()700 hint_graph = self.construct_graph()
693 tiling_def, host_tiling, op_kernel = fuser.autofuse_backend(hint_graph)701 tiling_def, host_tiling, op_kernel = fuser.autofuse_backend(hint_graph)
694 702 
703+ def test_autofuse_backend_runtime_error_does_not_return_partial_result(self):
704+ assert RUNTIME_ERROR_TILING_LIB.is_file(), (
705+ f"missing runtime error tiling library: {RUNTIME_ERROR_TILING_LIB}"
706+ )
707+ options = AutofuserOptions(
708+ tiling_lib_path=str(RUNTIME_ERROR_TILING_LIB),
709+ tiling_lib_codegen_symbol="CodegenTiling",
710+ )
711+ fuser = Autofuser(options)
712+ 
713+ hint_graph = self.construct_graph()
714+ with pytest.raises(
715+ RuntimeError,
716+ match=r"^Codegen generate kernel failed: pyautofuse runtime error test$",
717+ ):
718+ fuser.autofuse_backend(hint_graph)
719+ 
695 720 
696class TestAutofuseLoadMatMulStore:721class TestAutofuseLoadMatMulStore:
697 @staticmethod722 @staticmethod
@@ -27,6 +27,7 @@
27#include "test_common_utils.h"27#include "test_common_utils.h"
28#include "runtime_stub.h"28#include "runtime_stub.h"
29#include "common/platform_context.h"29#include "common/platform_context.h"
30+#include "../../../../common/att/soc_perf_test_config.h"
30using namespace af::ascir_op;31using namespace af::ascir_op;
31namespace ascir {32namespace ascir {
32using namespace ge;33using namespace ge;
@@ -176,6 +177,9 @@ class STestGenConcatV2 : public ::testing::Test {
176 AutoFuseConfig::MutableAttStrategyConfig().force_template_op_name = "";177 AutoFuseConfig::MutableAttStrategyConfig().force_template_op_name = "";
177 AutoFuseConfig::MutableAttStrategyConfig().force_tiling_case = "";178 AutoFuseConfig::MutableAttStrategyConfig().force_tiling_case = "";
178 AutoFuseConfig::MutableAttStrategyConfig().force_schedule_result = -1L;179 AutoFuseConfig::MutableAttStrategyConfig().force_schedule_result = -1L;
180+ ASSERT_EQ(
181+ att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35NpuArch, att::soc_perf_test::kSocEmpty),
182+ af::SUCCESS);
179 }183 }
180 184 
181 void TearDown() override {185 void TearDown() override {
@@ -10,10 +10,15 @@
10 10 
11#include <iostream>11#include <iostream>
12#include <chrono>12#include <chrono>
13+#include <sstream>
14+#include <string>
15+#include <vector>
13#include "gtest/gtest.h"16#include "gtest/gtest.h"
14#include "api_perf_register/ascendc_api_perf.h"17#include "api_perf_register/ascendc_api_perf.h"
15#include "api_perf_register/api_perf_factory.h"18#include "api_perf_register/api_perf_factory.h"
19+#include "gen_model_info.h"
16#include "../../../../st/att/testcase/source_mirror/gen_model_info_content/runtime_stub.h"20#include "../../../../st/att/testcase/source_mirror/gen_model_info_content/runtime_stub.h"
21+#include "../../../../common/att/soc_perf_test_config.h"
17#include "common/platform_context.h"22#include "common/platform_context.h"
18#include "v35/att/api_perf_register/ascir_api_perf_v2.h"23#include "v35/att/api_perf_register/ascir_api_perf_v2.h"
19#include "v35/att/api_perf_register/perf_param_v2.h"24#include "v35/att/api_perf_register/perf_param_v2.h"
@@ -43,6 +48,202 @@ class STestAscirPerfV2 : public ::testing::Test {
43};48};
44af::RuntimeStubV2 STestAscirPerfV2::stub_v_2;49af::RuntimeStubV2 STestAscirPerfV2::stub_v_2;
45 50 
51+namespace {
52+NodePerfInfo MakeSocStAbsPerfInfo() {
53+ NodePerfInfo node;
54+ node.optype = "Abs";
55+ node.input_dtype = "float16";
56+ node.output_dtype = "float16";
57+ node.dims = {CreateExpr(64)};
58+ return node;
59+}
60+ 
61+::ascir::FusedScheduledResult MakeSocStScheduleResult() {
62+ af::AscGraph graph("soc_st_abs_graph");
63+ if (GraphConstructUtils::CreateSimpleLoadStoreOp(graph) != af::SUCCESS) {
64+ return {};
65+ }
66+ GraphConstructUtils::UpdateGraphVectorizedStride(graph);
67+ 
68+ ::ascir::ScheduledResult schedule_result;
69+ ::ascir::ScheduleGroup schedule_group;
70+ schedule_group.impl_graphs.emplace_back(graph);
71+ schedule_result.schedule_groups.emplace_back(schedule_group);
72+ ::ascir::FusedScheduledResult fused_schedule_result;
73+ fused_schedule_result.node_idx_to_scheduled_results.emplace_back(
74+ std::vector<::ascir::ScheduledResult>{schedule_result});
75+ return fused_schedule_result;
76+}
77+ 
78+af::Status GenerateSocStModelInfos(const std::string &soc_version, FusedParsedScheduleResult &model_infos) {
79+ if (att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35NpuArch, soc_version) != af::SUCCESS) {
80+ return af::FAILED;
81+ }
82+ model_infos.clear();
83+ return GetModelInfoMap(MakeSocStScheduleResult(), {}, model_infos);
84+}
85+ 
86+std::vector<const ModelInfo *> CollectSocStModelInfos(const FusedParsedScheduleResult &model_infos) {
87+ std::vector<const ModelInfo *> result;
88+ for (const auto &asc_graph_item : model_infos) {
89+ for (const auto &impl_graph_item : asc_graph_item.second) {
90+ for (const auto &group_item : impl_graph_item.second.groups_tiling_model_info) {
91+ for (const auto &model_info : group_item.second) {
92+ result.emplace_back(&model_info);
93+ }
94+ }
95+ }
96+ }
97+ return result;
98+}
99+ 
100+std::string MakeSocStTilingIdentity(const ModelInfo &model_info) {
101+ std::ostringstream identity;
102+ identity << model_info.tiling_case_id << "|" << model_info.graph_name << "|" << model_info.score_func << "|"
103+ << model_info.sub_case_tag << "|" << model_info.is_enable_equal_order_tiling << "|"
104+ << model_info.tiling_schedule_config.DebugString();
105+ return identity.str();
106+}
107+ 
108+std::string MakeSocStCostIdentity(const ModelInfo &model_info) {
109+ std::ostringstream cost;
110+ for (const auto &object_item : model_info.objects) {
111+ cost << static_cast<int32_t>(object_item.first) << ":" << Str(object_item.second) << ";";
112+ }
113+ return cost.str();
114+}
115+} // namespace
116+ 
117+TEST_F(STestAscirPerfV2, TestSocPerfSerialTargetSelection) {
118+ Expr abs_perf;
119+ ASSERT_EQ(att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35NpuArch, att::soc_perf_test::kSocA),
120+ af::SUCCESS);
121+ ASSERT_EQ(GetPerf(MakeSocStAbsPerfInfo(), abs_perf), af::SUCCESS);
122+ EXPECT_EQ(Str(abs_perf), "74.0");
123+ const auto abs_api_a1 = GetApiPerf("Abs");
124+ ASSERT_NE(abs_api_a1, nullptr);
125+ EXPECT_EQ(abs_api_a1->GetPerfFunc(), EvalCosts::Instance().GetFunc("ExpV2"));
126+ 
127+ ASSERT_EQ(att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35NpuArch, att::soc_perf_test::kSocB),
128+ af::SUCCESS);
129+ ASSERT_EQ(GetPerf(MakeSocStAbsPerfInfo(), abs_perf), af::SUCCESS);
130+ EXPECT_EQ(Str(abs_perf), "148.0");
131+ const auto abs_api_b = GetApiPerf("Abs");
132+ ASSERT_NE(abs_api_b, nullptr);
133+ EXPECT_EQ(abs_api_b->GetPerfFunc(), EvalCosts::Instance().GetFunc("AbsV2"));
134+ 
135+ ASSERT_EQ(att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35NpuArch, att::soc_perf_test::kSocA),
136+ af::SUCCESS);
137+ ASSERT_EQ(GetPerf(MakeSocStAbsPerfInfo(), abs_perf), af::SUCCESS);
138+ EXPECT_EQ(Str(abs_perf), "74.0");
139+ const auto abs_api_a2 = GetApiPerf("Abs");
140+ ASSERT_NE(abs_api_a2, nullptr);
141+ EXPECT_EQ(abs_api_a2->GetPerfFunc(), EvalCosts::Instance().GetFunc("ExpV2"));
142+ EXPECT_EQ(abs_api_a1->GetTilingScheduleConfigTable(), abs_api_a2->GetTilingScheduleConfigTable());
143+ 
144+ FusedParsedScheduleResult model_infos_a1;
145+ FusedParsedScheduleResult model_infos_b;
146+ FusedParsedScheduleResult model_infos_a2;
147+ ASSERT_EQ(GenerateSocStModelInfos(att::soc_perf_test::kSocA, model_infos_a1), af::SUCCESS);
148+ ASSERT_EQ(GenerateSocStModelInfos(att::soc_perf_test::kSocB, model_infos_b), af::SUCCESS);
149+ ASSERT_EQ(GenerateSocStModelInfos(att::soc_perf_test::kSocA, model_infos_a2), af::SUCCESS);
150+ const auto model_info_ptrs_a1 = CollectSocStModelInfos(model_infos_a1);
151+ const auto model_info_ptrs_b = CollectSocStModelInfos(model_infos_b);
152+ const auto model_info_ptrs_a2 = CollectSocStModelInfos(model_infos_a2);
153+ ASSERT_FALSE(model_info_ptrs_a1.empty());
154+ ASSERT_EQ(model_info_ptrs_a1.size(), model_info_ptrs_b.size());
155+ ASSERT_EQ(model_info_ptrs_a1.size(), model_info_ptrs_a2.size());
156+ for (size_t i = 0U; i < model_info_ptrs_a1.size(); ++i) {
157+ const std::string tiling_identity_a1 = MakeSocStTilingIdentity(*model_info_ptrs_a1[i]);
158+ EXPECT_EQ(tiling_identity_a1, MakeSocStTilingIdentity(*model_info_ptrs_b[i]));
159+ EXPECT_EQ(tiling_identity_a1, MakeSocStTilingIdentity(*model_info_ptrs_a2[i]));
160+ EXPECT_EQ(model_info_ptrs_a1[i]->tiling_schedule_config_table, model_info_ptrs_b[i]->tiling_schedule_config_table);
161+ const std::string cost_identity_a1 = MakeSocStCostIdentity(*model_info_ptrs_a1[i]);
162+ EXPECT_EQ(cost_identity_a1, MakeSocStCostIdentity(*model_info_ptrs_a2[i]));
163+ EXPECT_NE(cost_identity_a1, MakeSocStCostIdentity(*model_info_ptrs_b[i]));
164+ }
165+}
166+ 
167+TEST_F(STestAscirPerfV2, TestSocPerfV2ArchitecturesUnknownSocUseOriginalBaseline) {
168+ for (const std::string &npu_arch : {"3510", "5102", "9201", "9202"}) {
169+ FusedParsedScheduleResult baseline;
170+ ASSERT_EQ(soc_perf_test::SetSocPerfTestPlatform(npu_arch, ""), af::SUCCESS);
171+ ASSERT_EQ(GetModelInfoMap(MakeSocStScheduleResult(), {}, baseline), af::SUCCESS);
172+ const auto baseline_models = CollectSocStModelInfos(baseline);
173+ ASSERT_FALSE(baseline_models.empty());
174+ for (const std::string &soc : {"SOC_UNREGISTERED", "SOC_UNREGISTERED_AGAIN"}) {
175+ ASSERT_EQ(soc_perf_test::SetSocPerfTestPlatform(npu_arch, soc), af::SUCCESS);
176+ FusedParsedScheduleResult models;
177+ ASSERT_EQ(GetModelInfoMap(MakeSocStScheduleResult(), {}, models), af::SUCCESS);
178+ const auto actual_models = CollectSocStModelInfos(models);
179+ ASSERT_EQ(actual_models.size(), baseline_models.size());
180+ for (size_t i = 0U; i < actual_models.size(); ++i) {
181+ EXPECT_EQ(MakeSocStTilingIdentity(*actual_models[i]), MakeSocStTilingIdentity(*baseline_models[i]));
182+ EXPECT_EQ(MakeSocStCostIdentity(*actual_models[i]), MakeSocStCostIdentity(*baseline_models[i]));
183+ }
184+ }
185+ }
186+ ge::PlatformContext::GetInstance().Reset();
187+}
188+ 
189+TEST_F(STestAscirPerfV2, TestSocPerfRegisteredArchitectureKeepsOriginalModel) {
190+ ASSERT_EQ(soc_perf_test::SetSocPerfTestPlatform(soc_perf_test::kV35AltNpuArch, ""), af::SUCCESS);
191+ Expr baseline;
192+ ASSERT_EQ(GetPerf(MakeSocStAbsPerfInfo(), baseline), af::SUCCESS);
193+ const auto default_api = GetApiPerf("Abs");
194+ ASSERT_NE(default_api, nullptr);
195+ 
196+ soc_perf_test::RegisterSocPerfTestArchitecture();
197+ ASSERT_EQ(soc_perf_test::SetSocPerfTestPlatform(soc_perf_test::kRegisteredNpuArch, "SOC_UNREGISTERED"), af::SUCCESS);
198+ ASSERT_EQ(ValidateSocPerfEntry(), af::SUCCESS);
199+ Expr perf;
200+ ASSERT_EQ(GetPerf(MakeSocStAbsPerfInfo(), perf), af::SUCCESS);
201+ EXPECT_EQ(Str(perf), Str(baseline));
202+ const auto actual_api = GetApiPerf("Abs");
203+ ASSERT_NE(actual_api, nullptr);
204+ EXPECT_EQ(actual_api->GetPerfFunc(), default_api->GetPerfFunc());
205+ ge::PlatformContext::GetInstance().Reset();
206+}
207+ 
208+TEST_F(STestAscirPerfV2, TestSocPerfUnknownArchFailsAndUnknownSocKeepsBaseline) {
209+ FusedParsedScheduleResult model_infos;
210+ ge::PlatformContext::GetInstance().SetPlatform("UnknownArch");
211+ EXPECT_NE(GetModelInfoMap(MakeSocStScheduleResult(), {}, model_infos), af::SUCCESS);
212+ EXPECT_TRUE(model_infos.empty());
213+ 
214+ ASSERT_EQ(att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35NpuArch, "SOC_NOT_BOUND"), af::SUCCESS);
215+ EXPECT_EQ(GetModelInfoMap(MakeSocStScheduleResult(), {}, model_infos), af::SUCCESS);
216+ EXPECT_FALSE(model_infos.empty());
217+ 
218+ ASSERT_EQ(GenerateSocStModelInfos(att::soc_perf_test::kSocEmpty, model_infos), af::SUCCESS);
219+ EXPECT_FALSE(model_infos.empty());
220+}
221+ 
222+TEST_F(STestAscirPerfV2, TestSocPerfDefaultModelIsStableAndTimed) {
223+ FusedParsedScheduleResult first_model_infos;
224+ FusedParsedScheduleResult second_model_infos;
225+ auto start_time = std::chrono::steady_clock::now();
226+ ASSERT_EQ(GenerateSocStModelInfos(att::soc_perf_test::kSocEmpty, first_model_infos), af::SUCCESS);
227+ const auto first_duration = std::chrono::steady_clock::now() - start_time;
228+ 
229+ start_time = std::chrono::steady_clock::now();
230+ ASSERT_EQ(GenerateSocStModelInfos(att::soc_perf_test::kSocEmpty, second_model_infos), af::SUCCESS);
231+ const auto second_duration = std::chrono::steady_clock::now() - start_time;
232+ 
233+ const auto first_model_info_ptrs = CollectSocStModelInfos(first_model_infos);
234+ const auto second_model_info_ptrs = CollectSocStModelInfos(second_model_infos);
235+ ASSERT_FALSE(first_model_info_ptrs.empty());
236+ ASSERT_EQ(first_model_info_ptrs.size(), second_model_info_ptrs.size());
237+ for (size_t i = 0U; i < first_model_info_ptrs.size(); ++i) {
238+ EXPECT_EQ(MakeSocStTilingIdentity(*first_model_info_ptrs[i]), MakeSocStTilingIdentity(*second_model_info_ptrs[i]));
239+ EXPECT_EQ(MakeSocStCostIdentity(*first_model_info_ptrs[i]), MakeSocStCostIdentity(*second_model_info_ptrs[i]));
240+ }
241+ 
242+ const auto first_ms = std::chrono::duration_cast<std::chrono::milliseconds>(first_duration).count();
243+ const auto second_ms = std::chrono::duration_cast<std::chrono::milliseconds>(second_duration).count();
244+ std::cout << "[SocPerfST] default model first=" << first_ms << "ms, second=" << second_ms << "ms" << std::endl;
245+}
246+ 
46// 测试 Load/Store API - 不同数据类型大小247// 测试 Load/Store API - 不同数据类型大小
47TEST_F(STestAscirPerfV2, TestLoadStoreDataTypeSizes) {248TEST_F(STestAscirPerfV2, TestLoadStoreDataTypeSizes) {
48 std::vector<att::TensorShapeInfo> input_shapes;249 std::vector<att::TensorShapeInfo> input_shapes;
@@ -9,6 +9,7 @@
9 */9 */
10 10 
11#include "common/platform_context.h"11#include "common/platform_context.h"
12+#include "../../../../common/att/soc_perf_test_config.h"
12#include "runtime_stub.h"13#include "runtime_stub.h"
13#include "common/test_common_headers.h"14#include "common/test_common_headers.h"
14#include "common/st_scenario_utils.h"15#include "common/st_scenario_utils.h"
@@ -22,6 +23,9 @@ class STestReduceSplitPenaltyV2 : public ::testing::Test {
22 AutoFuseConfig::MutableAttStrategyConfig().Reset();23 AutoFuseConfig::MutableAttStrategyConfig().Reset();
23 ge::RuntimeStub::Install(&stub_v_2);24 ge::RuntimeStub::Install(&stub_v_2);
24 ge::PlatformContext::GetInstance().Reset();25 ge::PlatformContext::GetInstance().Reset();
26+ ASSERT_EQ(
27+ att::soc_perf_test::SetSocPerfTestPlatform(att::soc_perf_test::kV35NpuArch, att::soc_perf_test::kSocEmpty),
28+ af::SUCCESS);
25 // V2形态:通过TilingScheduleConfigTableV2自动返回true,无需手动设置29 // V2形态:通过TilingScheduleConfigTableV2自动返回true,无需手动设置
26 }30 }
27 void TearDown() override {31 void TearDown() override {
@@ -18,8 +18,7 @@ class TestBackendAbsBf16E2e : public testing::Test {
18 void SetUp() override {18 void SetUp() override {
19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
20 ge::PlatformContext::GetInstance().Reset();20 ge::PlatformContext::GetInstance().Reset();
21- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();21+ af::InstallV35SocPerfRuntimeStub();
22- ge::RuntimeStub::SetInstance(stub_v2);
23 }22 }
24 void TearDown() override {23 void TearDown() override {
25 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);24 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -28,8 +28,7 @@ class TestBackendAbsBrcAddE2e : public testing::Test {
28 void SetUp() override {28 void SetUp() override {
29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
30 ge::PlatformContext::GetInstance().Reset();30 ge::PlatformContext::GetInstance().Reset();
31- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();31+ af::InstallV35SocPerfRuntimeStub();
32- ge::RuntimeStub::SetInstance(stub_v2);
33 }32 }
34 void TearDown() override {33 void TearDown() override {
35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);34 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAbsClipE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAbsFmaBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAbsFmaE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -18,8 +18,7 @@ class TestBackendAbsUint8E2e : public testing::Test {
18 void SetUp() override {18 void SetUp() override {
19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
20 ge::PlatformContext::GetInstance().Reset();20 ge::PlatformContext::GetInstance().Reset();
21- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();21+ af::InstallV35SocPerfRuntimeStub();
22- ge::RuntimeStub::SetInstance(stub_v2);
23 }22 }
24 void TearDown() override {23 void TearDown() override {
25 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);24 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -33,8 +33,7 @@ class TestBackendAcosBf16E2e : public testing::Test {
33 void SetUp() override {33 void SetUp() override {
34 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);34 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
35 ge::PlatformContext::GetInstance().Reset();35 ge::PlatformContext::GetInstance().Reset();
36- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();36+ af::InstallV35SocPerfRuntimeStub();
37- ge::RuntimeStub::SetInstance(stub_v2);
38 }37 }
39 void TearDown() override {38 void TearDown() override {
40 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);39 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAcoshBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAddAbsFloatScalarE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAddAbsHalfScalarE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAddAbsInt8ScalarE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAddAbsE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAddExp2E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAddExpBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAddFloorBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAddFloorE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendV2AddRsqrtE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -32,8 +32,7 @@ class TestBackendAsinBf16E2e : public testing::Test {
32 void SetUp() override {32 void SetUp() override {
33 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);33 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
34 ge::PlatformContext::GetInstance().Reset();34 ge::PlatformContext::GetInstance().Reset();
35- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();35+ af::InstallV35SocPerfRuntimeStub();
36- ge::RuntimeStub::SetInstance(stub_v2);
37 }36 }
38 void TearDown() override {37 void TearDown() override {
39 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);38 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -18,8 +18,7 @@ class TestBackendAsinhBf16E2e : public testing::Test {
18 void SetUp() override {18 void SetUp() override {
19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
20 ge::PlatformContext::GetInstance().Reset();20 ge::PlatformContext::GetInstance().Reset();
21- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();21+ af::InstallV35SocPerfRuntimeStub();
22- ge::RuntimeStub::SetInstance(stub_v2);
23 }22 }
24 void TearDown() override {23 void TearDown() override {
25 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);24 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAtan2Bf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAtanBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendAtanhBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -30,8 +30,7 @@ class TestBackendBesselJ0StoreE2e : public testing::Test {
30 void SetUp() override {30 void SetUp() override {
31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
32 ge::PlatformContext::GetInstance().Reset();32 ge::PlatformContext::GetInstance().Reset();
33- auto bessel_j0_stub_v2 = std::make_shared<af::RuntimeStubV2>();33+ af::InstallV35SocPerfRuntimeStub();
34- ge::RuntimeStub::SetInstance(bessel_j0_stub_v2);
35 }34 }
36 void TearDown() override {35 void TearDown() override {
37 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -64,8 +64,7 @@ class TestBackendBesselJ1StoreE2e : public testing::Test {
64 void SetUp() override {64 void SetUp() override {
65 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);65 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
66 ge::PlatformContext::GetInstance().Reset();66 ge::PlatformContext::GetInstance().Reset();
67- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();67+ af::InstallV35SocPerfRuntimeStub();
68- ge::RuntimeStub::SetInstance(stub_v2);
69 }68 }
70 void TearDown() override {69 void TearDown() override {
71 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);70 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -64,8 +64,7 @@ class TestBackendBesselY0StoreE2e : public testing::Test {
64 void SetUp() override {64 void SetUp() override {
65 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);65 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
66 ge::PlatformContext::GetInstance().Reset();66 ge::PlatformContext::GetInstance().Reset();
67- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();67+ af::InstallV35SocPerfRuntimeStub();
68- ge::RuntimeStub::SetInstance(stub_v2);
69 }68 }
70 void TearDown() override {69 void TearDown() override {
71 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);70 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -64,8 +64,7 @@ class TestBackendBesselY1StoreE2e : public testing::Test {
64 void SetUp() override {64 void SetUp() override {
65 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);65 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
66 ge::PlatformContext::GetInstance().Reset();66 ge::PlatformContext::GetInstance().Reset();
67- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();67+ af::InstallV35SocPerfRuntimeStub();
68- ge::RuntimeStub::SetInstance(stub_v2);
69 }68 }
70 void TearDown() override {69 void TearDown() override {
71 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);70 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -19,8 +19,7 @@ class TestBackendBF16AddE2e : public testing::Test {
19 void SetUp() override {19 void SetUp() override {
20 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);20 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
21 ge::PlatformContext::GetInstance().Reset();21 ge::PlatformContext::GetInstance().Reset();
22- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();22+ af::InstallV35SocPerfRuntimeStub();
23- ge::RuntimeStub::SetInstance(stub_v2);
24 }23 }
25 void TearDown() override {24 void TearDown() override {
26 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);25 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -19,8 +19,7 @@ class TestBackendBF16NddmaAddE2e : public testing::Test {
19 void SetUp() override {19 void SetUp() override {
20 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);20 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
21 ge::PlatformContext::GetInstance().Reset();21 ge::PlatformContext::GetInstance().Reset();
22- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();22+ af::InstallV35SocPerfRuntimeStub();
23- ge::RuntimeStub::SetInstance(stub_v2);
24 }23 }
25 void TearDown() override {24 void TearDown() override {
26 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);25 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendBf16RsqrtE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -76,4 +75,4 @@ TEST_F(TestBackendBf16RsqrtE2e, Bf16RsqrtE2eCodegen) {
76 }75 }
77 76 
78 EXPECT_EQ(gen_success, true);77 EXPECT_EQ(gen_success, true);
79-}78+}
@@ -29,8 +29,7 @@ class TestBackendBf16SigmoidE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -76,4 +75,4 @@ TEST_F(TestBackendBf16SigmoidE2e, Bf16SigmoidE2eCodegen) {
76 }75 }
77 76 
78 EXPECT_EQ(gen_success, true);77 EXPECT_EQ(gen_success, true);
79-}78+}
@@ -29,8 +29,7 @@ class TestBackendBf16SinE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -76,4 +75,4 @@ TEST_F(TestBackendBf16SinE2e, Bf16SinE2eCodegen) {
76 }75 }
77 76 
78 EXPECT_EQ(gen_success, true);77 EXPECT_EQ(gen_success, true);
79-}78+}
@@ -29,8 +29,7 @@ class TestBackendBf16SqrtE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -76,4 +75,4 @@ TEST_F(TestBackendBf16SqrtE2e, Bf16SqrtE2eCodegen) {
76 }75 }
77 76 
78 EXPECT_EQ(gen_success, true);77 EXPECT_EQ(gen_success, true);
79-}78+}
@@ -29,8 +29,7 @@ class TestBackendBinaryApiScalarE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -30,8 +30,7 @@ class TestBackendLoadBitwiseBoolStoreE2e : public testing::Test {
30 void SetUp() override {30 void SetUp() override {
31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
32 ge::PlatformContext::GetInstance().Reset();32 ge::PlatformContext::GetInstance().Reset();
33- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();33+ af::InstallV35SocPerfRuntimeStub();
34- ge::RuntimeStub::SetInstance(stub_v2);
35 }34 }
36 void TearDown() override {35 void TearDown() override {
37 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -31,8 +31,7 @@ class BoolBackendCodegenE2e : public testing::Test {
31 void SetUp() override {31 void SetUp() override {
32 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);32 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
33 ge::PlatformContext::GetInstance().Reset();33 ge::PlatformContext::GetInstance().Reset();
34- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();34+ af::InstallV35SocPerfRuntimeStub();
35- ge::RuntimeStub::SetInstance(stub_v2);
36 }35 }
37 36 
38 void TearDown() override {37 void TearDown() override {
@@ -28,8 +28,7 @@ class TestBackendBrcReduceAddE2e : public testing::Test {
28 void SetUp() override {28 void SetUp() override {
29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
30 ge::PlatformContext::GetInstance().Reset();30 ge::PlatformContext::GetInstance().Reset();
31- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();31+ af::InstallV35SocPerfRuntimeStub();
32- ge::RuntimeStub::SetInstance(stub_v2);
33 }32 }
34};33};
35 34 
@@ -29,8 +29,7 @@ class TestBackendCastAbsFloat16FloatE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendCastAbsE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendCastIsFiniteE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendCastNanE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendCastReciprocalE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendCeil2intBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -18,8 +18,7 @@ class TestBackendCeilBf16E2e : public testing::Test {
18 void SetUp() override {18 void SetUp() override {
19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
20 ge::PlatformContext::GetInstance().Reset();20 ge::PlatformContext::GetInstance().Reset();
21- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();21+ af::InstallV35SocPerfRuntimeStub();
22- ge::RuntimeStub::SetInstance(stub_v2);
23 }22 }
24 void TearDown() override {23 void TearDown() override {
25 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);24 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -30,8 +30,7 @@ class TestBackendChebyshevPolynomialTStoreE2e : public testing::Test {
30 void SetUp() override {30 void SetUp() override {
31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
32 ge::PlatformContext::GetInstance().Reset();32 ge::PlatformContext::GetInstance().Reset();
33- auto chebyshev_stub_v2 = std::make_shared<af::RuntimeStubV2>();33+ af::InstallV35SocPerfRuntimeStub();
34- ge::RuntimeStub::SetInstance(chebyshev_stub_v2);
35 }34 }
36 void TearDown() override {35 void TearDown() override {
37 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -30,8 +30,7 @@ class TestBackendChebyshevPolynomialUStoreE2e : public testing::Test {
30 void SetUp() override {30 void SetUp() override {
31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
32 ge::PlatformContext::GetInstance().Reset();32 ge::PlatformContext::GetInstance().Reset();
33- auto chebyshev_stub_v2 = std::make_shared<af::RuntimeStubV2>();33+ af::InstallV35SocPerfRuntimeStub();
34- ge::RuntimeStub::SetInstance(chebyshev_stub_v2);
35 }34 }
36 void TearDown() override {35 void TearDown() override {
37 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -30,8 +30,7 @@ class TestBackendChebyshevPolynomialVStoreE2e : public testing::Test {
30 void SetUp() override {30 void SetUp() override {
31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
32 ge::PlatformContext::GetInstance().Reset();32 ge::PlatformContext::GetInstance().Reset();
33- auto chebyshev_stub_v2 = std::make_shared<af::RuntimeStubV2>();33+ af::InstallV35SocPerfRuntimeStub();
34- ge::RuntimeStub::SetInstance(chebyshev_stub_v2);
35 }34 }
36 void TearDown() override {35 void TearDown() override {
37 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -30,8 +30,7 @@ class TestBackendChebyshevPolynomialWStoreE2e : public testing::Test {
30 void SetUp() override {30 void SetUp() override {
31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
32 ge::PlatformContext::GetInstance().Reset();32 ge::PlatformContext::GetInstance().Reset();
33- auto chebyshev_stub_v2 = std::make_shared<af::RuntimeStubV2>();33+ af::InstallV35SocPerfRuntimeStub();
34- ge::RuntimeStub::SetInstance(chebyshev_stub_v2);
35 }34 }
36 void TearDown() override {35 void TearDown() override {
37 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendConcatE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -28,8 +28,7 @@ class TestBackendContinuesBrcAddE2e : public testing::Test {
28 void SetUp() override {28 void SetUp() override {
29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
30 ge::PlatformContext::GetInstance().Reset();30 ge::PlatformContext::GetInstance().Reset();
31- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();31+ af::InstallV35SocPerfRuntimeStub();
32- ge::RuntimeStub::SetInstance(stub_v2);
33 }32 }
34};33};
35 34 
@@ -29,8 +29,7 @@ class TestBackendCopysignBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -18,8 +18,7 @@ class TestBackendCosBf16E2e : public testing::Test {
18 void SetUp() override {18 void SetUp() override {
19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
20 ge::PlatformContext::GetInstance().Reset();20 ge::PlatformContext::GetInstance().Reset();
21- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();21+ af::InstallV35SocPerfRuntimeStub();
22- ge::RuntimeStub::SetInstance(stub_v2);
23 }22 }
24 void TearDown() override {23 void TearDown() override {
25 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);24 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendCoshBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendDigammaBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -28,8 +28,7 @@ class TestBackendDivAbsE2e : public testing::Test {
28 void SetUp() override {28 void SetUp() override {
29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
30 ge::PlatformContext::GetInstance().Reset();30 ge::PlatformContext::GetInstance().Reset();
31- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();31+ af::InstallV35SocPerfRuntimeStub();
32- ge::RuntimeStub::SetInstance(stub_v2);
33 }32 }
34};33};
35 34 
@@ -18,8 +18,7 @@ class TestBackendErfBf16E2e : public testing::Test {
18 void SetUp() override {18 void SetUp() override {
19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);19 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
20 ge::PlatformContext::GetInstance().Reset();20 ge::PlatformContext::GetInstance().Reset();
21- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();21+ af::InstallV35SocPerfRuntimeStub();
22- ge::RuntimeStub::SetInstance(stub_v2);
23 }22 }
24 void TearDown() override {23 void TearDown() override {
25 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);24 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendErfcBf16E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendErfcxTestE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -33,8 +33,7 @@ class TestBackendExpm1E2e : public testing::Test {
33 void SetUp() override {33 void SetUp() override {
34 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);34 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
35 ge::PlatformContext::GetInstance().Reset();35 ge::PlatformContext::GetInstance().Reset();
36- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();36+ af::InstallV35SocPerfRuntimeStub();
37- ge::RuntimeStub::SetInstance(stub_v2);
38 }37 }
39 void TearDown() override {38 void TearDown() override {
40 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);39 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendFloatLogicalNotE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -30,8 +30,7 @@ class TestBackendFloorDivInt32StoreE2e : public testing::Test {
30 void SetUp() override {30 void SetUp() override {
31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);31 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
32 ge::PlatformContext::GetInstance().Reset();32 ge::PlatformContext::GetInstance().Reset();
33- auto floor_div_stub_v2 = std::make_shared<af::RuntimeStubV2>();33+ af::InstallV35SocPerfRuntimeStub();
34- ge::RuntimeStub::SetInstance(floor_div_stub_v2);
35 }34 }
36 void TearDown() override {35 void TearDown() override {
37 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendFloordivAbsE2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -28,8 +28,7 @@ class TestBackendFloorDivMulLessEqualSelectE2e : public testing::Test {
28 void SetUp() override {28 void SetUp() override {
29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
30 ge::PlatformContext::GetInstance().Reset();30 ge::PlatformContext::GetInstance().Reset();
31- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();31+ af::InstallV35SocPerfRuntimeStub();
32- ge::RuntimeStub::SetInstance(stub_v2);
33 }32 }
34 void TearDown() override {33 void TearDown() override {
35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);34 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -28,8 +28,7 @@ class TestBackendFloortointFloatE2e : public testing::Test {
28 void SetUp() override {28 void SetUp() override {
29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);29 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
30 ge::PlatformContext::GetInstance().Reset();30 ge::PlatformContext::GetInstance().Reset();
31- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();31+ af::InstallV35SocPerfRuntimeStub();
32- ge::RuntimeStub::SetInstance(stub_v2);
33 }32 }
34 void TearDown() override {33 void TearDown() override {
35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);34 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
@@ -29,8 +29,7 @@ class TestBackendFmaInt8E2e : public testing::Test {
29 void SetUp() override {29 void SetUp() override {
30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);30 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);
31 ge::PlatformContext::GetInstance().Reset();31 ge::PlatformContext::GetInstance().Reset();
32- auto stub_v2 = std::make_shared<af::RuntimeStubV2>();32+ af::InstallV35SocPerfRuntimeStub();
33- ge::RuntimeStub::SetInstance(stub_v2);
34 }33 }
35 void TearDown() override {34 void TearDown() override {
36 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);35 dlog_setlevel(ASCGEN_MODULE_NAME, DLOG_ERROR, 0);