已合并
【PR】: sync develop to master 0715 #1301
yangyongqiang创建于 7月15日
【PR】: sync develop to master 0715 #1301
已合并
yangyongqiang创建于 7月15日
develop合入到master
46 个文件变更+3150-728
M.gitignore+3-0
@@ -39,3 +39,6 @@ super_kernel/tests/aot/third_party/mockcpp_src/
39# IDE settings39# IDE settings
40.vscode/40.vscode/
41.idea/41.idea/
42+ 
43+# AOT reports
44+oat_reports/
Mautofuse/ascir/meta/ascir_utils.cpp+0-1
@@ -851,7 +851,6 @@ std::string DebugStr(const ascir::Graph &graph, bool verbose) {
851 ss << "Nodes:" << std::endl;851 ss << "Nodes:" << std::endl;
852 size_t idx = 0UL;852 size_t idx = 0UL;
853 for (auto node : graph.GetAllNodes()) {853 for (auto node : graph.GetAllNodes()) {
854- // Node name and exec_order
855 ss << " " << node->GetName() << ": " << node->GetType() << " (" << idx++ << ")" << std::endl;854 ss << " " << node->GetName() << ": " << node->GetType() << " (" << idx++ << ")" << std::endl;
856 855 
857 NodeAttrStr(ss, graph, node, verbose);856 NodeAttrStr(ss, graph, node, verbose);
Mautofuse/graph_metadef/graph/ascendc_ir/core/ascendc_ir.cc+4-31
@@ -819,7 +819,7 @@ AscGraphAttr *AscGraphImpl::GetGraphAttrsGroup() const {
819}819}
820 820 
821AscOpOutput AscGraphImpl::CreateContiguousData(const char *name, const ge::DataType &dt, const vector<Axis> &axes,821AscOpOutput AscGraphImpl::CreateContiguousData(const char *name, const ge::DataType &dt, const vector<Axis> &axes,
822- const Format &format) {822+ const size_t index, const Format &format) {
823 auto data_op_desc = OpDescBuilder(name, kAscData).AddOutput("y").Build();823 auto data_op_desc = OpDescBuilder(name, kAscData).AddOutput("y").Build();
824 GE_ASSERT_NOTNULL(data_op_desc);824 GE_ASSERT_NOTNULL(data_op_desc);
825 // Add output and attr825 // Add output and attr
@@ -831,10 +831,9 @@ AscOpOutput AscGraphImpl::CreateContiguousData(const char *name, const ge::DataT
831 GE_ASSERT_NOTNULL(data_attr);831 GE_ASSERT_NOTNULL(data_attr);
832 AddNode(*data_op);832 AddNode(*data_op);
833 data_op_desc->SetExtAttr(ascir::cg::RELATED_OP, data_op);833 data_op_desc->SetExtAttr(ascir::cg::RELATED_OP, data_op);
834- data_attr->sched.exec_order = ascir::cg::CodeGenUtils::GenNextExecId(*data_op);
835 auto data_ir_attr = ComGraphMakeUnique<AscDataIrAttrDef>();834 auto data_ir_attr = ComGraphMakeUnique<AscDataIrAttrDef>();
836 GE_ASSERT_NOTNULL(data_ir_attr);835 GE_ASSERT_NOTNULL(data_ir_attr);
837- GE_ASSERT_GRAPH_SUCCESS(data_ir_attr->SetIndex(data_attr->sched.exec_order));836+ GE_ASSERT_GRAPH_SUCCESS(data_ir_attr->SetIndex(index));
838 data_attr->ir_attr = std::move(data_ir_attr);837 data_attr->ir_attr = std::move(data_ir_attr);
839 838 
840 AscOpOutput asc_op_output(data_op.get(), 0U); // data只有一个输出839 AscOpOutput asc_op_output(data_op.get(), 0U); // data只有一个输出
@@ -861,14 +860,6 @@ AscOpOutput AscGraphImpl::CreateContiguousOut(const char *name, const DataType &
861 return asc_op_output;860 return asc_op_output;
862}861}
863 862 
864-void AscGraphImpl::SortByExecOrder() {
865- compute_graph_->TopologicalSorting([](const NodePtr &a, const NodePtr &b) {
866- auto node_a = std::dynamic_pointer_cast<AscNode>(a);
867- auto node_b = std::dynamic_pointer_cast<AscNode>(b);
868- return node_a->attr.sched.exec_order < node_b->attr.sched.exec_order;
869- });
870-}
871- 
872const ComputeGraphPtr AscGraphImpl::GetComputeGraph() const {863const ComputeGraphPtr AscGraphImpl::GetComputeGraph() const {
873 return compute_graph_;864 return compute_graph_;
874}865}
@@ -915,10 +906,6 @@ std::string AscGraph::GetName() const {
915 return impl_->GetName();906 return impl_->GetName();
916}907}
917 908 
918-void AscGraph::SortByExecOrder() {
919- impl_->SortByExecOrder();
920-}
921- 
922bool AscGraph::CopyFrom(const AscGraph &graph) {909bool AscGraph::CopyFrom(const AscGraph &graph) {
923 GE_ASSERT_TRUE(impl_->CopyFrom(graph, *this));910 GE_ASSERT_TRUE(impl_->CopyFrom(graph, *this));
924 std::vector<AscGraph> sub_graphs;911 std::vector<AscGraph> sub_graphs;
@@ -1167,17 +1154,6 @@ bool AscGraph::CheckAxisValid() const {
1167 return true;1154 return true;
1168}1155}
1169 1156 
1170-bool AscGraph::CheckExecOrderValid() const {
1171- std::set<int64_t> exec_order_set;
1172- for (const auto &node : GetAllNodes()) {
1173- const auto exec_order = node->attr.sched.exec_order;
1174- const auto iter = exec_order_set.find(exec_order);
1175- GE_ASSERT_TRUE(iter == exec_order_set.end(), "Redundant exec_order[%ld].", exec_order);
1176- exec_order_set.insert(exec_order);
1177- }
1178- return true;
1179-}
1180- 
1181bool AscGraph::CheckTensorValid() const {1157bool AscGraph::CheckTensorValid() const {
1182 for (const auto &node : GetAllNodes()) {1158 for (const auto &node : GetAllNodes()) {
1183 int32_t output_index = -1;1159 int32_t output_index = -1;
@@ -1238,8 +1214,8 @@ TransInfoRoadOfGraph AscGraph::GetAllAxisTransInfo() const {
1238}1214}
1239 1215 
1240AscOpOutput AscGraph::CreateContiguousData(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,1216AscOpOutput AscGraph::CreateContiguousData(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,
1241- const ge::Format &format) {1217+ const size_t index, const ge::Format &format) {
1242- return impl_->CreateContiguousData(name, dt, axes, format);1218+ return impl_->CreateContiguousData(name, dt, axes, index, format);
1243}1219}
1244 1220 
1245AscOpOutput AscGraph::CreateContiguousOut(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,1221AscOpOutput AscGraph::CreateContiguousOut(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,
@@ -1466,12 +1442,10 @@ graphStatus AscNodeAttr::SerializeAttr(ascendc_ir::proto::AscNodeAttrGroupsDef &
1466 asc_node_group.set_name(name);1442 asc_node_group.set_name(name);
1467 asc_node_group.set_type(type);1443 asc_node_group.set_type(type);
1468 auto sched_def = asc_node_group.mutable_sched();1444 auto sched_def = asc_node_group.mutable_sched();
1469- sched_def->set_exec_order(sched.exec_order);
1470 for (const int64_t axis_id : sched.axis) {1445 for (const int64_t axis_id : sched.axis) {
1471 sched_def->add_axis(axis_id);1446 sched_def->add_axis(axis_id);
1472 }1447 }
1473 sched_def->set_loop_axis(sched.loop_axis);1448 sched_def->set_loop_axis(sched.loop_axis);
1474- sched_def->set_exec_order(sched.exec_order);
1475 sched_def->set_exec_condition(static_cast<int32_t>(sched.exec_condition));1449 sched_def->set_exec_condition(static_cast<int32_t>(sched.exec_condition));
1476 auto api_def = asc_node_group.mutable_api();1450 auto api_def = asc_node_group.mutable_api();
1477 api_def->set_type(static_cast<int32_t>(api.type));1451 api_def->set_type(static_cast<int32_t>(api.type));
@@ -1509,7 +1483,6 @@ graphStatus AscNodeAttr::DeserializeAttr(const ascendc_ir::proto::AscNodeAttrGro
1509 sched.axis.emplace_back(ax);1483 sched.axis.emplace_back(ax);
1510 }1484 }
1511 sched.loop_axis = sched_def.loop_axis();1485 sched.loop_axis = sched_def.loop_axis();
1512- sched.exec_order = sched_def.exec_order();
1513 sched.exec_condition = static_cast<ExecuteCondition>(sched_def.exec_condition());1486 sched.exec_condition = static_cast<ExecuteCondition>(sched_def.exec_condition());
1514 const auto &api_def = asc_node_group.api();1487 const auto &api_def = asc_node_group.api();
1515 api.type = static_cast<ApiType>((api_def.type()));1488 api.type = static_cast<ApiType>((api_def.type()));
Mautofuse/graph_metadef/graph/ascendc_ir/core/ascendc_ir_impl.h+1-3
@@ -105,13 +105,11 @@ class AscGraphImpl {
105 std::string GetName() const;105 std::string GetName() const;
106 106 
107 AscOpOutput CreateContiguousData(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,107 AscOpOutput CreateContiguousData(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,
108- const ge::Format &format);108+ const size_t index, const ge::Format &format);
109 109 
110 AscOpOutput CreateContiguousOut(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,110 AscOpOutput CreateContiguousOut(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,
111 const ge::Format &format);111 const ge::Format &format);
112 112 
113- void SortByExecOrder();
114- 
115 const ComputeGraphPtr GetComputeGraph() const;113 const ComputeGraphPtr GetComputeGraph() const;
116 114 
117 static bool CopyFrom(const AscGraph &src_graph, AscGraph &dst_graph);115 static bool CopyFrom(const AscGraph &src_graph, AscGraph &dst_graph);
Mautofuse/graph_metadef/graph/ascendc_ir/generator/generator.cc+0-3
@@ -1436,7 +1436,6 @@ class FunctionGenerator {
1436 virtual bool GenConnectInputs(std::stringstream &ss, const bool has_optional_input) const;1436 virtual bool GenConnectInputs(std::stringstream &ss, const bool has_optional_input) const;
1437 virtual bool GenAttrAssignment(std::stringstream &ss) const;1437 virtual bool GenAttrAssignment(std::stringstream &ss) const;
1438 virtual void GenSchedInfo(std::stringstream &ss) const {1438 virtual void GenSchedInfo(std::stringstream &ss) const {
1439- ss << " op.attr.sched.exec_order = CodeGenUtils::GenNextExecId(op);" << std::endl;
1440 ss << " SET_SCHED_AXIS_IF_IN_CONTEXT(op);" << std::endl;1439 ss << " SET_SCHED_AXIS_IF_IN_CONTEXT(op);" << std::endl;
1441 }1440 }
1442 virtual void TryGenOutputsVectorizedAxis(std::stringstream &ss) const {1441 virtual void TryGenOutputsVectorizedAxis(std::stringstream &ss) const {
@@ -1645,8 +1644,6 @@ class StoreNodeFuncGenerator : public FunctionGenerator {
1645 ss << " auto &store_op = const_cast<af::Operator &>(store_out.GetOwnerOp());" << std::endl;1644 ss << " auto &store_op = const_cast<af::Operator &>(store_out.GetOwnerOp());" << std::endl;
1646 ss << " gm_producer.SetInput(0U, store_op, 0U);" << std::endl;1645 ss << " gm_producer.SetInput(0U, store_op, 0U);" << std::endl;
1647 ss << " AddEdgeForNode(store_op, 0U, gm_producer, 0U);" << std::endl;1646 ss << " AddEdgeForNode(store_op, 0U, gm_producer, 0U);" << std::endl;
1648- ss << " auto *gm_producer_attr = CodeGenUtils::GetOwnerOpAscAttr(gm_producer);" << std::endl;
1649- ss << " gm_producer_attr->sched.exec_order = CodeGenUtils::GenNextExecId(store_op);" << std::endl;
1650 ss << "}" << std::endl;1647 ss << "}" << std::endl;
1651 }1648 }
1652};1649};
Mautofuse/graph_metadef/graph/ascendc_ir/utils/ascendc_ir_dump_utils.cc+1-2
@@ -94,7 +94,7 @@ std::string DumpAscirGraph::ComputeTypeToString(ComputeType type) {
94 {ComputeType::kComputeElewise, "ELEWISE"},94 {ComputeType::kComputeElewise, "ELEWISE"},
95 {ComputeType::kComputeBroadcast, "BROADCAST"},95 {ComputeType::kComputeBroadcast, "BROADCAST"},
96 {ComputeType::kComputeReduce, "REDUCE"},96 {ComputeType::kComputeReduce, "REDUCE"},
97- {ComputeType::kComputeTranspose, "TRANPOSE"},97+ {ComputeType::kComputeTranspose, "TRANSPOSE"},
98 {ComputeType::kComputeGather, "GATHER"},98 {ComputeType::kComputeGather, "GATHER"},
99 {ComputeType::kComputeInvalid, "INVALID"},99 {ComputeType::kComputeInvalid, "INVALID"},
100 };100 };
@@ -108,7 +108,6 @@ std::string DumpAscirGraph::ComputeTypeToString(ComputeType type) {
108std::stringstream &DumpAscirGraph::AscNodeAttrStr(std::stringstream &ss, AscNodeAttr &attr) {108std::stringstream &DumpAscirGraph::AscNodeAttrStr(std::stringstream &ss, AscNodeAttr &attr) {
109 ss << " AscNode: " << std::endl;109 ss << " AscNode: " << std::endl;
110 ss << " sched: " << std::endl;110 ss << " sched: " << std::endl;
111- ss << " exec_order: " << attr.sched.exec_order << std::endl;
112 ss << " axis: ";111 ss << " axis: ";
113 for (auto axis : attr.sched.axis) {112 for (auto axis : attr.sched.axis) {
114 ss << axis << ", ";113 ss << axis << ", ";
Mautofuse/graph_metadef/proto/af_ir.proto+3-2
@@ -182,7 +182,8 @@ message ShapeEnvAttrGroupsDef {
182}182}
183 183 
184message SchedInfoDef {184message SchedInfoDef {
185- int64 exec_order = 1;185+ // Deprecated since 2026-07-15. Kept only for compatibility and can be removed after compatibility window.
186+ int64 exec_order = 1 [deprecated = true];
186 repeated int64 axis = 2;187 repeated int64 axis = 2;
187 int64 loop_axis = 3;188 int64 loop_axis = 3;
188 int32 exec_condition = 4;189 int32 exec_condition = 4;
@@ -396,7 +397,7 @@ message GraphDef
396message ModelDef397message ModelDef
397{398{
398 string name = 1; // name399 string name = 1; // name
399- uint32 version = 2; // IR Proto verion400+ uint32 version = 2; // IR Proto version
400 string custom_version = 3; // User model version number, passed in by user401 string custom_version = 3; // User model version number, passed in by user
401 402 
402 repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef403 repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef
Mautofuse/inc/graph_metadef/graph/ascendc_ir/ascendc_ir_core/ascendc_ir.h+1-3
@@ -591,11 +591,10 @@ class AscGraph {
591 bool CheckValid() const;591 bool CheckValid() const;
592 592 
593 AscOpOutput CreateContiguousData(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,593 AscOpOutput CreateContiguousData(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,
594- const ge::Format &format = ge::FORMAT_ND);594+ const size_t index, const ge::Format &format = ge::FORMAT_ND);
595 595 
596 AscOpOutput CreateContiguousOut(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,596 AscOpOutput CreateContiguousOut(const char *name, const ge::DataType &dt, const std::vector<Axis> &axes,
597 const ge::Format &format = ge::FORMAT_ND);597 const ge::Format &format = ge::FORMAT_ND);
598- void SortByExecOrder();
599 bool CopyFrom(const AscGraph &graph);598 bool CopyFrom(const AscGraph &graph);
600 bool CopyAttrFrom(const AscGraph &src_graph);599 bool CopyAttrFrom(const AscGraph &src_graph);
601 static bool CopyAscNodeTensorAttr(const AscNodePtr &src_node, AscNodePtr &dst_node);600 static bool CopyAscNodeTensorAttr(const AscNodePtr &src_node, AscNodePtr &dst_node);
@@ -606,7 +605,6 @@ class AscGraph {
606 private:605 private:
607 bool CheckExprValid() const;606 bool CheckExprValid() const;
608 bool CheckAxisValid() const;607 bool CheckAxisValid() const;
609- bool CheckExecOrderValid() const;
610 bool CheckTensorValid() const;608 bool CheckTensorValid() const;
611 bool CheckNodeConnectionValid() const;609 bool CheckNodeConnectionValid() const;
612 std::shared_ptr<AscGraphImpl> impl_;610 std::shared_ptr<AscGraphImpl> impl_;
Mautofuse/inc/graph_metadef/graph/ascendc_ir/ascendc_ir_core/ascendc_ir_def.h+1-1
@@ -237,7 +237,7 @@ struct ApiInfo {
237};237};
238 238 
239struct SchedInfo {239struct SchedInfo {
240- // [HI] 执行序按值从小到大执行240+ // [HI] 已废弃(2026-07-15)仅为兼容性保留,经过兼容周期后可删除
241 int64_t exec_order{kIdNone};241 int64_t exec_order{kIdNone};
242 242 
243 // [HI] 节点所处的多层嵌套循环的轴`id`,按循环表示从外层到内层的轴`id`243 // [HI] 节点所处的多层嵌套循环的轴`id`,按循环表示从外层到内层的轴`id`
Mautofuse/optimize/fused_graph/fused_graph_unfolder.cpp+403-29
@@ -11,7 +11,10 @@
11#include "fused_graph_unfolder.h"11#include "fused_graph_unfolder.h"
12 12 
13#include <cstdint>13#include <cstdint>
14+#include <limits>
14#include <map>15#include <map>
16+#include <numeric>
17+#include <queue>
15#include "ascendc_ir/ascendc_ir_core/ascendc_ir.h"18#include "ascendc_ir/ascendc_ir_core/ascendc_ir.h"
16#include "ascendc_ir/ascendc_ir_core/ascendc_ir_def.h"19#include "ascendc_ir/ascendc_ir_core/ascendc_ir_def.h"
17#include "ascendc_ir/utils/asc_graph_utils.h"20#include "ascendc_ir/utils/asc_graph_utils.h"
@@ -27,6 +30,214 @@
27#include "ascgraph_info_complete.h"30#include "ascgraph_info_complete.h"
28 31 
29namespace optimize {32namespace optimize {
33+namespace {
34+const af::AscTensorAttr *FindBoundaryTensorAttr(const af::AscGraph &graph, const int32_t index, const bool is_output) {
35+ // External anchor indices are mirrored by the internal Data/Output ir_attr index.
36+ for (const auto &node : graph.GetAllNodes()) {
37+ const bool is_expected_node =
38+ is_output ? af::ops::IsOps<af::ascir_op::Output>(node) : ScheduleUtils::IsDataInput(node);
39+ if (!is_expected_node) {
40+ continue;
41+ }
42+ int64_t node_index = -1;
43+ if (ScheduleUtils::GetNodeIrAttrIndex(node, node_index) != af::SUCCESS || node_index != index) {
44+ continue;
45+ }
46+ const auto tensors = is_output ? node->inputs() : node->outputs();
47+ if (tensors.empty()) {
48+ return nullptr;
49+ }
50+ return &tensors[0]->attr;
51+ }
52+ return nullptr;
53+}
54+ 
55+} // namespace
56+ 
57+bool FusedGraphUnfolder::BuildGraphAxisMapping(const af::AscGraph &source_graph, const af::AscTensorAttr &source_attr,
58+ const af::AscGraph &target_graph, const af::AscTensorAttr &target_attr,
59+ const std::vector<size_t> &target_to_global,
60+ std::vector<size_t> &source_to_global) {
61+ const auto source_axes = source_graph.GetAllAxis();
62+ const auto target_axes = target_graph.GetAllAxis();
63+ if (target_axes.size() != target_to_global.size()) {
64+ return false;
65+ }
66+ std::map<af::AxisId, size_t> source_axis_to_index;
67+ std::map<af::AxisId, size_t> target_axis_to_index;
68+ if (!BuildAxisIndex(source_axes, source_axis_to_index) || !BuildAxisIndex(target_axes, target_axis_to_index)) {
69+ return false;
70+ }
71+ return ComposeGraphAxisMapping(source_attr, target_attr, source_axis_to_index, target_axis_to_index, target_to_global,
72+ source_to_global);
73+}
74+ 
75+// AxisId -> graph axis index
76+bool FusedGraphUnfolder::BuildAxisIndex(const std::vector<af::AxisPtr> &axes,
77+ std::map<af::AxisId, size_t> &axis_to_index) {
78+ for (size_t index = 0UL; index < axes.size(); ++index) {
79+ if (axes[index] == nullptr || !axis_to_index.emplace(axes[index]->id, index).second) {
80+ return false;
81+ }
82+ }
83+ return true;
84+}
85+ 
86+// 把局部 tensor 映射组合成图级映射
87+bool FusedGraphUnfolder::ComposeGraphAxisMapping(const af::AscTensorAttr &source_attr,
88+ const af::AscTensorAttr &target_attr,
89+ const std::map<af::AxisId, size_t> &source_axis_to_index,
90+ const std::map<af::AxisId, size_t> &target_axis_to_index,
91+ const std::vector<size_t> &target_to_global,
92+ std::vector<size_t> &source_to_global) {
93+ AxisMappingResult local_mapping;
94+ if (BuildLocalAxisMapping(source_attr, target_attr, local_mapping) != af::SUCCESS) {
95+ return false;
96+ }
97+ const auto unmapped_axis = std::numeric_limits<size_t>::max();
98+ source_to_global.assign(source_axis_to_index.size(), unmapped_axis);
99+ std::set<size_t> mapped_global_axes;
100+ // Tensor axes are local to a graph. Convert through the target graph before using global positions.
101+ for (size_t index = 0UL; index < source_attr.axis.size(); ++index) {
102+ const auto source_iter = source_axis_to_index.find(source_attr.axis[index]);
103+ const auto target_iter = target_axis_to_index.find(target_attr.axis[local_mapping.old_to_global[index]]);
104+ if (source_iter == source_axis_to_index.end() || target_iter == target_axis_to_index.end()) {
105+ return false;
106+ }
107+ const auto global_index = target_to_global[target_iter->second];
108+ if (source_to_global[source_iter->second] != unmapped_axis &&
109+ source_to_global[source_iter->second] != global_index) {
110+ return false;
111+ }
112+ if (!mapped_global_axes.emplace(global_index).second && source_to_global[source_iter->second] == unmapped_axis) {
113+ return false;
114+ }
115+ source_to_global[source_iter->second] = global_index;
116+ }
117+ return true;
118+}
119+ 
120+// 合并同一个 AscGraph 从多条边得到的映射约束
121+bool FusedGraphUnfolder::MergeGraphAxisMapping(std::vector<size_t> &existing_mapping,
122+ const std::vector<size_t> &new_mapping) {
123+ const auto unmapped_axis = std::numeric_limits<size_t>::max();
124+ if (existing_mapping.empty()) {
125+ existing_mapping = new_mapping;
126+ return true;
127+ }
128+ if (existing_mapping.size() != new_mapping.size()) {
129+ return false;
130+ }
131+ for (size_t index = 0UL; index < existing_mapping.size(); ++index) {
132+ if (new_mapping[index] == unmapped_axis) {
133+ continue;
134+ }
135+ if (existing_mapping[index] != unmapped_axis && existing_mapping[index] != new_mapping[index]) {
136+ return false;
137+ }
138+ existing_mapping[index] = new_mapping[index];
139+ }
140+ return true;
141+}
142+ 
143+// 检查图级映射是否还有未映射轴
144+bool FusedGraphUnfolder::IsGraphAxisMappingComplete(const std::vector<size_t> &mapping) {
145+ const auto unmapped_axis = std::numeric_limits<size_t>::max();
146+ return std::none_of(mapping.begin(), mapping.end(),
147+ [unmapped_axis](const size_t index) { return index == unmapped_axis; });
148+}
149+ 
150+// 校验 AscTensorAttr 的基本结构是否一致
151+bool FusedGraphUnfolder::IsTensorAttrValid(const af::AscTensorAttr &attr) {
152+ return attr.axis.size() == attr.repeats.size() && attr.axis.size() == attr.strides.size();
153+}
154+ 
155+// 判断 source 某一维能否匹配 target 某一维
156+// repeats 必须静态相等。
157+// 如果 source repeat 静态等于 1,则 stride 可以不同,因为该维索引恒为 0,不影响地址。
158+// 如果 source repeat 不是 1,则 stride 也必须静态相等。
159+bool FusedGraphUnfolder::IsAxisMatch(const af::AscTensorAttr &source_attr, const size_t source_index,
160+ const af::AscTensorAttr &target_attr, const size_t target_index) {
161+ if (af::SymbolicUtils::StaticCheckEq(source_attr.repeats[source_index], target_attr.repeats[target_index]) !=
162+ af::TriBool::kTrue) {
163+ return false;
164+ }
165+ return af::SymbolicUtils::StaticCheckEq(source_attr.repeats[source_index], af::sym::kSymbolOne) ==
166+ af::TriBool::kTrue ||
167+ af::SymbolicUtils::StaticCheckEq(source_attr.strides[source_index], target_attr.strides[target_index]) ==
168+ af::TriBool::kTrue;
169+}
170+ 
171+// 受限 DFS,搜索 source tensor 维度到 target tensor 维度的保序映射:
172+void FusedGraphUnfolder::SearchLocalAxisMappings(const af::AscTensorAttr &source_attr,
173+ const af::AscTensorAttr &target_attr, const size_t source_index,
174+ const size_t target_index, std::vector<size_t> &mapping,
175+ std::vector<std::vector<size_t>> &candidates) {
176+ // 找到第二个候选即可判定歧义,避免组合爆炸
177+ // 剩余 source 维度数 > 剩余 target 维度数 也直接剪枝返回
178+ if (candidates.size() == 2UL || source_attr.axis.size() - source_index > target_attr.axis.size() - target_index) {
179+ return;
180+ }
181+ 
182+ // source_index 到达末尾 → 检查剩余 target 维度均为 size-1,若是则记录一个候选
183+ if (source_index == source_attr.axis.size()) {
184+ for (size_t index = target_index; index < target_attr.axis.size(); ++index) {
185+ if (af::SymbolicUtils::StaticCheckEq(target_attr.repeats[index], af::sym::kSymbolOne) != af::TriBool::kTrue) {
186+ return;
187+ }
188+ }
189+ candidates.push_back(mapping);
190+ return;
191+ }
192+ if (target_index == target_attr.axis.size()) {
193+ return;
194+ }
195+ if (IsAxisMatch(source_attr, source_index, target_attr, target_index)) {
196+ mapping.push_back(target_index);
197+ SearchLocalAxisMappings(source_attr, target_attr, source_index + 1UL, target_index + 1UL, mapping, candidates);
198+ mapping.pop_back();
199+ }
200+ if (af::SymbolicUtils::StaticCheckEq(target_attr.repeats[target_index], af::sym::kSymbolOne) == af::TriBool::kTrue) {
201+ // Only unit target axes may be inserted without changing the source address calculation.
202+ SearchLocalAxisMappings(source_attr, target_attr, source_index, target_index + 1UL, mapping, candidates);
203+ }
204+}
205+ 
206+// 局部映射的完整入口,将 DFS 搜索结果转换为状态枚举。
207+Status FusedGraphUnfolder::BuildLocalAxisMapping(const af::AscTensorAttr &source_attr,
208+ const af::AscTensorAttr &target_attr, AxisMappingResult &result) {
209+ result = {};
210+ if (!IsTensorAttrValid(source_attr) || !IsTensorAttrValid(target_attr)) {
211+ result.reason = AxisMappingFailureReason::kInvalidTensorAttr;
212+ return af::FAILED;
213+ }
214+ if (source_attr.axis.size() > target_attr.axis.size()) {
215+ result.reason = AxisMappingFailureReason::kInvalidRank;
216+ return af::FAILED;
217+ }
218+ 
219+ std::vector<std::vector<size_t>> candidates;
220+ std::vector<size_t> mapping;
221+ SearchLocalAxisMappings(source_attr, target_attr, 0UL, 0UL, mapping, candidates);
222+ 
223+ if (candidates.empty()) {
224+ result.reason = AxisMappingFailureReason::kNonUnitInsertedAxis;
225+ return af::FAILED;
226+ }
227+ if (candidates.size() > 1UL) {
228+ result.status = AxisMappingStatus::kAmbiguous;
229+ result.reason = AxisMappingFailureReason::kMultipleMappings;
230+ return af::FAILED;
231+ }
232+ result.status = AxisMappingStatus::kSuccess;
233+ result.old_to_global = std::move(candidates.front());
234+ result.inserted_axes.assign(target_attr.axis.size(), true);
235+ for (const auto index : result.old_to_global) {
236+ result.inserted_axes[index] = false;
237+ }
238+ return af::SUCCESS;
239+}
240+ 
30Status FusedGraphUnfolder::RemoveUnusedNode(const af::ComputeGraphPtr &graph, const af::NodePtr &node,241Status FusedGraphUnfolder::RemoveUnusedNode(const af::ComputeGraphPtr &graph, const af::NodePtr &node,
31 const bool force) {242 const bool force) {
32 GE_CHECK_NOTNULL(graph);243 GE_CHECK_NOTNULL(graph);
@@ -393,7 +604,7 @@ Status FusedGraphUnfolder::UnfoldFusedGraph(const af::ComputeGraphPtr &fused_gra
393 af::AscGraph &unfolded_asc_graph) {604 af::AscGraph &unfolded_asc_graph) {
394 // step1 verify and choose loop605 // step1 verify and choose loop
395 std::vector<af::AxisPtr> new_loop_axes;606 std::vector<af::AxisPtr> new_loop_axes;
396- GE_CHK_STATUS_RET(SelectCommonLoopAxis(asc_backend_to_asc_graph, new_loop_axes),607+ GE_CHK_STATUS_RET(SelectCommonLoopAxis(fused_graph, asc_backend_to_asc_graph, new_loop_axes),
397 "The loop axis verification failed. Please confirm whether the fused graph [%s] is legitimate.",608 "The loop axis verification failed. Please confirm whether the fused graph [%s] is legitimate.",
398 fused_graph->GetName().c_str());609 fused_graph->GetName().c_str());
399 // set loop and convert to ascgraph610 // set loop and convert to ascgraph
@@ -441,48 +652,146 @@ Status FusedGraphUnfolder::UnfoldFusedGraph(const af::ComputeGraphPtr &fused_gra
441 fused_graph->GetName().c_str());652 fused_graph->GetName().c_str());
442 653 
443 GE_ASSERT_GRAPH_SUCCESS(af::AscGraphUtils::ConvertComputeGraphToAscGraph(fused_graph, unfolded_asc_graph));654 GE_ASSERT_GRAPH_SUCCESS(af::AscGraphUtils::ConvertComputeGraphToAscGraph(fused_graph, unfolded_asc_graph));
444- 
445 return af::SUCCESS;655 return af::SUCCESS;
446}656}
447 657 
448-Status FusedGraphUnfolder::SelectCommonLoopAxis(std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,658+Status FusedGraphUnfolder::CloneAscGraphs(const std::map<af::Node *, af::AscGraph> &source_graphs,
449- std::vector<af::AxisPtr> &new_loop_axes) {659+ std::map<af::Node *, af::AscGraph> &cloned_graphs) {
450- GE_ASSERT_TRUE(!asc_backend_to_asc_graph.empty(),660+ // AxisPtr instances must not be shared with the original graphs before commit.
451- "The map is empty after deserialization, which means the fused graph is valid.");661+ for (const auto &iter : source_graphs) {
452- size_t concat_dim = 0UL;662+ std::string serialized_graph;
453- bool has_concat = false;663+ GE_CHK_STATUS_RET(af::AscGraphUtils::SerializeToReadable(iter.second, serialized_graph), "Serialize failed.");
454- std::map<af::Node *, af::AscGraph> post_concat_node_to_asc_graph;664+ af::AscGraph cloned_graph(iter.second.GetName().c_str());
455- std::vector<af::AxisId> loop_axis_ids;665+ GE_CHK_STATUS_RET(af::AscGraphUtils::DeserializeFromReadable(serialized_graph, cloned_graph),
456- std::set<af::Node *> seen_nodes;666+ "Deserialize failed.");
457- for (auto &iter : asc_backend_to_asc_graph) {667+ GE_CHK_STATUS_RET(AscGraphInfoComplete::CompleteApiInfo(cloned_graph), "Complete api info failed.");
458- for (const auto &node : iter.second.GetAllNodes()) {668+ cloned_graphs.emplace(iter.first, std::move(cloned_graph));
669+ }
670+ return af::SUCCESS;
671+}
672+ 
673+Status FusedGraphUnfolder::FindConcatContext(const af::ComputeGraphPtr &fused_graph,
674+ const std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,
675+ af::Node *&concat_ascbc_node, std::vector<af::AxisPtr> &new_loop_axes,
676+ std::vector<af::AxisId> &loop_axis_ids, size_t &concat_dim) {
677+ for (const auto &graph_node : fused_graph->GetDirectNodePtr()) {
678+ const auto graph_iter = asc_backend_to_asc_graph.find(graph_node);
679+ if (graph_iter == asc_backend_to_asc_graph.end()) {
680+ continue;
681+ }
682+ for (const auto &node : graph_iter->second.GetAllNodes()) {
459 if (!af::ops::IsOps<af::ascir_op::Concat>(node)) {683 if (!af::ops::IsOps<af::ascir_op::Concat>(node)) {
460 continue;684 continue;
461 }685 }
462- GE_ASSERT_SUCCESS(ScheduleUtils::GetConcatDim(node, concat_dim));686+ GE_ASSERT_TRUE(concat_ascbc_node == nullptr, "Only one concat is supported in a fused graph.");
463- has_concat = true;687+ GE_CHK_STATUS_RET(ScheduleUtils::GetConcatDim(node, concat_dim), "Get concat dim failed.");
464- auto loop_axis = iter.second.GetAllAxis();688+ concat_ascbc_node = graph_node;
465- loop_axis_ids.resize(loop_axis.size());689+ new_loop_axes = graph_iter->second.GetAllAxis();
466- for (size_t i = 0UL; i < loop_axis.size(); ++i) {690+ for (const auto &axis : new_loop_axes) {
467- loop_axis_ids[i] = loop_axis[i]->id;691+ GE_ASSERT_NOTNULL(axis);
692+ loop_axis_ids.push_back(axis->id);
468 }693 }
469- GE_ASSERT_SUCCESS(CollectPostConcatAscGraphs(iter.first, asc_backend_to_asc_graph, loop_axis, loop_axis_ids,
470- post_concat_node_to_asc_graph));
471- new_loop_axes = iter.second.GetAllAxis();
472- break;
473 }694 }
474 }695 }
475- GE_ASSERT_TRUE(concat_dim < new_loop_axes.size(), "Concat dim [%zu] is greater than loop size:[%zu].", concat_dim,696+ GE_ASSERT_NOTNULL(concat_ascbc_node);
476- new_loop_axes.size());697+ GE_ASSERT_TRUE(concat_dim < new_loop_axes.size(), "Concat dim is invalid.");
477- GE_ASSERT_TRUE(has_concat, "Only subgraphs with concat currently support fused graphs.");698+ return af::SUCCESS;
699+}
478 700 
479- // merge and check701+Status FusedGraphUnfolder::CollectPreConcatMappings(const std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,
702+ af::Node *concat_ascbc_node,
703+ const std::vector<af::AxisId> &loop_axis_ids,
704+ std::map<af::Node *, std::vector<size_t>> &pre_concat_mappings) {
705+ std::queue<af::Node *> pending_nodes;
706+ pre_concat_mappings.emplace(concat_ascbc_node, std::vector<size_t>(loop_axis_ids.size()));
707+ std::iota(pre_concat_mappings[concat_ascbc_node].begin(), pre_concat_mappings[concat_ascbc_node].end(), 0UL);
708+ pending_nodes.push(concat_ascbc_node);
709+ while (!pending_nodes.empty()) {
710+ const auto target_node = pending_nodes.front();
711+ pending_nodes.pop();
712+ const auto target_iter = asc_backend_to_asc_graph.find(target_node);
713+ GE_ASSERT_TRUE(target_iter != asc_backend_to_asc_graph.end(), "Cannot find target ascgraph.");
714+ for (const auto &in_anchor : target_node->GetAllInDataAnchorsPtr()) {
715+ const auto source_out_anchor = in_anchor->GetPeerOutAnchor();
716+ if (source_out_anchor == nullptr ||
717+ asc_backend_to_asc_graph.count(source_out_anchor->GetOwnerNodeBarePtr()) == 0UL) {
718+ continue;
719+ }
720+ const auto source_node = source_out_anchor->GetOwnerNodeBarePtr();
721+ const auto source_iter = asc_backend_to_asc_graph.find(source_node);
722+ const auto source_attr = FindBoundaryTensorAttr(source_iter->second, source_out_anchor->GetIdx(), true);
723+ const auto target_attr = FindBoundaryTensorAttr(target_iter->second, in_anchor->GetIdx(), false);
724+ GE_ASSERT_NOTNULL(source_attr);
725+ GE_ASSERT_NOTNULL(target_attr);
726+ std::vector<size_t> mapping;
727+ if (!BuildGraphAxisMapping(source_iter->second, *source_attr, target_iter->second, *target_attr,
728+ pre_concat_mappings.at(target_node), mapping)) {
729+ GELOGW("Cannot map pre-concat for source node [%s], falling back to merged loop axis.",
730+ source_node->GetNamePtr());
731+ continue;
732+ }
733+ const auto mapping_iter = pre_concat_mappings.find(source_node);
734+ if (mapping_iter == pre_concat_mappings.end()) {
735+ pre_concat_mappings.emplace(source_node, std::move(mapping));
736+ pending_nodes.push(source_node);
737+ } else {
738+ const auto previous_mapping = mapping_iter->second;
739+ GE_ASSERT_TRUE(MergeGraphAxisMapping(mapping_iter->second, mapping), "Conflicting boundary mappings.");
740+ // Newly constrained target axes may unlock a complete mapping for its upstream producers.
741+ if (mapping_iter->second != previous_mapping) {
742+ pending_nodes.push(source_node);
743+ }
744+ }
745+ }
746+ }
747+ return af::SUCCESS;
748+}
749+ 
750+Status FusedGraphUnfolder::ApplyPreConcatMappings(
751+ const std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,
752+ const std::map<af::Node *, af::AscGraph> &post_concat_node_to_asc_graph,
753+ const std::map<af::Node *, std::vector<size_t>> &pre_concat_mappings, const std::vector<af::AxisPtr> &new_loop_axes,
754+ const std::vector<af::AxisId> &loop_axis_ids, const size_t concat_dim) {
480 for (const auto &iter : asc_backend_to_asc_graph) {755 for (const auto &iter : asc_backend_to_asc_graph) {
481- if (post_concat_node_to_asc_graph.count(iter.first) == 0UL) {756+ if (post_concat_node_to_asc_graph.count(iter.first) != 0UL) {
482- GE_ASSERT_SUCCESS(ApplyMergedLoopAxis(iter.second, new_loop_axes, loop_axis_ids, concat_dim));757+ continue;
483 }758 }
759+ const auto mapping_iter = pre_concat_mappings.find(iter.first);
760+ if (mapping_iter == pre_concat_mappings.end()) {
761+ GE_CHK_STATUS_RET(ApplyMergedLoopAxis(iter.second, new_loop_axes, loop_axis_ids, concat_dim), "Apply failed.");
762+ continue;
763+ }
764+ GE_ASSERT_TRUE(IsGraphAxisMappingComplete(mapping_iter->second), "Pre-concat graph has unmapped axes.");
765+ GE_CHK_STATUS_RET(ApplyMappedLoopAxis(iter.second, new_loop_axes, loop_axis_ids, mapping_iter->second),
766+ "Apply failed.");
484 }767 }
768+ return af::SUCCESS;
769+}
485 770 
771+Status FusedGraphUnfolder::SelectCommonLoopAxis(const af::ComputeGraphPtr &fused_graph,
772+ std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,
773+ std::vector<af::AxisPtr> &new_loop_axes) {
774+ GE_ASSERT_TRUE(!asc_backend_to_asc_graph.empty(), "The map is empty after deserialization.");
775+ std::map<af::Node *, af::AscGraph> cloned_graphs;
776+ GE_CHK_STATUS_RET(CloneAscGraphs(asc_backend_to_asc_graph, cloned_graphs), "Clone ascgraphs failed.");
777+ size_t concat_dim = 0UL;
778+ af::Node *concat_ascbc_node = nullptr;
779+ std::vector<af::AxisId> loop_axis_ids;
780+ GE_CHK_STATUS_RET(
781+ FindConcatContext(fused_graph, cloned_graphs, concat_ascbc_node, new_loop_axes, loop_axis_ids, concat_dim),
782+ "Find concat context failed.");
783+ std::map<af::Node *, af::AscGraph> post_concat_graphs;
784+ GE_CHK_STATUS_RET(
785+ CollectPostConcatAscGraphs(concat_ascbc_node, cloned_graphs, new_loop_axes, loop_axis_ids, post_concat_graphs),
786+ "Collect post-concat graphs failed.");
787+ std::map<af::Node *, std::vector<size_t>> pre_concat_mappings;
788+ GE_CHK_STATUS_RET(CollectPreConcatMappings(cloned_graphs, concat_ascbc_node, loop_axis_ids, pre_concat_mappings),
789+ "Collect pre-concat mappings failed.");
790+ GE_CHK_STATUS_RET(ApplyPreConcatMappings(cloned_graphs, post_concat_graphs, pre_concat_mappings, new_loop_axes,
791+ loop_axis_ids, concat_dim),
792+ "Apply pre-concat mappings failed.");
793+ // The original map remains untouched until every clone has been mapped successfully.
794+ asc_backend_to_asc_graph.swap(cloned_graphs);
486 return af::SUCCESS;795 return af::SUCCESS;
487}796}
488 797 
@@ -609,6 +918,71 @@ Status FusedGraphUnfolder::ApplyMergedLoopAxis(const af::AscGraph &graph, const
609 return af::SUCCESS;918 return af::SUCCESS;
610}919}
611 920 
921+Status FusedGraphUnfolder::ApplyMappedLoopAxis(const af::AscGraph &graph, const std::vector<af::AxisPtr> &new_loop_axes,
922+ const std::vector<af::AxisId> &loop_axis_ids,
923+ const std::vector<size_t> &old_to_global) {
924+ auto compute_graph = af::AscGraphUtils::GetComputeGraph(graph);
925+ GE_ASSERT_NOTNULL(compute_graph);
926+ const auto graph_attr = compute_graph->GetOrCreateAttrsGroup<af::AscGraphAttr>();
927+ GE_ASSERT_NOTNULL(graph_attr);
928+ const auto old_axis = graph_attr->axis;
929+ GE_ASSERT_TRUE(old_axis.size() == old_to_global.size(), "Axis mapping rank mismatch, graph:[%s].",
930+ graph.GetName().c_str());
931+ std::map<af::AxisId, size_t> old_axis_to_global;
932+ std::set<size_t> mapped_global_axes;
933+ for (size_t index = 0UL; index < old_axis.size(); ++index) {
934+ GE_ASSERT_NOTNULL(old_axis[index]);
935+ GE_ASSERT_TRUE(old_to_global[index] < loop_axis_ids.size(), "Axis mapping index is invalid, graph:[%s].",
936+ graph.GetName().c_str());
937+ GE_ASSERT_TRUE(mapped_global_axes.emplace(old_to_global[index]).second, "Axis mapping is not injective.");
938+ GE_ASSERT_TRUE(old_axis_to_global.emplace(old_axis[index]->id, old_to_global[index]).second,
939+ "Graph has duplicate axis id.");
940+ }
941+ graph_attr->axis = new_loop_axes;
942+ for (const auto &node : graph.GetAllNodes()) {
943+ GE_ASSERT_NOTNULL(node);
944+ if (ScheduleUtils::IsBuffer(node)) {
945+ continue;
946+ }
947+ node->attr.sched.axis = loop_axis_ids;
948+ if (node->attr.sched.loop_axis != af::kIdNone) {
949+ const auto loop_iter = old_axis_to_global.find(node->attr.sched.loop_axis);
950+ GE_ASSERT_TRUE(loop_iter != old_axis_to_global.end(), "Cannot map loop axis, node:[%s].", node->GetNamePtr());
951+ node->attr.sched.loop_axis = loop_axis_ids[loop_iter->second];
952+ }
953+ for (auto &output : node->outputs()) {
954+ GE_ASSERT_NOTNULL(output);
955+ GE_CHK_STATUS_RET(RewriteTensorAxis(node, output->attr, old_axis_to_global, loop_axis_ids),
956+ "Rewrite tensor axis failed.");
957+ }
958+ }
959+ return af::SUCCESS;
960+}
961+ 
962+Status FusedGraphUnfolder::RewriteTensorAxis(const af::AscNodePtr &node, af::AscTensorAttr &tensor_attr,
963+ const std::map<af::AxisId, size_t> &old_axis_to_global,
964+ const std::vector<af::AxisId> &loop_axis_ids) {
965+ GE_ASSERT_TRUE(IsTensorAttrValid(tensor_attr), "Tensor axis attr size mismatch, node:[%s].", node->GetNamePtr());
966+ std::vector<af::Expression> new_repeats(loop_axis_ids.size(), af::sym::kSymbolOne);
967+ std::vector<af::Expression> new_strides(loop_axis_ids.size(), af::sym::kSymbolZero);
968+ for (size_t index = 0UL; index < tensor_attr.axis.size(); ++index) {
969+ const auto axis_iter = old_axis_to_global.find(tensor_attr.axis[index]);
970+ GE_ASSERT_TRUE(axis_iter != old_axis_to_global.end(), "Cannot map tensor axis, node:[%s].", node->GetNamePtr());
971+ new_repeats[axis_iter->second] = tensor_attr.repeats[index];
972+ new_strides[axis_iter->second] = tensor_attr.strides[index];
973+ }
974+ tensor_attr.axis = loop_axis_ids;
975+ // Preserve local repeat/stride at mapped positions; missing global axes are unit/zero-stride.
976+ tensor_attr.repeats = std::move(new_repeats);
977+ tensor_attr.strides = std::move(new_strides);
978+ for (auto &axis_id : tensor_attr.vectorized_axis) {
979+ const auto axis_iter = old_axis_to_global.find(axis_id);
980+ GE_ASSERT_TRUE(axis_iter != old_axis_to_global.end(), "Cannot map vectorized axis, node:[%s].", node->GetNamePtr());
981+ axis_id = loop_axis_ids[axis_iter->second];
982+ }
983+ return af::SUCCESS;
984+}
985+ 
612Status FusedGraphUnfolder::DoAxisMappingForConstPostAscGraph(const af::AscGraph &graph,986Status FusedGraphUnfolder::DoAxisMappingForConstPostAscGraph(const af::AscGraph &graph,
613 const std::vector<af::AxisPtr> &new_loop_axes,987 const std::vector<af::AxisPtr> &new_loop_axes,
614 const std::vector<af::AxisId> &loop_axis_ids) {988 const std::vector<af::AxisId> &loop_axis_ids) {
Mautofuse/optimize/fused_graph/fused_graph_unfolder.h+59-1
@@ -28,7 +28,59 @@ class FusedGraphUnfolder {
28 af::AscGraph &unfolded_asc_graph);28 af::AscGraph &unfolded_asc_graph);
29 29 
30 private:30 private:
31- static Status SelectCommonLoopAxis(std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,31+ enum class AxisMappingStatus {
32+ kSuccess, // 找到唯一合法映射。
33+ kUnsupported, // 无法找到合法映射,例如 rank 不合法、非 unit 插入轴、symbolic equality 无法静态证明。
34+ kAmbiguous, // 多个合法映射导致歧义。
35+ };
36+ enum class AxisMappingFailureReason {
37+ kNone,
38+ kInvalidRank,
39+ kInvalidTensorAttr,
40+ kNonUnitInsertedAxis,
41+ kMultipleMappings,
42+ };
43+ struct AxisMappingResult {
44+ AxisMappingStatus status = AxisMappingStatus::kUnsupported;
45+ AxisMappingFailureReason reason = AxisMappingFailureReason::kNone;
46+ std::vector<size_t> old_to_global; // source tensor 第 i 个维度映射到 target tensor 第几个维度。
47+ std::vector<bool> inserted_axes; // target tensor 哪些维度是 source 中没有的插入轴。
48+ };
49+ static bool IsTensorAttrValid(const af::AscTensorAttr &attr);
50+ static bool IsAxisMatch(const af::AscTensorAttr &source_attr, size_t source_index,
51+ const af::AscTensorAttr &target_attr, size_t target_index);
52+ static void SearchLocalAxisMappings(const af::AscTensorAttr &source_attr, const af::AscTensorAttr &target_attr,
53+ size_t source_index, size_t target_index, std::vector<size_t> &mapping,
54+ std::vector<std::vector<size_t>> &candidates);
55+ static Status BuildLocalAxisMapping(const af::AscTensorAttr &source_attr, const af::AscTensorAttr &target_attr,
56+ AxisMappingResult &result);
57+ static bool BuildAxisIndex(const std::vector<af::AxisPtr> &axes, std::map<af::AxisId, size_t> &axis_to_index);
58+ static bool ComposeGraphAxisMapping(const af::AscTensorAttr &source_attr, const af::AscTensorAttr &target_attr,
59+ const std::map<af::AxisId, size_t> &source_axis_to_index,
60+ const std::map<af::AxisId, size_t> &target_axis_to_index,
61+ const std::vector<size_t> &target_to_global,
62+ std::vector<size_t> &source_to_global);
63+ static bool MergeGraphAxisMapping(std::vector<size_t> &existing_mapping, const std::vector<size_t> &new_mapping);
64+ static bool IsGraphAxisMappingComplete(const std::vector<size_t> &mapping);
65+ static bool BuildGraphAxisMapping(const af::AscGraph &source_graph, const af::AscTensorAttr &source_attr,
66+ const af::AscGraph &target_graph, const af::AscTensorAttr &target_attr,
67+ const std::vector<size_t> &target_to_global, std::vector<size_t> &source_to_global);
68+ static Status CloneAscGraphs(const std::map<af::Node *, af::AscGraph> &source_graphs,
69+ std::map<af::Node *, af::AscGraph> &cloned_graphs);
70+ static Status FindConcatContext(const af::ComputeGraphPtr &fused_graph,
71+ const std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,
72+ af::Node *&concat_ascbc_node, std::vector<af::AxisPtr> &new_loop_axes,
73+ std::vector<af::AxisId> &loop_axis_ids, size_t &concat_dim);
74+ static Status CollectPreConcatMappings(const std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,
75+ af::Node *concat_ascbc_node, const std::vector<af::AxisId> &loop_axis_ids,
76+ std::map<af::Node *, std::vector<size_t>> &pre_concat_mappings);
77+ static Status ApplyPreConcatMappings(const std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,
78+ const std::map<af::Node *, af::AscGraph> &post_concat_node_to_asc_graph,
79+ const std::map<af::Node *, std::vector<size_t>> &pre_concat_mappings,
80+ const std::vector<af::AxisPtr> &new_loop_axes,
81+ const std::vector<af::AxisId> &loop_axis_ids, size_t concat_dim);
82+ static Status SelectCommonLoopAxis(const af::ComputeGraphPtr &fused_graph,
83+ std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,
32 std::vector<af::AxisPtr> &new_loop_axes);84 std::vector<af::AxisPtr> &new_loop_axes);
33 static Status MarkAllOutputAxisId(af::Node *concat_ascbc_node,85 static Status MarkAllOutputAxisId(af::Node *concat_ascbc_node,
34 std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,86 std::map<af::Node *, af::AscGraph> &asc_backend_to_asc_graph,
@@ -44,6 +96,12 @@ class FusedGraphUnfolder {
44 96 
45 static Status ApplyMergedLoopAxis(const af::AscGraph &graph, const std::vector<af::AxisPtr> &new_loop_axes,97 static Status ApplyMergedLoopAxis(const af::AscGraph &graph, const std::vector<af::AxisPtr> &new_loop_axes,
46 const std::vector<af::AxisId> &loop_axis_ids, const size_t concat_dim);98 const std::vector<af::AxisId> &loop_axis_ids, const size_t concat_dim);
99+ static Status ApplyMappedLoopAxis(const af::AscGraph &graph, const std::vector<af::AxisPtr> &new_loop_axes,
100+ const std::vector<af::AxisId> &loop_axis_ids,
101+ const std::vector<size_t> &old_to_global);
102+ static Status RewriteTensorAxis(const af::AscNodePtr &node, af::AscTensorAttr &tensor_attr,
103+ const std::map<af::AxisId, size_t> &old_axis_to_global,
104+ const std::vector<af::AxisId> &loop_axis_ids);
47 static Status UnfoldAscbcNode(af::Node *const &ascbc_node, const af::AscGraph &asc_graph,105 static Status UnfoldAscbcNode(af::Node *const &ascbc_node, const af::AscGraph &asc_graph,
48 const af::ComputeGraphPtr &target_computer_graph);106 const af::ComputeGraphPtr &target_computer_graph);
49 static Status ReAssembleDataIrAttr(const af::ComputeGraphPtr &fused_graph,107 static Status ReAssembleDataIrAttr(const af::ComputeGraphPtr &fused_graph,
Mautofuse/tests/st/ascir/code_dumper/code_dumper_unittest.cc+0-12
@@ -55,7 +55,6 @@ void ConstructAscGraph(AscGraph &graph) {
55 Axis &s1_axis = graph.CreateAxis("S1", s1);55 Axis &s1_axis = graph.CreateAxis("S1", s1);
56 56 
57 ascir_op::Scalar scalar("Scalar", graph);57 ascir_op::Scalar scalar("Scalar", graph);
58- scalar.attr.sched.exec_order = 0;
59 scalar.attr.sched.axis = {s0_axis.id, s1_axis.id};58 scalar.attr.sched.axis = {s0_axis.id, s1_axis.id};
60 scalar.y.dtype = ge::DT_FLOAT16;59 scalar.y.dtype = ge::DT_FLOAT16;
61 scalar.y.format = ge::FORMAT_ND;60 scalar.y.format = ge::FORMAT_ND;
@@ -65,7 +64,6 @@ void ConstructAscGraph(AscGraph &graph) {
65 scalar.ir_attr.SetValue("Test");64 scalar.ir_attr.SetValue("Test");
66 65 
67 ascir_op::Data data1("data1", graph);66 ascir_op::Data data1("data1", graph);
68- data1.attr.sched.exec_order = 0;
69 data1.attr.sched.axis = {s0_axis.id, s1_axis.id};67 data1.attr.sched.axis = {s0_axis.id, s1_axis.id};
70 data1.y.dtype = ge::DT_FLOAT16;68 data1.y.dtype = ge::DT_FLOAT16;
71 data1.y.format = ge::FORMAT_ND;69 data1.y.format = ge::FORMAT_ND;
@@ -75,7 +73,6 @@ void ConstructAscGraph(AscGraph &graph) {
75 data1.ir_attr.SetIndex(2);73 data1.ir_attr.SetIndex(2);
76 74 
77 ascir_op::Data data2("data2", graph);75 ascir_op::Data data2("data2", graph);
78- data2.attr.sched.exec_order = 0;
79 data2.attr.sched.axis = {s0_axis.id, s1_axis.id};76 data2.attr.sched.axis = {s0_axis.id, s1_axis.id};
80 data2.y.dtype = ge::DT_FLOAT16;77 data2.y.dtype = ge::DT_FLOAT16;
81 data2.y.format = ge::FORMAT_ND;78 data2.y.format = ge::FORMAT_ND;
@@ -87,7 +84,6 @@ void ConstructAscGraph(AscGraph &graph) {
87 ascir_op::Add add("add");84 ascir_op::Add add("add");
88 add.x1 = scalar.y;85 add.x1 = scalar.y;
89 add.x2 = scalar.y;86 add.x2 = scalar.y;
90- add.attr.sched.exec_order = 1;
91 add.attr.sched.axis = {s0_axis.id, s1_axis.id};87 add.attr.sched.axis = {s0_axis.id, s1_axis.id};
92 add.y.dtype = ge::DT_FLOAT16;88 add.y.dtype = ge::DT_FLOAT16;
93 add.y.format = ge::FORMAT_ND;89 add.y.format = ge::FORMAT_ND;
@@ -97,7 +93,6 @@ void ConstructAscGraph(AscGraph &graph) {
97 93 
98 ascir_op::Exp exp("exp");94 ascir_op::Exp exp("exp");
99 exp.x = scalar.y;95 exp.x = scalar.y;
100- exp.attr.sched.exec_order = 2;
101 exp.attr.sched.axis = {s0_axis.id, s1_axis.id};96 exp.attr.sched.axis = {s0_axis.id, s1_axis.id};
102 exp.y.dtype = ge::DT_FLOAT16;97 exp.y.dtype = ge::DT_FLOAT16;
103 exp.y.format = ge::FORMAT_ND;98 exp.y.format = ge::FORMAT_ND;
@@ -107,7 +102,6 @@ void ConstructAscGraph(AscGraph &graph) {
107 102 
108 ascir_op::Concat concat("concat");103 ascir_op::Concat concat("concat");
109 concat.x = {add.y, exp.y};104 concat.x = {add.y, exp.y};
110- concat.attr.sched.exec_order = 3;
111 concat.attr.sched.axis = {s0_axis.id, s1_axis.id};105 concat.attr.sched.axis = {s0_axis.id, s1_axis.id};
112 concat.y.dtype = ge::DT_FLOAT16;106 concat.y.dtype = ge::DT_FLOAT16;
113 concat.y.format = ge::FORMAT_ND;107 concat.y.format = ge::FORMAT_ND;
@@ -119,7 +113,6 @@ void ConstructAscGraph(AscGraph &graph) {
119 fake_opa.x1 = exp.y;113 fake_opa.x1 = exp.y;
120 fake_opa.x2 = exp.y; // 可选输入114 fake_opa.x2 = exp.y; // 可选输入
121 fake_opa.x3 = data1.y;115 fake_opa.x3 = data1.y;
122- fake_opa.attr.sched.exec_order = 4;
123 fake_opa.attr.sched.axis = {s0_axis.id, s1_axis.id};116 fake_opa.attr.sched.axis = {s0_axis.id, s1_axis.id};
124 fake_opa.y.dtype = ge::DT_FLOAT16;117 fake_opa.y.dtype = ge::DT_FLOAT16;
125 fake_opa.y.format = ge::FORMAT_ND;118 fake_opa.y.format = ge::FORMAT_ND;
@@ -132,7 +125,6 @@ void ConstructAscGraph(AscGraph &graph) {
132 leaky_relu.ir_attr.SetNegative_slope(1);125 leaky_relu.ir_attr.SetNegative_slope(1);
133 126 
134 ascir_op::Output output("output");127 ascir_op::Output output("output");
135- output.attr.sched.exec_order = 4;
136 output.x = fake_opa.y;128 output.x = fake_opa.y;
137 output.ir_attr.SetIndex(1);129 output.ir_attr.SetIndex(1);
138}130}
@@ -225,7 +217,6 @@ void ConstructWrongAscGraph(AscGraph &graph) {
225 Axis &s1_axis = graph.CreateAxis("S1", s1);217 Axis &s1_axis = graph.CreateAxis("S1", s1);
226 218 
227 ascir_op::Data data("data", graph);219 ascir_op::Data data("data", graph);
228- data.attr.sched.exec_order = 0;
229 data.attr.sched.axis = {s0_axis.id, s1_axis.id};220 data.attr.sched.axis = {s0_axis.id, s1_axis.id};
230 data.y.dtype = ge::DT_FLOAT16;221 data.y.dtype = ge::DT_FLOAT16;
231 data.y.format = ge::FORMAT_ND;222 data.y.format = ge::FORMAT_ND;
@@ -236,7 +227,6 @@ void ConstructWrongAscGraph(AscGraph &graph) {
236 227 
237 ascir_op::Add add("add");228 ascir_op::Add add("add");
238 add.x1 = data.y;229 add.x1 = data.y;
239- add.attr.sched.exec_order = 1;
240 add.attr.sched.axis = {s0_axis.id, s1_axis.id};230 add.attr.sched.axis = {s0_axis.id, s1_axis.id};
241 add.y.dtype = ge::DT_FLOAT16;231 add.y.dtype = ge::DT_FLOAT16;
242 add.y.format = ge::FORMAT_ND;232 add.y.format = ge::FORMAT_ND;
@@ -246,7 +236,6 @@ void ConstructWrongAscGraph(AscGraph &graph) {
246 236 
247 ascir_op::Exp exp("exp");237 ascir_op::Exp exp("exp");
248 exp.x = add.y;238 exp.x = add.y;
249- exp.attr.sched.exec_order = 2;
250 exp.attr.sched.axis = {s0_axis.id, s1_axis.id};239 exp.attr.sched.axis = {s0_axis.id, s1_axis.id};
251 exp.y.dtype = ge::DT_FLOAT16;240 exp.y.dtype = ge::DT_FLOAT16;
252 exp.y.format = ge::FORMAT_ND;241 exp.y.format = ge::FORMAT_ND;
@@ -257,7 +246,6 @@ void ConstructWrongAscGraph(AscGraph &graph) {
257 add.x2 = exp.y;246 add.x2 = exp.y;
258 247 
259 ascir_op::Output output("output");248 ascir_op::Output output("output");
260- output.attr.sched.exec_order = 4;
261 output.x = add.y;249 output.x = add.y;
262 output.ir_attr.SetIndex(1);250 output.ir_attr.SetIndex(1);
263}251}
Mautofuse/tests/st/att/testcase/scenario/add_layer_norm/test_add_layer_norm.cpp+77-87
@@ -32,10 +32,9 @@ using namespace att;
32 32 
33namespace {33namespace {
34template <typename NodeT>34template <typename NodeT>
35-void SetNodeScheduleAndTensor(NodeT &node, int &exec_order, std::initializer_list<int64_t> axis, ge::DataType dtype,35+void SetNodeScheduleAndTensor(NodeT &node, std::initializer_list<int64_t> axis, ge::DataType dtype,
36 std::initializer_list<af::Expression> repeats,36 std::initializer_list<af::Expression> repeats,
37 std::initializer_list<af::Expression> strides) {37 std::initializer_list<af::Expression> strides) {
38- node.attr.sched.exec_order = exec_order++;
39 node.attr.sched.axis = axis;38 node.attr.sched.axis = axis;
40 node.y.dtype = dtype;39 node.y.dtype = dtype;
41 *node.y.axis = axis;40 *node.y.axis = axis;
@@ -44,11 +43,10 @@ void SetNodeScheduleAndTensor(NodeT &node, int &exec_order, std::initializer_lis
44}43}
45 44 
46template <typename NodeT, typename InputT>45template <typename NodeT, typename InputT>
47-void InitInputNode(NodeT &node, const InputT &input, int &exec_order, std::initializer_list<int64_t> axis,46+void InitInputNode(NodeT &node, const InputT &input, std::initializer_list<int64_t> axis, ge::DataType dtype,
48- ge::DataType dtype, std::initializer_list<af::Expression> repeats,47+ std::initializer_list<af::Expression> repeats, std::initializer_list<af::Expression> strides) {
49- std::initializer_list<af::Expression> strides) {
50 node.x = input;48 node.x = input;
51- SetNodeScheduleAndTensor(node, exec_order, axis, dtype, repeats, strides);49+ SetNodeScheduleAndTensor(node, axis, dtype, repeats, strides);
52}50}
53 51 
54template <typename NodeT>52template <typename NodeT>
@@ -71,12 +69,12 @@ void SetQueueNode(const NodeT &node, int &tensor_id, int queue_id, af::Position
71 node->outputs[0].attr.opt.ref_tensor = ascir::ID_NONE;69 node->outputs[0].attr.opt.ref_tensor = ascir::ID_NONE;
72}70}
73 71 
74-void CreateDataAndLoad(Load &load, ascir::HintGraph &graph, const char *data_name, int &exec_order,72+void CreateDataAndLoad(Load &load, ascir::HintGraph &graph, const char *data_name, std::initializer_list<int64_t> axis,
75- std::initializer_list<int64_t> axis, ge::DataType dtype,73+ ge::DataType dtype, std::initializer_list<af::Expression> repeats,
76- std::initializer_list<af::Expression> repeats, std::initializer_list<af::Expression> strides) {74+ std::initializer_list<af::Expression> strides) {
77 Data data(data_name, graph);75 Data data(data_name, graph);
78- SetNodeScheduleAndTensor(data, exec_order, axis, dtype, repeats, strides);76+ SetNodeScheduleAndTensor(data, axis, dtype, repeats, strides);
79- InitInputNode(load, data.y, exec_order, axis, dtype, repeats, strides);77+ InitInputNode(load, data.y, axis, dtype, repeats, strides);
80}78}
81 79 
82template <typename NodeT>80template <typename NodeT>
@@ -141,55 +139,53 @@ void Add_Layer_Norm_Normal_BeforeAutofuseConstInput(ascir::HintGraph &graph) {
141 auto r = graph.CreateAxis("R", R);139 auto r = graph.CreateAxis("R", R);
142 auto bl = graph.CreateAxis("BL", BL);140 auto bl = graph.CreateAxis("BL", BL);
143 const std::initializer_list<int64_t> axes = {a.id, r.id, bl.id};141 const std::initializer_list<int64_t> axes = {a.id, r.id, bl.id};
144- 
145- int exec_order = 0;
146 Load x1Local("x1Local");142 Load x1Local("x1Local");
147- CreateDataAndLoad(x1Local, graph, "x1", exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});143+ CreateDataAndLoad(x1Local, graph, "x1", axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
148 Load x2Local("x2Local");144 Load x2Local("x2Local");
149- CreateDataAndLoad(x2Local, graph, "x2", exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});145+ CreateDataAndLoad(x2Local, graph, "x2", axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
150 Load biasLocal("biasLocal");146 Load biasLocal("biasLocal");
151- CreateDataAndLoad(biasLocal, graph, "bias", exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});147+ CreateDataAndLoad(biasLocal, graph, "bias", axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
152 148 
153 Concat mean("mean");149 Concat mean("mean");
154 mean.x = {x1Local.y, x2Local.y, biasLocal.y};150 mean.x = {x1Local.y, x2Local.y, biasLocal.y};
155- SetNodeScheduleAndTensor(mean, exec_order, axes, ge::DT_FLOAT, {A, R, ONE}, {R, ONE, ZERO});151+ SetNodeScheduleAndTensor(mean, axes, ge::DT_FLOAT, {A, R, ONE}, {R, ONE, ZERO});
156 152 
157 Store x_out("x_out");153 Store x_out("x_out");
158- InitInputNode(x_out, mean.y, exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});154+ InitInputNode(x_out, mean.y, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
159 Store mean_out("mean_out");155 Store mean_out("mean_out");
160- InitInputNode(mean_out, mean.y, exec_order, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});156+ InitInputNode(mean_out, mean.y, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});
161 157 
162 Data one("one", graph);158 Data one("one", graph);
163- SetNodeScheduleAndTensor(one, exec_order, axes, ge::DT_FLOAT, {ONE, ONE, BL}, {ZERO, ZERO, ONE});159+ SetNodeScheduleAndTensor(one, axes, ge::DT_FLOAT, {ONE, ONE, BL}, {ZERO, ZERO, ONE});
164 160 
165 Concat rstd("rstd");161 Concat rstd("rstd");
166 rstd.x = {mean.y, mean.y, one.y};162 rstd.x = {mean.y, mean.y, one.y};
167- SetNodeScheduleAndTensor(rstd, exec_order, axes, ge::DT_FLOAT, {A, R, ONE}, {R, ONE, ZERO});163+ SetNodeScheduleAndTensor(rstd, axes, ge::DT_FLOAT, {A, R, ONE}, {R, ONE, ZERO});
168 164 
169 Store rstd_out("rstd_out");165 Store rstd_out("rstd_out");
170- InitInputNode(rstd_out, rstd.y, exec_order, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});166+ InitInputNode(rstd_out, rstd.y, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});
171 167 
172 Load betaLocal("betaLocal");168 Load betaLocal("betaLocal");
173- CreateDataAndLoad(betaLocal, graph, "beta", exec_order, axes, ge::DT_FLOAT16, {ONE, R, ONE}, {ZERO, ONE, ZERO});169+ CreateDataAndLoad(betaLocal, graph, "beta", axes, ge::DT_FLOAT16, {ONE, R, ONE}, {ZERO, ONE, ZERO});
174 Load gammaLocal("gammaLocal");170 Load gammaLocal("gammaLocal");
175- CreateDataAndLoad(gammaLocal, graph, "gamma", exec_order, axes, ge::DT_FLOAT16, {ONE, R, ONE}, {ZERO, ONE, ZERO});171+ CreateDataAndLoad(gammaLocal, graph, "gamma", axes, ge::DT_FLOAT16, {ONE, R, ONE}, {ZERO, ONE, ZERO});
176 172 
177 Concat y("y");173 Concat y("y");
178 y.attr.api.unit = af::ComputeUnit::kUnitVector;174 y.attr.api.unit = af::ComputeUnit::kUnitVector;
179 y.x = {rstd.y, betaLocal.y, gammaLocal.y, rstd.y};175 y.x = {rstd.y, betaLocal.y, gammaLocal.y, rstd.y};
180- SetNodeScheduleAndTensor(y, exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});176+ SetNodeScheduleAndTensor(y, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
181 177 
182 Store y_out("y_out");178 Store y_out("y_out");
183- InitInputNode(y_out, y.y, exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});179+ InitInputNode(y_out, y.y, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
184 180 
185 Output buf1("buf1");181 Output buf1("buf1");
186- InitInputNode(buf1, x_out.y, exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});182+ InitInputNode(buf1, x_out.y, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
187 Output buf2("buf2");183 Output buf2("buf2");
188- InitInputNode(buf2, mean_out.y, exec_order, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});184+ InitInputNode(buf2, mean_out.y, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});
189 Output buf3("buf3");185 Output buf3("buf3");
190- InitInputNode(buf3, rstd_out.y, exec_order, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});186+ InitInputNode(buf3, rstd_out.y, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});
191 Output buf("buf");187 Output buf("buf");
192- InitInputNode(buf, y_out.y, exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});188+ InitInputNode(buf, y_out.y, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
193}189}
194 190 
195void Add_Layer_Norm_Normal_BeforeAutofuse(ascir::HintGraph &graph, const std::string &ident = "") {191void Add_Layer_Norm_Normal_BeforeAutofuse(ascir::HintGraph &graph, const std::string &ident = "") {
@@ -209,55 +205,53 @@ void Add_Layer_Norm_Normal_BeforeAutofuse(ascir::HintGraph &graph, const std::st
209 auto r = graph.CreateAxis(axis_name2, R);205 auto r = graph.CreateAxis(axis_name2, R);
210 auto bl = graph.CreateAxis(axis_name3, BL);206 auto bl = graph.CreateAxis(axis_name3, BL);
211 const std::initializer_list<int64_t> axes = {a.id, r.id, bl.id};207 const std::initializer_list<int64_t> axes = {a.id, r.id, bl.id};
212- 
213- int exec_order = 0;
214 Load x1Local("x1Local");208 Load x1Local("x1Local");
215- CreateDataAndLoad(x1Local, graph, "x1", exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});209+ CreateDataAndLoad(x1Local, graph, "x1", axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
216 Load x2Local("x2Local");210 Load x2Local("x2Local");
217- CreateDataAndLoad(x2Local, graph, "x2", exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});211+ CreateDataAndLoad(x2Local, graph, "x2", axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
218 Load biasLocal("biasLocal");212 Load biasLocal("biasLocal");
219- CreateDataAndLoad(biasLocal, graph, "bias", exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});213+ CreateDataAndLoad(biasLocal, graph, "bias", axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
220 214 
221 Concat mean("mean");215 Concat mean("mean");
222 mean.x = {x1Local.y, x2Local.y, biasLocal.y};216 mean.x = {x1Local.y, x2Local.y, biasLocal.y};
223- SetNodeScheduleAndTensor(mean, exec_order, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});217+ SetNodeScheduleAndTensor(mean, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});
224 218 
225 Store x_out("x_out");219 Store x_out("x_out");
226- InitInputNode(x_out, mean.y, exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});220+ InitInputNode(x_out, mean.y, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
227 Store mean_out("mean_out");221 Store mean_out("mean_out");
228- InitInputNode(mean_out, mean.y, exec_order, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});222+ InitInputNode(mean_out, mean.y, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});
229 223 
230 Data one("one", graph);224 Data one("one", graph);
231- SetNodeScheduleAndTensor(one, exec_order, axes, ge::DT_FLOAT, {ONE, ONE, BL}, {ZERO, ZERO, ONE});225+ SetNodeScheduleAndTensor(one, axes, ge::DT_FLOAT, {ONE, ONE, BL}, {ZERO, ZERO, ONE});
232 226 
233 Concat rstd("rstd");227 Concat rstd("rstd");
234 rstd.x = {mean.y, mean.y, one.y};228 rstd.x = {mean.y, mean.y, one.y};
235- SetNodeScheduleAndTensor(rstd, exec_order, axes, ge::DT_FLOAT, {A, R, ONE}, {R, ONE, ZERO});229+ SetNodeScheduleAndTensor(rstd, axes, ge::DT_FLOAT, {A, R, ONE}, {R, ONE, ZERO});
236 230 
237 Store rstd_out("rstd_out");231 Store rstd_out("rstd_out");
238- InitInputNode(rstd_out, rstd.y, exec_order, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});232+ InitInputNode(rstd_out, rstd.y, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});
239 233 
240 Load betaLocal("betaLocal");234 Load betaLocal("betaLocal");
241- CreateDataAndLoad(betaLocal, graph, "beta", exec_order, axes, ge::DT_FLOAT16, {ONE, R, ONE}, {ZERO, ONE, ZERO});235+ CreateDataAndLoad(betaLocal, graph, "beta", axes, ge::DT_FLOAT16, {ONE, R, ONE}, {ZERO, ONE, ZERO});
242 Load gammaLocal("gammaLocal");236 Load gammaLocal("gammaLocal");
243- CreateDataAndLoad(gammaLocal, graph, "gamma", exec_order, axes, ge::DT_FLOAT16, {ONE, R, ONE}, {ZERO, ONE, ZERO});237+ CreateDataAndLoad(gammaLocal, graph, "gamma", axes, ge::DT_FLOAT16, {ONE, R, ONE}, {ZERO, ONE, ZERO});
244 238 
245 Concat y("y");239 Concat y("y");
246 y.attr.api.unit = af::ComputeUnit::kUnitVector;240 y.attr.api.unit = af::ComputeUnit::kUnitVector;
247 y.x = {rstd.y, betaLocal.y, gammaLocal.y, rstd.y};241 y.x = {rstd.y, betaLocal.y, gammaLocal.y, rstd.y};
248- SetNodeScheduleAndTensor(y, exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});242+ SetNodeScheduleAndTensor(y, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
249 243 
250 Store y_out("y_out");244 Store y_out("y_out");
251- InitInputNode(y_out, y.y, exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});245+ InitInputNode(y_out, y.y, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
252 246 
253 Output buf1("buf1");247 Output buf1("buf1");
254- InitInputNode(buf1, x_out.y, exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});248+ InitInputNode(buf1, x_out.y, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
255 Output buf2("buf2");249 Output buf2("buf2");
256- InitInputNode(buf2, mean_out.y, exec_order, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});250+ InitInputNode(buf2, mean_out.y, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});
257 Output buf3("buf3");251 Output buf3("buf3");
258- InitInputNode(buf3, rstd_out.y, exec_order, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});252+ InitInputNode(buf3, rstd_out.y, axes, ge::DT_FLOAT, {A, ONE, ONE}, {ONE, ZERO, ZERO});
259 Output buf("buf");253 Output buf("buf");
260- InitInputNode(buf, y_out.y, exec_order, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});254+ InitInputNode(buf, y_out.y, axes, ge::DT_FLOAT16, {A, R, ONE}, {R, ONE, ZERO});
261}255}
262 256 
263/*257/*
@@ -365,53 +359,51 @@ void Add_Layer_Norm_Slice_BeforeAutofuse(ascir::HintGraph &graph) {
365 auto a = graph.CreateAxis("A", A);359 auto a = graph.CreateAxis("A", A);
366 auto r = graph.CreateAxis("R", R);360 auto r = graph.CreateAxis("R", R);
367 const std::initializer_list<int64_t> axes = {a.id, r.id};361 const std::initializer_list<int64_t> axes = {a.id, r.id};
368- 
369- int exec_order = 0;
370 Load x1Local("x1Local");362 Load x1Local("x1Local");
371- CreateDataAndLoad(x1Local, graph, "x1", exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});363+ CreateDataAndLoad(x1Local, graph, "x1", axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
372 Load x2Local("x2Local");364 Load x2Local("x2Local");
373- CreateDataAndLoad(x2Local, graph, "x2", exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});365+ CreateDataAndLoad(x2Local, graph, "x2", axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
374 Load biasLocal("biasLocal");366 Load biasLocal("biasLocal");
375- CreateDataAndLoad(biasLocal, graph, "bias", exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});367+ CreateDataAndLoad(biasLocal, graph, "bias", axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
376 368 
377 Concat mean("mean");369 Concat mean("mean");
378 mean.attr.api.unit = af::ComputeUnit::kUnitVector;370 mean.attr.api.unit = af::ComputeUnit::kUnitVector;
379 mean.x = {x1Local.y, x2Local.y, biasLocal.y};371 mean.x = {x1Local.y, x2Local.y, biasLocal.y};
380- SetNodeScheduleAndTensor(mean, exec_order, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});372+ SetNodeScheduleAndTensor(mean, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});
381 373 
382 Store x_out("x_out");374 Store x_out("x_out");
383- InitInputNode(x_out, mean.y, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});375+ InitInputNode(x_out, mean.y, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
384 376 
385 Concat rstd("rstd");377 Concat rstd("rstd");
386 rstd.attr.api.unit = af::ComputeUnit::kUnitVector;378 rstd.attr.api.unit = af::ComputeUnit::kUnitVector;
387 rstd.x = {mean.y, mean.y};379 rstd.x = {mean.y, mean.y};
388- SetNodeScheduleAndTensor(rstd, exec_order, axes, ge::DT_FLOAT, {A, R}, {R, ONE});380+ SetNodeScheduleAndTensor(rstd, axes, ge::DT_FLOAT, {A, R}, {R, ONE});
389 381 
390 Store mean_out("mean_out");382 Store mean_out("mean_out");
391- InitInputNode(mean_out, mean.y, exec_order, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});383+ InitInputNode(mean_out, mean.y, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});
392 Store rstd_out("rstd_out");384 Store rstd_out("rstd_out");
393- InitInputNode(rstd_out, rstd.y, exec_order, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});385+ InitInputNode(rstd_out, rstd.y, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});
394 386 
395 Load betaLocal("betaLocal");387 Load betaLocal("betaLocal");
396- CreateDataAndLoad(betaLocal, graph, "beta", exec_order, axes, ge::DT_FLOAT16, {ONE, R}, {ZERO, ONE});388+ CreateDataAndLoad(betaLocal, graph, "beta", axes, ge::DT_FLOAT16, {ONE, R}, {ZERO, ONE});
397 Load gammaLocal("gammaLocal");389 Load gammaLocal("gammaLocal");
398- CreateDataAndLoad(gammaLocal, graph, "gamma", exec_order, axes, ge::DT_FLOAT16, {ONE, R}, {ZERO, ONE});390+ CreateDataAndLoad(gammaLocal, graph, "gamma", axes, ge::DT_FLOAT16, {ONE, R}, {ZERO, ONE});
399 391 
400 Concat y("y");392 Concat y("y");
401 y.attr.api.unit = af::ComputeUnit::kUnitVector;393 y.attr.api.unit = af::ComputeUnit::kUnitVector;
402 y.x = {rstd.y, betaLocal.y, gammaLocal.y, rstd.y};394 y.x = {rstd.y, betaLocal.y, gammaLocal.y, rstd.y};
403- SetNodeScheduleAndTensor(y, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});395+ SetNodeScheduleAndTensor(y, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
404 Store y_out("y_out");396 Store y_out("y_out");
405- InitInputNode(y_out, y.y, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});397+ InitInputNode(y_out, y.y, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
406 398 
407 Output buf1("buf1");399 Output buf1("buf1");
408- InitInputNode(buf1, x_out.y, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});400+ InitInputNode(buf1, x_out.y, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
409 Output buf2("buf2");401 Output buf2("buf2");
410- InitInputNode(buf2, mean_out.y, exec_order, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});402+ InitInputNode(buf2, mean_out.y, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});
411 Output buf3("buf3");403 Output buf3("buf3");
412- InitInputNode(buf3, rstd_out.y, exec_order, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});404+ InitInputNode(buf3, rstd_out.y, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});
413 Output buf("buf");405 Output buf("buf");
414- InitInputNode(buf, y_out.y, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});406+ InitInputNode(buf, y_out.y, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
415}407}
416 408 
417/*409/*
@@ -532,57 +524,55 @@ void Add_Layer_Norm_Welford_BeforeAutofuse(ascir::HintGraph &graph) {
532 auto a = graph.CreateAxis("A", A);524 auto a = graph.CreateAxis("A", A);
533 auto r = graph.CreateAxis("R", R);525 auto r = graph.CreateAxis("R", R);
534 const std::initializer_list<int64_t> axes = {a.id, r.id};526 const std::initializer_list<int64_t> axes = {a.id, r.id};
535- 
536- int exec_order = 0;
537 Load x1Local("x1Local");527 Load x1Local("x1Local");
538- CreateDataAndLoad(x1Local, graph, "x1", exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});528+ CreateDataAndLoad(x1Local, graph, "x1", axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
539 Load x2Local("x2Local");529 Load x2Local("x2Local");
540- CreateDataAndLoad(x2Local, graph, "x2", exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});530+ CreateDataAndLoad(x2Local, graph, "x2", axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
541 Load biasLocal("biasLocal");531 Load biasLocal("biasLocal");
542- CreateDataAndLoad(biasLocal, graph, "bias", exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});532+ CreateDataAndLoad(biasLocal, graph, "bias", axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
543 533 
544 Concat part1("part1");534 Concat part1("part1");
545 part1.attr.api.unit = af::ComputeUnit::kUnitVector;535 part1.attr.api.unit = af::ComputeUnit::kUnitVector;
546 part1.x = {x1Local.y, x2Local.y, biasLocal.y};536 part1.x = {x1Local.y, x2Local.y, biasLocal.y};
547- SetNodeScheduleAndTensor(part1, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});537+ SetNodeScheduleAndTensor(part1, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
548 538 
549 Store x_out("x_out");539 Store x_out("x_out");
550- InitInputNode(x_out, part1.y, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});540+ InitInputNode(x_out, part1.y, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
551 Store x_fp32_out("x_fp32_out");541 Store x_fp32_out("x_fp32_out");
552- InitInputNode(x_fp32_out, part1.y, exec_order, axes, ge::DT_FLOAT, {A, R}, {R, ONE});542+ InitInputNode(x_fp32_out, part1.y, axes, ge::DT_FLOAT, {A, R}, {R, ONE});
553 543 
554 Concat part1Final("part1Final");544 Concat part1Final("part1Final");
555 part1Final.attr.api.unit = af::ComputeUnit::kUnitVector;545 part1Final.attr.api.unit = af::ComputeUnit::kUnitVector;
556 part1Final.x = {part1.y, part1.y};546 part1Final.x = {part1.y, part1.y};
557- SetNodeScheduleAndTensor(part1Final, exec_order, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});547+ SetNodeScheduleAndTensor(part1Final, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});
558 548 
559 Store mean_out("mean_out");549 Store mean_out("mean_out");
560- InitInputNode(mean_out, part1Final.y, exec_order, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});550+ InitInputNode(mean_out, part1Final.y, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});
561 Store rstd_out("rstd_out");551 Store rstd_out("rstd_out");
562- InitInputNode(rstd_out, part1Final.y, exec_order, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});552+ InitInputNode(rstd_out, part1Final.y, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});
563 553 
564 Load x32("x32");554 Load x32("x32");
565- InitInputNode(x32, x_fp32_out.y, exec_order, axes, ge::DT_FLOAT, {A, R}, {R, ONE});555+ InitInputNode(x32, x_fp32_out.y, axes, ge::DT_FLOAT, {A, R}, {R, ONE});
566 Load betaLocal("betaLocal");556 Load betaLocal("betaLocal");
567- CreateDataAndLoad(betaLocal, graph, "beta", exec_order, axes, ge::DT_FLOAT16, {ONE, R}, {ZERO, ONE});557+ CreateDataAndLoad(betaLocal, graph, "beta", axes, ge::DT_FLOAT16, {ONE, R}, {ZERO, ONE});
568 Load gammaLocal("gammaLocal");558 Load gammaLocal("gammaLocal");
569- CreateDataAndLoad(gammaLocal, graph, "gamma", exec_order, axes, ge::DT_FLOAT16, {ONE, R}, {ZERO, ONE});559+ CreateDataAndLoad(gammaLocal, graph, "gamma", axes, ge::DT_FLOAT16, {ONE, R}, {ZERO, ONE});
570 560 
571 Concat y("y");561 Concat y("y");
572 y.attr.api.unit = af::ComputeUnit::kUnitVector;562 y.attr.api.unit = af::ComputeUnit::kUnitVector;
573 y.x = {x32.y, betaLocal.y, gammaLocal.y, x32.y};563 y.x = {x32.y, betaLocal.y, gammaLocal.y, x32.y};
574- SetNodeScheduleAndTensor(y, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});564+ SetNodeScheduleAndTensor(y, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
575 Store y_out("y_out");565 Store y_out("y_out");
576- InitInputNode(y_out, y.y, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});566+ InitInputNode(y_out, y.y, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
577 567 
578 Output buf1("buf1");568 Output buf1("buf1");
579- InitInputNode(buf1, x_out.y, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});569+ InitInputNode(buf1, x_out.y, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
580 Output buf2("buf2");570 Output buf2("buf2");
581- InitInputNode(buf2, mean_out.y, exec_order, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});571+ InitInputNode(buf2, mean_out.y, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});
582 Output buf3("buf3");572 Output buf3("buf3");
583- InitInputNode(buf3, rstd_out.y, exec_order, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});573+ InitInputNode(buf3, rstd_out.y, axes, ge::DT_FLOAT, {A, ONE}, {ONE, ONE});
584 Output buf("buf");574 Output buf("buf");
585- InitInputNode(buf, y_out.y, exec_order, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});575+ InitInputNode(buf, y_out.y, axes, ge::DT_FLOAT16, {A, R}, {R, ONE});
586}576}
587 577 
588void Add_Layer_Norm_Welford_AfterScheduler(ascir::HintGraph &graph) {578void Add_Layer_Norm_Welford_AfterScheduler(ascir::HintGraph &graph) {
Mautofuse/tests/st/att/testcase/scenario/concat/test_concat.cpp+74-85
@@ -434,10 +434,9 @@ struct ConcatNormalAxisInfo {
434};434};
435 435 
436// 创建Data节点(输入数据)并设置属性436// 创建Data节点(输入数据)并设置属性
437-void CreateDataNode(Data &node, ascir::HintGraph &graph, const char *name, int &exec_order,437+void CreateDataNode(Data &node, ascir::HintGraph &graph, const char *name, const ConcatNormalAxisInfo &ax,
438- const ConcatNormalAxisInfo &ax, ge::DataType dtype, const std::vector<af::Expression> &repeats,438+ ge::DataType dtype, const std::vector<af::Expression> &repeats,
439 const std::vector<af::Expression> &strides) {439 const std::vector<af::Expression> &strides) {
440- node.attr.sched.exec_order = exec_order++;
441 node.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};440 node.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};
442 node.y.dtype = dtype;441 node.y.dtype = dtype;
443 *node.y.axis = {ax.a_id, ax.r_id, ax.bl_id};442 *node.y.axis = {ax.a_id, ax.r_id, ax.bl_id};
@@ -446,10 +445,9 @@ void CreateDataNode(Data &node, ascir::HintGraph &graph, const char *name, int &
446}445}
447 446 
448// 创建Load节点并设置属性447// 创建Load节点并设置属性
449-void CreateLoadNode(Load &node, const Data &src, int &exec_order, const ConcatNormalAxisInfo &ax, ge::DataType dtype,448+void CreateLoadNode(Load &node, const Data &src, const ConcatNormalAxisInfo &ax, ge::DataType dtype,
450 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {449 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {
451 node.x = src.y;450 node.x = src.y;
452- node.attr.sched.exec_order = exec_order++;
453 node.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};451 node.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};
454 node.y.dtype = dtype;452 node.y.dtype = dtype;
455 *node.y.axis = {ax.a_id, ax.r_id, ax.bl_id};453 *node.y.axis = {ax.a_id, ax.r_id, ax.bl_id};
@@ -458,9 +456,8 @@ void CreateLoadNode(Load &node, const Data &src, int &exec_order, const ConcatNo
458}456}
459 457 
460// 创建Store节点并设置属性458// 创建Store节点并设置属性
461-void CreateStoreNode(Store &node, int &exec_order, const ConcatNormalAxisInfo &ax, ge::DataType dtype,459+void CreateStoreNode(Store &node, const ConcatNormalAxisInfo &ax, ge::DataType dtype,
462 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {460 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {
463- node.attr.sched.exec_order = exec_order++;
464 node.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};461 node.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};
465 node.y.dtype = dtype;462 node.y.dtype = dtype;
466 *node.y.axis = {ax.a_id, ax.r_id, ax.bl_id};463 *node.y.axis = {ax.a_id, ax.r_id, ax.bl_id};
@@ -469,22 +466,19 @@ void CreateStoreNode(Store &node, int &exec_order, const ConcatNormalAxisInfo &a
469}466}
470 467 
471// 创建Output节点并设置属性468// 创建Output节点并设置属性
472-void CreateOutputNode(Output &node, int &exec_order, const ConcatNormalAxisInfo &ax, ge::DataType dtype,469+void CreateOutputNode(Output &node, const ConcatNormalAxisInfo &ax, ge::DataType dtype,
473 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {470 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {
474- node.attr.sched.exec_order = exec_order++;
475 node.y.dtype = dtype;471 node.y.dtype = dtype;
476 *node.y.axis = {ax.a_id, ax.r_id, ax.bl_id};472 *node.y.axis = {ax.a_id, ax.r_id, ax.bl_id};
477 *node.y.repeats = repeats;473 *node.y.repeats = repeats;
478 *node.y.strides = strides;474 *node.y.strides = strides;
479}475}
480 476 
481-void BuildMeanConcatNode(Concat &mean, int &exec_order, const ConcatNormalAxisInfo &ax,477+void BuildMeanConcatNode(Concat &mean, const ConcatNormalAxisInfo &ax, const std::vector<af::AscOpOutput> &inputs) {
482- const std::vector<af::AscOpOutput> &inputs) {
483 auto aoo = std::vector<af::Expression>{ax.A, ax.ONE, ax.ONE};478 auto aoo = std::vector<af::Expression>{ax.A, ax.ONE, ax.ONE};
484 auto oss_v = std::vector<af::Expression>{ax.ONE, ax.ZERO, ax.ZERO};479 auto oss_v = std::vector<af::Expression>{ax.ONE, ax.ZERO, ax.ZERO};
485 mean.attr.api.unit = af::ComputeUnit::kUnitVector;480 mean.attr.api.unit = af::ComputeUnit::kUnitVector;
486 mean.x = inputs;481 mean.x = inputs;
487- mean.attr.sched.exec_order = exec_order++;
488 mean.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};482 mean.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};
489 mean.y.dtype = ge::DT_FLOAT;483 mean.y.dtype = ge::DT_FLOAT;
490 *mean.y.axis = {ax.a_id, ax.r_id, ax.bl_id};484 *mean.y.axis = {ax.a_id, ax.r_id, ax.bl_id};
@@ -492,7 +486,7 @@ void BuildMeanConcatNode(Concat &mean, int &exec_order, const ConcatNormalAxisIn
492 *mean.y.strides = oss_v;486 *mean.y.strides = oss_v;
493}487}
494 488 
495-void BuildConcatOutputNodes(int &exec_order, const ConcatNormalAxisInfo &ax, const Store &x_out,489+void BuildConcatOutputNodes(const ConcatNormalAxisInfo &ax, const Store &x_out,
496 const std::vector<Store> &output_stores) {490 const std::vector<Store> &output_stores) {
497 auto arb = std::vector<af::Expression>{ax.A, ax.R, ax.ONE};491 auto arb = std::vector<af::Expression>{ax.A, ax.R, ax.ONE};
498 auto rs = std::vector<af::Expression>{ax.R, ax.ONE, ax.ZERO};492 auto rs = std::vector<af::Expression>{ax.R, ax.ONE, ax.ZERO};
@@ -500,23 +494,22 @@ void BuildConcatOutputNodes(int &exec_order, const ConcatNormalAxisInfo &ax, con
500 auto oss_v = std::vector<af::Expression>{ax.ONE, ax.ZERO, ax.ZERO};494 auto oss_v = std::vector<af::Expression>{ax.ONE, ax.ZERO, ax.ZERO};
501 Output buf1("buf1");495 Output buf1("buf1");
502 buf1.x = x_out.y;496 buf1.x = x_out.y;
503- buf1.attr.sched.exec_order = exec_order++;
504 buf1.y.dtype = ge::DT_FLOAT16;497 buf1.y.dtype = ge::DT_FLOAT16;
505 *buf1.y.axis = {ax.a_id, ax.r_id, ax.bl_id};498 *buf1.y.axis = {ax.a_id, ax.r_id, ax.bl_id};
506 *buf1.y.repeats = arb;499 *buf1.y.repeats = arb;
507 *buf1.y.strides = rs;500 *buf1.y.strides = rs;
508 501 
509 Output buf2("buf2");502 Output buf2("buf2");
510- CreateOutputNode(buf2, exec_order, ax, ge::DT_FLOAT, aoo, oss_v);503+ CreateOutputNode(buf2, ax, ge::DT_FLOAT, aoo, oss_v);
511 buf2.x = output_stores[0].y;504 buf2.x = output_stores[0].y;
512 Output buf3("buf3");505 Output buf3("buf3");
513- CreateOutputNode(buf3, exec_order, ax, ge::DT_FLOAT, aoo, oss_v);506+ CreateOutputNode(buf3, ax, ge::DT_FLOAT, aoo, oss_v);
514 buf3.x = output_stores[1].y;507 buf3.x = output_stores[1].y;
515 Output buf("buf");508 Output buf("buf");
516- CreateOutputNode(buf, exec_order, ax, ge::DT_FLOAT16, arb, rs);509+ CreateOutputNode(buf, ax, ge::DT_FLOAT16, arb, rs);
517 buf.x = output_stores[2].y;510 buf.x = output_stores[2].y;
518 Output buf4("buf4");511 Output buf4("buf4");
519- CreateOutputNode(buf4, exec_order, ax, ge::DT_FLOAT16, arb, rs);512+ CreateOutputNode(buf4, ax, ge::DT_FLOAT16, arb, rs);
520 buf4.x = output_stores[3].y;513 buf4.x = output_stores[3].y;
521}514}
522 515 
@@ -527,9 +520,8 @@ struct ConcatVecExprs {
527 std::vector<af::Expression> oss_v;520 std::vector<af::Expression> oss_v;
528};521};
529 522 
530-void CreateStoreFp16Node(Store &store, int &exec_order, const ConcatNormalAxisInfo &ax, const af::AscOpOutput &input,523+void CreateStoreFp16Node(Store &store, const ConcatNormalAxisInfo &ax, const af::AscOpOutput &input,
531 const ConcatVecExprs &vecs) {524 const ConcatVecExprs &vecs) {
532- store.attr.sched.exec_order = exec_order++;
533 store.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};525 store.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};
534 store.x = input;526 store.x = input;
535 store.y.dtype = ge::DT_FLOAT16;527 store.y.dtype = ge::DT_FLOAT16;
@@ -538,16 +530,15 @@ void CreateStoreFp16Node(Store &store, int &exec_order, const ConcatNormalAxisIn
538 *store.y.strides = vecs.rs;530 *store.y.strides = vecs.rs;
539}531}
540 532 
541-void BuildConcatRstdYAndOutputs(int &exec_order, const ConcatNormalAxisInfo &ax, const ConcatVecExprs &vecs,533+void BuildConcatRstdYAndOutputs(const ConcatNormalAxisInfo &ax, const ConcatVecExprs &vecs,
542 const af::AscOpOutput &mean_y, const Store &x_out, const Store &mean_out,534 const af::AscOpOutput &mean_y, const Store &x_out, const Store &mean_out,
543 ascir::HintGraph &graph, const af::AscOpOutput &x1_out, const af::AscOpOutput &x2_out) {535 ascir::HintGraph &graph, const af::AscOpOutput &x1_out, const af::AscOpOutput &x2_out) {
544 auto oob = std::vector<af::Expression>{ax.ONE, ax.ONE, ax.BL};536 auto oob = std::vector<af::Expression>{ax.ONE, ax.ONE, ax.BL};
545 auto oso = std::vector<af::Expression>{ax.ZERO, ax.ZERO, ax.ONE};537 auto oso = std::vector<af::Expression>{ax.ZERO, ax.ZERO, ax.ONE};
546 Data one("one", graph);538 Data one("one", graph);
547- CreateDataNode(one, graph, "one", exec_order, ax, ge::DT_FLOAT, oob, oso);539+ CreateDataNode(one, graph, "one", ax, ge::DT_FLOAT, oob, oso);
548 Concat rstd("rstd");540 Concat rstd("rstd");
549 rstd.attr.api.unit = af::ComputeUnit::kUnitVector;541 rstd.attr.api.unit = af::ComputeUnit::kUnitVector;
550- rstd.attr.sched.exec_order = exec_order++;
551 rstd.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};542 rstd.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};
552 rstd.x = {mean_y, mean_y, one.y};543 rstd.x = {mean_y, mean_y, one.y};
553 rstd.y.dtype = ge::DT_FLOAT;544 rstd.y.dtype = ge::DT_FLOAT;
@@ -556,23 +547,22 @@ void BuildConcatRstdYAndOutputs(int &exec_order, const ConcatNormalAxisInfo &ax,
556 *rstd.y.strides = vecs.rs;547 *rstd.y.strides = vecs.rs;
557 548 
558 Store rstd_out("rstd_out");549 Store rstd_out("rstd_out");
559- CreateStoreNode(rstd_out, exec_order, ax, ge::DT_FLOAT, vecs.aoo, vecs.oss_v);550+ CreateStoreNode(rstd_out, ax, ge::DT_FLOAT, vecs.aoo, vecs.oss_v);
560 rstd_out.x = rstd.y;551 rstd_out.x = rstd.y;
561 552 
562 auto orb = std::vector<af::Expression>{ax.ONE, ax.R, ax.ONE};553 auto orb = std::vector<af::Expression>{ax.ONE, ax.R, ax.ONE};
563 auto bg_strides = std::vector<af::Expression>{ax.ZERO, ax.ONE, ax.ZERO};554 auto bg_strides = std::vector<af::Expression>{ax.ZERO, ax.ONE, ax.ZERO};
564 Data beta("beta", graph);555 Data beta("beta", graph);
565- CreateDataNode(beta, graph, "beta", exec_order, ax, ge::DT_FLOAT16, orb, bg_strides);556+ CreateDataNode(beta, graph, "beta", ax, ge::DT_FLOAT16, orb, bg_strides);
566 Load betaLocal("betaLocal");557 Load betaLocal("betaLocal");
567- CreateLoadNode(betaLocal, beta, exec_order, ax, ge::DT_FLOAT16, orb, bg_strides);558+ CreateLoadNode(betaLocal, beta, ax, ge::DT_FLOAT16, orb, bg_strides);
568 Data gamma("gamma", graph);559 Data gamma("gamma", graph);
569- CreateDataNode(gamma, graph, "gamma", exec_order, ax, ge::DT_FLOAT16, orb, bg_strides);560+ CreateDataNode(gamma, graph, "gamma", ax, ge::DT_FLOAT16, orb, bg_strides);
570 Load gammaLocal("gammaLocal");561 Load gammaLocal("gammaLocal");
571- CreateLoadNode(gammaLocal, gamma, exec_order, ax, ge::DT_FLOAT16, orb, bg_strides);562+ CreateLoadNode(gammaLocal, gamma, ax, ge::DT_FLOAT16, orb, bg_strides);
572 563 
573 Concat y("y");564 Concat y("y");
574 y.attr.api.unit = af::ComputeUnit::kUnitVector;565 y.attr.api.unit = af::ComputeUnit::kUnitVector;
575- y.attr.sched.exec_order = exec_order++;
576 y.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};566 y.attr.sched.axis = {ax.a_id, ax.r_id, ax.bl_id};
577 y.x = {rstd.y, betaLocal.y, gammaLocal.y, rstd.y};567 y.x = {rstd.y, betaLocal.y, gammaLocal.y, rstd.y};
578 y.y.dtype = ge::DT_FLOAT16;568 y.y.dtype = ge::DT_FLOAT16;
@@ -590,13 +580,13 @@ void BuildConcatRstdYAndOutputs(int &exec_order, const ConcatNormalAxisInfo &ax,
590 *concat.y.strides = vecs.rs;580 *concat.y.strides = vecs.rs;
591 581 
592 Store y_out("y_out");582 Store y_out("y_out");
593- CreateStoreFp16Node(y_out, exec_order, ax, y.y, vecs);583+ CreateStoreFp16Node(y_out, ax, y.y, vecs);
594 Store cat_out("cat_out");584 Store cat_out("cat_out");
595- CreateStoreFp16Node(cat_out, exec_order, ax, y.y, vecs);585+ CreateStoreFp16Node(cat_out, ax, y.y, vecs);
596 (void)y_out;586 (void)y_out;
597 (void)cat_out;587 (void)cat_out;
598 588 
599- BuildConcatOutputNodes(exec_order, ax, x_out, {mean_out, rstd_out, y_out, cat_out});589+ BuildConcatOutputNodes(ax, x_out, {mean_out, rstd_out, y_out, cat_out});
600}590}
601 591 
602void Concat_Normal_BeforeAutofuse(ascir::HintGraph &graph) {592void Concat_Normal_BeforeAutofuse(ascir::HintGraph &graph) {
@@ -610,32 +600,31 @@ void Concat_Normal_BeforeAutofuse(ascir::HintGraph &graph) {
610 auto bl = graph.CreateAxis("BL", BL);600 auto bl = graph.CreateAxis("BL", BL);
611 ConcatNormalAxisInfo ax{A, R, BL, ONE, ZERO, a.id, r.id, bl.id};601 ConcatNormalAxisInfo ax{A, R, BL, ONE, ZERO, a.id, r.id, bl.id};
612 ConcatVecExprs vecs{{A, R, ONE}, {R, ONE, ZERO}, {A, ONE, ONE}, {ONE, ZERO, ZERO}};602 ConcatVecExprs vecs{{A, R, ONE}, {R, ONE, ZERO}, {A, ONE, ONE}, {ONE, ZERO, ZERO}};
613- int exec_order = 0;
614 603 
615 auto arb = std::vector<af::Expression>{ax.A, ax.R, ax.ONE};604 auto arb = std::vector<af::Expression>{ax.A, ax.R, ax.ONE};
616 auto rs = std::vector<af::Expression>{ax.R, ax.ONE, ax.ZERO};605 auto rs = std::vector<af::Expression>{ax.R, ax.ONE, ax.ZERO};
617 Data x1("x1", graph);606 Data x1("x1", graph);
618- CreateDataNode(x1, graph, "x1", exec_order, ax, ge::DT_FLOAT16, arb, rs);607+ CreateDataNode(x1, graph, "x1", ax, ge::DT_FLOAT16, arb, rs);
619 Load x1Local("x1Local");608 Load x1Local("x1Local");
620- CreateLoadNode(x1Local, x1, exec_order, ax, ge::DT_FLOAT16, arb, rs);609+ CreateLoadNode(x1Local, x1, ax, ge::DT_FLOAT16, arb, rs);
621 Data x2("x2", graph);610 Data x2("x2", graph);
622- CreateDataNode(x2, graph, "x2", exec_order, ax, ge::DT_FLOAT16, arb, rs);611+ CreateDataNode(x2, graph, "x2", ax, ge::DT_FLOAT16, arb, rs);
623 Load x2Local("x2Local");612 Load x2Local("x2Local");
624- CreateLoadNode(x2Local, x2, exec_order, ax, ge::DT_FLOAT16, arb, rs);613+ CreateLoadNode(x2Local, x2, ax, ge::DT_FLOAT16, arb, rs);
625 Data bias("bias", graph);614 Data bias("bias", graph);
626- CreateDataNode(bias, graph, "bias", exec_order, ax, ge::DT_FLOAT16, arb, rs);615+ CreateDataNode(bias, graph, "bias", ax, ge::DT_FLOAT16, arb, rs);
627 Load biasLocal("biasLocal");616 Load biasLocal("biasLocal");
628- CreateLoadNode(biasLocal, bias, exec_order, ax, ge::DT_FLOAT16, arb, rs);617+ CreateLoadNode(biasLocal, bias, ax, ge::DT_FLOAT16, arb, rs);
629 Concat mean("mean");618 Concat mean("mean");
630- BuildMeanConcatNode(mean, exec_order, ax, {x1Local.y, x2Local.y, biasLocal.y});619+ BuildMeanConcatNode(mean, ax, {x1Local.y, x2Local.y, biasLocal.y});
631 620 
632 Store x_out("x_out");621 Store x_out("x_out");
633- CreateStoreFp16Node(x_out, exec_order, ax, mean.y, vecs);622+ CreateStoreFp16Node(x_out, ax, mean.y, vecs);
634 Store mean_out("mean_out");623 Store mean_out("mean_out");
635- CreateStoreNode(mean_out, exec_order, ax, ge::DT_FLOAT, vecs.aoo, vecs.oss_v);624+ CreateStoreNode(mean_out, ax, ge::DT_FLOAT, vecs.aoo, vecs.oss_v);
636 mean_out.x = mean.y;625 mean_out.x = mean.y;
637 626 
638- BuildConcatRstdYAndOutputs(exec_order, ax, vecs, mean.y, x_out, mean_out, graph, x1Local.y, x2Local.y);627+ BuildConcatRstdYAndOutputs(ax, vecs, mean.y, x_out, mean_out, graph, x1Local.y, x2Local.y);
639}628}
640 629 
641/*630/*
@@ -775,8 +764,8 @@ Status BuildConcatGroupAscendGraphND(af::AscGraph &graph) {
775 auto nd = graph.CreateAxis("nd", ND);764 auto nd = graph.CreateAxis("nd", ND);
776 auto [ndB, ndb] = graph.BlockSplit(nd.id);765 auto [ndB, ndb] = graph.BlockSplit(nd.id);
777 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);766 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
778- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});767+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
779- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});768+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
780 LOOP(*ndB) {769 LOOP(*ndB) {
781 LOOP(*ndbT) {770 LOOP(*ndbT) {
782 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);771 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -801,7 +790,7 @@ Status BuildConcatGroupAscendGraphS0S1MultiTiling(af::AscGraph &graph) {
801 auto [s1T, s1t] = graph.TileSplit(s1.id);790 auto [s1T, s1t] = graph.TileSplit(s1.id);
802 auto s1Ts2T = *graph.MergeAxis({s1T->id, s2T->id});791 auto s1Ts2T = *graph.MergeAxis({s1T->id, s2T->id});
803 auto [s1Ts2TB, s1Ts2Tb] = graph.BlockSplit(s1Ts2T.id);792 auto [s1Ts2TB, s1Ts2Tb] = graph.BlockSplit(s1Ts2T.id);
804- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s0, s1});793+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s0, s1}, 0);
805 LOOP(*s1Ts2TB) {794 LOOP(*s1Ts2TB) {
806 LOOP(*s1Ts2Tb) {795 LOOP(*s1Ts2Tb) {
807 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);796 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -851,8 +840,8 @@ Status BuildConcatGroupAscendGraphS0S1_Reorder(af::AscGraph &graph) {
851 auto s1 = graph.CreateAxis("s1", S1);840 auto s1 = graph.CreateAxis("s1", S1);
852 auto [ndB, ndb] = graph.BlockSplit(s0.id);841 auto [ndB, ndb] = graph.BlockSplit(s0.id);
853 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);842 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
854- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s0});843+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s0}, 0);
855- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {s1});844+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {s1}, 1);
856 LOOP(*ndB) {845 LOOP(*ndB) {
857 LOOP(*ndbT) {846 LOOP(*ndbT) {
858 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);847 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -883,8 +872,8 @@ Status BuildConcatGroupAscendGraphS1S0_Reorder(af::AscGraph &graph) {
883 auto s0 = graph.CreateAxis("s0", S0);872 auto s0 = graph.CreateAxis("s0", S0);
884 auto [ndB, ndb] = graph.BlockSplit(s1.id);873 auto [ndB, ndb] = graph.BlockSplit(s1.id);
885 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);874 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
886- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s1});875+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s1}, 0);
887- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {s0});876+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {s0}, 1);
888 LOOP(*ndB) {877 LOOP(*ndB) {
889 LOOP(*ndbT) {878 LOOP(*ndbT) {
890 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);879 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -913,8 +902,8 @@ Status BuildConcatGroupAscendGraphS0(af::AscGraph &graph) {
913 auto z0 = graph.CreateAxis("z0", S0);902 auto z0 = graph.CreateAxis("z0", S0);
914 auto [z0B, z0b] = graph.BlockSplit(z0.id);903 auto [z0B, z0b] = graph.BlockSplit(z0.id);
915 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);904 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);
916- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});905+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
917- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0});906+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0}, 1);
918 LOOP(*z0B) {907 LOOP(*z0B) {
919 LOOP(*z0bT) {908 LOOP(*z0bT) {
920 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);909 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -942,8 +931,8 @@ Status BuildConcatGroupAscendGraphND2(af::AscGraph &graph) {
942 auto nd = graph.CreateAxis("nd2", ND);931 auto nd = graph.CreateAxis("nd2", ND);
943 auto [ndB, ndb] = graph.BlockSplit(nd.id);932 auto [ndB, ndb] = graph.BlockSplit(nd.id);
944 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);933 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
945- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});934+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
946- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});935+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
947 LOOP(*ndB) {936 LOOP(*ndB) {
948 LOOP(*ndbT) {937 LOOP(*ndbT) {
949 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);938 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -965,8 +954,8 @@ Status BuildConcatGroupAscendGraphND2WithAbs(af::AscGraph &graph) {
965 auto nd = graph.CreateAxis("nd2", ND);954 auto nd = graph.CreateAxis("nd2", ND);
966 auto [ndB, ndb] = graph.BlockSplit(nd.id);955 auto [ndB, ndb] = graph.BlockSplit(nd.id);
967 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);956 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
968- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});957+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
969- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});958+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
970 LOOP(*ndB) {959 LOOP(*ndB) {
971 LOOP(*ndbT) {960 LOOP(*ndbT) {
972 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);961 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -989,8 +978,8 @@ Status BuildConcatGroupAscendGraphND2TB(af::AscGraph &graph) {
989 auto nd = graph.CreateAxis("nd2", ND);978 auto nd = graph.CreateAxis("nd2", ND);
990 auto [ndT, ndt] = graph.TileSplit(nd.id);979 auto [ndT, ndt] = graph.TileSplit(nd.id);
991 auto [ndTB, ndTb] = graph.BlockSplit(ndT->id);980 auto [ndTB, ndTb] = graph.BlockSplit(ndT->id);
992- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});981+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
993- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});982+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
994 LOOP(*ndTB) {983 LOOP(*ndTB) {
995 LOOP(*ndTb) {984 LOOP(*ndTb) {
996 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);985 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -1019,8 +1008,8 @@ Status BuildConcatGroupAscendGraphStatic(af::AscGraph &graph) {
1019 auto nd = graph.CreateAxis("nd", ND);1008 auto nd = graph.CreateAxis("nd", ND);
1020 auto [ndB, ndb] = graph.BlockSplit(nd.id);1009 auto [ndB, ndb] = graph.BlockSplit(nd.id);
1021 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);1010 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
1022- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});1011+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
1023- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});1012+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
1024 LOOP(*ndB) {1013 LOOP(*ndB) {
1025 LOOP(*ndbT) {1014 LOOP(*ndbT) {
1026 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);1015 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -1048,8 +1037,8 @@ Status BuildTqueTbufAscendGraph_single_case(af::AscGraph &graph) {
1048 auto nd = graph.CreateAxis("nd", ND);1037 auto nd = graph.CreateAxis("nd", ND);
1049 auto [ndB, ndb] = graph.BlockSplit(nd.id);1038 auto [ndB, ndb] = graph.BlockSplit(nd.id);
1050 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);1039 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
1051- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});1040+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
1052- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});1041+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
1053 LOOP(*ndB) {1042 LOOP(*ndB) {
1054 LOOP(*ndbT) {1043 LOOP(*ndbT) {
1055 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);1044 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -1079,10 +1068,10 @@ Status BuildTqueTbufAscendGraphMultiCaseG0(af::AscGraph &graph) {
1079 auto nd = graph.CreateAxis("nd", ND);1068 auto nd = graph.CreateAxis("nd", ND);
1080 auto [ndB, ndb] = graph.BlockSplit(nd.id);1069 auto [ndB, ndb] = graph.BlockSplit(nd.id);
1081 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);1070 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
1082- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});1071+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
1083- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});1072+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
1084- auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {nd});1073+ auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {nd}, 2);
1085- auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {nd});1074+ auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {nd}, 3);
1086 LOOP(*ndB) {1075 LOOP(*ndB) {
1087 LOOP(*ndbT) {1076 LOOP(*ndbT) {
1088 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);1077 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -1122,10 +1111,10 @@ Status BuildTqueTbufAscendGraphMultiCaseG1(af::AscGraph &graph) {
1122 auto z0 = graph.CreateAxis("z0", S0);1111 auto z0 = graph.CreateAxis("z0", S0);
1123 auto [z0B, z0b] = graph.BlockSplit(z0.id);1112 auto [z0B, z0b] = graph.BlockSplit(z0.id);
1124 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);1113 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);
1125- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});1114+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
1126- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0});1115+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0}, 1);
1127- auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {z0});1116+ auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {z0}, 2);
1128- auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {z0});1117+ auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {z0}, 3);
1129 LOOP(*z0B) {1118 LOOP(*z0B) {
1130 LOOP(*z0bT) {1119 LOOP(*z0bT) {
1131 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);1120 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -1155,10 +1144,10 @@ Status BuildMultiCaseG0(af::AscGraph &graph) {
1155 auto nd = graph.CreateAxis("nd", ND);1144 auto nd = graph.CreateAxis("nd", ND);
1156 auto [ndT, ndt] = graph.TileSplit(nd.id);1145 auto [ndT, ndt] = graph.TileSplit(nd.id);
1157 auto [ndTB, ndTb] = graph.BlockSplit(ndT->id);1146 auto [ndTB, ndTb] = graph.BlockSplit(ndT->id);
1158- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});1147+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
1159- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});1148+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
1160- auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {nd});1149+ auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {nd}, 2);
1161- auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {nd});1150+ auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {nd}, 3);
1162 LOOP(*ndTB) {1151 LOOP(*ndTB) {
1163 LOOP(*ndTb) {1152 LOOP(*ndTb) {
1164 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);1153 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -1190,10 +1179,10 @@ Status BuildMultiCaseG1(af::AscGraph &graph) {
1190 auto z0 = graph.CreateAxis("z0", S0);1179 auto z0 = graph.CreateAxis("z0", S0);
1191 auto [z0T, z0t] = graph.TileSplit(z0.id);1180 auto [z0T, z0t] = graph.TileSplit(z0.id);
1192 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);1181 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
1193- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});1182+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
1194- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0});1183+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0}, 1);
1195- auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {z0});1184+ auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {z0}, 2);
1196- auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {z0});1185+ auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {z0}, 3);
1197 LOOP(*z0TB) {1186 LOOP(*z0TB) {
1198 LOOP(*z0Tb) {1187 LOOP(*z0Tb) {
1199 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);1188 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -1224,13 +1213,13 @@ Status BuildSevenInputsMiddleAxisCacheLineConflict(ge::AscGraph &graph) {
1224 auto s1 = graph.CreateAxis("s1", S1);1213 auto s1 = graph.CreateAxis("s1", S1);
1225 auto [s0B, s0b] = graph.BlockSplit(s0.id);1214 auto [s0B, s0b] = graph.BlockSplit(s0.id);
1226 auto [s0bT, s0bt] = graph.TileSplit(s0b->id);1215 auto [s0bT, s0bt] = graph.TileSplit(s0b->id);
1227- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s0, s1});1216+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s0, s1}, 0);
1228- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {s0, s1});1217+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {s0, s1}, 1);
1229- auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {s0, s1});1218+ auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {s0, s1}, 2);
1230- auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {s0, s1});1219+ auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {s0, s1}, 3);
1231- auto data5 = graph.CreateContiguousData("input5", DT_FLOAT, {s0, s1});1220+ auto data5 = graph.CreateContiguousData("input5", DT_FLOAT, {s0, s1}, 4);
1232- auto data6 = graph.CreateContiguousData("input6", DT_FLOAT, {s0, s1});1221+ auto data6 = graph.CreateContiguousData("input6", DT_FLOAT, {s0, s1}, 5);
1233- auto data7 = graph.CreateContiguousData("input7", DT_FLOAT, {s0, s1});1222+ auto data7 = graph.CreateContiguousData("input7", DT_FLOAT, {s0, s1}, 6);
1234 LOOP(*s0B) {1223 LOOP(*s0B) {
1235 LOOP(*s0bT) {1224 LOOP(*s0bT) {
1236 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);1225 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/tests/st/att/testcase/scenario/e2e_brc_buf/att_test_brc_buf.cpp+18-26
@@ -24,9 +24,8 @@ using namespace ge::ascir_op;
24 24 
25namespace {25namespace {
26template <typename NodeT>26template <typename NodeT>
27-void InitNode(NodeT &node, int32_t &exec_order, std::initializer_list<int64_t> axis, ge::DataType dtype,27+void InitNode(NodeT &node, std::initializer_list<int64_t> axis, ge::DataType dtype,
28 std::initializer_list<ge::Expression> repeats, std::initializer_list<ge::Expression> strides) {28 std::initializer_list<ge::Expression> repeats, std::initializer_list<ge::Expression> strides) {
29- node.attr.sched.exec_order = exec_order++;
30 node.attr.sched.axis = axis;29 node.attr.sched.axis = axis;
31 node.y.dtype = dtype;30 node.y.dtype = dtype;
32 *node.y.axis = axis;31 *node.y.axis = axis;
@@ -35,11 +34,10 @@ void InitNode(NodeT &node, int32_t &exec_order, std::initializer_list<int64_t> a
35}34}
36 35 
37template <typename NodeT, typename InputT>36template <typename NodeT, typename InputT>
38-void InitInputNode(NodeT &node, const InputT &input, int32_t &exec_order, std::initializer_list<int64_t> axis,37+void InitInputNode(NodeT &node, const InputT &input, std::initializer_list<int64_t> axis, ge::DataType dtype,
39- ge::DataType dtype, std::initializer_list<ge::Expression> repeats,38+ std::initializer_list<ge::Expression> repeats, std::initializer_list<ge::Expression> strides) {
40- std::initializer_list<ge::Expression> strides) {
41 node.x = input;39 node.x = input;
42- InitNode(node, exec_order, axis, dtype, repeats, strides);40+ InitNode(node, axis, dtype, repeats, strides);
43}41}
44 42 
45void ApplySchedulerTransform(ge::AscGraph &graph, const char *name, int64_t z1T, int64_t z1t, int64_t z2T, int64_t z2t,43void ApplySchedulerTransform(ge::AscGraph &graph, const char *name, int64_t z1T, int64_t z1t, int64_t z2T, int64_t z2t,
@@ -113,32 +111,29 @@ void BrcBufBeforeAutoFuse1(ge::AscGraph &graph) {
113 auto z2 = graph.CreateAxis("z2", Z2);111 auto z2 = graph.CreateAxis("z2", Z2);
114 112 
115 auto normalAxis = {z0.id, z1.id, z2.id};113 auto normalAxis = {z0.id, z1.id, z2.id};
116- 
117- int32_t exec_order = 0;
118 Data input_data("input_data", graph);114 Data input_data("input_data", graph);
119- InitNode(input_data, exec_order, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});115+ InitNode(input_data, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});
120 116 
121 Load load("load");117 Load load("load");
122- InitInputNode(load, input_data.y, exec_order, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});118+ InitInputNode(load, input_data.y, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});
123 119 
124 Cast cast0("cast0");120 Cast cast0("cast0");
125- InitInputNode(cast0, load.y, exec_order, normalAxis, ge::DT_FLOAT, {Z0, ONE, Z2}, {Z2, ZERO, ONE});121+ InitInputNode(cast0, load.y, normalAxis, ge::DT_FLOAT, {Z0, ONE, Z2}, {Z2, ZERO, ONE});
126 122 
127 Broadcast broadcast("broadcast");123 Broadcast broadcast("broadcast");
128- InitInputNode(broadcast, cast0.y, exec_order, normalAxis, ge::DT_FLOAT, {Z0, Z1, Z2}, {Z1 * Z2, Z2, ONE});124+ InitInputNode(broadcast, cast0.y, normalAxis, ge::DT_FLOAT, {Z0, Z1, Z2}, {Z1 * Z2, Z2, ONE});
129 125 
130 Sum sum("sum");126 Sum sum("sum");
131- InitInputNode(sum, broadcast.y, exec_order, normalAxis, ge::DT_FLOAT, {Z0, ONE, Z2}, {Z2, ZERO, ONE});127+ InitInputNode(sum, broadcast.y, normalAxis, ge::DT_FLOAT, {Z0, ONE, Z2}, {Z2, ZERO, ONE});
132 128 
133 Cast cast1("cast1");129 Cast cast1("cast1");
134- InitInputNode(cast1, sum.y, exec_order, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});130+ InitInputNode(cast1, sum.y, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});
135 131 
136 Store store("store");132 Store store("store");
137- InitInputNode(store, cast1.y, exec_order, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});133+ InitInputNode(store, cast1.y, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});
138 134 
139 Output output_data("output_data");135 Output output_data("output_data");
140 output_data.x = store.y;136 output_data.x = store.y;
141- output_data.attr.sched.exec_order = exec_order++;
142}137}
143 138 
144void BrcBufAfterScheduler1(ge::AscGraph &graph) {139void BrcBufAfterScheduler1(ge::AscGraph &graph) {
@@ -197,32 +192,29 @@ void BrcBufBeforeAutoFuse2(ge::AscGraph &graph) {
197 auto z2 = graph.CreateAxis("z2", Z2);192 auto z2 = graph.CreateAxis("z2", Z2);
198 193 
199 auto normalAxis = {z0.id, z1.id, z2.id};194 auto normalAxis = {z0.id, z1.id, z2.id};
200- 
201- int32_t exec_order = 0;
202 Data input_data("input_data", graph);195 Data input_data("input_data", graph);
203- InitNode(input_data, exec_order, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});196+ InitNode(input_data, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});
204 197 
205 Load load("load");198 Load load("load");
206- InitInputNode(load, input_data.y, exec_order, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});199+ InitInputNode(load, input_data.y, normalAxis, ge::DT_FLOAT16, {Z0, ONE, Z2}, {Z2, ZERO, ONE});
207 200 
208 Cast cast0("cast0");201 Cast cast0("cast0");
209- InitInputNode(cast0, load.y, exec_order, normalAxis, ge::DT_FLOAT, {Z0, ONE, Z2}, {Z2, ZERO, ONE});202+ InitInputNode(cast0, load.y, normalAxis, ge::DT_FLOAT, {Z0, ONE, Z2}, {Z2, ZERO, ONE});
210 203 
211 Broadcast broadcast("broadcast");204 Broadcast broadcast("broadcast");
212- InitInputNode(broadcast, cast0.y, exec_order, normalAxis, ge::DT_FLOAT, {Z0, Z1, Z2}, {Z1 * Z2, Z2, ONE});205+ InitInputNode(broadcast, cast0.y, normalAxis, ge::DT_FLOAT, {Z0, Z1, Z2}, {Z1 * Z2, Z2, ONE});
213 206 
214 Sum sum("sum");207 Sum sum("sum");
215- InitInputNode(sum, broadcast.y, exec_order, normalAxis, ge::DT_FLOAT, {Z0, Z1, ONE}, {Z1, ONE, ZERO});208+ InitInputNode(sum, broadcast.y, normalAxis, ge::DT_FLOAT, {Z0, Z1, ONE}, {Z1, ONE, ZERO});
216 209 
217 Cast cast1("cast1");210 Cast cast1("cast1");
218- InitInputNode(cast1, sum.y, exec_order, normalAxis, ge::DT_FLOAT16, {Z0, Z1, ONE}, {Z1, ONE, ZERO});211+ InitInputNode(cast1, sum.y, normalAxis, ge::DT_FLOAT16, {Z0, Z1, ONE}, {Z1, ONE, ZERO});
219 212 
220 Store store("store");213 Store store("store");
221- InitInputNode(store, cast1.y, exec_order, normalAxis, ge::DT_FLOAT16, {Z0, Z1, ONE}, {Z1, ONE, ZERO});214+ InitInputNode(store, cast1.y, normalAxis, ge::DT_FLOAT16, {Z0, Z1, ONE}, {Z1, ONE, ZERO});
222 215 
223 Output output_data("output_data");216 Output output_data("output_data");
224 output_data.x = store.y;217 output_data.x = store.y;
225- output_data.attr.sched.exec_order = exec_order++;
226}218}
227 219 
228void BrcBufAfterScheduler2(ge::AscGraph &graph) {220void BrcBufAfterScheduler2(ge::AscGraph &graph) {
Mautofuse/tests/st/att/testcase/source_mirror/gen_model_info_content/stub_graph.cpp+0-36
@@ -51,10 +51,7 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
51 51 
52 std::initializer_list<Expr> reduceResRepeat = {ONE, ONE, ONE, S1, ONE, ONE, BL};52 std::initializer_list<Expr> reduceResRepeat = {ONE, ONE, ONE, S1, ONE, ONE, BL};
53 std::initializer_list<Expr> reduceResStride = {ZERO, ZERO, ZERO, BL, ZERO, ZERO, ONE};53 std::initializer_list<Expr> reduceResStride = {ZERO, ZERO, ZERO, BL, ZERO, ZERO, ONE};
54- 
55- int32_t exec_order = 0;
56 Data query("query", graph);54 Data query("query", graph);
57- query.attr.sched.exec_order = exec_order++;
58 query.attr.sched.axis = bmm1ResAxis;55 query.attr.sched.axis = bmm1ResAxis;
59 query.y.dtype = ge::DT_FLOAT16;56 query.y.dtype = ge::DT_FLOAT16;
60 *query.y.axis = bmm1ResAxis;57 *query.y.axis = bmm1ResAxis;
@@ -64,7 +61,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
64 query.axis_continuous_map = {{0, 1}, {2}, {3}, {4}, {INT64_MAX}, {5}, {INT64_MAX}};61 query.axis_continuous_map = {{0, 1}, {2}, {3}, {4}, {INT64_MAX}, {5}, {INT64_MAX}};
65 62 
66 Data key("key", graph);63 Data key("key", graph);
67- key.attr.sched.exec_order = exec_order++;
68 key.attr.sched.axis = bmm1ResAxis;64 key.attr.sched.axis = bmm1ResAxis;
69 key.y.dtype = ge::DT_FLOAT16;65 key.y.dtype = ge::DT_FLOAT16;
70 *key.y.axis = bmm1ResAxis;66 *key.y.axis = bmm1ResAxis;
@@ -76,7 +72,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
76 MatMul bmm1("bmm1");72 MatMul bmm1("bmm1");
77 bmm1.x1 = query.y;73 bmm1.x1 = query.y;
78 bmm1.x2 = key.y;74 bmm1.x2 = key.y;
79- bmm1.attr.sched.exec_order = exec_order++;
80 bmm1.attr.sched.axis = bmm1ResAxis;75 bmm1.attr.sched.axis = bmm1ResAxis;
81 bmm1.y.dtype = ge::DT_FLOAT;76 bmm1.y.dtype = ge::DT_FLOAT;
82 *bmm1.y.axis = bmm1ResAxis;77 *bmm1.y.axis = bmm1ResAxis;
@@ -85,7 +80,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
85 80 
86 Load load1("load1");81 Load load1("load1");
87 load1.x = bmm1.y;82 load1.x = bmm1.y;
88- load1.attr.sched.exec_order = exec_order++;
89 load1.attr.sched.axis = bmm1ResAxis;83 load1.attr.sched.axis = bmm1ResAxis;
90 load1.y.dtype = ge::DT_FLOAT;84 load1.y.dtype = ge::DT_FLOAT;
91 *load1.y.axis = bmm1ResAxis;85 *load1.y.axis = bmm1ResAxis;
@@ -93,7 +87,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
93 *load1.y.strides = vec1ResStride;87 *load1.y.strides = vec1ResStride;
94 88 
95 Data pse("pse", graph);89 Data pse("pse", graph);
96- pse.attr.sched.exec_order = exec_order++;
97 pse.y.dtype = ge::DT_FLOAT16;90 pse.y.dtype = ge::DT_FLOAT16;
98 *pse.y.axis = bmm1ResAxis;91 *pse.y.axis = bmm1ResAxis;
99 *pse.y.repeats = vec1ResRepeat;92 *pse.y.repeats = vec1ResRepeat;
@@ -101,7 +94,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
101 94 
102 Load loadPse("loadPse");95 Load loadPse("loadPse");
103 loadPse.x = pse.y;96 loadPse.x = pse.y;
104- loadPse.attr.sched.exec_order = exec_order++;
105 loadPse.attr.sched.axis = bmm1ResAxis;97 loadPse.attr.sched.axis = bmm1ResAxis;
106 loadPse.y.dtype = ge::DT_FLOAT16;98 loadPse.y.dtype = ge::DT_FLOAT16;
107 *loadPse.y.axis = bmm1ResAxis;99 *loadPse.y.axis = bmm1ResAxis;
@@ -110,7 +102,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
110 102 
111 Cast castPse("castPse");103 Cast castPse("castPse");
112 castPse.x = loadPse.y;104 castPse.x = loadPse.y;
113- castPse.attr.sched.exec_order = exec_order++;
114 castPse.attr.sched.axis = bmm1ResAxis;105 castPse.attr.sched.axis = bmm1ResAxis;
115 castPse.y.dtype = ge::DT_FLOAT;106 castPse.y.dtype = ge::DT_FLOAT;
116 *castPse.y.axis = bmm1ResAxis;107 *castPse.y.axis = bmm1ResAxis;
@@ -120,7 +111,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
120 ge::ascir_op::Add add1("add1");111 ge::ascir_op::Add add1("add1");
121 add1.x1 = load1.y;112 add1.x1 = load1.y;
122 add1.x2 = castPse.y;113 add1.x2 = castPse.y;
123- add1.attr.sched.exec_order = exec_order++;
124 add1.attr.sched.axis = bmm1ResAxis;114 add1.attr.sched.axis = bmm1ResAxis;
125 add1.y.dtype = ge::DT_FLOAT;115 add1.y.dtype = ge::DT_FLOAT;
126 *add1.y.axis = bmm1ResAxis;116 *add1.y.axis = bmm1ResAxis;
@@ -128,13 +118,11 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
128 *add1.y.strides = vec1ResStride;118 *add1.y.strides = vec1ResStride;
129 119 
130 Data scaleValue("scaleValue", graph);120 Data scaleValue("scaleValue", graph);
131- scaleValue.attr.sched.exec_order = exec_order++;
132 scaleValue.y.dtype = ge::DT_FLOAT;121 scaleValue.y.dtype = ge::DT_FLOAT;
133 122 
134 ge::ascir_op::Muls mul1("mul1");123 ge::ascir_op::Muls mul1("mul1");
135 mul1.x1 = add1.y;124 mul1.x1 = add1.y;
136 mul1.x2 = scaleValue.y;125 mul1.x2 = scaleValue.y;
137- mul1.attr.sched.exec_order = exec_order++;
138 mul1.attr.sched.axis = bmm1ResAxis;126 mul1.attr.sched.axis = bmm1ResAxis;
139 mul1.y.dtype = ge::DT_FLOAT;127 mul1.y.dtype = ge::DT_FLOAT;
140 *mul1.y.axis = bmm1ResAxis;128 *mul1.y.axis = bmm1ResAxis;
@@ -142,7 +130,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
142 *mul1.y.strides = vec1ResStride;130 *mul1.y.strides = vec1ResStride;
143 131 
144 Data attenMask("attenMask", graph);132 Data attenMask("attenMask", graph);
145- attenMask.attr.sched.exec_order = exec_order++;
146 attenMask.y.dtype = ge::DT_UINT8;133 attenMask.y.dtype = ge::DT_UINT8;
147 *attenMask.y.axis = bmm1ResAxis;134 *attenMask.y.axis = bmm1ResAxis;
148 *attenMask.y.repeats = {B, ONE, ONE, S1, S2, ONE, ONE};135 *attenMask.y.repeats = {B, ONE, ONE, S1, S2, ONE, ONE};
@@ -150,7 +137,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
150 137 
151 Load loadAttenMask("loadAttenMask");138 Load loadAttenMask("loadAttenMask");
152 loadAttenMask.x = attenMask.y;139 loadAttenMask.x = attenMask.y;
153- loadAttenMask.attr.sched.exec_order = exec_order++;
154 loadAttenMask.attr.sched.axis = bmm1ResAxis;140 loadAttenMask.attr.sched.axis = bmm1ResAxis;
155 loadAttenMask.y.dtype = ge::DT_UINT8;141 loadAttenMask.y.dtype = ge::DT_UINT8;
156 *loadAttenMask.y.axis = bmm1ResAxis;142 *loadAttenMask.y.axis = bmm1ResAxis;
@@ -160,7 +146,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
160 Select select("select");146 Select select("select");
161 select.x1 = mul1.y;147 select.x1 = mul1.y;
162 select.x2 = loadAttenMask.y;148 select.x2 = loadAttenMask.y;
163- select.attr.sched.exec_order = exec_order++;
164 select.attr.sched.axis = bmm1ResAxis;149 select.attr.sched.axis = bmm1ResAxis;
165 select.y.dtype = ge::DT_FLOAT;150 select.y.dtype = ge::DT_FLOAT;
166 *select.y.axis = bmm1ResAxis;151 *select.y.axis = bmm1ResAxis;
@@ -168,7 +153,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
168 *select.y.strides = vec1ResStride;153 *select.y.strides = vec1ResStride;
169 154 
170 TbufData softmaxExp("softmaxExp", graph);155 TbufData softmaxExp("softmaxExp", graph);
171- softmaxExp.attr.sched.exec_order = exec_order++;
172 softmaxExp.attr.sched.axis = bmm1ResAxis;156 softmaxExp.attr.sched.axis = bmm1ResAxis;
173 softmaxExp.y.dtype = ge::DT_FLOAT;157 softmaxExp.y.dtype = ge::DT_FLOAT;
174 *softmaxExp.y.axis = bmm1ResAxis;158 *softmaxExp.y.axis = bmm1ResAxis;
@@ -176,7 +160,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
176 *softmaxExp.y.strides = reduceResStride;160 *softmaxExp.y.strides = reduceResStride;
177 161 
178 TbufData softmaxApiTmpBuf("softmaxApiTmpBuf", graph);162 TbufData softmaxApiTmpBuf("softmaxApiTmpBuf", graph);
179- softmaxApiTmpBuf.attr.sched.exec_order = exec_order++;
180 softmaxApiTmpBuf.attr.sched.axis = bmm1ResAxis;163 softmaxApiTmpBuf.attr.sched.axis = bmm1ResAxis;
181 softmaxApiTmpBuf.y.dtype = ge::DT_FLOAT;164 softmaxApiTmpBuf.y.dtype = ge::DT_FLOAT;
182 *softmaxApiTmpBuf.y.axis = bmm1ResAxis;165 *softmaxApiTmpBuf.y.axis = bmm1ResAxis;
@@ -187,7 +170,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
187 flashSoftmax.x1 = select.y;170 flashSoftmax.x1 = select.y;
188 flashSoftmax.x2 = softmaxExp.y;171 flashSoftmax.x2 = softmaxExp.y;
189 flashSoftmax.x3 = softmaxApiTmpBuf.y;172 flashSoftmax.x3 = softmaxApiTmpBuf.y;
190- flashSoftmax.attr.sched.exec_order = exec_order++;
191 flashSoftmax.attr.sched.axis = bmm1ResAxis;173 flashSoftmax.attr.sched.axis = bmm1ResAxis;
192 flashSoftmax.y1.dtype = ge::DT_FLOAT;174 flashSoftmax.y1.dtype = ge::DT_FLOAT;
193 *flashSoftmax.y1.axis = bmm1ResAxis;175 *flashSoftmax.y1.axis = bmm1ResAxis;
@@ -206,7 +188,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
206 188 
207 Store storeSoftmaxMax("storeSoftmaxMax");189 Store storeSoftmaxMax("storeSoftmaxMax");
208 storeSoftmaxMax.x = flashSoftmax.y3;190 storeSoftmaxMax.x = flashSoftmax.y3;
209- storeSoftmaxMax.attr.sched.exec_order = exec_order++;
210 storeSoftmaxMax.attr.sched.axis = bmm1ResAxis;191 storeSoftmaxMax.attr.sched.axis = bmm1ResAxis;
211 storeSoftmaxMax.y.dtype = ge::DT_FLOAT;192 storeSoftmaxMax.y.dtype = ge::DT_FLOAT;
212 *storeSoftmaxMax.y.axis = bmm1ResAxis;193 *storeSoftmaxMax.y.axis = bmm1ResAxis;
@@ -215,10 +196,8 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
215 196 
216 Output softmaxMax("softmaxMax");197 Output softmaxMax("softmaxMax");
217 softmaxMax.x = storeSoftmaxMax.y;198 softmaxMax.x = storeSoftmaxMax.y;
218- softmaxMax.attr.sched.exec_order = exec_order++;
219 199 
220 Data dropMask("dropMask", graph);200 Data dropMask("dropMask", graph);
221- dropMask.attr.sched.exec_order = exec_order++;
222 dropMask.y.dtype = ge::DT_UINT8;201 dropMask.y.dtype = ge::DT_UINT8;
223 *dropMask.y.axis = bmm1ResAxis;202 *dropMask.y.axis = bmm1ResAxis;
224 *dropMask.y.repeats = vec1ResRepeat;203 *dropMask.y.repeats = vec1ResRepeat;
@@ -226,7 +205,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
226 205 
227 Load loadDropMask("loadDropMask");206 Load loadDropMask("loadDropMask");
228 loadDropMask.x = dropMask.y;207 loadDropMask.x = dropMask.y;
229- loadDropMask.attr.sched.exec_order = exec_order++;
230 loadDropMask.attr.sched.axis = bmm1ResAxis;208 loadDropMask.attr.sched.axis = bmm1ResAxis;
231 loadDropMask.y.dtype = ge::DT_UINT8;209 loadDropMask.y.dtype = ge::DT_UINT8;
232 *loadDropMask.y.axis = bmm1ResAxis;210 *loadDropMask.y.axis = bmm1ResAxis;
@@ -236,7 +214,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
236 Dropout dropout("dropout");214 Dropout dropout("dropout");
237 dropout.x1 = flashSoftmax.y1;215 dropout.x1 = flashSoftmax.y1;
238 dropout.x2 = loadDropMask.y;216 dropout.x2 = loadDropMask.y;
239- dropout.attr.sched.exec_order = exec_order++;
240 dropout.attr.sched.axis = bmm1ResAxis;217 dropout.attr.sched.axis = bmm1ResAxis;
241 dropout.y.dtype = ge::DT_FLOAT;218 dropout.y.dtype = ge::DT_FLOAT;
242 *dropout.y.axis = bmm1ResAxis;219 *dropout.y.axis = bmm1ResAxis;
@@ -245,7 +222,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
245 222 
246 Cast castVec1Res("castVec1Res");223 Cast castVec1Res("castVec1Res");
247 castVec1Res.x = dropout.y;224 castVec1Res.x = dropout.y;
248- castVec1Res.attr.sched.exec_order = exec_order++;
249 castVec1Res.attr.sched.axis = bmm1ResAxis;225 castVec1Res.attr.sched.axis = bmm1ResAxis;
250 castVec1Res.y.dtype = ge::DT_FLOAT16;226 castVec1Res.y.dtype = ge::DT_FLOAT16;
251 *castVec1Res.y.axis = bmm1ResAxis;227 *castVec1Res.y.axis = bmm1ResAxis;
@@ -254,7 +230,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
254 230 
255 Store storeVec1Res("storeVec1Res");231 Store storeVec1Res("storeVec1Res");
256 storeVec1Res.x = castVec1Res.y;232 storeVec1Res.x = castVec1Res.y;
257- storeVec1Res.attr.sched.exec_order = exec_order++;
258 storeVec1Res.attr.sched.axis = bmm1ResAxis;233 storeVec1Res.attr.sched.axis = bmm1ResAxis;
259 storeVec1Res.y.dtype = ge::DT_FLOAT16;234 storeVec1Res.y.dtype = ge::DT_FLOAT16;
260 *storeVec1Res.y.axis = bmm1ResAxis;235 *storeVec1Res.y.axis = bmm1ResAxis;
@@ -262,7 +237,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
262 *storeVec1Res.y.strides = vec1ResStride;237 *storeVec1Res.y.strides = vec1ResStride;
263 238 
264 Data value("value", graph);239 Data value("value", graph);
265- value.attr.sched.exec_order = exec_order++;
266 value.attr.sched.axis = bmm2ResAxis;240 value.attr.sched.axis = bmm2ResAxis;
267 value.y.dtype = ge::DT_FLOAT16;241 value.y.dtype = ge::DT_FLOAT16;
268 *value.y.axis = bmm2ResAxis;242 *value.y.axis = bmm2ResAxis;
@@ -272,7 +246,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
272 MatMul bmm2("bmm2");246 MatMul bmm2("bmm2");
273 bmm2.x1 = storeVec1Res.y;247 bmm2.x1 = storeVec1Res.y;
274 bmm2.x2 = value.y;248 bmm2.x2 = value.y;
275- bmm2.attr.sched.exec_order = exec_order++;
276 bmm2.attr.sched.axis = bmm2ResAxis;249 bmm2.attr.sched.axis = bmm2ResAxis;
277 bmm2.y.dtype = ge::DT_FLOAT;250 bmm2.y.dtype = ge::DT_FLOAT;
278 *bmm2.y.axis = bmm2ResAxis;251 *bmm2.y.axis = bmm2ResAxis;
@@ -281,7 +254,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
281 254 
282 Load load2("load2");255 Load load2("load2");
283 load2.x = bmm2.y;256 load2.x = bmm2.y;
284- load2.attr.sched.exec_order = exec_order++;
285 load2.attr.sched.axis = bmm2ResAxis;257 load2.attr.sched.axis = bmm2ResAxis;
286 load2.y.dtype = ge::DT_FLOAT;258 load2.y.dtype = ge::DT_FLOAT;
287 *load2.y.axis = bmm2ResAxis;259 *load2.y.axis = bmm2ResAxis;
@@ -289,7 +261,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
289 *load2.y.strides = vec2ResStride;261 *load2.y.strides = vec2ResStride;
290 262 
291 Workspace addResOut("addResOut", graph);263 Workspace addResOut("addResOut", graph);
292- addResOut.attr.sched.exec_order = exec_order++;
293 addResOut.attr.sched.axis = bmm2ResAxis;264 addResOut.attr.sched.axis = bmm2ResAxis;
294 addResOut.y.dtype = ge::DT_FLOAT;265 addResOut.y.dtype = ge::DT_FLOAT;
295 *addResOut.y.axis = bmm2ResAxis;266 *addResOut.y.axis = bmm2ResAxis;
@@ -298,7 +269,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
298 269 
299 Load loadAddResOut("loadAddResOut");270 Load loadAddResOut("loadAddResOut");
300 loadAddResOut.x = addResOut.y;271 loadAddResOut.x = addResOut.y;
301- loadAddResOut.attr.sched.exec_order = exec_order++;
302 loadAddResOut.attr.sched.axis = bmm2ResAxis;272 loadAddResOut.attr.sched.axis = bmm2ResAxis;
303 loadAddResOut.y.dtype = ge::DT_FLOAT;273 loadAddResOut.y.dtype = ge::DT_FLOAT;
304 *loadAddResOut.y.axis = bmm2ResAxis;274 *loadAddResOut.y.axis = bmm2ResAxis;
@@ -308,7 +278,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
308 ge::ascir_op::Mul mulRes("mulRes");278 ge::ascir_op::Mul mulRes("mulRes");
309 mulRes.x1 = loadAddResOut.y;279 mulRes.x1 = loadAddResOut.y;
310 mulRes.x2 = softmaxExp.y;280 mulRes.x2 = softmaxExp.y;
311- mulRes.attr.sched.exec_order = exec_order++;
312 mulRes.attr.sched.axis = bmm2ResAxis;281 mulRes.attr.sched.axis = bmm2ResAxis;
313 mulRes.y.dtype = ge::DT_FLOAT;282 mulRes.y.dtype = ge::DT_FLOAT;
314 *mulRes.y.axis = bmm2ResAxis;283 *mulRes.y.axis = bmm2ResAxis;
@@ -318,7 +287,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
318 ge::ascir_op::Add addRes("addRes");287 ge::ascir_op::Add addRes("addRes");
319 addRes.x1 = load2.y;288 addRes.x1 = load2.y;
320 addRes.x2 = mulRes.y;289 addRes.x2 = mulRes.y;
321- addRes.attr.sched.exec_order = exec_order++;
322 addRes.attr.sched.axis = bmm2ResAxis;290 addRes.attr.sched.axis = bmm2ResAxis;
323 addRes.y.dtype = ge::DT_FLOAT;291 addRes.y.dtype = ge::DT_FLOAT;
324 *addRes.y.axis = bmm2ResAxis;292 *addRes.y.axis = bmm2ResAxis;
@@ -328,7 +296,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
328 ge::ascir_op::Div div("div");296 ge::ascir_op::Div div("div");
329 div.x1 = addRes.y;297 div.x1 = addRes.y;
330 div.x2 = flashSoftmax.y3;298 div.x2 = flashSoftmax.y3;
331- div.attr.sched.exec_order = exec_order++;
332 div.attr.sched.axis = bmm2ResAxis;299 div.attr.sched.axis = bmm2ResAxis;
333 div.y.dtype = ge::DT_FLOAT;300 div.y.dtype = ge::DT_FLOAT;
334 *div.y.axis = bmm2ResAxis;301 *div.y.axis = bmm2ResAxis;
@@ -337,7 +304,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
337 304 
338 Cast castBmm2Res("castBmm2Res");305 Cast castBmm2Res("castBmm2Res");
339 castBmm2Res.x = div.y;306 castBmm2Res.x = div.y;
340- castBmm2Res.attr.sched.exec_order = exec_order++;
341 castBmm2Res.attr.sched.axis = bmm2ResAxis;307 castBmm2Res.attr.sched.axis = bmm2ResAxis;
342 castBmm2Res.y.dtype = ge::DT_FLOAT16;308 castBmm2Res.y.dtype = ge::DT_FLOAT16;
343 *castBmm2Res.y.axis = bmm2ResAxis;309 *castBmm2Res.y.axis = bmm2ResAxis;
@@ -346,7 +312,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
346 312 
347 Store store("store");313 Store store("store");
348 store.x = castBmm2Res.y;314 store.x = castBmm2Res.y;
349- store.attr.sched.exec_order = exec_order++;
350 store.attr.sched.axis = bmm2ResAxis;315 store.attr.sched.axis = bmm2ResAxis;
351 store.y.dtype = ge::DT_FLOAT16;316 store.y.dtype = ge::DT_FLOAT16;
352 *store.y.axis = bmm2ResAxis;317 *store.y.axis = bmm2ResAxis;
@@ -355,7 +320,6 @@ void FaBeforeAutoFuse(ge::AscGraph &graph) {
355 320 
356 Output buf("buf");321 Output buf("buf");
357 buf.x = store.y;322 buf.x = store.y;
358- buf.attr.sched.exec_order = exec_order++;
359 buf.y.dtype = ge::DT_FLOAT16;323 buf.y.dtype = ge::DT_FLOAT16;
360 *buf.y.axis = bmm2ResAxis;324 *buf.y.axis = bmm2ResAxis;
361 *buf.y.repeats = vec2ResRepeat;325 *buf.y.repeats = vec2ResRepeat;
Mautofuse/tests/st/att/testcase/source_mirror/gen_model_info_content/test_api_tiling_gen.cpp+12-12
@@ -136,8 +136,8 @@ Status BuildTransposeAscendGraph(ge::AscGraph &graph, const std::vector<int64_t>
136 auto [z0T, z0t] = graph.TileSplit(z0.id);136 auto [z0T, z0t] = graph.TileSplit(z0.id);
137 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);137 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
138 138 
139- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1, z2}, FORMAT_ND);139+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1, z2}, 0, FORMAT_ND);
140- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1, z2}, FORMAT_ND);140+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1, z2}, 1, FORMAT_ND);
141 141 
142 // 根据原始维度设置repeats和strides142 // 根据原始维度设置repeats和strides
143 *data1.repeats = {s0, s1, s2};143 *data1.repeats = {s0, s1, s2};
@@ -209,8 +209,8 @@ Status BuildTransposeSplitAscendGraph(ge::AscGraph &graph) {
209 auto [z0T, z0t] = graph.TileSplit(z0.id);209 auto [z0T, z0t] = graph.TileSplit(z0.id);
210 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);210 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
211 211 
212- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1, z2}, FORMAT_ND);212+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1, z2}, 0, FORMAT_ND);
213- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1, z2}, FORMAT_ND);213+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1, z2}, 1, FORMAT_ND);
214 214 
215 // 根据原始维度设置repeats和strides215 // 根据原始维度设置repeats和strides
216 *data1.repeats = {s0, s1, s2};216 *data1.repeats = {s0, s1, s2};
@@ -284,7 +284,7 @@ Status Build4DTransposeAscendGraph(ge::AscGraph &graph, const std::vector<int64_
284 auto [z0T, z0t] = graph.TileSplit(z0.id);284 auto [z0T, z0t] = graph.TileSplit(z0.id);
285 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);285 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
286 286 
287- auto data = graph.CreateContiguousData("input", DT_FLOAT, {z0, z1, z2, z3}, FORMAT_ND);287+ auto data = graph.CreateContiguousData("input", DT_FLOAT, {z0, z1, z2, z3}, 0, FORMAT_ND);
288 288 
289 // 根据原始维度设置repeats和strides289 // 根据原始维度设置repeats和strides
290 *data.repeats = {s0, s1, s2, s3};290 *data.repeats = {s0, s1, s2, s3};
@@ -332,8 +332,8 @@ Status BuildFlashSoftmaxAscendGraph(ge::AscGraph &graph) {
332 auto nd = graph.CreateAxis("nd", ND);332 auto nd = graph.CreateAxis("nd", ND);
333 auto [ndB, ndb] = graph.BlockSplit(nd.id);333 auto [ndB, ndb] = graph.BlockSplit(nd.id);
334 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);334 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
335- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});335+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
336- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});336+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
337 LOOP(*ndB) {337 LOOP(*ndB) {
338 LOOP(*ndbT) {338 LOOP(*ndbT) {
339 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);339 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -362,8 +362,8 @@ Status BuildWorkSpaceAscendGraph(ge::AscGraph &graph) {
362 auto nd = graph.CreateAxis("nd", ND);362 auto nd = graph.CreateAxis("nd", ND);
363 auto [ndB, ndb] = graph.BlockSplit(nd.id);363 auto [ndB, ndb] = graph.BlockSplit(nd.id);
364 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);364 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
365- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});365+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
366- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});366+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
367 LOOP(*ndB) {367 LOOP(*ndB) {
368 LOOP(*ndbT) {368 LOOP(*ndbT) {
369 auto load1 = Workspace("workspace1", data1).TQue(Position::kPositionVecIn, 1, 1);369 auto load1 = Workspace("workspace1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -395,7 +395,7 @@ Status BuildTilingReduceAscendGraph(ge::AscGraph &graph) {
395 auto [rT, rt] = graph.TileSplit(r.id);395 auto [rT, rt] = graph.TileSplit(r.id);
396 auto [rTB, rTb] = graph.BlockSplit(rT->id);396 auto [rTB, rTb] = graph.BlockSplit(rT->id);
397 auto [aT, at] = graph.TileSplit(a.id);397 auto [aT, at] = graph.TileSplit(a.id);
398- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {r, a});398+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {r, a}, 0);
399 LOOP(*rT) {399 LOOP(*rT) {
400 LOOP(*rTB) {400 LOOP(*rTB) {
401 LOOP(*rTb) {401 LOOP(*rTb) {
@@ -428,8 +428,8 @@ Status BuildMatMulDemoAscendGraph(ge::AscGraph &graph) {
428 auto nd = graph.CreateAxis("nd", ND);428 auto nd = graph.CreateAxis("nd", ND);
429 auto [ndB, ndb] = graph.BlockSplit(nd.id);429 auto [ndB, ndb] = graph.BlockSplit(nd.id);
430 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);430 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
431- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});431+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
432- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});432+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
433 LOOP(*ndB) {433 LOOP(*ndB) {
434 LOOP(*ndbT) {434 LOOP(*ndbT) {
435 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);435 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/tests/st/att/testcase/source_mirror/gen_model_info_content/test_auto_fuse.cpp+11-15
@@ -25,9 +25,8 @@ using namespace ge::ascir_op;
25 25 
26namespace {26namespace {
27template <typename NodeT>27template <typename NodeT>
28-void InitNode(NodeT &node, int32_t &exec_order, std::initializer_list<int64_t> axis, ge::DataType dtype,28+void InitNode(NodeT &node, std::initializer_list<int64_t> axis, ge::DataType dtype,
29 std::initializer_list<ge::Expression> repeats, std::initializer_list<ge::Expression> strides) {29 std::initializer_list<ge::Expression> repeats, std::initializer_list<ge::Expression> strides) {
30- node.attr.sched.exec_order = exec_order++;
31 node.attr.sched.axis = axis;30 node.attr.sched.axis = axis;
32 node.y.dtype = dtype;31 node.y.dtype = dtype;
33 *node.y.axis = axis;32 *node.y.axis = axis;
@@ -36,11 +35,10 @@ void InitNode(NodeT &node, int32_t &exec_order, std::initializer_list<int64_t> a
36}35}
37 36 
38template <typename NodeT, typename InputT>37template <typename NodeT, typename InputT>
39-void InitInputNode(NodeT &node, const InputT &input, int32_t &exec_order, std::initializer_list<int64_t> axis,38+void InitInputNode(NodeT &node, const InputT &input, std::initializer_list<int64_t> axis, ge::DataType dtype,
40- ge::DataType dtype, std::initializer_list<ge::Expression> repeats,39+ std::initializer_list<ge::Expression> repeats, std::initializer_list<ge::Expression> strides) {
41- std::initializer_list<ge::Expression> strides) {
42 node.x = input;40 node.x = input;
43- InitNode(node, exec_order, axis, dtype, repeats, strides);41+ InitNode(node, axis, dtype, repeats, strides);
44}42}
45 43 
46void ApplySchedulerTransform(ge::AscGraph &graph, const char *name, int64_t z1T, int64_t z1t, int64_t z0z1T,44void ApplySchedulerTransform(ge::AscGraph &graph, const char *name, int64_t z1T, int64_t z1t, int64_t z0z1T,
@@ -88,30 +86,28 @@ void AutoFuseBeforeAutoFuse(ge::AscGraph &graph) {
88 auto axis_list = {z0.id, z1.id};86 auto axis_list = {z0.id, z1.id};
89 auto repeats = std::initializer_list<Expr>{s0 * s1, s2};87 auto repeats = std::initializer_list<Expr>{s0 * s1, s2};
90 auto strides = std::initializer_list<Expr>{ZERO, ONE};88 auto strides = std::initializer_list<Expr>{ZERO, ONE};
91- 
92- int32_t exec_order = 0;
93 Data data("data", graph);89 Data data("data", graph);
94- InitNode(data, exec_order, axis_list, ge::DT_FLOAT16, repeats, strides);90+ InitNode(data, axis_list, ge::DT_FLOAT16, repeats, strides);
95 91 
96 Load load("load");92 Load load("load");
97- InitInputNode(load, data.y, exec_order, axis_list, ge::DT_FLOAT16, repeats, strides);93+ InitInputNode(load, data.y, axis_list, ge::DT_FLOAT16, repeats, strides);
98 94 
99 Data data1("data1", graph);95 Data data1("data1", graph);
100- InitNode(data1, exec_order, axis_list, ge::DT_FLOAT16, repeats, strides);96+ InitNode(data1, axis_list, ge::DT_FLOAT16, repeats, strides);
101 97 
102 Load load1("load1");98 Load load1("load1");
103- InitInputNode(load1, data1.y, exec_order, axis_list, ge::DT_FLOAT16, repeats, strides);99+ InitInputNode(load1, data1.y, axis_list, ge::DT_FLOAT16, repeats, strides);
104 100 
105 ge::ascir_op::Add add("add");101 ge::ascir_op::Add add("add");
106 add.x1 = load.y;102 add.x1 = load.y;
107 add.x2 = load1.y;103 add.x2 = load1.y;
108- InitNode(add, exec_order, axis_list, ge::DT_FLOAT16, repeats, strides);104+ InitNode(add, axis_list, ge::DT_FLOAT16, repeats, strides);
109 105 
110 Store store("store");106 Store store("store");
111- InitInputNode(store, add.y, exec_order, axis_list, ge::DT_FLOAT16, repeats, strides);107+ InitInputNode(store, add.y, axis_list, ge::DT_FLOAT16, repeats, strides);
112 108 
113 Output data_out("out");109 Output data_out("out");
114- InitInputNode(data_out, store.y, exec_order, axis_list, ge::DT_FLOAT16, repeats, strides);110+ InitInputNode(data_out, store.y, axis_list, ge::DT_FLOAT16, repeats, strides);
115 std::cout << graph.GetAllAxis()[0]->id << std::endl;111 std::cout << graph.GetAllAxis()[0]->id << std::endl;
116 std::cout << graph.GetAllAxis()[0]->id << std::endl;112 std::cout << graph.GetAllAxis()[0]->id << std::endl;
117 std::cout << graph.GetAllAxis()[0]->id << std::endl;113 std::cout << graph.GetAllAxis()[0]->id << std::endl;
Mautofuse/tests/st/att/testcase/source_mirror/gen_model_info_content/test_gen_model_info.cpp+0-12
@@ -172,14 +172,12 @@ TEST_F(TestGenModelInfo, input_check_01)
172 auto g = graph.CreateAxis("g", G, 1, 100000);172 auto g = graph.CreateAxis("g", G, 1, 100000);
173 173 
174 Data query("query", graph);174 Data query("query", graph);
175- query.attr.sched.exec_order = 0;
176 query.attr.sched.axis = {b.id, n.id, g.id};175 query.attr.sched.axis = {b.id, n.id, g.id};
177 query.y.dtype = ge::DT_FLOAT16;176 query.y.dtype = ge::DT_FLOAT16;
178 *query.y.axis = {b.id, n.id, g.id};177 *query.y.axis = {b.id, n.id, g.id};
179 *query.y.repeats = {B, N, G};178 *query.y.repeats = {B, N, G};
180 179 
181 Data key("key", graph);180 Data key("key", graph);
182- key.attr.sched.exec_order = 1;
183 key.attr.sched.axis = {b.id, n.id, g.id};181 key.attr.sched.axis = {b.id, n.id, g.id};
184 key.y.dtype = ge::DT_FLOAT16;182 key.y.dtype = ge::DT_FLOAT16;
185 *key.y.axis = {b.id, n.id, g.id};183 *key.y.axis = {b.id, n.id, g.id};
@@ -215,14 +213,12 @@ TEST_F(TestGenModelInfo, input_check_02)
215 auto g = graph.CreateAxis("g", G, 1, 100000);213 auto g = graph.CreateAxis("g", G, 1, 100000);
216 214 
217 Data query("query", graph);215 Data query("query", graph);
218- query.attr.sched.exec_order = 0;
219 query.attr.sched.axis = {b.id, n.id, g.id};216 query.attr.sched.axis = {b.id, n.id, g.id};
220 query.y.dtype = ge::DT_FLOAT16;217 query.y.dtype = ge::DT_FLOAT16;
221 *query.y.axis = {b.id, n.id, g.id};218 *query.y.axis = {b.id, n.id, g.id};
222 *query.y.repeats = {B, N, G};219 *query.y.repeats = {B, N, G};
223 220 
224 Data key("key", graph);221 Data key("key", graph);
225- key.attr.sched.exec_order = 1;
226 key.attr.sched.axis = {b.id, n.id, g.id};222 key.attr.sched.axis = {b.id, n.id, g.id};
227 key.y.dtype = ge::DT_FLOAT16;223 key.y.dtype = ge::DT_FLOAT16;
228 *key.y.axis = {b.id, n.id, g.id};224 *key.y.axis = {b.id, n.id, g.id};
@@ -259,14 +255,12 @@ TEST_F(TestGenModelInfo, input_check_03)
259 auto g = graph.CreateAxis("g", G, 1, 100000);255 auto g = graph.CreateAxis("g", G, 1, 100000);
260 256 
261 Data query("query", graph);257 Data query("query", graph);
262- query.attr.sched.exec_order = 0;
263 query.attr.sched.axis = {b.id, n.id, g.id};258 query.attr.sched.axis = {b.id, n.id, g.id};
264 query.y.dtype = ge::DT_FLOAT16;259 query.y.dtype = ge::DT_FLOAT16;
265 *query.y.axis = {b.id, n.id, g.id};260 *query.y.axis = {b.id, n.id, g.id};
266 *query.y.repeats = {B, N, G};261 *query.y.repeats = {B, N, G};
267 262 
268 Data key("key", graph);263 Data key("key", graph);
269- key.attr.sched.exec_order = 1;
270 key.attr.sched.axis = {b.id, n.id, g.id};264 key.attr.sched.axis = {b.id, n.id, g.id};
271 key.y.dtype = ge::DT_FLOAT16;265 key.y.dtype = ge::DT_FLOAT16;
272 *key.y.axis = {b.id, n.id, g.id};266 *key.y.axis = {b.id, n.id, g.id};
@@ -303,14 +297,12 @@ TEST_F(TestGenModelInfo, input_check_04)
303 auto g = graph.CreateAxis("g", G, 1, 100000);297 auto g = graph.CreateAxis("g", G, 1, 100000);
304 298 
305 Data query("query", graph);299 Data query("query", graph);
306- query.attr.sched.exec_order = 0;
307 query.attr.sched.axis = {b.id, n.id, g.id};300 query.attr.sched.axis = {b.id, n.id, g.id};
308 query.y.dtype = ge::DT_FLOAT16;301 query.y.dtype = ge::DT_FLOAT16;
309 *query.y.axis = {b.id, n.id, g.id};302 *query.y.axis = {b.id, n.id, g.id};
310 *query.y.repeats = {B, N, G};303 *query.y.repeats = {B, N, G};
311 304 
312 Data key("key", graph);305 Data key("key", graph);
313- key.attr.sched.exec_order = 1;
314 key.attr.sched.axis = {b.id, n.id, g.id};306 key.attr.sched.axis = {b.id, n.id, g.id};
315 key.y.dtype = ge::DT_FLOAT16;307 key.y.dtype = ge::DT_FLOAT16;
316 *key.y.axis = {b.id, n.id, g.id};308 *key.y.axis = {b.id, n.id, g.id};
@@ -347,14 +339,12 @@ TEST_F(TestGenModelInfo, input_check_05)
347 auto g = graph.CreateAxis("g", G, 1, 100000);339 auto g = graph.CreateAxis("g", G, 1, 100000);
348 340 
349 Data query("query", graph);341 Data query("query", graph);
350- query.attr.sched.exec_order = 0;
351 query.attr.sched.axis = {b.id, n.id, g.id};342 query.attr.sched.axis = {b.id, n.id, g.id};
352 query.y.dtype = ge::DT_FLOAT16;343 query.y.dtype = ge::DT_FLOAT16;
353 *query.y.axis = {b.id, n.id, g.id};344 *query.y.axis = {b.id, n.id, g.id};
354 *query.y.repeats = {B, N, G};345 *query.y.repeats = {B, N, G};
355 346 
356 Data key("key", graph);347 Data key("key", graph);
357- key.attr.sched.exec_order = 1;
358 key.attr.sched.axis = {b.id, n.id, g.id};348 key.attr.sched.axis = {b.id, n.id, g.id};
359 key.y.dtype = ge::DT_FLOAT16;349 key.y.dtype = ge::DT_FLOAT16;
360 *key.y.axis = {b.id, n.id, g.id};350 *key.y.axis = {b.id, n.id, g.id};
@@ -397,14 +387,12 @@ TEST_F(TestGenModelInfo, input_check_06)
397 auto m = graph.CreateAxis("g", M, 1, 100000);387 auto m = graph.CreateAxis("g", M, 1, 100000);
398 388 
399 Data query("query", graph);389 Data query("query", graph);
400- query.attr.sched.exec_order = 0;
401 query.attr.sched.axis = {b.id, n.id, g.id};390 query.attr.sched.axis = {b.id, n.id, g.id};
402 query.y.dtype = ge::DT_FLOAT16;391 query.y.dtype = ge::DT_FLOAT16;
403 *query.y.axis = {b.id, n.id, g.id};392 *query.y.axis = {b.id, n.id, g.id};
404 *query.y.repeats = {B, N, G};393 *query.y.repeats = {B, N, G};
405 394 
406 Data key("key", graph);395 Data key("key", graph);
407- key.attr.sched.exec_order = 1;
408 key.attr.sched.axis = {b.id, n.id, g.id};396 key.attr.sched.axis = {b.id, n.id, g.id};
409 key.y.dtype = ge::DT_FLOAT16;397 key.y.dtype = ge::DT_FLOAT16;
410 *key.y.axis = {b.id, n.id, g.id};398 *key.y.axis = {b.id, n.id, g.id};
Mautofuse/tests/st/att/testcase/source_mirror/gen_model_info_content/test_schedule.cpp+1-10
@@ -58,9 +58,7 @@ void OriGraphBasicBlock(ge::AscGraph &graph) {
58 auto axis_list = {z0.id, z1.id};58 auto axis_list = {z0.id, z1.id};
59 std::initializer_list<Expr> repeats = {s0, s1};59 std::initializer_list<Expr> repeats = {s0, s1};
60 std::initializer_list<Expr> strides = {s1, ONE};60 std::initializer_list<Expr> strides = {s1, ONE};
61- int32_t exec_order = 0;
62 Data data("data", graph);61 Data data("data", graph);
63- data.attr.sched.exec_order = exec_order++;
64 data.attr.sched.axis = axis_list;62 data.attr.sched.axis = axis_list;
65 data.y.dtype = ge::DT_FLOAT16;63 data.y.dtype = ge::DT_FLOAT16;
66 *data.y.axis = axis_list;64 *data.y.axis = axis_list;
@@ -69,7 +67,6 @@ void OriGraphBasicBlock(ge::AscGraph &graph) {
69 67 
70 Load load("load");68 Load load("load");
71 load.x = data.y;69 load.x = data.y;
72- load.attr.sched.exec_order = exec_order++;
73 load.attr.sched.axis = axis_list;70 load.attr.sched.axis = axis_list;
74 load.y.dtype = ge::DT_FLOAT16;71 load.y.dtype = ge::DT_FLOAT16;
75 *load.y.axis = axis_list;72 *load.y.axis = axis_list;
@@ -78,7 +75,6 @@ void OriGraphBasicBlock(ge::AscGraph &graph) {
78 75 
79 Output data_out("out");76 Output data_out("out");
80 data_out.x = load.y;77 data_out.x = load.y;
81- data_out.attr.sched.exec_order = exec_order++;
82 data_out.y.dtype = ge::DT_FLOAT16;78 data_out.y.dtype = ge::DT_FLOAT16;
83 *data_out.y.axis = axis_list;79 *data_out.y.axis = axis_list;
84 *data_out.y.repeats = repeats;80 *data_out.y.repeats = repeats;
@@ -130,9 +126,7 @@ void OriGraphReduceScalar(ge::AscGraph &graph) {
130 auto axis_list = {z0.id, z1.id};126 auto axis_list = {z0.id, z1.id};
131 std::initializer_list<Expr> repeats = {s0, s1};127 std::initializer_list<Expr> repeats = {s0, s1};
132 std::initializer_list<Expr> strides = {s1, ONE};128 std::initializer_list<Expr> strides = {s1, ONE};
133- int32_t exec_order = 0;
134 Data data("data", graph);129 Data data("data", graph);
135- data.attr.sched.exec_order = exec_order++;
136 data.attr.sched.axis = axis_list;130 data.attr.sched.axis = axis_list;
137 data.y.dtype = ge::DT_FLOAT16;131 data.y.dtype = ge::DT_FLOAT16;
138 *data.y.axis = axis_list;132 *data.y.axis = axis_list;
@@ -141,7 +135,6 @@ void OriGraphReduceScalar(ge::AscGraph &graph) {
141 135 
142 Load load("load");136 Load load("load");
143 load.x = data.y;137 load.x = data.y;
144- load.attr.sched.exec_order = exec_order++;
145 load.attr.sched.axis = axis_list;138 load.attr.sched.axis = axis_list;
146 load.y.dtype = ge::DT_FLOAT16;139 load.y.dtype = ge::DT_FLOAT16;
147 *load.y.axis = axis_list;140 *load.y.axis = axis_list;
@@ -150,7 +143,6 @@ void OriGraphReduceScalar(ge::AscGraph &graph) {
150 143 
151 Sum reduce_sum("reduce_sum");144 Sum reduce_sum("reduce_sum");
152 reduce_sum.x = load.y;145 reduce_sum.x = load.y;
153- reduce_sum.attr.sched.exec_order = exec_order++;
154 reduce_sum.attr.sched.axis = axis_list;146 reduce_sum.attr.sched.axis = axis_list;
155 reduce_sum.y.dtype = ge::DT_FLOAT16;147 reduce_sum.y.dtype = ge::DT_FLOAT16;
156 *reduce_sum.y.axis = axis_list;148 *reduce_sum.y.axis = axis_list;
@@ -159,7 +151,6 @@ void OriGraphReduceScalar(ge::AscGraph &graph) {
159 151 
160 Output data_out("out");152 Output data_out("out");
161 data_out.x = reduce_sum.y;153 data_out.x = reduce_sum.y;
162- data_out.attr.sched.exec_order = exec_order++;
163 data_out.y.dtype = ge::DT_FLOAT16;154 data_out.y.dtype = ge::DT_FLOAT16;
164 *data_out.y.axis = axis_list;155 *data_out.y.axis = axis_list;
165 *data_out.y.repeats = repeats;156 *data_out.y.repeats = repeats;
@@ -243,4 +234,4 @@ TEST_F(TestSchedule, case0) {
243 EXPECT_EQ(ret, 0);234 EXPECT_EQ(ret, 0);
244 235 
245 ret = std::system("./tiling_func_main_special");236 ret = std::system("./tiling_func_main_special");
246-}237+}
Mautofuse/tests/st/att/utils/graph_construct_utils.cpp+2-2
@@ -22,7 +22,7 @@ Status ConstructSimpleLoadStoreOp(af::AscGraph &graph) {
22 auto nd = graph.CreateAxis("nd", ND);22 auto nd = graph.CreateAxis("nd", ND);
23 auto [ndB, ndb] = graph.BlockSplit(nd.id);23 auto [ndB, ndb] = graph.BlockSplit(nd.id);
24 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);24 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
25- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});25+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
26 LOOP(*ndB) {26 LOOP(*ndB) {
27 LOOP(*ndbT) {27 LOOP(*ndbT) {
28 auto load1 = Load("load", data1).TQue(Position::kPositionVecIn, 1, 1);28 auto load1 = Load("load", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -54,7 +54,7 @@ Status BuildConcatGroupAscendGraphS0S1ReduceMultiTiling(af::AscGraph &graph) {
54 auto [s1T, s1t] = graph.TileSplit(s1.id);54 auto [s1T, s1t] = graph.TileSplit(s1.id);
55 auto s1Ts0T = *graph.MergeAxis({s1T->id, s0T->id});55 auto s1Ts0T = *graph.MergeAxis({s1T->id, s0T->id});
56 auto [s1Ts0TB, s1Ts0Tb] = graph.BlockSplit(s1Ts0T.id);56 auto [s1Ts0TB, s1Ts0Tb] = graph.BlockSplit(s1Ts0T.id);
57- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s0, s1});57+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s0, s1}, 0);
58 LOOP(*s1Ts0TB) {58 LOOP(*s1Ts0TB) {
59 LOOP(*s1Ts0Tb) {59 LOOP(*s1Ts0Tb) {
60 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);60 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/tests/st/codegen/ascir_tool/testcase/reduce_sum_arar_4dim_not_align/input_ascir.py+11-16
@@ -2,10 +2,10 @@
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3# -----------------------------------------------------------------------------------------------------------3# -----------------------------------------------------------------------------------------------------------
4# Copyright (c) 2025 Huawei Technologies Co., Ltd.4# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of 5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6# CANN Open Software License Agreement Version 2.0 (the "License").6# CANN Open Software License Agreement Version 2.0 (the "License").
7# Please refer to the License for details. You may not use this file except in compliance with the License.7# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10# See LICENSE in the root of the software repository for the full text of the License.10# See LICENSE in the root of the software repository for the full text of the License.
11# -----------------------------------------------------------------------------------------------------------11# -----------------------------------------------------------------------------------------------------------
@@ -13,7 +13,8 @@
13# Python code to construct AscGraph13# Python code to construct AscGraph
14from autofuse.pyautofuse import ascir14from autofuse.pyautofuse import ascir
15from autofuse.pyautofuse import Autofuser, AutofuserOptions15from autofuse.pyautofuse import Autofuser, AutofuserOptions
16-NpuKernel0Graph = ascir.HintGraph('fused_graph_0_arar')16+ 
17+NpuKernel0Graph = ascir.HintGraph("fused_graph_0_arar")
17A0 = ascir.SizeExpr(2)18A0 = ascir.SizeExpr(2)
18R0 = ascir.SizeExpr(1000)19R0 = ascir.SizeExpr(1000)
19A1 = ascir.SizeExpr(50)20A1 = ascir.SizeExpr(50)
@@ -22,43 +23,37 @@ buf8_a0 = NpuKernel0Graph.create_axis("buf8_z0", A0)
22buf8_r0 = NpuKernel0Graph.create_axis("buf8_z1", R0)23buf8_r0 = NpuKernel0Graph.create_axis("buf8_z1", R0)
23buf8_a1 = NpuKernel0Graph.create_axis("buf8_z2", A1)24buf8_a1 = NpuKernel0Graph.create_axis("buf8_z2", A1)
24buf8_r1 = NpuKernel0Graph.create_axis("buf8_z3", R1)25buf8_r1 = NpuKernel0Graph.create_axis("buf8_z3", R1)
25-arg2_1 = ascir.ops.Data('arg2_1', NpuKernel0Graph)26+arg2_1 = ascir.ops.Data("arg2_1", NpuKernel0Graph)
26-#arg2_1.attr.sched.exec_order = 0
27arg2_1.y.dtype = ascir.dtypes.float3227arg2_1.y.dtype = ascir.dtypes.float32
28-load = ascir.ops.Load('load', NpuKernel0Graph)28+load = ascir.ops.Load("load", NpuKernel0Graph)
29-#load.attr.sched.exec_order = 1
30load.attr.sched.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]29load.attr.sched.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]
31load.x = arg2_1.y30load.x = arg2_1.y
32load.y.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]31load.y.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]
33load.y.strides = [R0 * A1 * R1, A1 * R1, R1, ascir.SizeExpr(1)]32load.y.strides = [R0 * A1 * R1, A1 * R1, R1, ascir.SizeExpr(1)]
34load.y.size = [A0, R0, A1, R1]33load.y.size = [A0, R0, A1, R1]
35load.y.dtype = ascir.dtypes.float3234load.y.dtype = ascir.dtypes.float32
36-abs = ascir.ops.Abs('abs', NpuKernel0Graph)35+abs = ascir.ops.Abs("abs1", NpuKernel0Graph)
37-#abs.attr.sched.exec_order = 2
38abs.attr.sched.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]36abs.attr.sched.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]
39abs.x = load.y37abs.x = load.y
40abs.y.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]38abs.y.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]
41abs.y.strides = [R0 * A1 * R1, A1 * R1, R1, ascir.SizeExpr(1)]39abs.y.strides = [R0 * A1 * R1, A1 * R1, R1, ascir.SizeExpr(1)]
42abs.y.size = [A0, R0, A1, R1]40abs.y.size = [A0, R0, A1, R1]
43abs.y.dtype = ascir.dtypes.float3241abs.y.dtype = ascir.dtypes.float32
44-sum = ascir.ops.Sum('sum', NpuKernel0Graph)42+sum = ascir.ops.Sum("sum1", NpuKernel0Graph)
45-#sum.attr.sched.exec_order = 3
46sum.attr.sched.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]43sum.attr.sched.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]
47sum.x = abs.y44sum.x = abs.y
48sum.y.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]45sum.y.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]
49sum.y.strides = [A1, 0, 1, 0]46sum.y.strides = [A1, 0, 1, 0]
50sum.y.size = [A0, 1, A1, 1]47sum.y.size = [A0, 1, A1, 1]
51sum.y.dtype = ascir.dtypes.float3248sum.y.dtype = ascir.dtypes.float32
52-store8 = ascir.ops.Store('store8', NpuKernel0Graph)49+store8 = ascir.ops.Store("store8", NpuKernel0Graph)
53-#store8.attr.sched.exec_order = 4
54store8.attr.sched.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]50store8.attr.sched.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]
55store8.x = sum.y51store8.x = sum.y
56store8.y.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]52store8.y.axis = [buf8_a0, buf8_r0, buf8_a1, buf8_r1]
57store8.y.strides = [A1, 0, 1, 0]53store8.y.strides = [A1, 0, 1, 0]
58store8.y.size = [A0, 1, A1, 1]54store8.y.size = [A0, 1, A1, 1]
59store8.y.dtype = ascir.dtypes.float3255store8.y.dtype = ascir.dtypes.float32
60-buf8 = ascir.ops.Output('buf8', NpuKernel0Graph)56+buf8 = ascir.ops.Output("buf8", NpuKernel0Graph)
61-#buf8.attr.sched.exec_order = 5
62buf8.x = store8.y57buf8.x = store8.y
63buf8.y.dtype = ascir.dtypes.float3258buf8.y.dtype = ascir.dtypes.float32
64 59 
@@ -66,4 +61,4 @@ fuser = Autofuser(AutofuserOptions())
66fused_NpuKernel0Graph = fuser.schedule(NpuKernel0Graph)61fused_NpuKernel0Graph = fuser.schedule(NpuKernel0Graph)
67tiling_def, host_impl, device_impl = fuser.codegen(fused_NpuKernel0Graph)62tiling_def, host_impl, device_impl = fuser.codegen(fused_NpuKernel0Graph)
68print("=================================")63print("=================================")
69-print(device_impl)64+print(device_impl)
Mautofuse/tests/st/optimize/optimize_st.cpp+16-15
@@ -556,15 +556,16 @@ static AscGraph BuildAddAscGraphAfterConcat(const std::string &name) {
556 return graph;556 return graph;
557}557}
558 558 
559-static AscGraph BuildConcatAscGraph(const std::string &name) {559+static AscGraph BuildConcatAscGraph(const std::string &name, const bool same_data = false) {
560 auto ONE = Symbol(1);560 auto ONE = Symbol(1);
561 const auto s0 = Symbol("s0");561 const auto s0 = Symbol("s0");
562 const auto s1 = Symbol("s1");562 const auto s1 = Symbol("s1");
563 const auto s2 = Symbol("s2");563 const auto s2 = Symbol("s2");
564+ const auto input_dim = same_data ? s1 : s2;
564 565 
565 af::AscGraph graph(name.c_str());566 af::AscGraph graph(name.c_str());
566 auto z0 = graph.CreateAxis("z0", s0);567 auto z0 = graph.CreateAxis("z0", s0);
567- auto z1 = graph.CreateAxis("z1", s1 + s2 + s2 + s2);568+ auto z1 = graph.CreateAxis("z1", s1 + input_dim + input_dim + input_dim);
568 569 
569 af::ascir_op::Data x1("concat_data0", graph);570 af::ascir_op::Data x1("concat_data0", graph);
570 x1.attr.sched.axis = {z0.id, z1.id};571 x1.attr.sched.axis = {z0.id, z1.id};
@@ -583,44 +584,44 @@ static AscGraph BuildConcatAscGraph(const std::string &name) {
583 af::ascir_op::Data x2("concat_data1", graph);584 af::ascir_op::Data x2("concat_data1", graph);
584 x2.attr.sched.axis = {z0.id, z1.id};585 x2.attr.sched.axis = {z0.id, z1.id};
585 *x2.y.axis = {z0.id, z1.id};586 *x2.y.axis = {z0.id, z1.id};
586- *x2.y.repeats = {s0, s2};587+ *x2.y.repeats = {s0, input_dim};
587- *x2.y.strides = {s2, ONE};588+ *x2.y.strides = {input_dim, ONE};
588 x2.ir_attr.SetIndex(1);589 x2.ir_attr.SetIndex(1);
589 590 
590 af::ascir_op::Load x2Local("concat_load1");591 af::ascir_op::Load x2Local("concat_load1");
591 x2Local.x = x2.y;592 x2Local.x = x2.y;
592 x2Local.attr.sched.axis = {z0.id, z1.id};593 x2Local.attr.sched.axis = {z0.id, z1.id};
593 *x2Local.y.axis = {z0.id, z1.id};594 *x2Local.y.axis = {z0.id, z1.id};
594- *x2Local.y.repeats = {s0, s2};595+ *x2Local.y.repeats = {s0, input_dim};
595- *x2Local.y.strides = {s2, ONE};596+ *x2Local.y.strides = {input_dim, ONE};
596 597 
597 af::ascir_op::Data concat_data2("concat_data2", graph);598 af::ascir_op::Data concat_data2("concat_data2", graph);
598 concat_data2.attr.sched.axis = {z0.id, z1.id};599 concat_data2.attr.sched.axis = {z0.id, z1.id};
599 *concat_data2.y.axis = {z0.id, z1.id};600 *concat_data2.y.axis = {z0.id, z1.id};
600- *concat_data2.y.repeats = {s0, s2};601+ *concat_data2.y.repeats = {s0, input_dim};
601- *concat_data2.y.strides = {s2, ONE};602+ *concat_data2.y.strides = {input_dim, ONE};
602 concat_data2.ir_attr.SetIndex(2);603 concat_data2.ir_attr.SetIndex(2);
603 604 
604 af::ascir_op::Load concat_load2("concat_load2");605 af::ascir_op::Load concat_load2("concat_load2");
605 concat_load2.x = concat_data2.y;606 concat_load2.x = concat_data2.y;
606 concat_load2.attr.sched.axis = {z0.id, z1.id};607 concat_load2.attr.sched.axis = {z0.id, z1.id};
607 *concat_load2.y.axis = {z0.id, z1.id};608 *concat_load2.y.axis = {z0.id, z1.id};
608- *concat_load2.y.repeats = {s0, s2};609+ *concat_load2.y.repeats = {s0, input_dim};
609- *concat_load2.y.strides = {s2, ONE};610+ *concat_load2.y.strides = {input_dim, ONE};
610 611 
611 af::ascir_op::Concat concat("concat");612 af::ascir_op::Concat concat("concat");
612 concat.x = {x1Local.y, x2Local.y, concat_load2.y};613 concat.x = {x1Local.y, x2Local.y, concat_load2.y};
613 concat.attr.sched.axis = {z0.id, z1.id};614 concat.attr.sched.axis = {z0.id, z1.id};
614 *concat.y.axis = {z0.id, z1.id};615 *concat.y.axis = {z0.id, z1.id};
615- *concat.y.repeats = {s0, s1 + s2 + s2};616+ *concat.y.repeats = {s0, s1 + input_dim + input_dim};
616- *concat.y.strides = {s1 + s2 + s2, ONE};617+ *concat.y.strides = {s1 + input_dim + input_dim, ONE};
617 618 
618 af::ascir_op::Store x_out("concat_store");619 af::ascir_op::Store x_out("concat_store");
619 x_out.x = concat.y;620 x_out.x = concat.y;
620 x_out.attr.sched.axis = {z0.id, z1.id};621 x_out.attr.sched.axis = {z0.id, z1.id};
621 *x_out.y.axis = {z0.id, z1.id};622 *x_out.y.axis = {z0.id, z1.id};
622- *x_out.y.repeats = {s0, s1 + s2 + s2};623+ *x_out.y.repeats = {s0, s1 + input_dim + input_dim};
623- *x_out.y.strides = {s1 + s2 + s2, ONE};624+ *x_out.y.strides = {s1 + input_dim + input_dim, ONE};
624 625 
625 af::ascir_op::Output y("concat_out");626 af::ascir_op::Output y("concat_out");
626 y.x = x_out.y;627 y.x = x_out.y;
@@ -1378,7 +1379,7 @@ TEST_F(OptimizerSt, AscBcNodeUnfolder_With_Same_Data_Same_Load) {
1378 1379 
1379 auto add_sub_graph1 = BuildAddAscGraph("sub1_add");1380 auto add_sub_graph1 = BuildAddAscGraph("sub1_add");
1380 auto add_sub_graph2 = BuildAddAscGraph3("sub2_add");1381 auto add_sub_graph2 = BuildAddAscGraph3("sub2_add");
1381- auto concat_sub_graph = BuildConcatAscGraph("sub3_concat");1382+ auto concat_sub_graph = BuildConcatAscGraph("sub3_concat", true);
1382 1383 
1383 asc_backend_to_asc_graph.emplace(ascbc1.get(), add_sub_graph1);1384 asc_backend_to_asc_graph.emplace(ascbc1.get(), add_sub_graph1);
1384 asc_backend_to_asc_graph.emplace(ascbc2.get(), add_sub_graph2);1385 asc_backend_to_asc_graph.emplace(ascbc2.get(), add_sub_graph2);
Mautofuse/tests/ut/ascir/code_dumper_unittest.cc+0-12
@@ -55,7 +55,6 @@ void ConstructAscGraph(AscGraph &graph) {
55 Axis &s1_axis = graph.CreateAxis("S1", s1);55 Axis &s1_axis = graph.CreateAxis("S1", s1);
56 56 
57 ascir_op::Scalar scalar("Scalar", graph);57 ascir_op::Scalar scalar("Scalar", graph);
58- scalar.attr.sched.exec_order = 0;
59 scalar.attr.sched.axis = {s0_axis.id, s1_axis.id};58 scalar.attr.sched.axis = {s0_axis.id, s1_axis.id};
60 scalar.y.dtype = af::DT_FLOAT16;59 scalar.y.dtype = af::DT_FLOAT16;
61 scalar.y.format = af::FORMAT_ND;60 scalar.y.format = af::FORMAT_ND;
@@ -65,7 +64,6 @@ void ConstructAscGraph(AscGraph &graph) {
65 scalar.ir_attr.SetValue("Test");64 scalar.ir_attr.SetValue("Test");
66 65 
67 ascir_op::Data data1("data1", graph);66 ascir_op::Data data1("data1", graph);
68- data1.attr.sched.exec_order = 0;
69 data1.attr.sched.axis = {s0_axis.id, s1_axis.id};67 data1.attr.sched.axis = {s0_axis.id, s1_axis.id};
70 data1.y.dtype = af::DT_FLOAT16;68 data1.y.dtype = af::DT_FLOAT16;
71 data1.y.format = af::FORMAT_ND;69 data1.y.format = af::FORMAT_ND;
@@ -75,7 +73,6 @@ void ConstructAscGraph(AscGraph &graph) {
75 data1.ir_attr.SetIndex(2);73 data1.ir_attr.SetIndex(2);
76 74 
77 ascir_op::Data data2("data2", graph);75 ascir_op::Data data2("data2", graph);
78- data2.attr.sched.exec_order = 0;
79 data2.attr.sched.axis = {s0_axis.id, s1_axis.id};76 data2.attr.sched.axis = {s0_axis.id, s1_axis.id};
80 data2.y.dtype = af::DT_FLOAT16;77 data2.y.dtype = af::DT_FLOAT16;
81 data2.y.format = af::FORMAT_ND;78 data2.y.format = af::FORMAT_ND;
@@ -87,7 +84,6 @@ void ConstructAscGraph(AscGraph &graph) {
87 ascir_op::Add add("add");84 ascir_op::Add add("add");
88 add.x1 = scalar.y;85 add.x1 = scalar.y;
89 add.x2 = scalar.y;86 add.x2 = scalar.y;
90- add.attr.sched.exec_order = 1;
91 add.attr.sched.axis = {s0_axis.id, s1_axis.id};87 add.attr.sched.axis = {s0_axis.id, s1_axis.id};
92 add.y.dtype = af::DT_FLOAT16;88 add.y.dtype = af::DT_FLOAT16;
93 add.y.format = af::FORMAT_ND;89 add.y.format = af::FORMAT_ND;
@@ -97,7 +93,6 @@ void ConstructAscGraph(AscGraph &graph) {
97 93 
98 ascir_op::Exp exp("exp");94 ascir_op::Exp exp("exp");
99 exp.x = scalar.y;95 exp.x = scalar.y;
100- exp.attr.sched.exec_order = 2;
101 exp.attr.sched.axis = {s0_axis.id, s1_axis.id};96 exp.attr.sched.axis = {s0_axis.id, s1_axis.id};
102 exp.y.dtype = af::DT_FLOAT16;97 exp.y.dtype = af::DT_FLOAT16;
103 exp.y.format = af::FORMAT_ND;98 exp.y.format = af::FORMAT_ND;
@@ -107,7 +102,6 @@ void ConstructAscGraph(AscGraph &graph) {
107 102 
108 ascir_op::Concat concat("concat");103 ascir_op::Concat concat("concat");
109 concat.x = {add.y, exp.y};104 concat.x = {add.y, exp.y};
110- concat.attr.sched.exec_order = 3;
111 concat.attr.sched.axis = {s0_axis.id, s1_axis.id};105 concat.attr.sched.axis = {s0_axis.id, s1_axis.id};
112 concat.y.dtype = af::DT_FLOAT16;106 concat.y.dtype = af::DT_FLOAT16;
113 concat.y.format = af::FORMAT_ND;107 concat.y.format = af::FORMAT_ND;
@@ -119,7 +113,6 @@ void ConstructAscGraph(AscGraph &graph) {
119 fake_opa.x1 = exp.y;113 fake_opa.x1 = exp.y;
120 fake_opa.x2 = exp.y; // 可选输入114 fake_opa.x2 = exp.y; // 可选输入
121 fake_opa.x3 = data1.y;115 fake_opa.x3 = data1.y;
122- fake_opa.attr.sched.exec_order = 4;
123 fake_opa.attr.sched.axis = {s0_axis.id, s1_axis.id};116 fake_opa.attr.sched.axis = {s0_axis.id, s1_axis.id};
124 fake_opa.y.dtype = af::DT_FLOAT16;117 fake_opa.y.dtype = af::DT_FLOAT16;
125 fake_opa.y.format = af::FORMAT_ND;118 fake_opa.y.format = af::FORMAT_ND;
@@ -132,7 +125,6 @@ void ConstructAscGraph(AscGraph &graph) {
132 leaky_relu.ir_attr.SetNegative_slope(1);125 leaky_relu.ir_attr.SetNegative_slope(1);
133 126 
134 ascir_op::Output output("output");127 ascir_op::Output output("output");
135- output.attr.sched.exec_order = 4;
136 output.x = fake_opa.y;128 output.x = fake_opa.y;
137 output.ir_attr.SetIndex(1);129 output.ir_attr.SetIndex(1);
138}130}
@@ -225,7 +217,6 @@ void ConstructWrongAscGraph(AscGraph &graph) {
225 Axis &s1_axis = graph.CreateAxis("S1", s1);217 Axis &s1_axis = graph.CreateAxis("S1", s1);
226 218 
227 ascir_op::Data data("data", graph);219 ascir_op::Data data("data", graph);
228- data.attr.sched.exec_order = 0;
229 data.attr.sched.axis = {s0_axis.id, s1_axis.id};220 data.attr.sched.axis = {s0_axis.id, s1_axis.id};
230 data.y.dtype = af::DT_FLOAT16;221 data.y.dtype = af::DT_FLOAT16;
231 data.y.format = af::FORMAT_ND;222 data.y.format = af::FORMAT_ND;
@@ -236,7 +227,6 @@ void ConstructWrongAscGraph(AscGraph &graph) {
236 227 
237 ascir_op::Add add("add");228 ascir_op::Add add("add");
238 add.x1 = data.y;229 add.x1 = data.y;
239- add.attr.sched.exec_order = 1;
240 add.attr.sched.axis = {s0_axis.id, s1_axis.id};230 add.attr.sched.axis = {s0_axis.id, s1_axis.id};
241 add.y.dtype = af::DT_FLOAT16;231 add.y.dtype = af::DT_FLOAT16;
242 add.y.format = af::FORMAT_ND;232 add.y.format = af::FORMAT_ND;
@@ -246,7 +236,6 @@ void ConstructWrongAscGraph(AscGraph &graph) {
246 236 
247 ascir_op::Exp exp("exp");237 ascir_op::Exp exp("exp");
248 exp.x = add.y;238 exp.x = add.y;
249- exp.attr.sched.exec_order = 2;
250 exp.attr.sched.axis = {s0_axis.id, s1_axis.id};239 exp.attr.sched.axis = {s0_axis.id, s1_axis.id};
251 exp.y.dtype = af::DT_FLOAT16;240 exp.y.dtype = af::DT_FLOAT16;
252 exp.y.format = af::FORMAT_ND;241 exp.y.format = af::FORMAT_ND;
@@ -257,7 +246,6 @@ void ConstructWrongAscGraph(AscGraph &graph) {
257 add.x2 = exp.y;246 add.x2 = exp.y;
258 247 
259 ascir_op::Output output("output");248 ascir_op::Output output("output");
260- output.attr.sched.exec_order = 4;
261 output.x = add.y;249 output.x = add.y;
262 output.ir_attr.SetIndex(1);250 output.ir_attr.SetIndex(1);
263}251}
Mautofuse/tests/ut/att/testcase/ascir/test_ascir_graph.cpp+0-6
@@ -29,7 +29,6 @@ void MakeGraph0Normal(af::AscGraph &graph) {
29 auto z2 = graph.CreateAxis("z2", s2);29 auto z2 = graph.CreateAxis("z2", s2);
30 30 
31 Data x("x", graph);31 Data x("x", graph);
32- x.attr.sched.exec_order = 0;
33 x.attr.sched.axis = {z0.id, z1.id, z2.id};32 x.attr.sched.axis = {z0.id, z1.id, z2.id};
34 33 
35 x.y.dtype = af::DT_FLOAT16;34 x.y.dtype = af::DT_FLOAT16;
@@ -39,7 +38,6 @@ void MakeGraph0Normal(af::AscGraph &graph) {
39 38 
40 Load load("load");39 Load load("load");
41 load.x = x.y;40 load.x = x.y;
42- load.attr.sched.exec_order = 1;
43 load.attr.sched.axis = {z0.id, z1.id, z2.id};41 load.attr.sched.axis = {z0.id, z1.id, z2.id};
44 42 
45 load.y.dtype = af::DT_FLOAT16;43 load.y.dtype = af::DT_FLOAT16;
@@ -48,7 +46,6 @@ void MakeGraph0Normal(af::AscGraph &graph) {
48 *load.y.strides = {s1 * s2, s2, ONE};46 *load.y.strides = {s1 * s2, s2, ONE};
49 Abs abs("abs");47 Abs abs("abs");
50 abs.x = load.y;48 abs.x = load.y;
51- abs.attr.sched.exec_order = 2;
52 abs.attr.sched.axis = {z0.id, z1.id, z2.id};49 abs.attr.sched.axis = {z0.id, z1.id, z2.id};
53 50 
54 abs.y.dtype = af::DT_FLOAT16;51 abs.y.dtype = af::DT_FLOAT16;
@@ -57,7 +54,6 @@ void MakeGraph0Normal(af::AscGraph &graph) {
57 *abs.y.strides = {s1 * s2, s2, ONE};54 *abs.y.strides = {s1 * s2, s2, ONE};
58 Store store("store");55 Store store("store");
59 store.x = abs.y;56 store.x = abs.y;
60- store.attr.sched.exec_order = 3;
61 store.attr.sched.axis = {z0.id, z1.id, z2.id};57 store.attr.sched.axis = {z0.id, z1.id, z2.id};
62 58 
63 store.y.dtype = af::DT_FLOAT16;59 store.y.dtype = af::DT_FLOAT16;
@@ -66,7 +62,6 @@ void MakeGraph0Normal(af::AscGraph &graph) {
66 *store.y.strides = {s1 * s2, s2, ONE};62 *store.y.strides = {s1 * s2, s2, ONE};
67 Output y("y");63 Output y("y");
68 y.x = store.y;64 y.x = store.y;
69- y.attr.sched.exec_order = 4;
70 y.attr.sched.axis = {z0.id, z1.id, z2.id};65 y.attr.sched.axis = {z0.id, z1.id, z2.id};
71 66 
72 y.y.dtype = af::DT_FLOAT16;67 y.y.dtype = af::DT_FLOAT16;
@@ -88,7 +83,6 @@ void MakeGraph0ByCg(af::AscGraph &graph) {
88 LOOP(z1) {83 LOOP(z1) {
89 LOOP(z2) {84 LOOP(z2) {
90 // 当前作用域内的所有的节点自动设置为sched.axis设置为{z0, z1, z2}85 // 当前作用域内的所有的节点自动设置为sched.axis设置为{z0, z1, z2}
91- // 执行序exec_order根据创建的节点顺序自动生成
92 auto x =86 auto x =
93 cg::ContiguousData("x", graph, af::DT_FLOAT16, axis); // 因为是连续tensor, 由axis推导出repeats, strides87 cg::ContiguousData("x", graph, af::DT_FLOAT16, axis); // 因为是连续tensor, 由axis推导出repeats, strides
94 auto load = ascir::cg::Load(88 auto load = ascir::cg::Load(
Mautofuse/tests/ut/att/testcase/ascir/test_ascir_ops.cpp+0-24
@@ -183,28 +183,4 @@ TEST(AscirOps_FlashSoftmaxInferDataType, Ok) {
183 EXPECT_EQ(fs->outputs[1].attr.dtype, af::DT_INT32);183 EXPECT_EQ(fs->outputs[1].attr.dtype, af::DT_INT32);
184 EXPECT_EQ(fs->outputs[2].attr.dtype, af::DT_INT32);184 EXPECT_EQ(fs->outputs[2].attr.dtype, af::DT_INT32);
185}185}
186-TEST(AscirOps, ExecOrderIncreaseOk) {
187- af::AscGraph graph("test_graph");
188- auto A = af::Symbol("A");
189- auto B = af::Symbol("B");
190- auto C = af::Symbol("C");
191- auto a = graph.CreateAxis("a", A);
192- auto b = graph.CreateAxis("b", B);
193- auto c = graph.CreateAxis("c", C);
194- 
195- auto data0 = ascir::cg::ContiguousData("data0", graph, af::DT_INT32, {a, b, c});
196- auto data1 = ascir::cg::ContiguousData("data1", graph, af::DT_FLOAT16, {a, b, c});
197- auto data2 = ascir::cg::ContiguousData("data2", graph, af::DT_FLOAT16, {a, b, c});
198- 
199- ascir::cg::FlashSoftmax("fs", data0, data1, data2);
200- 
201- auto data0_node = graph.FindNode("data0");
202- auto data1_node = graph.FindNode("data1");
203- auto data2_node = graph.FindNode("data2");
204- auto fs_node = graph.FindNode("fs");
205- EXPECT_EQ(static_cast<int64_t>(data0_node->attr.sched.exec_order), 0);
206- EXPECT_EQ(static_cast<int64_t>(data1_node->attr.sched.exec_order), 1);
207- EXPECT_EQ(static_cast<int64_t>(data2_node->attr.sched.exec_order), 2);
208- EXPECT_EQ(static_cast<int64_t>(fs_node->attr.sched.exec_order), 3);
209-}
210}; // namespace af186}; // namespace af
Mautofuse/tests/ut/att/testcase/gen_model_info/core/test_brc_buf_graph.cpp+27-36
@@ -15,9 +15,8 @@ using namespace att;
15using namespace af::ascir_op;15using namespace af::ascir_op;
16namespace {16namespace {
17template <typename T>17template <typename T>
18-void InitGraphNode(T &node, int32_t &exec_order, std::initializer_list<int64_t> axis, af::DataType dtype,18+void InitGraphNode(T &node, std::initializer_list<int64_t> axis, af::DataType dtype,
19 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {19 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {
20- node.attr.sched.exec_order = exec_order++;
21 node.attr.sched.axis = axis;20 node.attr.sched.axis = axis;
22 node.y.dtype = dtype;21 node.y.dtype = dtype;
23 *node.y.axis = axis;22 *node.y.axis = axis;
@@ -106,31 +105,29 @@ void BrcBufBeforeAutoFuse1(af::AscGraph &graph) {
106 auto normalS = std::initializer_list<Expr>{Z1 * Z2, Z2, ONE};105 auto normalS = std::initializer_list<Expr>{Z1 * Z2, Z2, ONE};
107 auto beforeR = std::initializer_list<Expr>{Z0, ONE, Z2};106 auto beforeR = std::initializer_list<Expr>{Z0, ONE, Z2};
108 auto beforeS = std::initializer_list<Expr>{Z2, ZERO, ONE};107 auto beforeS = std::initializer_list<Expr>{Z2, ZERO, ONE};
109- int32_t exec_order = 0;
110 108 
111 Data input_data("input_data", graph);109 Data input_data("input_data", graph);
112- InitGraphNode(input_data, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);110+ InitGraphNode(input_data, axis, af::DT_FLOAT16, beforeR, beforeS);
113 Load load("load");111 Load load("load");
114 load.x = input_data.y;112 load.x = input_data.y;
115- InitGraphNode(load, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);113+ InitGraphNode(load, axis, af::DT_FLOAT16, beforeR, beforeS);
116 Cast cast0("cast0");114 Cast cast0("cast0");
117 cast0.x = load.y;115 cast0.x = load.y;
118- InitGraphNode(cast0, exec_order, axis, af::DT_FLOAT, beforeR, beforeS);116+ InitGraphNode(cast0, axis, af::DT_FLOAT, beforeR, beforeS);
119 Broadcast broadcast("broadcast");117 Broadcast broadcast("broadcast");
120 broadcast.x = cast0.y;118 broadcast.x = cast0.y;
121- InitGraphNode(broadcast, exec_order, axis, af::DT_FLOAT, normalR, normalS);119+ InitGraphNode(broadcast, axis, af::DT_FLOAT, normalR, normalS);
122 Sum sum("sum");120 Sum sum("sum");
123 sum.x = broadcast.y;121 sum.x = broadcast.y;
124- InitGraphNode(sum, exec_order, axis, af::DT_FLOAT, beforeR, beforeS);122+ InitGraphNode(sum, axis, af::DT_FLOAT, beforeR, beforeS);
125 Cast cast1("cast1");123 Cast cast1("cast1");
126 cast1.x = sum.y;124 cast1.x = sum.y;
127- InitGraphNode(cast1, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);125+ InitGraphNode(cast1, axis, af::DT_FLOAT16, beforeR, beforeS);
128 Store store("store");126 Store store("store");
129 store.x = cast1.y;127 store.x = cast1.y;
130- InitGraphNode(store, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);128+ InitGraphNode(store, axis, af::DT_FLOAT16, beforeR, beforeS);
131 Output output_data("output_data");129 Output output_data("output_data");
132 output_data.x = store.y;130 output_data.x = store.y;
133- output_data.attr.sched.exec_order = exec_order++;
134}131}
135 132 
136void BrcBufAfterScheduler1(af::AscGraph &graph) {133void BrcBufAfterScheduler1(af::AscGraph &graph) {
@@ -194,31 +191,29 @@ void BrcBufBeforeAutoFuse2(af::AscGraph &graph) {
194 auto beforeS = std::initializer_list<Expr>{Z2, ZERO, ONE};191 auto beforeS = std::initializer_list<Expr>{Z2, ZERO, ONE};
195 auto reduceR = std::initializer_list<Expr>{Z0, Z1, ONE};192 auto reduceR = std::initializer_list<Expr>{Z0, Z1, ONE};
196 auto reduceS = std::initializer_list<Expr>{Z1, ONE, ZERO};193 auto reduceS = std::initializer_list<Expr>{Z1, ONE, ZERO};
197- int32_t exec_order = 0;
198 194 
199 Data input_data("input_data", graph);195 Data input_data("input_data", graph);
200- InitGraphNode(input_data, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);196+ InitGraphNode(input_data, axis, af::DT_FLOAT16, beforeR, beforeS);
201 Load load("load");197 Load load("load");
202 load.x = input_data.y;198 load.x = input_data.y;
203- InitGraphNode(load, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);199+ InitGraphNode(load, axis, af::DT_FLOAT16, beforeR, beforeS);
204 Cast cast0("cast0");200 Cast cast0("cast0");
205 cast0.x = load.y;201 cast0.x = load.y;
206- InitGraphNode(cast0, exec_order, axis, af::DT_FLOAT, beforeR, beforeS);202+ InitGraphNode(cast0, axis, af::DT_FLOAT, beforeR, beforeS);
207 Broadcast broadcast("broadcast");203 Broadcast broadcast("broadcast");
208 broadcast.x = cast0.y;204 broadcast.x = cast0.y;
209- InitGraphNode(broadcast, exec_order, axis, af::DT_FLOAT, normalR, normalS);205+ InitGraphNode(broadcast, axis, af::DT_FLOAT, normalR, normalS);
210 Sum sum("sum");206 Sum sum("sum");
211 sum.x = broadcast.y;207 sum.x = broadcast.y;
212- InitGraphNode(sum, exec_order, axis, af::DT_FLOAT, reduceR, reduceS);208+ InitGraphNode(sum, axis, af::DT_FLOAT, reduceR, reduceS);
213 Cast cast1("cast1");209 Cast cast1("cast1");
214 cast1.x = sum.y;210 cast1.x = sum.y;
215- InitGraphNode(cast1, exec_order, axis, af::DT_FLOAT16, reduceR, reduceS);211+ InitGraphNode(cast1, axis, af::DT_FLOAT16, reduceR, reduceS);
216 Store store("store");212 Store store("store");
217 store.x = cast1.y;213 store.x = cast1.y;
218- InitGraphNode(store, exec_order, axis, af::DT_FLOAT16, reduceR, reduceS);214+ InitGraphNode(store, axis, af::DT_FLOAT16, reduceR, reduceS);
219 Output output_data("output_data");215 Output output_data("output_data");
220 output_data.x = store.y;216 output_data.x = store.y;
221- output_data.attr.sched.exec_order = exec_order++;
222}217}
223 218 
224void BrcBufBeforeAutoFuse3(af::AscGraph &graph) {219void BrcBufBeforeAutoFuse3(af::AscGraph &graph) {
@@ -236,28 +231,26 @@ void BrcBufBeforeAutoFuse3(af::AscGraph &graph) {
236 auto normalS = std::initializer_list<Expr>{Z1 * Z2, Z2, ONE};231 auto normalS = std::initializer_list<Expr>{Z1 * Z2, Z2, ONE};
237 auto beforeR = std::initializer_list<Expr>{Z0, ONE, Z2};232 auto beforeR = std::initializer_list<Expr>{Z0, ONE, Z2};
238 auto beforeS = std::initializer_list<Expr>{Z2, ZERO, ONE};233 auto beforeS = std::initializer_list<Expr>{Z2, ZERO, ONE};
239- int32_t exec_order = 0;
240 234 
241 Data input_data("input_data", graph);235 Data input_data("input_data", graph);
242- InitGraphNode(input_data, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);236+ InitGraphNode(input_data, axis, af::DT_FLOAT16, beforeR, beforeS);
243 Load load("load");237 Load load("load");
244 load.x = input_data.y;238 load.x = input_data.y;
245- InitGraphNode(load, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);239+ InitGraphNode(load, axis, af::DT_FLOAT16, beforeR, beforeS);
246 Cast cast0("cast0");240 Cast cast0("cast0");
247 cast0.x = load.y;241 cast0.x = load.y;
248- InitGraphNode(cast0, exec_order, axis, af::DT_FLOAT, beforeR, beforeS);242+ InitGraphNode(cast0, axis, af::DT_FLOAT, beforeR, beforeS);
249 Broadcast broadcast("broadcast");243 Broadcast broadcast("broadcast");
250 broadcast.x = cast0.y;244 broadcast.x = cast0.y;
251- InitGraphNode(broadcast, exec_order, axis, af::DT_FLOAT, normalR, normalS);245+ InitGraphNode(broadcast, axis, af::DT_FLOAT, normalR, normalS);
252 Cast cast1("cast1");246 Cast cast1("cast1");
253 cast1.x = broadcast.y;247 cast1.x = broadcast.y;
254- InitGraphNode(cast1, exec_order, axis, af::DT_FLOAT16, normalR, normalS);248+ InitGraphNode(cast1, axis, af::DT_FLOAT16, normalR, normalS);
255 Store store("store");249 Store store("store");
256 store.x = cast1.y;250 store.x = cast1.y;
257- InitGraphNode(store, exec_order, axis, af::DT_FLOAT16, normalR, normalS);251+ InitGraphNode(store, axis, af::DT_FLOAT16, normalR, normalS);
258 Output output_data("output_data");252 Output output_data("output_data");
259 output_data.x = store.y;253 output_data.x = store.y;
260- output_data.attr.sched.exec_order = exec_order++;
261}254}
262 255 
263void BrcBufAfterScheduler3(af::AscGraph &graph) {256void BrcBufAfterScheduler3(af::AscGraph &graph) {
@@ -318,28 +311,26 @@ void BrcBufBeforeAutoFuse4(af::AscGraph &graph) {
318 auto normalS = std::initializer_list<Expr>{Z1 * Z2, Z2, ONE};311 auto normalS = std::initializer_list<Expr>{Z1 * Z2, Z2, ONE};
319 auto beforeR = std::initializer_list<Expr>{Z0, ONE, Z2};312 auto beforeR = std::initializer_list<Expr>{Z0, ONE, Z2};
320 auto beforeS = std::initializer_list<Expr>{Z2, ZERO, ONE};313 auto beforeS = std::initializer_list<Expr>{Z2, ZERO, ONE};
321- int32_t exec_order = 0;
322 314 
323 Data input_data("input_data", graph);315 Data input_data("input_data", graph);
324- InitGraphNode(input_data, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);316+ InitGraphNode(input_data, axis, af::DT_FLOAT16, beforeR, beforeS);
325 Load load("load");317 Load load("load");
326 load.x = input_data.y;318 load.x = input_data.y;
327- InitGraphNode(load, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);319+ InitGraphNode(load, axis, af::DT_FLOAT16, beforeR, beforeS);
328 Cast cast0("cast0");320 Cast cast0("cast0");
329 cast0.x = load.y;321 cast0.x = load.y;
330- InitGraphNode(cast0, exec_order, axis, af::DT_FLOAT, beforeR, beforeS);322+ InitGraphNode(cast0, axis, af::DT_FLOAT, beforeR, beforeS);
331 Sum sum("sum");323 Sum sum("sum");
332 sum.x = cast0.y;324 sum.x = cast0.y;
333- InitGraphNode(sum, exec_order, axis, af::DT_FLOAT, beforeR, beforeS);325+ InitGraphNode(sum, axis, af::DT_FLOAT, beforeR, beforeS);
334 Cast cast1("cast1");326 Cast cast1("cast1");
335 cast1.x = sum.y;327 cast1.x = sum.y;
336- InitGraphNode(cast1, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);328+ InitGraphNode(cast1, axis, af::DT_FLOAT16, beforeR, beforeS);
337 Store store("store");329 Store store("store");
338 store.x = cast1.y;330 store.x = cast1.y;
339- InitGraphNode(store, exec_order, axis, af::DT_FLOAT16, beforeR, beforeS);331+ InitGraphNode(store, axis, af::DT_FLOAT16, beforeR, beforeS);
340 Output output_data("output_data");332 Output output_data("output_data");
341 output_data.x = store.y;333 output_data.x = store.y;
342- output_data.attr.sched.exec_order = exec_order++;
343}334}
344 335 
345void BrcBufAfterScheduler4(af::AscGraph &graph) {336void BrcBufAfterScheduler4(af::AscGraph &graph) {
Mautofuse/tests/ut/att/testcase/gen_model_info/core/test_concat.cpp+38-45
@@ -21,9 +21,8 @@
21 21 
22using namespace af::ascir_op;22using namespace af::ascir_op;
23namespace {23namespace {
24-void InitDataNode(Data &node, int &exec_order, const std::vector<int64_t> &axis, af::DataType dtype,24+void InitDataNode(Data &node, const std::vector<int64_t> &axis, af::DataType dtype,
25 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {25 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {
26- node.attr.sched.exec_order = exec_order++;
27 node.attr.sched.axis = axis;26 node.attr.sched.axis = axis;
28 node.y.dtype = dtype;27 node.y.dtype = dtype;
29 *node.y.axis = axis;28 *node.y.axis = axis;
@@ -31,9 +30,8 @@ void InitDataNode(Data &node, int &exec_order, const std::vector<int64_t> &axis,
31 *node.y.strides = strides;30 *node.y.strides = strides;
32}31}
33 32 
34-void InitLoadNode(Load &node, int &exec_order, const std::vector<int64_t> &axis, af::DataType dtype,33+void InitLoadNode(Load &node, const std::vector<int64_t> &axis, af::DataType dtype,
35 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {34 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {
36- node.attr.sched.exec_order = exec_order++;
37 node.attr.sched.axis = axis;35 node.attr.sched.axis = axis;
38 node.y.dtype = dtype;36 node.y.dtype = dtype;
39 *node.y.axis = axis;37 *node.y.axis = axis;
@@ -41,9 +39,8 @@ void InitLoadNode(Load &node, int &exec_order, const std::vector<int64_t> &axis,
41 *node.y.strides = strides;39 *node.y.strides = strides;
42}40}
43 41 
44-void InitStoreNode(Store &node, int &exec_order, const std::vector<int64_t> &axis, af::DataType dtype,42+void InitStoreNode(Store &node, const std::vector<int64_t> &axis, af::DataType dtype,
45 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {43 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {
46- node.attr.sched.exec_order = exec_order++;
47 node.attr.sched.axis = axis;44 node.attr.sched.axis = axis;
48 node.y.dtype = dtype;45 node.y.dtype = dtype;
49 *node.y.axis = axis;46 *node.y.axis = axis;
@@ -51,9 +48,8 @@ void InitStoreNode(Store &node, int &exec_order, const std::vector<int64_t> &axi
51 *node.y.strides = strides;48 *node.y.strides = strides;
52}49}
53 50 
54-void InitOutputNode(Output &node, int &exec_order, const std::vector<int64_t> &axis, af::DataType dtype,51+void InitOutputNode(Output &node, const std::vector<int64_t> &axis, af::DataType dtype,
55 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {52 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {
56- node.attr.sched.exec_order = exec_order++;
57 node.y.dtype = dtype;53 node.y.dtype = dtype;
58 *node.y.axis = axis;54 *node.y.axis = axis;
59 *node.y.repeats = repeats;55 *node.y.repeats = repeats;
@@ -104,9 +100,8 @@ std::string RemoveAutoFuseTilingHeadGuards(const std::string &input) {
104 100 
105 return oss.str();101 return oss.str();
106}102}
107-void InitConcatAxes(Concat &node, int &exec_order, const std::vector<int64_t> &axis, af::DataType dtype,103+void InitConcatAxes(Concat &node, const std::vector<int64_t> &axis, af::DataType dtype,
108 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {104 const std::vector<af::Expression> &repeats, const std::vector<af::Expression> &strides) {
109- node.attr.sched.exec_order = exec_order++;
110 node.attr.sched.axis = axis;105 node.attr.sched.axis = axis;
111 node.y.dtype = dtype;106 node.y.dtype = dtype;
112 *node.y.axis = axis;107 *node.y.axis = axis;
@@ -123,59 +118,57 @@ void Concat_Normal_BeforeAutofuse(ascir::HintGraph &graph) {
123 auto str_ar = std::vector<af::Expression>{R, ONE, ZERO};118 auto str_ar = std::vector<af::Expression>{R, ONE, ZERO};
124 auto rep_a = std::vector<af::Expression>{A, ONE, ONE};119 auto rep_a = std::vector<af::Expression>{A, ONE, ONE};
125 auto str_a = std::vector<af::Expression>{ONE, ZERO, ZERO};120 auto str_a = std::vector<af::Expression>{ONE, ZERO, ZERO};
126- int exec_order = 0;
127 121 
128 Data x1("x1", graph);122 Data x1("x1", graph);
129- InitDataNode(x1, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);123+ InitDataNode(x1, axis, af::DT_FLOAT16, rep_ar, str_ar);
130 Load x1L("x1Local");124 Load x1L("x1Local");
131 x1L.x = x1.y;125 x1L.x = x1.y;
132- InitLoadNode(x1L, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);126+ InitLoadNode(x1L, axis, af::DT_FLOAT16, rep_ar, str_ar);
133 Data x2("x2", graph);127 Data x2("x2", graph);
134- InitDataNode(x2, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);128+ InitDataNode(x2, axis, af::DT_FLOAT16, rep_ar, str_ar);
135 Load x2L("x2Local");129 Load x2L("x2Local");
136 x2L.x = x2.y;130 x2L.x = x2.y;
137- InitLoadNode(x2L, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);131+ InitLoadNode(x2L, axis, af::DT_FLOAT16, rep_ar, str_ar);
138 Data bias("bias", graph);132 Data bias("bias", graph);
139- InitDataNode(bias, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);133+ InitDataNode(bias, axis, af::DT_FLOAT16, rep_ar, str_ar);
140 Load biasL("biasLocal");134 Load biasL("biasLocal");
141 biasL.x = bias.y;135 biasL.x = bias.y;
142- InitLoadNode(biasL, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);136+ InitLoadNode(biasL, axis, af::DT_FLOAT16, rep_ar, str_ar);
143 137 
144 Concat mean("mean");138 Concat mean("mean");
145 mean.x = {x1L.y, x2L.y, biasL.y};139 mean.x = {x1L.y, x2L.y, biasL.y};
146- InitConcatAxes(mean, exec_order, axis, af::DT_FLOAT, rep_ar, str_ar);140+ InitConcatAxes(mean, axis, af::DT_FLOAT, rep_ar, str_ar);
147 Store x_out("x_out");141 Store x_out("x_out");
148 x_out.x = mean.y;142 x_out.x = mean.y;
149- InitStoreNode(x_out, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);143+ InitStoreNode(x_out, axis, af::DT_FLOAT16, rep_ar, str_ar);
150 Store mean_out("mean_out");144 Store mean_out("mean_out");
151 mean_out.x = mean.y;145 mean_out.x = mean.y;
152- InitStoreNode(mean_out, exec_order, axis, af::DT_FLOAT, rep_a, str_a);146+ InitStoreNode(mean_out, axis, af::DT_FLOAT, rep_a, str_a);
153 147 
154 Data one("one", graph);148 Data one("one", graph);
155- InitDataNode(one, exec_order, axis, af::DT_FLOAT, {ONE, ONE, BL}, {ZERO, ZERO, ONE});149+ InitDataNode(one, axis, af::DT_FLOAT, {ONE, ONE, BL}, {ZERO, ZERO, ONE});
156 Concat rstd("rstd");150 Concat rstd("rstd");
157 rstd.x = {mean.y, mean.y, one.y};151 rstd.x = {mean.y, mean.y, one.y};
158- InitConcatAxes(rstd, exec_order, axis, af::DT_FLOAT, rep_ar, str_ar);152+ InitConcatAxes(rstd, axis, af::DT_FLOAT, rep_ar, str_ar);
159 Store rstd_out("rstd_out");153 Store rstd_out("rstd_out");
160 rstd_out.x = rstd.y;154 rstd_out.x = rstd.y;
161- InitStoreNode(rstd_out, exec_order, axis, af::DT_FLOAT, rep_a, str_a);155+ InitStoreNode(rstd_out, axis, af::DT_FLOAT, rep_a, str_a);
162 156 
163 auto rep_r = std::vector<af::Expression>{ONE, R, ONE};157 auto rep_r = std::vector<af::Expression>{ONE, R, ONE};
164 auto str_r = std::vector<af::Expression>{ZERO, ONE, ZERO};158 auto str_r = std::vector<af::Expression>{ZERO, ONE, ZERO};
165 Data beta("beta", graph);159 Data beta("beta", graph);
166- InitDataNode(beta, exec_order, axis, af::DT_FLOAT16, rep_r, str_r);160+ InitDataNode(beta, axis, af::DT_FLOAT16, rep_r, str_r);
167 Load betaL("betaLocal");161 Load betaL("betaLocal");
168 betaL.x = beta.y;162 betaL.x = beta.y;
169- InitLoadNode(betaL, exec_order, axis, af::DT_FLOAT16, rep_r, str_r);163+ InitLoadNode(betaL, axis, af::DT_FLOAT16, rep_r, str_r);
170 Data gamma("gamma", graph);164 Data gamma("gamma", graph);
171- InitDataNode(gamma, exec_order, axis, af::DT_FLOAT16, rep_r, str_r);165+ InitDataNode(gamma, axis, af::DT_FLOAT16, rep_r, str_r);
172 Load gammaL("gammaLocal");166 Load gammaL("gammaLocal");
173 gammaL.x = gamma.y;167 gammaL.x = gamma.y;
174- InitLoadNode(gammaL, exec_order, axis, af::DT_FLOAT16, rep_r, str_r);168+ InitLoadNode(gammaL, axis, af::DT_FLOAT16, rep_r, str_r);
175 169 
176 Concat y("y");170 Concat y("y");
177 y.attr.api.unit = af::ComputeUnit::kUnitVector;171 y.attr.api.unit = af::ComputeUnit::kUnitVector;
178- y.attr.sched.exec_order = exec_order++;
179 y.attr.sched.axis = axis;172 y.attr.sched.axis = axis;
180 y.x = {rstd.y, betaL.y, gammaL.y, rstd.y};173 y.x = {rstd.y, betaL.y, gammaL.y, rstd.y};
181 y.y.dtype = af::DT_FLOAT16;174 y.y.dtype = af::DT_FLOAT16;
@@ -187,26 +180,26 @@ void Concat_Normal_BeforeAutofuse(ascir::HintGraph &graph) {
187 *concat.y.axis = axis, *concat.y.repeats = rep_ar, *concat.y.strides = str_ar;180 *concat.y.axis = axis, *concat.y.repeats = rep_ar, *concat.y.strides = str_ar;
188 Store cat_out("cat_out");181 Store cat_out("cat_out");
189 cat_out.x = y.y;182 cat_out.x = y.y;
190- InitStoreNode(cat_out, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);183+ InitStoreNode(cat_out, axis, af::DT_FLOAT16, rep_ar, str_ar);
191 Store y_out("y_out");184 Store y_out("y_out");
192 y_out.x = y.y;185 y_out.x = y.y;
193- InitStoreNode(y_out, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);186+ InitStoreNode(y_out, axis, af::DT_FLOAT16, rep_ar, str_ar);
194 187 
195 Output buf1("buf1");188 Output buf1("buf1");
196 buf1.x = x_out.y;189 buf1.x = x_out.y;
197- InitOutputNode(buf1, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);190+ InitOutputNode(buf1, axis, af::DT_FLOAT16, rep_ar, str_ar);
198 Output buf2("buf2");191 Output buf2("buf2");
199 buf2.x = mean_out.y;192 buf2.x = mean_out.y;
200- InitOutputNode(buf2, exec_order, axis, af::DT_FLOAT, rep_a, str_a);193+ InitOutputNode(buf2, axis, af::DT_FLOAT, rep_a, str_a);
201 Output buf3("buf3");194 Output buf3("buf3");
202 buf3.x = rstd_out.y;195 buf3.x = rstd_out.y;
203- InitOutputNode(buf3, exec_order, axis, af::DT_FLOAT, rep_a, str_a);196+ InitOutputNode(buf3, axis, af::DT_FLOAT, rep_a, str_a);
204 Output buf("buf");197 Output buf("buf");
205 buf.x = y_out.y;198 buf.x = y_out.y;
206- InitOutputNode(buf, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);199+ InitOutputNode(buf, axis, af::DT_FLOAT16, rep_ar, str_ar);
207 Output buf4("buf4");200 Output buf4("buf4");
208 buf4.x = cat_out.y;201 buf4.x = cat_out.y;
209- InitOutputNode(buf4, exec_order, axis, af::DT_FLOAT16, rep_ar, str_ar);202+ InitOutputNode(buf4, axis, af::DT_FLOAT16, rep_ar, str_ar);
210}203}
211 204 
212/*205/*
@@ -449,8 +442,8 @@ Status BuildTqueTbufAscendGraph_single_case(af::AscGraph &graph, bool reuse_temp
449 auto nd = graph.CreateAxis("nd", ND);442 auto nd = graph.CreateAxis("nd", ND);
450 auto [ndB, ndb] = graph.BlockSplit(nd.id);443 auto [ndB, ndb] = graph.BlockSplit(nd.id);
451 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);444 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
452- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});445+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
453- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});446+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
454 LOOP(*ndB) {447 LOOP(*ndB) {
455 LOOP(*ndbT) {448 LOOP(*ndbT) {
456 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);449 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -480,10 +473,10 @@ Status BuildTqueTbufAscendGraph_multi_case_g0(af::AscGraph &graph) {
480 auto nd = graph.CreateAxis("nd", ND);473 auto nd = graph.CreateAxis("nd", ND);
481 auto [ndB, ndb] = graph.BlockSplit(nd.id);474 auto [ndB, ndb] = graph.BlockSplit(nd.id);
482 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);475 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
483- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});476+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
484- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});477+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
485- auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {nd});478+ auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {nd}, 2);
486- auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {nd});479+ auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {nd}, 3);
487 LOOP(*ndB) {480 LOOP(*ndB) {
488 LOOP(*ndbT) {481 LOOP(*ndbT) {
489 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);482 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -523,10 +516,10 @@ Status BuildTqueTbufAscendGraph_multi_case_g1(af::AscGraph &graph) {
523 auto z0 = graph.CreateAxis("z0", S0);516 auto z0 = graph.CreateAxis("z0", S0);
524 auto [z0B, z0b] = graph.BlockSplit(z0.id);517 auto [z0B, z0b] = graph.BlockSplit(z0.id);
525 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);518 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);
526- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});519+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
527- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0});520+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0}, 1);
528- auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {z0});521+ auto data3 = graph.CreateContiguousData("input3", DT_FLOAT, {z0}, 2);
529- auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {z0});522+ auto data4 = graph.CreateContiguousData("input4", DT_FLOAT, {z0}, 3);
530 LOOP(*z0B) {523 LOOP(*z0B) {
531 LOOP(*z0bT) {524 LOOP(*z0bT) {
532 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);525 auto load_tque0 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/tests/ut/att/testcase/gen_model_info/core/test_fa_ascir_graph.cpp+48-59
@@ -14,9 +14,8 @@ namespace att {
14using namespace att;14using namespace att;
15using namespace af::ascir_op;15using namespace af::ascir_op;
16namespace {16namespace {
17-void InitDataNode(Data &node, int32_t &exec_order, std::initializer_list<int64_t> axis, af::DataType dtype,17+void InitDataNode(Data &node, std::initializer_list<int64_t> axis, af::DataType dtype,
18 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {18 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {
19- node.attr.sched.exec_order = exec_order++;
20 node.attr.sched.axis = axis;19 node.attr.sched.axis = axis;
21 node.y.dtype = dtype;20 node.y.dtype = dtype;
22 *node.y.axis = axis;21 *node.y.axis = axis;
@@ -24,9 +23,8 @@ void InitDataNode(Data &node, int32_t &exec_order, std::initializer_list<int64_t
24 *node.y.strides = strides;23 *node.y.strides = strides;
25}24}
26 25 
27-void InitLoadNode(Load &node, int32_t &exec_order, std::initializer_list<int64_t> axis, af::DataType dtype,26+void InitLoadNode(Load &node, std::initializer_list<int64_t> axis, af::DataType dtype,
28 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {27 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {
29- node.attr.sched.exec_order = exec_order++;
30 node.attr.sched.axis = axis;28 node.attr.sched.axis = axis;
31 node.y.dtype = dtype;29 node.y.dtype = dtype;
32 *node.y.axis = axis;30 *node.y.axis = axis;
@@ -34,9 +32,8 @@ void InitLoadNode(Load &node, int32_t &exec_order, std::initializer_list<int64_t
34 *node.y.strides = strides;32 *node.y.strides = strides;
35}33}
36 34 
37-void InitStoreNode(Store &node, int32_t &exec_order, std::initializer_list<int64_t> axis, af::DataType dtype,35+void InitStoreNode(Store &node, std::initializer_list<int64_t> axis, af::DataType dtype,
38 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {36 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {
39- node.attr.sched.exec_order = exec_order++;
40 node.attr.sched.axis = axis;37 node.attr.sched.axis = axis;
41 node.y.dtype = dtype;38 node.y.dtype = dtype;
42 *node.y.axis = axis;39 *node.y.axis = axis;
@@ -44,9 +41,8 @@ void InitStoreNode(Store &node, int32_t &exec_order, std::initializer_list<int64
44 *node.y.strides = strides;41 *node.y.strides = strides;
45}42}
46 43 
47-void InitOutputNode(Output &node, int32_t &exec_order, std::initializer_list<int64_t> axis, af::DataType dtype,44+void InitOutputNode(Output &node, std::initializer_list<int64_t> axis, af::DataType dtype,
48 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {45 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {
49- node.attr.sched.exec_order = exec_order++;
50 node.y.dtype = dtype;46 node.y.dtype = dtype;
51 *node.y.axis = axis;47 *node.y.axis = axis;
52 *node.y.repeats = repeats;48 *node.y.repeats = repeats;
@@ -54,9 +50,8 @@ void InitOutputNode(Output &node, int32_t &exec_order, std::initializer_list<int
54}50}
55 51 
56template <typename T>52template <typename T>
57-void InitUnaryNode(T &node, int32_t &exec_order, std::initializer_list<int64_t> axis, af::DataType dtype,53+void InitUnaryNode(T &node, std::initializer_list<int64_t> axis, af::DataType dtype,
58 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {54 std::initializer_list<Expr> repeats, std::initializer_list<Expr> strides) {
59- node.attr.sched.exec_order = exec_order++;
60 node.attr.sched.axis = axis;55 node.attr.sched.axis = axis;
61 node.y.dtype = dtype;56 node.y.dtype = dtype;
62 *node.y.axis = axis;57 *node.y.axis = axis;
@@ -212,44 +207,43 @@ void ApplyVec2NodesSched(af::AscGraph &graph, const SchedAxis &a) {
212}207}
213} // namespace208} // namespace
214 209 
215-void FaBeforeAutoFuseBmm1(af::AscGraph &graph, int32_t &exec_order, const std::initializer_list<int64_t> &bmmAxis,210+void FaBeforeAutoFuseBmm1(af::AscGraph &graph, const std::initializer_list<int64_t> &bmmAxis,
216 const std::initializer_list<Expr> &vec1R, const std::initializer_list<Expr> &vec1S,211 const std::initializer_list<Expr> &vec1R, const std::initializer_list<Expr> &vec1S,
217 const Expr &B, const Expr &N, const Expr &G, const Expr &S1, const Expr &S2, const Expr &D,212 const Expr &B, const Expr &N, const Expr &G, const Expr &S1, const Expr &S2, const Expr &D,
218 const Expr &ONE, const Expr &ZERO, Add &out_mul1) {213 const Expr &ONE, const Expr &ZERO, Add &out_mul1) {
219 Data query("query", graph);214 Data query("query", graph);
220- InitDataNode(query, exec_order, bmmAxis, af::DT_FLOAT16, {B, N, G, S1, ONE, D, ONE},215+ InitDataNode(query, bmmAxis, af::DT_FLOAT16, {B, N, G, S1, ONE, D, ONE},
221 {N * G * S1 * D, G * S1 * D, S1 * D, D, ZERO, ONE, ZERO});216 {N * G * S1 * D, G * S1 * D, S1 * D, D, ZERO, ONE, ZERO});
222 Data key("key", graph);217 Data key("key", graph);
223- InitDataNode(key, exec_order, bmmAxis, af::DT_FLOAT16, {B, N, G, ONE, S2, D, ONE},218+ InitDataNode(key, bmmAxis, af::DT_FLOAT16, {B, N, G, ONE, S2, D, ONE},
224 {N * S1 * D, S2 * D, S2 * D, ZERO, D, ONE, ZERO});219 {N * S1 * D, S2 * D, S2 * D, ZERO, D, ONE, ZERO});
225 Add bmm1("bmm1");220 Add bmm1("bmm1");
226 bmm1.x1 = query.y;221 bmm1.x1 = query.y;
227 bmm1.x2 = key.y;222 bmm1.x2 = key.y;
228- InitUnaryNode(bmm1, exec_order, bmmAxis, af::DT_FLOAT, vec1R, vec1S);223+ InitUnaryNode(bmm1, bmmAxis, af::DT_FLOAT, vec1R, vec1S);
229 Load load1("load1");224 Load load1("load1");
230 load1.x = bmm1.y;225 load1.x = bmm1.y;
231- InitLoadNode(load1, exec_order, bmmAxis, af::DT_FLOAT, vec1R, vec1S);226+ InitLoadNode(load1, bmmAxis, af::DT_FLOAT, vec1R, vec1S);
232 Data pse("pse", graph);227 Data pse("pse", graph);
233- InitDataNode(pse, exec_order, bmmAxis, af::DT_FLOAT16, vec1R, vec1S);228+ InitDataNode(pse, bmmAxis, af::DT_FLOAT16, vec1R, vec1S);
234 Load loadPse("loadPse");229 Load loadPse("loadPse");
235 loadPse.x = pse.y;230 loadPse.x = pse.y;
236- InitLoadNode(loadPse, exec_order, bmmAxis, af::DT_FLOAT16, vec1R, vec1S);231+ InitLoadNode(loadPse, bmmAxis, af::DT_FLOAT16, vec1R, vec1S);
237 Cast castPse("castPse");232 Cast castPse("castPse");
238 castPse.x = loadPse.y;233 castPse.x = loadPse.y;
239- InitUnaryNode(castPse, exec_order, bmmAxis, af::DT_FLOAT, vec1R, vec1S);234+ InitUnaryNode(castPse, bmmAxis, af::DT_FLOAT, vec1R, vec1S);
240 Add add1("add1");235 Add add1("add1");
241 add1.x1 = load1.y;236 add1.x1 = load1.y;
242 add1.x2 = castPse.y;237 add1.x2 = castPse.y;
243- InitUnaryNode(add1, exec_order, bmmAxis, af::DT_FLOAT, vec1R, vec1S);238+ InitUnaryNode(add1, bmmAxis, af::DT_FLOAT, vec1R, vec1S);
244 Data scaleValue("scaleValue", graph);239 Data scaleValue("scaleValue", graph);
245- scaleValue.attr.sched.exec_order = exec_order++;
246 scaleValue.y.dtype = af::DT_FLOAT;240 scaleValue.y.dtype = af::DT_FLOAT;
247 out_mul1.x1 = add1.y;241 out_mul1.x1 = add1.y;
248 out_mul1.x2 = scaleValue.y;242 out_mul1.x2 = scaleValue.y;
249- InitUnaryNode(out_mul1, exec_order, bmmAxis, af::DT_FLOAT, vec1R, vec1S);243+ InitUnaryNode(out_mul1, bmmAxis, af::DT_FLOAT, vec1R, vec1S);
250}244}
251 245 
252-void FaBeforeAutoFuseVec1(af::AscGraph &graph, int32_t &exec_order, const std::initializer_list<int64_t> &bmmAxis,246+void FaBeforeAutoFuseVec1(af::AscGraph &graph, const std::initializer_list<int64_t> &bmmAxis,
253 const std::initializer_list<Expr> &vec1R, const std::initializer_list<Expr> &vec1S,247 const std::initializer_list<Expr> &vec1R, const std::initializer_list<Expr> &vec1S,
254 const std::initializer_list<Expr> &reduceR, const std::initializer_list<Expr> &reduceS,248 const std::initializer_list<Expr> &reduceR, const std::initializer_list<Expr> &reduceS,
255 const Expr &B, const Expr &N, const Expr &G, const Expr &S1, const Expr &S2, const Expr &BL,249 const Expr &B, const Expr &N, const Expr &G, const Expr &S1, const Expr &S2, const Expr &BL,
@@ -258,59 +252,57 @@ void FaBeforeAutoFuseVec1(af::AscGraph &graph, int32_t &exec_order, const std::i
258 auto maskR = std::initializer_list<Expr>{B, ONE, ONE, S1, S2, ONE, ONE};252 auto maskR = std::initializer_list<Expr>{B, ONE, ONE, S1, S2, ONE, ONE};
259 auto maskS = std::initializer_list<Expr>{S1 * S2, S1 * S2, S1 * S2, S2, ONE, ZERO, ZERO};253 auto maskS = std::initializer_list<Expr>{S1 * S2, S1 * S2, S1 * S2, S2, ONE, ZERO, ZERO};
260 Data attenMask("attenMask", graph);254 Data attenMask("attenMask", graph);
261- InitDataNode(attenMask, exec_order, bmmAxis, af::DT_UINT8, maskR, maskS);255+ InitDataNode(attenMask, bmmAxis, af::DT_UINT8, maskR, maskS);
262 Load loadAttenMask("loadAttenMask");256 Load loadAttenMask("loadAttenMask");
263 loadAttenMask.x = attenMask.y;257 loadAttenMask.x = attenMask.y;
264- InitLoadNode(loadAttenMask, exec_order, bmmAxis, af::DT_UINT8, maskR, maskS);258+ InitLoadNode(loadAttenMask, bmmAxis, af::DT_UINT8, maskR, maskS);
265 Select select("select");259 Select select("select");
266 select.x1 = mul1.y;260 select.x1 = mul1.y;
267 select.x2 = loadAttenMask.y;261 select.x2 = loadAttenMask.y;
268- InitUnaryNode(select, exec_order, bmmAxis, af::DT_FLOAT, vec1R, vec1S);262+ InitUnaryNode(select, bmmAxis, af::DT_FLOAT, vec1R, vec1S);
269- InitDataNode(out_softmaxExp, exec_order, bmmAxis, af::DT_FLOAT, reduceR, reduceS);263+ InitDataNode(out_softmaxExp, bmmAxis, af::DT_FLOAT, reduceR, reduceS);
270 Data softmaxApiTmpBuf("softmaxApiTmpBuf", graph);264 Data softmaxApiTmpBuf("softmaxApiTmpBuf", graph);
271- InitDataNode(softmaxApiTmpBuf, exec_order, bmmAxis, af::DT_FLOAT, {ONE, ONE, ONE, S1, S2, ONE, ONE},265+ InitDataNode(softmaxApiTmpBuf, bmmAxis, af::DT_FLOAT, {ONE, ONE, ONE, S1, S2, ONE, ONE},
272 {ZERO, ZERO, ZERO, S2, ONE, ZERO, ZERO});266 {ZERO, ZERO, ZERO, S2, ONE, ZERO, ZERO});
273 out_flashSoftmax.x = {select.y, out_softmaxExp.y, softmaxApiTmpBuf.y};267 out_flashSoftmax.x = {select.y, out_softmaxExp.y, softmaxApiTmpBuf.y};
274- InitUnaryNode(out_flashSoftmax, exec_order, bmmAxis, af::DT_FLOAT, vec1R, vec1S);268+ InitUnaryNode(out_flashSoftmax, bmmAxis, af::DT_FLOAT, vec1R, vec1S);
275 Store storeSoftmaxMax("storeSoftmaxMax");269 Store storeSoftmaxMax("storeSoftmaxMax");
276 storeSoftmaxMax.x = out_flashSoftmax.y;270 storeSoftmaxMax.x = out_flashSoftmax.y;
277- InitStoreNode(storeSoftmaxMax, exec_order, bmmAxis, af::DT_FLOAT, {B, N, G, S1, S2, ONE, BL},271+ InitStoreNode(storeSoftmaxMax, bmmAxis, af::DT_FLOAT, {B, N, G, S1, S2, ONE, BL},
278 {N * G * S1 * BL, G * S1 * BL, S1 * BL, BL, ZERO, ZERO, ONE});272 {N * G * S1 * BL, G * S1 * BL, S1 * BL, BL, ZERO, ZERO, ONE});
279 Output softmaxMax("softmaxMax");273 Output softmaxMax("softmaxMax");
280 softmaxMax.x = storeSoftmaxMax.y;274 softmaxMax.x = storeSoftmaxMax.y;
281- softmaxMax.attr.sched.exec_order = exec_order++;
282 Data dropMask("dropMask", graph);275 Data dropMask("dropMask", graph);
283- InitDataNode(dropMask, exec_order, bmmAxis, af::DT_UINT8, vec1R, vec1S);276+ InitDataNode(dropMask, bmmAxis, af::DT_UINT8, vec1R, vec1S);
284 Load loadDropMask("loadDropMask");277 Load loadDropMask("loadDropMask");
285 loadDropMask.x = dropMask.y;278 loadDropMask.x = dropMask.y;
286- InitLoadNode(loadDropMask, exec_order, bmmAxis, af::DT_UINT8, vec1R, vec1S);279+ InitLoadNode(loadDropMask, bmmAxis, af::DT_UINT8, vec1R, vec1S);
287 Add dropout("dropout");280 Add dropout("dropout");
288 dropout.x1 = out_flashSoftmax.y;281 dropout.x1 = out_flashSoftmax.y;
289 dropout.x2 = loadDropMask.y;282 dropout.x2 = loadDropMask.y;
290- InitUnaryNode(dropout, exec_order, bmmAxis, af::DT_FLOAT, vec1R, vec1S);283+ InitUnaryNode(dropout, bmmAxis, af::DT_FLOAT, vec1R, vec1S);
291 Cast castVec1Res("castVec1Res");284 Cast castVec1Res("castVec1Res");
292 castVec1Res.x = dropout.y;285 castVec1Res.x = dropout.y;
293- InitUnaryNode(castVec1Res, exec_order, bmmAxis, af::DT_FLOAT16, vec1R, vec1S);286+ InitUnaryNode(castVec1Res, bmmAxis, af::DT_FLOAT16, vec1R, vec1S);
294 out_storeVec1Res.x = castVec1Res.y;287 out_storeVec1Res.x = castVec1Res.y;
295- InitStoreNode(out_storeVec1Res, exec_order, bmmAxis, af::DT_FLOAT16, vec1R, vec1R);288+ InitStoreNode(out_storeVec1Res, bmmAxis, af::DT_FLOAT16, vec1R, vec1R);
296}289}
297 290 
298-void FaBeforeAutoFuseBmm2(af::AscGraph &graph, int32_t &exec_order, const std::initializer_list<int64_t> &bmmAxis,291+void FaBeforeAutoFuseBmm2(af::AscGraph &graph, const std::initializer_list<int64_t> &bmmAxis,
299 const std::initializer_list<Expr> &vec2R, const std::initializer_list<Expr> &vec2S,292 const std::initializer_list<Expr> &vec2R, const std::initializer_list<Expr> &vec2S,
300 const Expr &B, const Expr &N, const Expr &G, const Expr &S2, const Expr &D, const Expr &ONE,293 const Expr &B, const Expr &N, const Expr &G, const Expr &S2, const Expr &D, const Expr &ONE,
301 const Expr &ZERO, Store &storeVec1Res, Data &softmaxExp, Concat &flashSoftmax) {294 const Expr &ZERO, Store &storeVec1Res, Data &softmaxExp, Concat &flashSoftmax) {
302 Data value("value", graph);295 Data value("value", graph);
303- InitDataNode(value, exec_order, bmmAxis, af::DT_FLOAT16, {B, N, G, ONE, S2, D, ONE},296+ InitDataNode(value, bmmAxis, af::DT_FLOAT16, {B, N, G, ONE, S2, D, ONE},
304 {N * S2 * D, S2 * D, S2 * D, ZERO, D, ONE, ZERO});297 {N * S2 * D, S2 * D, S2 * D, ZERO, D, ONE, ZERO});
305 Add bmm2("bmm2");298 Add bmm2("bmm2");
306 bmm2.x1 = storeVec1Res.y;299 bmm2.x1 = storeVec1Res.y;
307 bmm2.x2 = value.y;300 bmm2.x2 = value.y;
308- InitUnaryNode(bmm2, exec_order, bmmAxis, af::DT_FLOAT, vec2R, vec2S);301+ InitUnaryNode(bmm2, bmmAxis, af::DT_FLOAT, vec2R, vec2S);
309 Load load2("load2");302 Load load2("load2");
310 load2.x = bmm2.y;303 load2.x = bmm2.y;
311- InitLoadNode(load2, exec_order, bmmAxis, af::DT_FLOAT, vec2R, vec2S);304+ InitLoadNode(load2, bmmAxis, af::DT_FLOAT, vec2R, vec2S);
312 Workspace addResOut("addResOut");305 Workspace addResOut("addResOut");
313- addResOut.attr.sched.exec_order = exec_order++;
314 addResOut.attr.sched.axis = bmmAxis;306 addResOut.attr.sched.axis = bmmAxis;
315 addResOut.x = load2.y;307 addResOut.x = load2.y;
316 addResOut.y.dtype = af::DT_FLOAT;308 addResOut.y.dtype = af::DT_FLOAT;
@@ -319,28 +311,28 @@ void FaBeforeAutoFuseBmm2(af::AscGraph &graph, int32_t &exec_order, const std::i
319 *addResOut.y.strides = vec2S;311 *addResOut.y.strides = vec2S;
320 Load loadAddResOut("loadAddResOut");312 Load loadAddResOut("loadAddResOut");
321 loadAddResOut.x = addResOut.y;313 loadAddResOut.x = addResOut.y;
322- InitLoadNode(loadAddResOut, exec_order, bmmAxis, af::DT_FLOAT, vec2R, vec2S);314+ InitLoadNode(loadAddResOut, bmmAxis, af::DT_FLOAT, vec2R, vec2S);
323 Mul mulRes("mulRes");315 Mul mulRes("mulRes");
324 mulRes.x1 = loadAddResOut.y;316 mulRes.x1 = loadAddResOut.y;
325 mulRes.x2 = softmaxExp.y;317 mulRes.x2 = softmaxExp.y;
326- InitUnaryNode(mulRes, exec_order, bmmAxis, af::DT_FLOAT, vec2R, vec2S);318+ InitUnaryNode(mulRes, bmmAxis, af::DT_FLOAT, vec2R, vec2S);
327 Add addRes("addRes");319 Add addRes("addRes");
328 addRes.x1 = load2.y;320 addRes.x1 = load2.y;
329 addRes.x2 = mulRes.y;321 addRes.x2 = mulRes.y;
330- InitUnaryNode(addRes, exec_order, bmmAxis, af::DT_FLOAT, vec2R, vec2S);322+ InitUnaryNode(addRes, bmmAxis, af::DT_FLOAT, vec2R, vec2S);
331 Div div("div");323 Div div("div");
332 div.x1 = addRes.y;324 div.x1 = addRes.y;
333 div.x2 = flashSoftmax.y;325 div.x2 = flashSoftmax.y;
334- InitUnaryNode(div, exec_order, bmmAxis, af::DT_FLOAT, vec2R, vec2S);326+ InitUnaryNode(div, bmmAxis, af::DT_FLOAT, vec2R, vec2S);
335 Cast castBmm2Res("castBmm2Res");327 Cast castBmm2Res("castBmm2Res");
336 castBmm2Res.x = div.y;328 castBmm2Res.x = div.y;
337- InitUnaryNode(castBmm2Res, exec_order, bmmAxis, af::DT_FLOAT16, vec2R, vec2S);329+ InitUnaryNode(castBmm2Res, bmmAxis, af::DT_FLOAT16, vec2R, vec2S);
338 Store store("store");330 Store store("store");
339 store.x = castBmm2Res.y;331 store.x = castBmm2Res.y;
340- InitStoreNode(store, exec_order, bmmAxis, af::DT_FLOAT16, vec2R, vec2S);332+ InitStoreNode(store, bmmAxis, af::DT_FLOAT16, vec2R, vec2S);
341 Output buf("buf");333 Output buf("buf");
342 buf.x = store.y;334 buf.x = store.y;
343- InitOutputNode(buf, exec_order, bmmAxis, af::DT_FLOAT16, vec2R, vec2S);335+ InitOutputNode(buf, bmmAxis, af::DT_FLOAT16, vec2R, vec2S);
344}336}
345 337 
346void FaBeforeAutoFuse(af::AscGraph &graph) {338void FaBeforeAutoFuse(af::AscGraph &graph) {
@@ -367,16 +359,14 @@ void FaBeforeAutoFuse(af::AscGraph &graph) {
367 auto vec2S = std::initializer_list<Expr>{N * G * S1 * D, G * S1 * D, S1 * D, D, ZERO, ONE, ZERO};359 auto vec2S = std::initializer_list<Expr>{N * G * S1 * D, G * S1 * D, S1 * D, D, ZERO, ONE, ZERO};
368 auto reduceR = std::initializer_list<Expr>{ONE, ONE, ONE, S1, ONE, ONE, BL};360 auto reduceR = std::initializer_list<Expr>{ONE, ONE, ONE, S1, ONE, ONE, BL};
369 auto reduceS = std::initializer_list<Expr>{ZERO, ZERO, ZERO, BL, ZERO, ZERO, ONE};361 auto reduceS = std::initializer_list<Expr>{ZERO, ZERO, ZERO, BL, ZERO, ZERO, ONE};
370- int32_t exec_order = 0;
371 Add mul1("mul1");362 Add mul1("mul1");
372- FaBeforeAutoFuseBmm1(graph, exec_order, bmmAxis, vec1R, vec1S, B, N, G, S1, S2, D, ONE, ZERO, mul1);363+ FaBeforeAutoFuseBmm1(graph, bmmAxis, vec1R, vec1S, B, N, G, S1, S2, D, ONE, ZERO, mul1);
373 Data softmaxExp("softmaxExp", graph);364 Data softmaxExp("softmaxExp", graph);
374 Concat flashSoftmax("flashSoftmax");365 Concat flashSoftmax("flashSoftmax");
375 Store storeVec1Res("storeVec1Res");366 Store storeVec1Res("storeVec1Res");
376- FaBeforeAutoFuseVec1(graph, exec_order, bmmAxis, vec1R, vec1S, reduceR, reduceS, B, N, G, S1, S2, BL, ONE, ZERO, mul1,367+ FaBeforeAutoFuseVec1(graph, bmmAxis, vec1R, vec1S, reduceR, reduceS, B, N, G, S1, S2, BL, ONE, ZERO, mul1, softmaxExp,
377- softmaxExp, flashSoftmax, storeVec1Res);368+ flashSoftmax, storeVec1Res);
378- FaBeforeAutoFuseBmm2(graph, exec_order, bmmAxis, vec2R, vec2S, B, N, G, S2, D, ONE, ZERO, storeVec1Res, softmaxExp,369+ FaBeforeAutoFuseBmm2(graph, bmmAxis, vec2R, vec2S, B, N, G, S2, D, ONE, ZERO, storeVec1Res, softmaxExp, flashSoftmax);
379- flashSoftmax);
380}370}
381 371 
382void FaAfterApiInfo(af::AscGraph &graph) {372void FaAfterApiInfo(af::AscGraph &graph) {
@@ -512,16 +502,15 @@ void UnknownGraph(af::AscGraph &graph) {
512 auto resAxis = {x.id, y.id};502 auto resAxis = {x.id, y.id};
513 auto resRepeat = std::initializer_list<Expr>{X, Y};503 auto resRepeat = std::initializer_list<Expr>{X, Y};
514 auto resStride = std::initializer_list<Expr>{Y, ONE};504 auto resStride = std::initializer_list<Expr>{Y, ONE};
515- int32_t exec_order = 0;
516 505 
517 Data input("input", graph);506 Data input("input", graph);
518- InitDataNode(input, exec_order, resAxis, af::DT_UINT32, resRepeat, resStride);507+ InitDataNode(input, resAxis, af::DT_UINT32, resRepeat, resStride);
519 SetApiAttr(graph.FindNode("input"), af::ApiType::kAPITypeBuffer, af::ComputeUnit::kUnitNone);508 SetApiAttr(graph.FindNode("input"), af::ApiType::kAPITypeBuffer, af::ComputeUnit::kUnitNone);
520 SetNodeMemAttr(graph.FindNode("input"), tensorID, {"input", 0, 0, 0, -1, -1, false, false});509 SetNodeMemAttr(graph.FindNode("input"), tensorID, {"input", 0, 0, 0, -1, -1, false, false});
521 510 
522 Load load("load");511 Load load("load");
523 load.x = input.y;512 load.x = input.y;
524- InitLoadNode(load, exec_order, resAxis, af::DT_UINT32, resRepeat, resStride);513+ InitLoadNode(load, resAxis, af::DT_UINT32, resRepeat, resStride);
525 auto load_node = graph.FindNode("load");514 auto load_node = graph.FindNode("load");
526 SetApiAttr(load_node, af::ApiType::kAPITypeCompute, af::ComputeUnit::kUnitNone);515 SetApiAttr(load_node, af::ApiType::kAPITypeCompute, af::ComputeUnit::kUnitNone);
527 load_node->attr.sched.loop_axis = x.id;516 load_node->attr.sched.loop_axis = x.id;
@@ -530,7 +519,7 @@ void UnknownGraph(af::AscGraph &graph) {
530 519 
531 Nop unknown("unknown");520 Nop unknown("unknown");
532 unknown.x = load.y;521 unknown.x = load.y;
533- InitUnaryNode(unknown, exec_order, resAxis, af::DT_UINT32, resRepeat, resStride);522+ InitUnaryNode(unknown, resAxis, af::DT_UINT32, resRepeat, resStride);
534 auto unknown_node = graph.FindNode("unknown");523 auto unknown_node = graph.FindNode("unknown");
535 SetApiAttr(unknown_node, af::ApiType::kAPITypeBuffer, af::ComputeUnit::kUnitVector);524 SetApiAttr(unknown_node, af::ApiType::kAPITypeBuffer, af::ComputeUnit::kUnitVector);
536 unknown_node->attr.sched.loop_axis = x.id;525 unknown_node->attr.sched.loop_axis = x.id;
@@ -539,7 +528,7 @@ void UnknownGraph(af::AscGraph &graph) {
539 528 
540 Store store("store");529 Store store("store");
541 store.x = unknown.y;530 store.x = unknown.y;
542- InitStoreNode(store, exec_order, resAxis, af::DT_UINT32, resRepeat, resStride);531+ InitStoreNode(store, resAxis, af::DT_UINT32, resRepeat, resStride);
543 auto store_node = graph.FindNode("store");532 auto store_node = graph.FindNode("store");
544 SetApiAttr(store_node, af::ApiType::kAPITypeCompute, af::ComputeUnit::kUnitNone);533 SetApiAttr(store_node, af::ApiType::kAPITypeCompute, af::ComputeUnit::kUnitNone);
545 store_node->attr.sched.loop_axis = x.id;534 store_node->attr.sched.loop_axis = x.id;
@@ -548,7 +537,7 @@ void UnknownGraph(af::AscGraph &graph) {
548 537 
549 Output output("output");538 Output output("output");
550 output.x = store.y;539 output.x = store.y;
551- InitOutputNode(output, exec_order, resAxis, af::DT_UINT32, resRepeat, resStride);540+ InitOutputNode(output, resAxis, af::DT_UINT32, resRepeat, resStride);
552 SetApiAttr(graph.FindNode("output"), af::ApiType::kAPITypeBuffer, af::ComputeUnit::kUnitNone);541 SetApiAttr(graph.FindNode("output"), af::ApiType::kAPITypeBuffer, af::ComputeUnit::kUnitNone);
553 SetNodeMemAttr(graph.FindNode("output"), tensorID, {"output", 0, 0, 0, -1, -1, false, false});542 SetNodeMemAttr(graph.FindNode("output"), tensorID, {"output", 0, 0, 0, -1, -1, false, false});
554}543}
Mautofuse/tests/ut/att/testcase/gen_model_info/core/test_gen_model_info.cpp+17-17
@@ -129,8 +129,8 @@ Status Build2DTransposeAscendGraph(af::AscGraph &graph, const std::vector<int64_
129 129 
130 auto [z0T, z0t] = graph.TileSplit(z0.id);130 auto [z0T, z0t] = graph.TileSplit(z0.id);
131 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);131 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
132- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1}, FORMAT_ND);132+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1}, 0, FORMAT_ND);
133- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1}, FORMAT_ND);133+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1}, 1, FORMAT_ND);
134 *data1.repeats = {s0, s1};134 *data1.repeats = {s0, s1};
135 *data2.repeats = {s0, s1};135 *data2.repeats = {s0, s1};
136 *data1.strides = {s1, One};136 *data1.strides = {s1, One};
@@ -177,8 +177,8 @@ Status Build2DPadAscendGraph(af::AscGraph &graph, const std::vector<int64_t> &pe
177 177 
178 auto [z0T, z0t] = graph.TileSplit(z0.id);178 auto [z0T, z0t] = graph.TileSplit(z0.id);
179 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);179 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
180- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1}, FORMAT_ND);180+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1}, 0, FORMAT_ND);
181- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1}, FORMAT_ND);181+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1}, 1, FORMAT_ND);
182 *data1.repeats = {s0, s1};182 *data1.repeats = {s0, s1};
183 *data2.repeats = {s0, s1};183 *data2.repeats = {s0, s1};
184 *data1.strides = {s1, One};184 *data1.strides = {s1, One};
@@ -222,8 +222,8 @@ Status BuildTransposeSplitAscendGraph(af::AscGraph &graph) {
222 222 
223 auto [z0T, z0t] = graph.TileSplit(z0.id);223 auto [z0T, z0t] = graph.TileSplit(z0.id);
224 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);224 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
225- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1, z2}, FORMAT_ND);225+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1, z2}, 0, FORMAT_ND);
226- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1, z2}, FORMAT_ND);226+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1, z2}, 1, FORMAT_ND);
227 *data1.repeats = {s0, s1, s2};227 *data1.repeats = {s0, s1, s2};
228 *data2.repeats = {s0, s1, s2};228 *data2.repeats = {s0, s1, s2};
229 *data1.strides = {s1 * s2, s2, One};229 *data1.strides = {s1 * s2, s2, One};
@@ -272,8 +272,8 @@ Status BuildTransposeAscendGraph(af::AscGraph &graph, const std::vector<int64_t>
272 272 
273 auto [z0T, z0t] = graph.TileSplit(z0.id);273 auto [z0T, z0t] = graph.TileSplit(z0.id);
274 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);274 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
275- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1, z2}, FORMAT_ND);275+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z1, z2}, 0, FORMAT_ND);
276- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1, z2}, FORMAT_ND);276+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0, z1, z2}, 1, FORMAT_ND);
277 *data1.repeats = {s0, s1, s2};277 *data1.repeats = {s0, s1, s2};
278 *data2.repeats = {s0, s1, s2};278 *data2.repeats = {s0, s1, s2};
279 *data1.strides = {s1 * s2, s2, One};279 *data1.strides = {s1 * s2, s2, One};
@@ -324,7 +324,7 @@ Status Build4DTransposeAscendGraph(af::AscGraph &graph, const std::vector<int64_
324 324 
325 auto [z0T, z0t] = graph.TileSplit(z0.id);325 auto [z0T, z0t] = graph.TileSplit(z0.id);
326 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);326 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
327- auto data = graph.CreateContiguousData("input", DT_FLOAT, {z0, z1, z2, z3}, FORMAT_ND);327+ auto data = graph.CreateContiguousData("input", DT_FLOAT, {z0, z1, z2, z3}, 0, FORMAT_ND);
328 *data.repeats = {s0, s1, s2, s3};328 *data.repeats = {s0, s1, s2, s3};
329 *data.strides = {s1 * s2 * s3, s2 * s3, s3, One};329 *data.strides = {s1 * s2 * s3, s2 * s3, s3, One};
330 330 
@@ -360,8 +360,8 @@ Status BuildFlashSoftmaxAscendGraph(af::AscGraph &graph) {
360 auto nd = graph.CreateAxis("nd", ND);360 auto nd = graph.CreateAxis("nd", ND);
361 auto [ndB, ndb] = graph.BlockSplit(nd.id);361 auto [ndB, ndb] = graph.BlockSplit(nd.id);
362 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);362 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
363- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});363+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
364- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});364+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
365 LOOP(*ndB) {365 LOOP(*ndB) {
366 LOOP(*ndbT) {366 LOOP(*ndbT) {
367 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);367 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -391,8 +391,8 @@ Status BuildWorkSpaceAscendGraph(af::AscGraph &graph) {
391 auto nd = graph.CreateAxis("nd", ND);391 auto nd = graph.CreateAxis("nd", ND);
392 auto [ndB, ndb] = graph.BlockSplit(nd.id);392 auto [ndB, ndb] = graph.BlockSplit(nd.id);
393 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);393 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
394- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});394+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
395- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});395+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
396 LOOP(*ndB) {396 LOOP(*ndB) {
397 LOOP(*ndbT) {397 LOOP(*ndbT) {
398 auto load1 = Workspace("workspace1", data1).TQue(Position::kPositionVecIn, 1, 1);398 auto load1 = Workspace("workspace1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -424,7 +424,7 @@ Status BuildTilingBroadcastAscendGraph(af::AscGraph &graph) {
424 auto [rT, rt] = graph.TileSplit(r.id);424 auto [rT, rt] = graph.TileSplit(r.id);
425 auto [rTB, rTb] = graph.BlockSplit(rT->id);425 auto [rTB, rTb] = graph.BlockSplit(rT->id);
426 auto [aT, at] = graph.TileSplit(a.id);426 auto [aT, at] = graph.TileSplit(a.id);
427- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {r, a});427+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {r, a}, 0);
428 LOOP(*rT) {428 LOOP(*rT) {
429 LOOP(*rTB) {429 LOOP(*rTB) {
430 LOOP(*rTb) {430 LOOP(*rTb) {
@@ -460,7 +460,7 @@ Status BuildHeavyOpTilingAscendGraph(af::AscGraph &graph) {
460 auto [rT, rt] = graph.TileSplit(r.id);460 auto [rT, rt] = graph.TileSplit(r.id);
461 auto [rTB, rTb] = graph.BlockSplit(rT->id);461 auto [rTB, rTb] = graph.BlockSplit(rT->id);
462 auto [aT, at] = graph.TileSplit(a.id);462 auto [aT, at] = graph.TileSplit(a.id);
463- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {r, a});463+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {r, a}, 0);
464 LOOP(*rT) {464 LOOP(*rT) {
465 LOOP(*rTB) {465 LOOP(*rTB) {
466 LOOP(*rTb) {466 LOOP(*rTb) {
@@ -494,8 +494,8 @@ Status BuildMatMulDemoAscendGraph(af::AscGraph &graph) {
494 auto nd = graph.CreateAxis("nd", ND);494 auto nd = graph.CreateAxis("nd", ND);
495 auto [ndB, ndb] = graph.BlockSplit(nd.id);495 auto [ndB, ndb] = graph.BlockSplit(nd.id);
496 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);496 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
497- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});497+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
498- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});498+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
499 LOOP(*ndB) {499 LOOP(*ndB) {
500 LOOP(*ndbT) {500 LOOP(*ndbT) {
501 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);501 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/tests/ut/att/testcase/gen_model_info/expr_gen/test_pipe_perf_expr.cpp+3-4
@@ -37,7 +37,7 @@ Status BuildEqAscendGraphND(af::AscGraph &graph) {
37 auto z3 = graph.CreateAxis("z3", s3);37 auto z3 = graph.CreateAxis("z3", s3);
38 auto [z0T, z0t] = graph.TileSplit(z0.id);38 auto [z0T, z0t] = graph.TileSplit(z0.id);
39 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);39 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
40- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z2, z3}, FORMAT_ND);40+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0, z2, z3}, 0, FORMAT_ND);
41 LOOP(*z0TB) {41 LOOP(*z0TB) {
42 LOOP(*z0T) {42 LOOP(*z0T) {
43 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);43 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -58,7 +58,7 @@ static Status BuildVectorFuncSubgraph(af::AscGraph &subgraph) {
58 auto nd = subgraph.CreateAxis("nd", ND);58 auto nd = subgraph.CreateAxis("nd", ND);
59 auto [ndB, ndb] = subgraph.BlockSplit(nd.id);59 auto [ndB, ndb] = subgraph.BlockSplit(nd.id);
60 auto [ndbT, ndbt] = subgraph.TileSplit(ndb->id);60 auto [ndbT, ndbt] = subgraph.TileSplit(ndb->id);
61- auto data1 = subgraph.CreateContiguousData("input1", DT_FLOAT, {*ndbt});61+ auto data1 = subgraph.CreateContiguousData("input1", DT_FLOAT, {*ndbt}, 0);
62 auto load1 = Load("load1", data1);62 auto load1 = Load("load1", data1);
63 auto abs1 = Abs("abs1", load1);63 auto abs1 = Abs("abs1", load1);
64 auto sub1 = Sub("sub1", abs1, abs1);64 auto sub1 = Sub("sub1", abs1, abs1);
@@ -78,8 +78,7 @@ static Status AddVectorFuncToMainGraph(af::AscGraph &graph) {
78 auto z0 = CreateS0Axis(graph);78 auto z0 = CreateS0Axis(graph);
79 auto [z0B, z0b] = graph.BlockSplit(z0.id);79 auto [z0B, z0b] = graph.BlockSplit(z0.id);
80 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);80 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);
81- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});81+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
82- 
83 LOOP(*z0B) {82 LOOP(*z0B) {
84 LOOP(*z0bT) {83 LOOP(*z0bT) {
85 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);84 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/tests/ut/att/testcase/gen_model_info/parser/test_ascend_graph_parser.cpp+4-4
@@ -33,8 +33,8 @@ Status BuildGatherAscendGraphND(AscGraph &graph) {
33 auto nd = graph.CreateAxis("nd", ND);33 auto nd = graph.CreateAxis("nd", ND);
34 auto [ndB, ndb] = graph.BlockSplit(nd.id);34 auto [ndB, ndb] = graph.BlockSplit(nd.id);
35 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);35 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
36- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});36+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
37- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});37+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
38 LOOP(*ndB) {38 LOOP(*ndB) {
39 LOOP(*ndbT) {39 LOOP(*ndbT) {
40 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);40 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -66,8 +66,8 @@ Status BuildReduceAscendGraphND(AscGraph &graph) {
66 auto nd = graph.CreateAxis("nd", ND);66 auto nd = graph.CreateAxis("nd", ND);
67 auto [ndB, ndb] = graph.BlockSplit(nd.id);67 auto [ndB, ndb] = graph.BlockSplit(nd.id);
68 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);68 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
69- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});69+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
70- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});70+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
71 LOOP(*ndB) {71 LOOP(*ndB) {
72 LOOP(*ndbT) {72 LOOP(*ndbT) {
73 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);73 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/tests/ut/att/testcase/gen_model_info/reuse_group_utils/test_equivalent_graph_recongnizer.cpp+28-28
@@ -47,8 +47,8 @@ Status BuildAscendGraphTest1(af::AscGraph &graph) {
47 auto nd = graph.CreateAxis("nd", ND);47 auto nd = graph.CreateAxis("nd", ND);
48 auto [ndB, ndb] = graph.BlockSplit(nd.id);48 auto [ndB, ndb] = graph.BlockSplit(nd.id);
49 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);49 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
50- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});50+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
51- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});51+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
52 GELOGD("axis id = [%d, %d, %d, %d, %d]", nd.id, ndB->id, ndb->id, ndbT->id, ndbt->id);52 GELOGD("axis id = [%d, %d, %d, %d, %d]", nd.id, ndB->id, ndb->id, ndbT->id, ndbt->id);
53 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);53 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);
54 LOOP(*ndB) {54 LOOP(*ndB) {
@@ -72,8 +72,8 @@ Status BuildAscendGraphTest2(af::AscGraph &graph) {
72 auto nd = graph.CreateAxis("nd", ND);72 auto nd = graph.CreateAxis("nd", ND);
73 auto [ndB, ndb] = graph.BlockSplit(nd.id);73 auto [ndB, ndb] = graph.BlockSplit(nd.id);
74 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);74 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
75- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});75+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
76- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});76+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
77 LOOP(*ndB) {77 LOOP(*ndB) {
78 LOOP(*ndbT) {78 LOOP(*ndbT) {
79 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);79 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -97,8 +97,8 @@ Status BuildAscendGraphTest3(af::AscGraph &graph) {
97 auto nd = graph.CreateAxis("nd", ND);97 auto nd = graph.CreateAxis("nd", ND);
98 auto [ndB, ndb] = graph.BlockSplit(nd.id);98 auto [ndB, ndb] = graph.BlockSplit(nd.id);
99 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);99 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
100- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});100+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
101- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});101+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
102 LOOP(*ndB) {102 LOOP(*ndB) {
103 LOOP(*ndbT) {103 LOOP(*ndbT) {
104 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);104 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -120,8 +120,8 @@ Status BuildAscendGraphTest4(af::AscGraph &graph) {
120 auto nd = graph.CreateAxis("nd", ND);120 auto nd = graph.CreateAxis("nd", ND);
121 auto [ndB, ndb] = graph.BlockSplit(nd.id);121 auto [ndB, ndb] = graph.BlockSplit(nd.id);
122 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);122 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
123- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});123+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
124- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});124+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
125 LOOP(*ndB) {125 LOOP(*ndB) {
126 LOOP(*ndbT) {126 LOOP(*ndbT) {
127 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);127 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -143,8 +143,8 @@ Status BuildAscendGraphTest5(af::AscGraph &graph) {
143 auto nd = graph.CreateAxis("nd", ND);143 auto nd = graph.CreateAxis("nd", ND);
144 auto [ndB, ndb] = graph.BlockSplit(nd.id);144 auto [ndB, ndb] = graph.BlockSplit(nd.id);
145 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);145 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
146- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT16, {nd});146+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT16, {nd}, 0);
147- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});147+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
148 LOOP(*ndB) {148 LOOP(*ndB) {
149 LOOP(*ndbT) {149 LOOP(*ndbT) {
150 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);150 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -171,8 +171,8 @@ Status BuildAscendGraphTest6(af::AscGraph &graph) {
171 auto [ndTB, ndTb] = graph.BlockSplit(ndt->id);171 auto [ndTB, ndTb] = graph.BlockSplit(ndt->id);
172 std::swap(ndTB->id, ndT->id);172 std::swap(ndTB->id, ndT->id);
173 std::swap(ndTb->id, ndt->id);173 std::swap(ndTb->id, ndt->id);
174- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});174+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
175- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});175+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
176 GELOGD("axis id = [%d, %d, %d, %d, %d]", nd.id, ndT->id, ndt->id, ndTB->id, ndTb->id);176 GELOGD("axis id = [%d, %d, %d, %d, %d]", nd.id, ndT->id, ndt->id, ndTB->id, ndTb->id);
177 GELOGD("axis id = [%d, %d]", ndTB->id, ndT->id);177 GELOGD("axis id = [%d, %d]", ndTB->id, ndT->id);
178 LOOP(*ndTB) {178 LOOP(*ndTB) {
@@ -196,8 +196,8 @@ Status BuildAscendGraphTest1_Equal(af::AscGraph &graph) {
196 auto z0 = graph.CreateAxis("z0", S0);196 auto z0 = graph.CreateAxis("z0", S0);
197 auto [ndB, ndb] = graph.BlockSplit(z0.id);197 auto [ndB, ndb] = graph.BlockSplit(z0.id);
198 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);198 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
199- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});199+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
200- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0});200+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0}, 1);
201 GELOGD("axis id = [%d, %d, %d, %d, %d]", z0.id, ndB->id, ndb->id, ndbT->id, ndbt->id);201 GELOGD("axis id = [%d, %d, %d, %d, %d]", z0.id, ndB->id, ndb->id, ndbT->id, ndbt->id);
202 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);202 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);
203 LOOP(*ndB) {203 LOOP(*ndB) {
@@ -220,8 +220,8 @@ Status BuildAscendGraphTest7_AddDefaultInput(af::AscGraph &graph) {
220 auto z0 = graph.CreateAxis("z0", S0);220 auto z0 = graph.CreateAxis("z0", S0);
221 auto [ndB, ndb] = graph.BlockSplit(z0.id);221 auto [ndB, ndb] = graph.BlockSplit(z0.id);
222 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);222 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
223- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});223+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
224- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0});224+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0}, 1);
225 GELOGD("axis id = [%d, %d, %d, %d, %d]", z0.id, ndB->id, ndb->id, ndbT->id, ndbt->id);225 GELOGD("axis id = [%d, %d, %d, %d, %d]", z0.id, ndB->id, ndb->id, ndbT->id, ndbt->id);
226 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);226 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);
227 LOOP(*ndB) {227 LOOP(*ndB) {
@@ -245,8 +245,8 @@ Status BuildAscendGraphTest7_AddSwapInput(af::AscGraph &graph) {
245 auto z1 = graph.CreateAxis("z1", S1);245 auto z1 = graph.CreateAxis("z1", S1);
246 auto [ndB, ndb] = graph.BlockSplit(z0.id);246 auto [ndB, ndb] = graph.BlockSplit(z0.id);
247 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);247 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
248- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});248+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
249- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z1});249+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z1}, 1);
250 GELOGD("axis id = [%d, %d, %d, %d, %d]", z0.id, ndB->id, ndb->id, ndbT->id, ndbt->id);250 GELOGD("axis id = [%d, %d, %d, %d, %d]", z0.id, ndB->id, ndb->id, ndbT->id, ndbt->id);
251 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);251 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);
252 LOOP(*ndB) {252 LOOP(*ndB) {
@@ -269,8 +269,8 @@ Status BuildAscendGraphTest1_ConstND(af::AscGraph &graph) {
269 auto nd = graph.CreateAxis("nd", ND);269 auto nd = graph.CreateAxis("nd", ND);
270 auto [ndB, ndb] = graph.BlockSplit(nd.id);270 auto [ndB, ndb] = graph.BlockSplit(nd.id);
271 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);271 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
272- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});272+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
273- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd});273+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {nd}, 1);
274 GELOGD("axis id = [%d, %d, %d, %d, %d]", nd.id, ndB->id, ndb->id, ndbT->id, ndbt->id);274 GELOGD("axis id = [%d, %d, %d, %d, %d]", nd.id, ndB->id, ndb->id, ndbT->id, ndbt->id);
275 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);275 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);
276 LOOP(*ndB) {276 LOOP(*ndB) {
@@ -294,8 +294,8 @@ Status BuildAscendGraphTest1_EqualValue(af::AscGraph &graph) {
294 auto z0 = graph.CreateAxis("z0", S0);294 auto z0 = graph.CreateAxis("z0", S0);
295 auto [ndB, ndb] = graph.BlockSplit(z0.id);295 auto [ndB, ndb] = graph.BlockSplit(z0.id);
296 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);296 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
297- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});297+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
298- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0});298+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0}, 1);
299 GELOGD("axis id = [%d, %d, %d, %d, %d]", z0.id, ndB->id, ndb->id, ndbT->id, ndbt->id);299 GELOGD("axis id = [%d, %d, %d, %d, %d]", z0.id, ndB->id, ndb->id, ndbT->id, ndbt->id);
300 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);300 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);
301 LOOP(*ndB) {301 LOOP(*ndB) {
@@ -319,8 +319,8 @@ Status BuildAscendGraphTest1_NotEqualValue(af::AscGraph &graph) {
319 auto z0 = graph.CreateAxis("z0", S0);319 auto z0 = graph.CreateAxis("z0", S0);
320 auto [ndB, ndb] = graph.BlockSplit(z0.id);320 auto [ndB, ndb] = graph.BlockSplit(z0.id);
321 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);321 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
322- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});322+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
323- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0});323+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z0}, 1);
324 GELOGD("axis id = [%d, %d, %d, %d, %d]", z0.id, ndB->id, ndb->id, ndbT->id, ndbt->id);324 GELOGD("axis id = [%d, %d, %d, %d, %d]", z0.id, ndB->id, ndb->id, ndbT->id, ndbt->id);
325 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);325 GELOGD("axis id = [%d, %d]", ndB->id, ndbT->id);
326 LOOP(*ndB) {326 LOOP(*ndB) {
@@ -366,8 +366,8 @@ Status BuildAscendGraphTest1_InputAxes1(af::AscGraph &graph) {
366 auto z2 = graph.CreateAxis("z2", S2); // 2366 auto z2 = graph.CreateAxis("z2", S2); // 2
367 auto [ndB, ndb] = graph.BlockSplit(z0.id); // 3,4367 auto [ndB, ndb] = graph.BlockSplit(z0.id); // 3,4
368 auto [ndbT, ndbt] = graph.TileSplit(ndb->id); // 5,6368 auto [ndbT, ndbt] = graph.TileSplit(ndb->id); // 5,6
369- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});369+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
370- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z1});370+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z1}, 1);
371 LOOP(*ndB) {371 LOOP(*ndB) {
372 LOOP(*ndbT) {372 LOOP(*ndbT) {
373 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);373 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -393,8 +393,8 @@ Status BuildAscendGraphTest1_InputAxes2(af::AscGraph &graph) {
393 auto z2 = graph.CreateAxis("z2", S2); // 2393 auto z2 = graph.CreateAxis("z2", S2); // 2
394 auto [ndB, ndb] = graph.BlockSplit(z0.id); // 3,4394 auto [ndB, ndb] = graph.BlockSplit(z0.id); // 3,4
395 auto [ndbT, ndbt] = graph.TileSplit(ndb->id); // 5,6395 auto [ndbT, ndbt] = graph.TileSplit(ndb->id); // 5,6
396- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});396+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
397- auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z1});397+ auto data2 = graph.CreateContiguousData("input2", DT_FLOAT, {z1}, 1);
398 LOOP(*ndB) {398 LOOP(*ndB) {
399 LOOP(*ndbT) {399 LOOP(*ndbT) {
400 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);400 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/tests/ut/att/utils/graph_construct_utils.cpp+2-2
@@ -22,7 +22,7 @@ Status ConstructSimpleLoadStoreOp(af::AscGraph &graph) {
22 auto nd = graph.CreateAxis("nd", ND);22 auto nd = graph.CreateAxis("nd", ND);
23 auto [ndB, ndb] = graph.BlockSplit(nd.id);23 auto [ndB, ndb] = graph.BlockSplit(nd.id);
24 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);24 auto [ndbT, ndbt] = graph.TileSplit(ndb->id);
25- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd});25+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {nd}, 0);
26 LOOP(*ndB) {26 LOOP(*ndB) {
27 LOOP(*ndbT) {27 LOOP(*ndbT) {
28 auto load1 = Load("load", data1).TQue(Position::kPositionVecIn, 1, 1);28 auto load1 = Load("load", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -53,7 +53,7 @@ Status BuildConcatGroupAscendGraphS0S1ReduceMultiTiling(af::AscGraph &graph) {
53 auto [s1T, s1t] = graph.TileSplit(s1.id);53 auto [s1T, s1t] = graph.TileSplit(s1.id);
54 auto s1Ts0T = *graph.MergeAxis({s1T->id, s0T->id});54 auto s1Ts0T = *graph.MergeAxis({s1T->id, s0T->id});
55 auto [s1Ts0TB, s1Ts0Tb] = graph.BlockSplit(s1Ts0T.id);55 auto [s1Ts0TB, s1Ts0Tb] = graph.BlockSplit(s1Ts0T.id);
56- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s0, s1});56+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {s0, s1}, 0);
57 LOOP(*s1Ts0TB) {57 LOOP(*s1Ts0TB) {
58 LOOP(*s1Ts0Tb) {58 LOOP(*s1Ts0Tb) {
59 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);59 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/tests/ut/optimize/test_fusedgraph_unfolder.cpp+197-75
@@ -306,8 +306,8 @@ ComputeGraphPtr BuildFusedGraphWithReuseOutput(const std::string node_type = "")
306 306 
307void CreateAddAscGraph(af::AscGraph &graph) {307void CreateAddAscGraph(af::AscGraph &graph) {
308 auto ONE = af::Symbol(1);308 auto ONE = af::Symbol(1);
309- const af::Expression s0 = graph.CreateSizeVar("s0");309+ const af::Expression s0 = af::Symbol("s0");
310- const af::Expression s1 = graph.CreateSizeVar("s1");310+ const af::Expression s1 = af::Symbol("s1");
311 311 
312 auto z0 = graph.CreateAxis("z0", s0);312 auto z0 = graph.CreateAxis("z0", s0);
313 auto z1 = graph.CreateAxis("z1", s1);313 auto z1 = graph.CreateAxis("z1", s1);
@@ -423,8 +423,8 @@ void CreateAddAscGraphOneDim(af::AscGraph &graph) {
423 423 
424void CreateAddAscGraph2(af::AscGraph &graph, const int64_t load1_offset = 0) {424void CreateAddAscGraph2(af::AscGraph &graph, const int64_t load1_offset = 0) {
425 auto ONE = af::Symbol(1);425 auto ONE = af::Symbol(1);
426- const af::Expression s0 = graph.CreateSizeVar("s0");426+ const af::Expression s0 = af::Symbol("s0");
427- const af::Expression s2 = graph.CreateSizeVar("s2");427+ const af::Expression s2 = af::Symbol("s2");
428 428 
429 auto z0 = graph.CreateAxis("z0", s0);429 auto z0 = graph.CreateAxis("z0", s0);
430 auto z1 = graph.CreateAxis("z1", s2);430 auto z1 = graph.CreateAxis("z1", s2);
@@ -494,8 +494,8 @@ void CreateAddAscGraph2(af::AscGraph &graph, const int64_t load1_offset = 0) {
494 494 
495void CreateAddAscGraph3(af::AscGraph &graph, const int64_t load1_offset = 0) {495void CreateAddAscGraph3(af::AscGraph &graph, const int64_t load1_offset = 0) {
496 auto ONE = af::Symbol(1);496 auto ONE = af::Symbol(1);
497- const af::Expression s0 = graph.CreateSizeVar("s0");497+ const af::Expression s0 = af::Symbol("s0");
498- const af::Expression s2 = graph.CreateSizeVar("s1");498+ const af::Expression s2 = af::Symbol("s1");
499 499 
500 auto z0 = graph.CreateAxis("z0", s0);500 auto z0 = graph.CreateAxis("z0", s0);
501 auto z1 = graph.CreateAxis("z1", s2);501 auto z1 = graph.CreateAxis("z1", s2);
@@ -635,8 +635,8 @@ void CreatePackFirstDimAscGraph(af::AscGraph &graph, const int64_t load1_offset
635 635 
636void CreateAddAscGraph3SameData(af::AscGraph &graph, const int64_t load1_offset = 0) {636void CreateAddAscGraph3SameData(af::AscGraph &graph, const int64_t load1_offset = 0) {
637 auto ONE = af::Symbol(1);637 auto ONE = af::Symbol(1);
638- const af::Expression s0 = graph.CreateSizeVar("s0");638+ const af::Expression s0 = af::Symbol("s0");
639- const af::Expression s2 = graph.CreateSizeVar("s1");639+ const af::Expression s2 = af::Symbol("s1");
640 640 
641 auto z0 = graph.CreateAxis("z0", s0);641 auto z0 = graph.CreateAxis("z0", s0);
642 auto z1 = graph.CreateAxis("z1", s2);642 auto z1 = graph.CreateAxis("z1", s2);
@@ -704,79 +704,64 @@ void CreateAddAscGraph3SameData(af::AscGraph &graph, const int64_t load1_offset
704 y2.ir_attr.SetIndex(1);704 y2.ir_attr.SetIndex(1);
705}705}
706 706 
707-void CreateConcatAscGraph(af::AscGraph &graph) {707+void CreateConcatInputChain(af::ascir_op::Data &data, af::ascir_op::Load &load, const af::Axis &z0, const af::Axis &z1,
708+ const af::Expression &s0, const af::Expression &input_dim, const af::Expression &stride) {
708 auto ONE = af::Symbol(1);709 auto ONE = af::Symbol(1);
709- const af::Expression s0 = graph.CreateSizeVar("s0");710+ data.attr.sched.axis = {z0.id, z1.id};
710- const af::Expression s1 = graph.CreateSizeVar("s1");711+ *data.y.axis = {z0.id, z1.id};
711- const af::Expression s2 = graph.CreateSizeVar("s2");712+ *data.y.repeats = {s0, input_dim};
713+ *data.y.strides = {stride, ONE};
714+ load.ir_attr.SetOffset(af::Symbol(0));
715+ load.x = data.y;
716+ load.attr.sched.axis = {z0.id, z1.id};
717+ *load.y.axis = {z0.id, z1.id};
718+ *load.y.repeats = {s0, input_dim};
719+ *load.y.strides = {stride, ONE};
720+}
712 721 
713- auto z0 = graph.CreateAxis("z0", s0);722+void CreateConcatOutputChain(af::ascir_op::Concat &concat, af::ascir_op::Store &store, af::ascir_op::Output &output,
714- auto z1 = graph.CreateAxis("z1", s1 + s2 + s2);723+ const af::Axis &z0, const af::Axis &z1, const af::Expression &s0,
715- 724+ const af::Expression &total_dim) {
716- af::ascir_op::Data x1("concat_data0", graph);725+ auto ONE = af::Symbol(1);
717- x1.ir_attr.SetIndex(0);
718- x1.attr.sched.axis = {z0.id, z1.id};
719- *x1.y.axis = {z0.id, z1.id};
720- *x1.y.repeats = {s0, s1};
721- *x1.y.strides = {s1, ONE};
722- 
723- af::ascir_op::Load x1Local("concat_load0");
724- x1Local.ir_attr.SetOffset(af::Symbol(0));
725- x1Local.x = x1.y;
726- x1Local.attr.sched.axis = {z0.id, z1.id};
727- *x1Local.y.axis = {z0.id, z1.id};
728- *x1Local.y.repeats = {s0, s1};
729- *x1Local.y.strides = {s1, ONE};
730- 
731- af::ascir_op::Data x2("concat_data1", graph);
732- x2.ir_attr.SetIndex(1);
733- x2.attr.sched.axis = {z0.id, z1.id};
734- *x2.y.axis = {z0.id, z1.id};
735- *x2.y.repeats = {s0, s2};
736- *x2.y.strides = {s2, ONE};
737- 
738- af::ascir_op::Load x2Local("concat_load1");
739- x2Local.ir_attr.SetOffset(af::Symbol(0));
740- x2Local.x = x2.y;
741- x2Local.attr.sched.axis = {z0.id, z1.id};
742- *x2Local.y.axis = {z0.id, z1.id};
743- *x2Local.y.repeats = {s0, s2};
744- *x2Local.y.strides = {s2, ONE};
745- 
746- af::ascir_op::Data concat_data2("concat_data2", graph);
747- concat_data2.ir_attr.SetIndex(2);
748- concat_data2.attr.sched.axis = {z0.id, z1.id};
749- *concat_data2.y.axis = {z0.id, z1.id};
750- *concat_data2.y.repeats = {s0, s2};
751- *concat_data2.y.strides = {s2, ONE};
752- 
753- af::ascir_op::Load concat_load2("concat_load2");
754- concat_load2.ir_attr.SetOffset(af::Symbol(0));
755- concat_load2.x = concat_data2.y;
756- concat_load2.attr.sched.axis = {z0.id, z1.id};
757- *concat_load2.y.axis = {z0.id, z1.id};
758- *concat_load2.y.repeats = {s0, s2};
759- *concat_load2.y.strides = {s2, ONE};
760- 
761- af::ascir_op::Concat concat("concat");
762- concat.x = {x1Local.y, x2Local.y, concat_load2.y};
763 concat.attr.sched.axis = {z0.id, z1.id};726 concat.attr.sched.axis = {z0.id, z1.id};
764 *concat.y.axis = {z0.id, z1.id};727 *concat.y.axis = {z0.id, z1.id};
765- *concat.y.repeats = {s0, s1 + s2 + s2};728+ *concat.y.repeats = {s0, total_dim};
766- *concat.y.strides = {s1 + s2 + s2, ONE};729+ *concat.y.strides = {total_dim, ONE};
730+ store.x = concat.y;
731+ store.attr.sched.axis = {z0.id, z1.id};
732+ *store.y.axis = {z0.id, z1.id};
733+ *store.y.repeats = {s0, total_dim};
734+ *store.y.strides = {total_dim, ONE};
735+ output.x = store.y;
736+ output.y.dtype = ge::DT_FLOAT16;
737+ output.ir_attr.SetIndex(0);
738+}
767 739 
740+void CreateConcatAscGraph(af::AscGraph &graph, const bool same_data = false) {
741+ const af::Expression s0 = af::Symbol("s0");
742+ const af::Expression s1 = af::Symbol("s1");
743+ const af::Expression s2 = af::Symbol("s2");
744+ const auto input_dim = same_data ? s1 : s2;
745+ const auto total_dim = s1 + input_dim + input_dim;
746+ auto z0 = graph.CreateAxis("z0", s0);
747+ auto z1 = graph.CreateAxis("z1", total_dim);
748+ af::ascir_op::Data x1("concat_data0", graph);
749+ x1.ir_attr.SetIndex(0);
750+ af::ascir_op::Load x1Local("concat_load0");
751+ CreateConcatInputChain(x1, x1Local, z0, z1, s0, s1, s1);
752+ af::ascir_op::Data x2("concat_data1", graph);
753+ x2.ir_attr.SetIndex(1);
754+ af::ascir_op::Load x2Local("concat_load1");
755+ CreateConcatInputChain(x2, x2Local, z0, z1, s0, input_dim, input_dim);
756+ af::ascir_op::Data concat_data2("concat_data2", graph);
757+ concat_data2.ir_attr.SetIndex(2);
758+ af::ascir_op::Load concat_load2("concat_load2");
759+ CreateConcatInputChain(concat_data2, concat_load2, z0, z1, s0, input_dim, input_dim);
760+ af::ascir_op::Concat concat("concat");
761+ concat.x = {x1Local.y, x2Local.y, concat_load2.y};
768 af::ascir_op::Store x_out("concat_store");762 af::ascir_op::Store x_out("concat_store");
769- x_out.x = concat.y;
770- x_out.attr.sched.axis = {z0.id, z1.id};
771- *x_out.y.axis = {z0.id, z1.id};
772- *x_out.y.repeats = {s0, s1 + s2 + s2};
773- *x_out.y.strides = {s1 + s2 + s2, ONE};
774- 
775 af::ascir_op::Output y("concat_out");763 af::ascir_op::Output y("concat_out");
776- y.x = x_out.y;764+ CreateConcatOutputChain(concat, x_out, y, z0, z1, s0, total_dim);
777- y.y.dtype = ge::DT_FLOAT16;
778- y.ir_attr.SetIndex(0);
779- 
780 AscGraphInfoComplete::CompleteApiInfo(graph);765 AscGraphInfoComplete::CompleteApiInfo(graph);
781}766}
782 767 
@@ -990,7 +975,7 @@ TEST_F(FusedGraphUnfolderTest, AscBcNodeUnfolder_With_Same_Data_Same_Load) {
990 975 
991 CreateAddAscGraph(add_sub_graph1);976 CreateAddAscGraph(add_sub_graph1);
992 CreateAddAscGraph3SameData(add_sub_graph2);977 CreateAddAscGraph3SameData(add_sub_graph2);
993- CreateConcatAscGraph(concat_sub_graph);978+ CreateConcatAscGraph(concat_sub_graph, true);
994 979 
995 asc_backend_to_asc_graph.emplace(ascbc1.get(), add_sub_graph1);980 asc_backend_to_asc_graph.emplace(ascbc1.get(), add_sub_graph1);
996 asc_backend_to_asc_graph.emplace(ascbc2.get(), add_sub_graph2);981 asc_backend_to_asc_graph.emplace(ascbc2.get(), add_sub_graph2);
@@ -1139,6 +1124,143 @@ TEST_F(FusedGraphUnfolderTest, AscBcNodeUnfolder_With_Reuse_Output) {
1139 EXPECT_EQ(idx, 0);1124 EXPECT_EQ(idx, 0);
1140}1125}
1141 1126 
1127+TEST_F(FusedGraphUnfolderTest, BuildLocalAxisMapping_MultipleUnitAxesHasUniqueMapping) {
1128+ AscTensorAttr source;
1129+ source.axis = {101, 102};
1130+ source.repeats = {af::Symbol(55), af::Symbol(3)};
1131+ source.strides = {af::Symbol(3), af::Symbol(1)};
1132+ AscTensorAttr target;
1133+ target.axis = {201, 202, 203, 204};
1134+ target.repeats = {af::Symbol(55), af::Symbol(1), af::Symbol(1), af::Symbol(3)};
1135+ target.strides = {af::Symbol(3), af::Symbol(0), af::Symbol(0), af::Symbol(1)};
1136+ FusedGraphUnfolder::AxisMappingResult result;
1137+ 
1138+ EXPECT_EQ(FusedGraphUnfolder::BuildLocalAxisMapping(source, target, result), af::SUCCESS);
1139+ EXPECT_EQ(result.old_to_global, (std::vector<size_t>{0UL, 3UL}));
1140+ EXPECT_EQ(result.inserted_axes, (std::vector<bool>{false, true, true, false}));
1141+}
1142+ 
1143+TEST_F(FusedGraphUnfolderTest, BuildLocalAxisMapping_MultipleEmbeddingsAreAmbiguous) {
1144+ AscTensorAttr source;
1145+ source.axis = {101, 102, 103};
1146+ source.repeats = {af::Symbol(55), af::Symbol(1), af::Symbol(3)};
1147+ source.strides = {af::Symbol(3), af::Symbol(0), af::Symbol(1)};
1148+ AscTensorAttr target;
1149+ target.axis = {201, 202, 203, 204};
1150+ target.repeats = {af::Symbol(55), af::Symbol(1), af::Symbol(1), af::Symbol(3)};
1151+ target.strides = {af::Symbol(3), af::Symbol(0), af::Symbol(0), af::Symbol(1)};
1152+ FusedGraphUnfolder::AxisMappingResult result;
1153+ 
1154+ EXPECT_EQ(FusedGraphUnfolder::BuildLocalAxisMapping(source, target, result), af::FAILED);
1155+ EXPECT_EQ(result.status, FusedGraphUnfolder::AxisMappingStatus::kAmbiguous);
1156+ EXPECT_EQ(result.reason, FusedGraphUnfolder::AxisMappingFailureReason::kMultipleMappings);
1157+}
1158+ 
1159+TEST_F(FusedGraphUnfolderTest, BuildLocalAxisMapping_NonUnitInsertedAxisIsUnsupported) {
1160+ AscTensorAttr source;
1161+ source.axis = {101, 102};
1162+ source.repeats = {af::Symbol(55), af::Symbol(3)};
1163+ source.strides = {af::Symbol(3), af::Symbol(1)};
1164+ AscTensorAttr target;
1165+ target.axis = {201, 202, 203};
1166+ target.repeats = {af::Symbol(55), af::Symbol(2), af::Symbol(3)};
1167+ target.strides = {af::Symbol(3), af::Symbol(0), af::Symbol(1)};
1168+ FusedGraphUnfolder::AxisMappingResult result;
1169+ 
1170+ EXPECT_EQ(FusedGraphUnfolder::BuildLocalAxisMapping(source, target, result), af::FAILED);
1171+ EXPECT_EQ(result.status, FusedGraphUnfolder::AxisMappingStatus::kUnsupported);
1172+ EXPECT_EQ(result.reason, FusedGraphUnfolder::AxisMappingFailureReason::kNonUnitInsertedAxis);
1173+}
1174+ 
1175+TEST_F(FusedGraphUnfolderTest, BuildLocalAxisMapping_UnknownRepeatEqualityIsUnsupported) {
1176+ AscTensorAttr source;
1177+ source.axis = {101};
1178+ source.repeats = {af::Symbol("source_repeat")};
1179+ source.strides = {af::Symbol(1)};
1180+ AscTensorAttr target;
1181+ target.axis = {201};
1182+ target.repeats = {af::Symbol("target_repeat")};
1183+ target.strides = {af::Symbol(1)};
1184+ FusedGraphUnfolder::AxisMappingResult result;
1185+ 
1186+ EXPECT_EQ(FusedGraphUnfolder::BuildLocalAxisMapping(source, target, result), af::FAILED);
1187+ EXPECT_EQ(result.status, FusedGraphUnfolder::AxisMappingStatus::kUnsupported);
1188+}
1189+ 
1190+TEST_F(FusedGraphUnfolderTest, BuildGraphAxisMapping_ComposesIntermediateMapping) {
1191+ AscGraph source_graph("source_graph");
1192+ auto source_axis0 = source_graph.CreateAxis("source_axis0", af::Symbol(55));
1193+ auto source_axis1 = source_graph.CreateAxis("source_axis1", af::Symbol(3));
1194+ AscGraph target_graph("target_graph");
1195+ auto target_axis0 = target_graph.CreateAxis("target_axis0", af::Symbol(55));
1196+ auto target_axis1 = target_graph.CreateAxis("target_axis1", af::Symbol(1));
1197+ auto target_axis2 = target_graph.CreateAxis("target_axis2", af::Symbol(3));
1198+ AscTensorAttr source;
1199+ source.axis = {source_axis0.id, source_axis1.id};
1200+ source.repeats = {af::Symbol(55), af::Symbol(3)};
1201+ source.strides = {af::Symbol(3), af::Symbol(1)};
1202+ AscTensorAttr target;
1203+ target.axis = {target_axis0.id, target_axis1.id, target_axis2.id};
1204+ target.repeats = {af::Symbol(55), af::Symbol(1), af::Symbol(3)};
1205+ target.strides = {af::Symbol(3), af::Symbol(0), af::Symbol(1)};
1206+ std::vector<size_t> source_to_global;
1207+ 
1208+ ASSERT_EQ(source_graph.GetAllAxis().size(), 2UL);
1209+ ASSERT_EQ(target_graph.GetAllAxis().size(), 3UL);
1210+ EXPECT_TRUE(FusedGraphUnfolder::BuildGraphAxisMapping(source_graph, source, target_graph, target, {0UL, 1UL, 3UL},
1211+ source_to_global));
1212+ EXPECT_EQ(source_to_global, (std::vector<size_t>{0UL, 3UL}));
1213+}
1214+ 
1215+TEST_F(FusedGraphUnfolderTest, BuildGraphAxisMapping_RejectsDuplicateGlobalAxis) {
1216+ AscGraph source_graph("source_graph");
1217+ auto source_axis0 = source_graph.CreateAxis("source_axis0", af::Symbol(55));
1218+ auto source_axis1 = source_graph.CreateAxis("source_axis1", af::Symbol(3));
1219+ AscGraph target_graph("target_graph");
1220+ auto target_axis0 = target_graph.CreateAxis("target_axis0", af::Symbol(55));
1221+ auto target_axis1 = target_graph.CreateAxis("target_axis1", af::Symbol(3));
1222+ AscTensorAttr source;
1223+ source.axis = {source_axis0.id, source_axis1.id};
1224+ source.repeats = {af::Symbol(55), af::Symbol(3)};
1225+ source.strides = {af::Symbol(3), af::Symbol(1)};
1226+ AscTensorAttr target;
1227+ target.axis = {target_axis0.id, target_axis1.id};
1228+ target.repeats = {af::Symbol(55), af::Symbol(3)};
1229+ target.strides = {af::Symbol(3), af::Symbol(1)};
1230+ std::vector<size_t> source_to_global;
1231+ 
1232+ EXPECT_FALSE(FusedGraphUnfolder::BuildGraphAxisMapping(source_graph, source, target_graph, target, {0UL, 0UL},
1233+ source_to_global));
1234+}
1235+ 
1236+TEST_F(FusedGraphUnfolderTest, ApplyMappedLoopAxis_PreservesBufferAttributes) {
1237+ AscGraph graph("buffer_graph");
1238+ const auto s0 = af::Symbol(2);
1239+ const auto s1 = af::Symbol(3);
1240+ auto z0 = graph.CreateAxis("z0", s0);
1241+ auto z1 = graph.CreateAxis("z1", s1);
1242+ AscGraph global_graph("global_graph");
1243+ auto global_z0 = global_graph.CreateAxis("z0", s0);
1244+ auto global_z1 = global_graph.CreateAxis("z1", s1);
1245+ auto global_z2 = global_graph.CreateAxis("z2", af::Symbol(5));
1246+ af::ascir_op::Data buffer("buffer", graph);
1247+ buffer.attr.api.type = af::ApiType::kAPITypeBuffer;
1248+ buffer.attr.sched.axis = {z0.id, z1.id};
1249+ *buffer.y.axis = {z0.id, z1.id};
1250+ *buffer.y.repeats = {s0, s1};
1251+ *buffer.y.strides = {s1, af::Symbol(1)};
1252+ 
1253+ ASSERT_EQ(FusedGraphUnfolder::ApplyMappedLoopAxis(graph, global_graph.GetAllAxis(),
1254+ {global_z0.id, global_z1.id, global_z2.id}, {0UL, 2UL}),
1255+ af::SUCCESS);
1256+ const auto buffer_node = graph.FindNode("buffer");
1257+ ASSERT_NE(buffer_node, nullptr);
1258+ EXPECT_EQ(buffer_node->attr.sched.axis, (std::vector<af::AxisId>{z0.id, z1.id}));
1259+ EXPECT_EQ(buffer_node->outputs[0].attr.axis, (std::vector<af::AxisId>{z0.id, z1.id}));
1260+ EXPECT_EQ(buffer_node->outputs[0].attr.repeats, (std::vector<af::Expression>{s0, s1}));
1261+ EXPECT_EQ(buffer_node->outputs[0].attr.strides, (std::vector<af::Expression>{s1, af::Symbol(1)}));
1262+}
1263+ 
1142TEST_F(FusedGraphUnfolderTest, TestIsSameLoad) {1264TEST_F(FusedGraphUnfolderTest, TestIsSameLoad) {
1143 af::AscGraph graph("test");1265 af::AscGraph graph("test");
1144 auto ONE = af::Symbol(1);1266 auto ONE = af::Symbol(1);
Mautofuse/tests/v35/st/att/concat/test_concat.cpp+4-7
@@ -195,7 +195,7 @@ Status BuildVectorFunctionSubgraph(af::AscGraph &subgraph) {
195 auto nd = subgraph.CreateAxis("nd", ND);195 auto nd = subgraph.CreateAxis("nd", ND);
196 auto [ndB, ndb] = subgraph.BlockSplit(nd.id);196 auto [ndB, ndb] = subgraph.BlockSplit(nd.id);
197 auto [ndbT, ndbt] = subgraph.TileSplit(ndb->id);197 auto [ndbT, ndbt] = subgraph.TileSplit(ndb->id);
198- auto data1 = subgraph.CreateContiguousData("input1", DT_FLOAT, {*ndbt});198+ auto data1 = subgraph.CreateContiguousData("input1", DT_FLOAT, {*ndbt}, 0);
199 auto load1 = Load("load1", data1);199 auto load1 = Load("load1", data1);
200 auto abs1 = Abs("abs1", load1);200 auto abs1 = Abs("abs1", load1);
201 auto sub1 = Sub("sub1", abs1, abs1);201 auto sub1 = Sub("sub1", abs1, abs1);
@@ -225,8 +225,7 @@ static Status BuildVectorFuncGraphS0(af::AscGraph &graph) {
225 auto z0 = graph.CreateAxis("z0", S0);225 auto z0 = graph.CreateAxis("z0", S0);
226 auto [z0B, z0b] = graph.BlockSplit(z0.id);226 auto [z0B, z0b] = graph.BlockSplit(z0.id);
227 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);227 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);
228- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});228+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
229- 
230 LOOP(*z0B) {229 LOOP(*z0B) {
231 LOOP(*z0bT) {230 LOOP(*z0bT) {
232 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);231 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -251,8 +250,7 @@ static Status BuildVectorFuncGraphS0V1(af::AscGraph &graph) {
251 auto z0 = graph.CreateAxis("z0", S0);250 auto z0 = graph.CreateAxis("z0", S0);
252 auto [z0T, z0t] = graph.TileSplit(z0.id);251 auto [z0T, z0t] = graph.TileSplit(z0.id);
253 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);252 auto [z0TB, z0Tb] = graph.BlockSplit(z0T->id);
254- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});253+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
255- 
256 LOOP(*z0TB) {254 LOOP(*z0TB) {
257 LOOP(*z0Tb) {255 LOOP(*z0Tb) {
258 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);256 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
@@ -313,8 +311,7 @@ Status BuildTwoGroupTestAscGraphCommon(af::AscGraph &graph, const std::string &z
313 auto [z0z1TB, z0z1Tb] = graph.BlockSplit(z0z1T->id);311 auto [z0z1TB, z0z1Tb] = graph.BlockSplit(z0z1T->id);
314 312 
315 std::vector<af::Axis> axes = {z0_axis, z1};313 std::vector<af::Axis> axes = {z0_axis, z1};
316- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, axes);314+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, axes, 0);
317- 
318 LOOP(*z0z1TB) {315 LOOP(*z0z1TB) {
319 LOOP(*z0z1Tb) {316 LOOP(*z0z1Tb) {
320 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);317 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/tests/v35/ut/ascendc/api_regbase/CMakeLists.txt+2-0
@@ -56,8 +56,10 @@ add_library(test_regbase_ascendc OBJECT
56 ./test_spherical_bessel_j0.cpp56 ./test_spherical_bessel_j0.cpp
57 ./test_ndtri.cpp57 ./test_ndtri.cpp
58 ./test_ndtr.cpp58 ./test_ndtr.cpp
59+ ./test_log_ndtr.cpp
59 ./test_nextafter.cpp60 ./test_nextafter.cpp
60 ./test_i0.cpp61 ./test_i0.cpp
62+ ./test_hypot.cpp
61 )63 )
62target_link_libraries(test_regbase_ascendc64target_link_libraries(test_regbase_ascendc
63 ascendc_api_regbase_extend65 ascendc_api_regbase_extend
Aautofuse/tests/v35/ut/ascendc/api_regbase/test_hypot.cpp+192-0
@@ -0,0 +1,192 @@
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 <cfloat>
12+#include <cmath>
13+#include <cstdint>
14+#include <cstring>
15+#include <random>
16+#include <utility>
17+#include <vector>
18+#include <securec.h>
19+#include "gtest/gtest.h"
20+#include "tikicpulib.h"
21+#include "test_api_utils.h"
22+#include "api_regbase/hypot.h"
23+ 
24+using namespace AscendC;
25+ 
26+namespace af {
27+ 
28+struct HypotInputParam {
29+ float *y{};
30+ float *exp{};
31+ float *src0{};
32+ float *src1{};
33+ uint32_t size{0};
34+};
35+ 
36+class TestRegbaseApiHypot : public testing::Test {
37+ protected:
38+ static void InvokeKernel(HypotInputParam &param) {
39+ TPipe tpipe;
40+ TBuf<TPosition::VECCALC> x0Buf, x1Buf, yBuf, tmpBuf;
41+ tpipe.InitBuffer(x0Buf, sizeof(float) * param.size);
42+ tpipe.InitBuffer(x1Buf, sizeof(float) * param.size);
43+ tpipe.InitBuffer(yBuf, sizeof(float) * AlignUp(param.size, ONE_BLK_SIZE / sizeof(float)));
44+ tpipe.InitBuffer(tmpBuf, TMP_UB_SIZE);
45+ 
46+ LocalTensor<float> l_x0 = x0Buf.Get<float>();
47+ LocalTensor<float> l_x1 = x1Buf.Get<float>();
48+ LocalTensor<float> l_y = yBuf.Get<float>();
49+ LocalTensor<uint8_t> l_tmp = tmpBuf.Get<uint8_t>();
50+ 
51+ GmToUb(l_x0, param.src0, param.size);
52+ GmToUb(l_x1, param.src1, param.size);
53+ HypotExtend(l_y, l_x0, l_x1, l_tmp, param.size);
54+ UbToGm(param.y, l_y, param.size);
55+ }
56+ 
57+ static void CreateRandomInput(HypotInputParam &param, uint32_t size) {
58+ param.size = size;
59+ param.y = static_cast<float *>(AscendC::GmAlloc(sizeof(float) * param.size));
60+ param.exp = static_cast<float *>(AscendC::GmAlloc(sizeof(float) * param.size));
61+ param.src0 = static_cast<float *>(AscendC::GmAlloc(sizeof(float) * param.size));
62+ param.src1 = static_cast<float *>(AscendC::GmAlloc(sizeof(float) * param.size));
63+ 
64+ std::mt19937 eng(1);
65+ std::uniform_real_distribution<float> distr(-100.0f, 100.0f);
66+ 
67+ for (uint32_t i = 0; i < param.size; i++) {
68+ param.src0[i] = distr(eng);
69+ param.src1[i] = distr(eng);
70+ param.exp[i] = std::hypot(param.src0[i], param.src1[i]);
71+ }
72+ }
73+ 
74+ static void CreateBoundaryInput(HypotInputParam &param, const std::vector<std::pair<float, float>> &cases) {
75+ param.size = static_cast<uint32_t>(cases.size());
76+ param.y = static_cast<float *>(AscendC::GmAlloc(sizeof(float) * param.size));
77+ param.exp = static_cast<float *>(AscendC::GmAlloc(sizeof(float) * param.size));
78+ param.src0 = static_cast<float *>(AscendC::GmAlloc(sizeof(float) * param.size));
79+ param.src1 = static_cast<float *>(AscendC::GmAlloc(sizeof(float) * param.size));
80+ 
81+ for (uint32_t i = 0; i < param.size; i++) {
82+ param.src0[i] = cases[i].first;
83+ param.src1[i] = cases[i].second;
84+ param.exp[i] = std::hypot(cases[i].first, cases[i].second);
85+ }
86+ }
87+ 
88+ static uint32_t Valid(float *y, float *exp, uint32_t size) {
89+ uint32_t diff_count = 0;
90+ for (uint32_t i = 0; i < size; i++) {
91+ bool both_nan = std::isnan(y[i]) && std::isnan(exp[i]);
92+ bool both_inf = std::isinf(y[i]) && std::isinf(exp[i]);
93+ bool close = false;
94+ if (!both_nan && !both_inf) {
95+ float rel_err = std::abs(y[i] - exp[i]) / std::max(std::abs(exp[i]), 1e-30f);
96+ close = rel_err < 1e-5f;
97+ }
98+ if (!both_nan && !both_inf && !close) {
99+ diff_count++;
100+ printf("diff at index %u: got=%.9f, exp=%.9f\n", i, y[i], exp[i]);
101+ }
102+ }
103+ return diff_count;
104+ }
105+ 
106+ static void FreeInput(HypotInputParam &param) {
107+ AscendC::GmFree(param.y);
108+ AscendC::GmFree(param.exp);
109+ AscendC::GmFree(param.src0);
110+ AscendC::GmFree(param.src1);
111+ }
112+ 
113+ static void HypotRandomTest(uint32_t size) {
114+ HypotInputParam param{};
115+ CreateRandomInput(param, size);
116+ 
117+ auto kernel = [&param] { InvokeKernel(param); };
118+ AscendC::SetKernelMode(KernelMode::AIV_MODE);
119+ ICPU_RUN_KF(kernel, 1);
120+ 
121+ uint32_t diff_count = Valid(param.y, param.exp, param.size);
122+ EXPECT_EQ(diff_count, 0);
123+ FreeInput(param);
124+ }
125+ 
126+ static void HypotBoundaryTest() {
127+ const std::vector<std::pair<float, float>> cases = {
128+ {0.0f, 0.0f},
129+ {-0.0f, 0.0f},
130+ {0.0f, -0.0f},
131+ {3.0f, 4.0f},
132+ {-3.0f, 4.0f},
133+ {3.0f, -4.0f},
134+ {-3.0f, -4.0f},
135+ {1e38f, 1e38f},
136+ {1e-20f, 1e-20f},
137+ {1e38f, 1e-20f},
138+ {1e-20f, 1e38f},
139+ {1e38f, 0.0f},
140+ {0.0f, 1e38f},
141+ {1e-20f, 0.0f},
142+ {0.0f, 1e-20f},
143+ {INFINITY, 3.0f},
144+ {3.0f, INFINITY},
145+ {-INFINITY, 3.0f},
146+ {3.0f, -INFINITY},
147+ {INFINITY, INFINITY},
148+ {-INFINITY, INFINITY},
149+ {INFINITY, -INFINITY},
150+ {-INFINITY, -INFINITY},
151+ {INFINITY, 0.0f},
152+ {0.0f, INFINITY},
153+ {NAN, 3.0f},
154+ {3.0f, NAN},
155+ {NAN, NAN},
156+ {NAN, 0.0f},
157+ {0.0f, NAN},
158+ {NAN, INFINITY},
159+ {INFINITY, NAN},
160+ {FLT_MAX, FLT_MAX},
161+ {1.0f, FLT_MAX},
162+ };
163+ 
164+ HypotInputParam param{};
165+ CreateBoundaryInput(param, cases);
166+ 
167+ auto kernel = [&param] { InvokeKernel(param); };
168+ AscendC::SetKernelMode(KernelMode::AIV_MODE);
169+ ICPU_RUN_KF(kernel, 1);
170+ 
171+ uint32_t diff_count = Valid(param.y, param.exp, param.size);
172+ EXPECT_EQ(diff_count, 0);
173+ FreeInput(param);
174+ }
175+};
176+ 
177+TEST_F(TestRegbaseApiHypot, Hypot_Random_Test) {
178+ HypotRandomTest(ONE_BLK_SIZE / sizeof(float));
179+ HypotRandomTest(ONE_REPEAT_BYTE_SIZE / sizeof(float));
180+ HypotRandomTest(MAX_REPEAT_NUM * ONE_REPEAT_BYTE_SIZE / 2 / sizeof(float));
181+ HypotRandomTest((ONE_BLK_SIZE - sizeof(float)) / sizeof(float));
182+ HypotRandomTest((ONE_REPEAT_BYTE_SIZE - ONE_BLK_SIZE) / sizeof(float));
183+ HypotRandomTest(((MAX_REPEAT_NUM - 1) * ONE_REPEAT_BYTE_SIZE + (ONE_REPEAT_BYTE_SIZE - ONE_BLK_SIZE) +
184+ (ONE_BLK_SIZE - sizeof(float))) /
185+ 2 / sizeof(float));
186+}
187+ 
188+TEST_F(TestRegbaseApiHypot, Hypot_Boundary_Test) {
189+ HypotBoundaryTest();
190+}
191+ 
192+} // namespace af
Aautofuse/tests/v35/ut/ascendc/api_regbase/test_log_ndtr.cpp+266-0
@@ -0,0 +1,266 @@
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 <cmath>
12+#include <random>
13+#include <algorithm>
14+#include "gtest/gtest.h"
15+#include "tikicpulib.h"
16+#include "test_api_utils.h"
17+#include "api_regbase/log_ndtr.h"
18+ 
19+using namespace AscendC;
20+ 
21+namespace af {
22+ 
23+template <typename T>
24+struct LogNdtrInputParam {
25+ T *dst{};
26+ T *exp{};
27+ T *src{};
28+ int32_t size{0};
29+};
30+ 
31+// Reference implementation using double precision
32+template <typename T>
33+static T calcRefLogNdtr(T x) {
34+ double dx = static_cast<double>(x);
35+ double t = dx * LOG_NDTR::LOG_NDTR_INV_SQRT_2;
36+ double result;
37+ if (dx < -1.0) {
38+ // Left tail: log(erfcx(-t)/2) - t^2
39+ double erfcx_val = std::exp(t * t) * std::erfc(-t);
40+ result = std::log(erfcx_val * 0.5) - t * t;
41+ } else {
42+ // Right tail: log1p(-erfc(t)/2)
43+ double erfc_val = std::erfc(t);
44+ result = std::log1p(-erfc_val * 0.5);
45+ }
46+ return static_cast<T>(result);
47+}
48+ 
49+class TestApiLogNdtr : public testing::Test {
50+ protected:
51+ template <typename T>
52+ static void InvokeTensorKernel(LogNdtrInputParam<T> &param) {
53+ TPipe tpipe;
54+ TBuf<TPosition::VECCALC> srcBuf, dstBuf, tmpBuf;
55+ tpipe.InitBuffer(srcBuf, sizeof(T) * param.size);
56+ tpipe.InitBuffer(dstBuf, sizeof(T) * param.size);
57+ tpipe.InitBuffer(tmpBuf, 2048 * sizeof(uint8_t));
58+ 
59+ LocalTensor<T> l_src = srcBuf.Get<T>();
60+ LocalTensor<T> l_dst = dstBuf.Get<T>();
61+ LocalTensor<uint8_t> l_tmp = tmpBuf.Get<uint8_t>();
62+ 
63+ GmToUb(l_src, param.src, param.size);
64+ LogNdtrExtend<T>(l_dst, l_src, l_tmp, param.size);
65+ UbToGm(param.dst, l_dst, param.size);
66+ }
67+ 
68+ // Create random input covering both left-tail and right-tail branches
69+ template <typename T>
70+ static void CreateTensorInput(LogNdtrInputParam<T> &param) {
71+ param.dst = static_cast<T *>(AscendC::GmAlloc(sizeof(T) * param.size));
72+ param.exp = static_cast<T *>(AscendC::GmAlloc(sizeof(T) * param.size));
73+ param.src = static_cast<T *>(AscendC::GmAlloc(sizeof(T) * param.size));
74+ 
75+ std::mt19937 eng(1);
76+ 
77+ // Mix of left tail [-30, -1.0) and right tail [-1.0, 20]
78+ std::uniform_real_distribution<float> distrLeft(-30.0f, -1.001f);
79+ std::uniform_real_distribution<float> distrRight(-1.0f, 20.0f);
80+ 
81+ for (int i = 0; i < param.size; i++) {
82+ T input;
83+ if (i % 2 == 0) {
84+ input = static_cast<T>(distrLeft(eng));
85+ } else {
86+ input = static_cast<T>(distrRight(eng));
87+ }
88+ param.src[i] = input;
89+ param.exp[i] = calcRefLogNdtr(input);
90+ }
91+ }
92+ 
93+ // Create special value inputs
94+ template <typename T>
95+ static void CreateSpecialInput(LogNdtrInputParam<T> &param) {
96+ param.dst = static_cast<T *>(AscendC::GmAlloc(sizeof(T) * param.size));
97+ param.exp = static_cast<T *>(AscendC::GmAlloc(sizeof(T) * param.size));
98+ param.src = static_cast<T *>(AscendC::GmAlloc(sizeof(T) * param.size));
99+ 
100+ T nan_val = std::numeric_limits<T>::quiet_NaN();
101+ T inf_val = std::numeric_limits<T>::infinity();
102+ 
103+ // [0] NaN → NaN
104+ param.src[0] = nan_val;
105+ param.exp[0] = nan_val;
106+ 
107+ // [1] +inf → -0.0
108+ param.src[1] = inf_val;
109+ param.exp[1] = -0.0f;
110+ 
111+ // [2] -inf → -inf
112+ param.src[2] = -inf_val;
113+ param.exp[2] = -inf_val;
114+ 
115+ // [3] 0.0 → -ln(2) ≈ -0.693147
116+ param.src[3] = 0.0f;
117+ param.exp[3] = static_cast<T>(-0.6931471805599453);
118+ 
119+ // [4] -0.0 → -ln(2)
120+ param.src[4] = -0.0f;
121+ param.exp[4] = static_cast<T>(-0.6931471805599453);
122+ 
123+ // [5] x = -1.0 (branch boundary) → ≈ -1.841
124+ param.src[5] = -1.0f;
125+ param.exp[5] = calcRefLogNdtr(-1.0f);
126+ 
127+ // [6] x = 1.0 → ≈ -0.17275
128+ param.src[6] = 1.0f;
129+ param.exp[6] = calcRefLogNdtr(1.0f);
130+ 
131+ // [7] x = -5.0 (deep left tail) → ≈ -13.42
132+ param.src[7] = -5.0f;
133+ param.exp[7] = calcRefLogNdtr(-5.0f);
134+ 
135+ // [8] x = 5.0 (right tail, small result) → ≈ -2.87e-7
136+ param.src[8] = 5.0f;
137+ param.exp[8] = calcRefLogNdtr(5.0f);
138+ 
139+ // [9] x = -20.0 (very deep left tail)
140+ param.src[9] = -20.0f;
141+ param.exp[9] = calcRefLogNdtr(-20.0f);
142+ 
143+ // [10] x = 10.0 (large positive, near underflow)
144+ param.src[10] = 10.0f;
145+ param.exp[10] = calcRefLogNdtr(10.0f);
146+ 
147+ // [11] x = -30.0 (maximum negative test value)
148+ param.src[11] = -30.0f;
149+ param.exp[11] = calcRefLogNdtr(-30.0f);
150+ 
151+ // [12] x = 20.0 (extreme positive, should underflow)
152+ param.src[12] = 20.0f;
153+ param.exp[12] = calcRefLogNdtr(20.0f);
154+ 
155+ // [13] x = -1.5 (left tail near boundary)
156+ param.src[13] = -1.5f;
157+ param.exp[13] = calcRefLogNdtr(-1.5f);
158+ 
159+ // [14] x = -0.5 (right tail near boundary)
160+ param.src[14] = -0.5f;
161+ param.exp[14] = calcRefLogNdtr(-0.5f);
162+ 
163+ // [15] x = 2.0
164+ param.src[15] = 2.0f;
165+ param.exp[15] = calcRefLogNdtr(2.0f);
166+ }
167+ 
168+ // Validation function with branch-aware tolerances
169+ template <typename T>
170+ static uint32_t Valid(T *dst, T *exp, T *src, size_t comp_size) {
171+ uint32_t diff_count = 0;
172+ 
173+ for (uint32_t i = 0; i < comp_size; i++) {
174+ bool is_diff = false;
175+ T abs_diff = 0;
176+ 
177+ if (std::isnan(exp[i])) {
178+ if (!std::isnan(dst[i])) {
179+ is_diff = true;
180+ }
181+ } else if (std::isinf(exp[i])) {
182+ if (dst[i] != exp[i]) {
183+ is_diff = true;
184+ }
185+ } else {
186+ // Combined absolute/relative error: denominator max(1, |exp|) uses
187+ // absolute error for small values and relative error for large ones
188+ abs_diff = std::abs(dst[i] - exp[i]);
189+ T rel_err = abs_diff / std::max(std::abs(exp[i]), T(1));
190+ if (rel_err > T(1e-5)) {
191+ is_diff = true;
192+ }
193+ }
194+ 
195+ if (is_diff) {
196+ diff_count++;
197+ }
198+ }
199+ 
200+ return diff_count;
201+ }
202+ 
203+ template <typename T>
204+ static void MainTest(const int32_t size) {
205+ LogNdtrInputParam<T> param{};
206+ param.size = size;
207+ CreateTensorInput(param);
208+ 
209+ auto kernel = [&param] { InvokeTensorKernel(param); };
210+ 
211+ AscendC::SetKernelMode(KernelMode::AIV_MODE);
212+ ICPU_RUN_KF(kernel, 1);
213+ 
214+ uint32_t diff_count = Valid<T>(param.dst, param.exp, param.src, param.size);
215+ EXPECT_EQ(diff_count, 0);
216+ 
217+ AscendC::GmFree(param.dst);
218+ AscendC::GmFree(param.exp);
219+ AscendC::GmFree(param.src);
220+ }
221+ 
222+ template <typename T>
223+ static void MainSpecialTest(const int32_t size) {
224+ LogNdtrInputParam<T> param{};
225+ param.size = size;
226+ CreateSpecialInput(param);
227+ 
228+ auto kernel = [&param] { InvokeTensorKernel(param); };
229+ 
230+ AscendC::SetKernelMode(KernelMode::AIV_MODE);
231+ ICPU_RUN_KF(kernel, 1);
232+ 
233+ uint32_t diff_count = Valid<T>(param.dst, param.exp, param.src, param.size);
234+ EXPECT_EQ(diff_count, 0);
235+ 
236+ AscendC::GmFree(param.dst);
237+ AscendC::GmFree(param.exp);
238+ AscendC::GmFree(param.src);
239+ }
240+};
241+ 
242+TEST_F(TestApiLogNdtr, LogNdtr_Special_Success) {
243+ MainSpecialTest<float>(16);
244+}
245+ 
246+TEST_F(TestApiLogNdtr, LogNdtr_Float_32_Success) {
247+ MainTest<float>(32);
248+}
249+ 
250+TEST_F(TestApiLogNdtr, LogNdtr_Float_64_Success) {
251+ MainTest<float>(64);
252+}
253+ 
254+TEST_F(TestApiLogNdtr, LogNdtr_Float_128_Success) {
255+ MainTest<float>(128);
256+}
257+ 
258+TEST_F(TestApiLogNdtr, LogNdtr_Float_256_Success) {
259+ MainTest<float>(256);
260+}
261+ 
262+TEST_F(TestApiLogNdtr, LogNdtr_Float_1000_Success) {
263+ MainTest<float>(1000);
264+}
265+ 
266+} // namespace af
Mautofuse/tests/v35/ut/att/gen_model_info/api_perf_register/test_pipe_perf_expr_v2.cpp+2-2
@@ -30,7 +30,7 @@ Status BuildVectorFunctionSubgraph(af::AscGraph &subgraph) {
30 auto nd = subgraph.CreateAxis("nd", ND);30 auto nd = subgraph.CreateAxis("nd", ND);
31 auto [ndB, ndb] = subgraph.BlockSplit(nd.id);31 auto [ndB, ndb] = subgraph.BlockSplit(nd.id);
32 auto [ndbT, ndbt] = subgraph.TileSplit(ndb->id);32 auto [ndbT, ndbt] = subgraph.TileSplit(ndb->id);
33- auto data1 = subgraph.CreateContiguousData("input1", DT_FLOAT, {*ndbt});33+ auto data1 = subgraph.CreateContiguousData("input1", DT_FLOAT, {*ndbt}, 0);
34 auto load1 = Load("load1", data1);34 auto load1 = Load("load1", data1);
35 auto abs1 = Abs("abs1", load1);35 auto abs1 = Abs("abs1", load1);
36 auto sub1 = Sub("sub1", abs1, abs1);36 auto sub1 = Sub("sub1", abs1, abs1);
@@ -44,7 +44,7 @@ Status BuildConcatGroupAscendGraphS0WithVectorFunc(af::AscGraph &graph) {
44 auto z0 = graph.CreateAxis("z0", S0);44 auto z0 = graph.CreateAxis("z0", S0);
45 auto [z0B, z0b] = graph.BlockSplit(z0.id);45 auto [z0B, z0b] = graph.BlockSplit(z0.id);
46 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);46 auto [z0bT, z0bt] = graph.TileSplit(z0b->id);
47- auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0});47+ auto data1 = graph.CreateContiguousData("input1", DT_FLOAT, {z0}, 0);
48 LOOP(*z0B) {48 LOOP(*z0B) {
49 LOOP(*z0bT) {49 LOOP(*z0bT) {
50 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);50 auto load1 = Load("load1", data1).TQue(Position::kPositionVecIn, 1, 1);
Mautofuse/v35/ascendc/api_regbase/CMakeLists.txt+2-0
@@ -64,12 +64,14 @@ set(ascendc_api_regbase_extend_src
64 shifted_chebyshev_polynomial_v.h64 shifted_chebyshev_polynomial_v.h
65 shifted_chebyshev_polynomial_w.h65 shifted_chebyshev_polynomial_w.h
66 ndtr.h66 ndtr.h
67+ log_ndtr.h
67 next_after.h68 next_after.h
68 i0.h69 i0.h
69 igammac_helper/series.h70 igammac_helper/series.h
70 igammac_helper/continued_fraction.h71 igammac_helper/continued_fraction.h
71 igammac_helper/asymptotic_series.h72 igammac_helper/asymptotic_series.h
72 igammac_helper/series_complement.h73 igammac_helper/series_complement.h
74+ hypot.h
73)75)
74 76 
75set(generated_regbase_files)77set(generated_regbase_files)
Aautofuse/v35/ascendc/api_regbase/hypot.h+108-0
@@ -0,0 +1,108 @@
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 __ASCENDC_API_REGBASE_HYPOT_H__
12+#define __ASCENDC_API_REGBASE_HYPOT_H__
13+ 
14+/*
15+ * hypot(x, y) = sqrt(x^2 + y^2)
16+ *
17+ * Naive computation overflows for large inputs and loses precision for small inputs.
18+ * Numerically stable algorithm:
19+ * a = |x|, b = |y|
20+ * m = max(a, b), n = min(a, b)
21+ * hypot(x, y) = m * sqrt(1 + (n/m)^2)
22+ *
23+ * Boundary handling (applied after normal computation, in priority order):
24+ * 1. m == 0 (both inputs are 0): ratio = 0/0 = NaN, override result to 0
25+ * 2. Either input is NaN: override result to NaN
26+ * (needed because max(NaN, x) returns x in IEEE 754)
27+ * 3. Either |input| is inf: override result to inf
28+ * (per C standard: inf dominates NaN, hypot(inf, nan) = inf)
29+ */
30+ 
31+template <typename T>
32+__simd_vf__ inline void HypotImplVF(__ubuf__ T *dst, __ubuf__ T *src0, __ubuf__ T *src1, uint32_t calc_cnt) {
33+ uint32_t vl_size = static_cast<uint32_t>(AscendC::GetVecLen() / sizeof(T));
34+ uint16_t repeat_time = static_cast<uint16_t>(AscendC::CeilDivision(calc_cnt, vl_size));
35+ 
36+ AscendC::Reg::RegTensor<T> src0_reg, src1_reg, dst_reg;
37+ AscendC::Reg::RegTensor<T> abs0_reg, abs1_reg, max_reg, min_reg, ratio_reg, ratio_sq_reg;
38+ AscendC::Reg::RegTensor<T> one_plus_reg, sqrt_reg, special_reg;
39+ AscendC::Reg::MaskReg mask, cmp_mask;
40+ 
41+ for (uint16_t i = 0U; i < repeat_time; ++i) {
42+ mask = AscendC::Reg::UpdateMask<T>(calc_cnt);
43+ AscendC::Reg::LoadAlign(src0_reg, src0 + i * vl_size);
44+ AscendC::Reg::LoadAlign(src1_reg, src1 + i * vl_size);
45+ 
46+ // a = |x|, b = |y|
47+ AscendC::Reg::Abs(abs0_reg, src0_reg, mask);
48+ AscendC::Reg::Abs(abs1_reg, src1_reg, mask);
49+ 
50+ // m = max(a, b), n = min(a, b)
51+ AscendC::Reg::Compare<T, AscendC::CMPMODE::GE>(cmp_mask, abs0_reg, abs1_reg, mask);
52+ AscendC::Reg::Select(max_reg, abs0_reg, abs1_reg, cmp_mask);
53+ AscendC::Reg::Select(min_reg, abs1_reg, abs0_reg, cmp_mask);
54+ 
55+ // ratio = n / m
56+ AscendC::Reg::Div(ratio_reg, min_reg, max_reg, mask);
57+ 
58+ // ratio_sq = ratio * ratio
59+ AscendC::Reg::Mul(ratio_sq_reg, ratio_reg, ratio_reg, mask);
60+ 
61+ // val = 1 + ratio_sq
62+ AscendC::Reg::Adds(one_plus_reg, ratio_sq_reg, (T)1.0, mask);
63+ 
64+ // sqrt_val = sqrt(val)
65+ AscendC::Reg::Sqrt(sqrt_reg, one_plus_reg, mask);
66+ 
67+ // result = m * sqrt_val
68+ AscendC::Reg::Mul(dst_reg, max_reg, sqrt_reg, mask);
69+ 
70+ // 1. Both inputs are 0 (m == 0): ratio = 0/0 = NaN, override result to 0
71+ AscendC::Reg::Duplicate<T>(special_reg, (T)0.0, mask);
72+ AscendC::Reg::Compares<T, AscendC::CMPMODE::EQ>(cmp_mask, max_reg, (T)0.0, mask);
73+ AscendC::Reg::Select(dst_reg, special_reg, dst_reg, cmp_mask);
74+ 
75+ // 2. Either input is NaN: override result to NaN
76+ // (needed because max(NaN, x) returns x in IEEE 754)
77+ AscendC::Reg::Compare<T, AscendC::CMPMODE::NE>(cmp_mask, src0_reg, src0_reg, mask);
78+ AscendC::Reg::Select(dst_reg, src0_reg, dst_reg, cmp_mask);
79+ AscendC::Reg::Compare<T, AscendC::CMPMODE::NE>(cmp_mask, src1_reg, src1_reg, mask);
80+ AscendC::Reg::Select(dst_reg, src1_reg, dst_reg, cmp_mask);
81+ 
82+ // 3. Either |input| is inf: override result to inf
83+ // (per C standard, inf dominates NaN: hypot(inf, nan) = inf)
84+ AscendC::Reg::Duplicate<T>(special_reg, (float &)AscendC::F32_INF, mask);
85+ AscendC::Reg::Compares<T, AscendC::CMPMODE::EQ>(cmp_mask, abs0_reg, (float &)AscendC::F32_INF, mask);
86+ AscendC::Reg::Select(dst_reg, special_reg, dst_reg, cmp_mask);
87+ AscendC::Reg::Compares<T, AscendC::CMPMODE::EQ>(cmp_mask, abs1_reg, (float &)AscendC::F32_INF, mask);
88+ AscendC::Reg::Select(dst_reg, special_reg, dst_reg, cmp_mask);
89+ 
90+ AscendC::Reg::StoreAlign(dst + i * vl_size, dst_reg, mask);
91+ }
92+}
93+ 
94+template <typename T>
95+__aicore__ inline void HypotExtend(const AscendC::LocalTensor<T> &dst, const AscendC::LocalTensor<T> &src0,
96+ const AscendC::LocalTensor<T> &src1, const LocalTensor<uint8_t> &tmpBuffer,
97+ const uint32_t calc_cnt) {
98+ static_assert(std::is_same<T, float>::value, "Hypot currently only supports float");
99+ ASCENDC_ASSERT(calc_cnt > 0, { KERNEL_LOG(KERNEL_ERROR, "calc_cnt must be positive, got %u", calc_cnt); });
100+ if ASCEND_IS_AIC {
101+ return;
102+ }
103+ 
104+ HypotImplVF<T>((__ubuf__ T *)dst.GetPhyAddr(), (__ubuf__ T *)src0.GetPhyAddr(), (__ubuf__ T *)src1.GetPhyAddr(),
105+ calc_cnt);
106+}
107+ 
108+#endif // __ASCENDC_API_REGBASE_HYPOT_H__
Aautofuse/v35/ascendc/api_regbase/log_ndtr.h+309-0
@@ -0,0 +1,309 @@
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 __ASCENDC_API_REGBASE_LOG_NDTR_H__
12+#define __ASCENDC_API_REGBASE_LOG_NDTR_H__
13+ 
14+using namespace AscendC;
15+ 
16+namespace LOG_NDTR {
17+ 
18+constexpr float LOG_NDTR_INV_SQRT_2 = 0.7071067811865475f;
19+constexpr float LOG_NDTR_BRANCH_THRESHOLD = -1.0f;
20+// |t| threshold for the erf Pade approximation; beyond it the result saturates to sign(t)
21+constexpr float LOG_NDTR_LARGE_THRESHOLD = 3.92f;
22+// Float bit patterns (AscendC TIK compiler does not provide memcpy/bit_cast;
23+// pointer-punning via reference is the established convention in api_regbase)
24+constexpr uint32_t LOG_NDTR_NAN_UINT = 0x7fc00000;
25+constexpr uint32_t LOG_NDTR_POS_INF_UINT = 0x7f800000;
26+constexpr uint32_t LOG_NDTR_NEG_INF_UINT = 0xff800000;
27+ 
28+// Pade coefficients for erf(t) rational approximation (from ndtr.h)
29+constexpr float LOG_NDTR_ERF_P0 = 0.29639'384698e5f;
30+constexpr float LOG_NDTR_ERF_P1 = 0.50637'915060e4f;
31+constexpr float LOG_NDTR_ERF_P2 = 0.13938'061484e4f;
32+constexpr float LOG_NDTR_ERF_P3 = 0.10162'808918e3f;
33+constexpr float LOG_NDTR_ERF_P4 = 0.75517'016694e1f;
34+constexpr float LOG_NDTR_ERF_P5 = 0.05344'3748819f;
35+constexpr float LOG_NDTR_ERF_Q0 = 0.26267'224157e5f;
36+constexpr float LOG_NDTR_ERF_Q1 = 0.13243'365831e5f;
37+constexpr float LOG_NDTR_ERF_Q2 = 0.30231'248150e4f;
38+constexpr float LOG_NDTR_ERF_Q3 = 0.39856'963806e3f;
39+constexpr float LOG_NDTR_ERF_Q4 = 0.31212'858877e2f;
40+ 
41+// Erfcx low-path polynomial coefficients (from erfcx.h)
42+constexpr float LOG_NDTR_P_COEFF0 = 0.0008912171f;
43+constexpr float LOG_NDTR_P_COEFF1 = 0.007045788f;
44+constexpr float LOG_NDTR_P_COEFF2 = -0.0158668961f;
45+constexpr float LOG_NDTR_P_COEFF3 = 0.036429625f;
46+constexpr float LOG_NDTR_P_COEFF4 = -0.06664343f;
47+constexpr float LOG_NDTR_P_COEFF5 = 0.09381453f;
48+constexpr float LOG_NDTR_P_COEFF6 = -0.100990564f;
49+constexpr float LOG_NDTR_P_COEFF7 = 0.068094f;
50+constexpr float LOG_NDTR_P_COEFF8 = 0.0153773874f;
51+constexpr float LOG_NDTR_P_COEFF9 = -0.139621079f;
52+constexpr float LOG_NDTR_P_COEFF10 = 1.23299515f;
53+ 
54+// ---------------------------------------------------------------------------
55+// ErfcxPolyLite: simplified low-path erfcx polynomial evaluation
56+// Input: axReg = |t| (non-negative)
57+// Output: erfcx(ax) = p(t_mapped) / (2*ax + 1), where t_mapped = (ax-4)/(ax+4)
58+// ---------------------------------------------------------------------------
59+__simd_callee__ inline void ErfcxPolyLite(Reg::RegTensor<float> &dstReg, Reg::RegTensor<float> &axReg,
60+ Reg::MaskReg &mask) {
61+ Reg::RegTensor<float> invAxP4Reg, tMappedReg, tmpReg, pReg, invDenomReg;
62+ 
63+ // inv_ax_plus_4 = 1 / (ax + 4)
64+ Reg::Adds(invAxP4Reg, axReg, 4.0f, mask);
65+ Reg::Duplicate(tmpReg, 1.0f, mask);
66+ Reg::Div(invAxP4Reg, tmpReg, invAxP4Reg, mask);
67+ 
68+ // t_mapped = (ax - 4) / (ax + 4) = (ax - 4) * inv_ax_plus_4
69+ Reg::Adds(tMappedReg, axReg, -4.0f, mask);
70+ Reg::Mul(tMappedReg, tMappedReg, invAxP4Reg, mask);
71+ 
72+ // Horner evaluation of polynomial P(t) = LOG_NDTR_P_COEFF0 + t*(LOG_NDTR_P_COEFF1 + t*(... + t*LOG_NDTR_P_COEFF10))
73+ Reg::Duplicate(pReg, LOG_NDTR_P_COEFF0, mask);
74+ Reg::Duplicate(tmpReg, LOG_NDTR_P_COEFF1, mask);
75+ Reg::FusedMulDstAdd(pReg, tMappedReg, tmpReg, mask);
76+ Reg::Duplicate(tmpReg, LOG_NDTR_P_COEFF2, mask);
77+ Reg::FusedMulDstAdd(pReg, tMappedReg, tmpReg, mask);
78+ Reg::Duplicate(tmpReg, LOG_NDTR_P_COEFF3, mask);
79+ Reg::FusedMulDstAdd(pReg, tMappedReg, tmpReg, mask);
80+ Reg::Duplicate(tmpReg, LOG_NDTR_P_COEFF4, mask);
81+ Reg::FusedMulDstAdd(pReg, tMappedReg, tmpReg, mask);
82+ Reg::Duplicate(tmpReg, LOG_NDTR_P_COEFF5, mask);
83+ Reg::FusedMulDstAdd(pReg, tMappedReg, tmpReg, mask);
84+ Reg::Duplicate(tmpReg, LOG_NDTR_P_COEFF6, mask);
85+ Reg::FusedMulDstAdd(pReg, tMappedReg, tmpReg, mask);
86+ Reg::Duplicate(tmpReg, LOG_NDTR_P_COEFF7, mask);
87+ Reg::FusedMulDstAdd(pReg, tMappedReg, tmpReg, mask);
88+ Reg::Duplicate(tmpReg, LOG_NDTR_P_COEFF8, mask);
89+ Reg::FusedMulDstAdd(pReg, tMappedReg, tmpReg, mask);
90+ Reg::Duplicate(tmpReg, LOG_NDTR_P_COEFF9, mask);
91+ Reg::FusedMulDstAdd(pReg, tMappedReg, tmpReg, mask);
92+ Reg::Duplicate(tmpReg, LOG_NDTR_P_COEFF10, mask);
93+ Reg::FusedMulDstAdd(pReg, tMappedReg, tmpReg, mask);
94+ 
95+ // inv_denom = 1 / (2*ax + 1)
96+ Reg::Muls(invDenomReg, axReg, 2.0f, mask);
97+ Reg::Adds(invDenomReg, invDenomReg, 1.0f, mask);
98+ Reg::Duplicate(tmpReg, 1.0f, mask);
99+ Reg::Div(invDenomReg, tmpReg, invDenomReg, mask);
100+ 
101+ // result = p * inv_denom
102+ Reg::Mul(dstReg, pReg, invDenomReg, mask);
103+}
104+ 
105+// ---------------------------------------------------------------------------
106+// ErfCompute: compute erf(t) using Pade rational approximation
107+// For |t| < 3.92: Pade approximation; for |t| >= 3.92: sign(t)
108+// ---------------------------------------------------------------------------
109+__simd_callee__ inline void ErfCompute(Reg::RegTensor<float> &dstReg, Reg::RegTensor<float> &tReg, Reg::MaskReg &mask) {
110+ Reg::RegTensor<float> clippedReg, tmpReg, pReg, qReg;
111+ Reg::RegTensor<float> absReg, negOneReg, oneReg;
112+ Reg::MaskReg maskLarge, maskNeg, maskLargeNeg, maskLargePos;
113+ 
114+ // Clip t to [-3.92, 3.92] for safe Pade evaluation
115+ Reg::Mins(clippedReg, tReg, LOG_NDTR_LARGE_THRESHOLD, mask);
116+ Reg::Maxs(clippedReg, clippedReg, -LOG_NDTR_LARGE_THRESHOLD, mask);
117+ 
118+ // tmp = clipped^2
119+ Reg::Mul(tmpReg, clippedReg, clippedReg, mask);
120+ 
121+ // P polynomial (degree 5): clipped * sum_i P_i * tmp^i
122+ Reg::Muls(pReg, tmpReg, LOG_NDTR_ERF_P5, mask);
123+ Reg::Adds(pReg, pReg, LOG_NDTR_ERF_P4, mask);
124+ Reg::Mul(pReg, pReg, tmpReg, mask);
125+ Reg::Adds(pReg, pReg, LOG_NDTR_ERF_P3, mask);
126+ Reg::Mul(pReg, pReg, tmpReg, mask);
127+ Reg::Adds(pReg, pReg, LOG_NDTR_ERF_P2, mask);
128+ Reg::Mul(pReg, pReg, tmpReg, mask);
129+ Reg::Adds(pReg, pReg, LOG_NDTR_ERF_P1, mask);
130+ Reg::Mul(pReg, pReg, tmpReg, mask);
131+ Reg::Adds(pReg, pReg, LOG_NDTR_ERF_P0, mask);
132+ Reg::Mul(pReg, pReg, clippedReg, mask);
133+ 
134+ // Q polynomial (degree 5 with leading coefficient 1): sum_i Q_i * tmp^i + tmp^5
135+ Reg::Adds(qReg, tmpReg, LOG_NDTR_ERF_Q4, mask);
136+ Reg::Mul(qReg, qReg, tmpReg, mask);
137+ Reg::Adds(qReg, qReg, LOG_NDTR_ERF_Q3, mask);
138+ Reg::Mul(qReg, qReg, tmpReg, mask);
139+ Reg::Adds(qReg, qReg, LOG_NDTR_ERF_Q2, mask);
140+ Reg::Mul(qReg, qReg, tmpReg, mask);
141+ Reg::Adds(qReg, qReg, LOG_NDTR_ERF_Q1, mask);
142+ Reg::Mul(qReg, qReg, tmpReg, mask);
143+ Reg::Adds(qReg, qReg, LOG_NDTR_ERF_Q0, mask);
144+ 
145+ // erf = p / q
146+ Reg::Div(dstReg, pReg, qReg, mask);
147+ 
148+ // For |t| >= 3.92: override with sign(t)
149+ Reg::Abs(absReg, tReg, mask);
150+ Reg::Compares<float, CMPMODE::GE>(maskLarge, absReg, LOG_NDTR_LARGE_THRESHOLD, mask);
151+ Reg::Compares<float, CMPMODE::LT>(maskNeg, tReg, 0.0f, mask);
152+ 
153+ Reg::And(maskLargeNeg, maskLarge, maskNeg, mask);
154+ Reg::Not(maskLargePos, maskNeg, mask);
155+ Reg::And(maskLargePos, maskLarge, maskLargePos, mask);
156+ 
157+ Reg::Duplicate(negOneReg, -1.0f, mask);
158+ Reg::Duplicate(oneReg, 1.0f, mask);
159+ 
160+ Reg::Copy<float, Reg::MaskMergeMode::MERGING>(dstReg, negOneReg, maskLargeNeg);
161+ Reg::Copy<float, Reg::MaskMergeMode::MERGING>(dstReg, oneReg, maskLargePos);
162+}
163+ 
164+// ---------------------------------------------------------------------------
165+// Left tail computation: result = log(erfcx(-t) / 2) - t^2
166+// Used when x < -1.0 (t < -0.707)
167+// ---------------------------------------------------------------------------
168+__simd_callee__ inline void LogNdtrComputeLeftTail(Reg::RegTensor<float> &resultReg, Reg::RegTensor<float> &tReg,
169+ Reg::MaskReg &maskLeft) {
170+ Reg::RegTensor<float> negTReg, erfcxReg, halfErfcxReg, logReg, tSqReg;
171+ 
172+ // neg_t = -t (positive since t < 0 in left tail)
173+ Reg::Neg(negTReg, tReg, maskLeft);
174+ 
175+ // erfcx_val = erfcx(neg_t)
176+ ErfcxPolyLite(erfcxReg, negTReg, maskLeft);
177+ 
178+ // log(erfcx_val / 2) = log(erfcx_val * 0.5)
179+ Reg::Muls(halfErfcxReg, erfcxReg, 0.5f, maskLeft);
180+ Reg::Log(logReg, halfErfcxReg, maskLeft);
181+ 
182+ // result = log(erfcx/2) - t^2
183+ Reg::Mul(tSqReg, tReg, tReg, maskLeft);
184+ Reg::Sub(resultReg, logReg, tSqReg, maskLeft);
185+}
186+ 
187+// ---------------------------------------------------------------------------
188+// Right tail computation: result = log(1 - erfc(t)/2) = log(0.5 + erf(t)/2)
189+// Used when x >= -1.0 (t >= -0.707)
190+// ---------------------------------------------------------------------------
191+__simd_callee__ inline void LogNdtrComputeRightTail(Reg::RegTensor<float> &resultReg, Reg::RegTensor<float> &tReg,
192+ Reg::MaskReg &maskRight) {
193+ Reg::RegTensor<float> erfReg, erfcReg, argReg;
194+ 
195+ // erf(t)
196+ ErfCompute(erfReg, tReg, maskRight);
197+ 
198+ // erfc = 1.0 - erf
199+ Reg::RegTensor<float> oneReg;
200+ Reg::Duplicate(oneReg, 1.0f, maskRight);
201+ Reg::Sub(erfcReg, oneReg, erfReg, maskRight);
202+ 
203+ // arg = 1.0 - erfc * 0.5
204+ Reg::Muls(argReg, erfcReg, -0.5f, maskRight);
205+ Reg::Adds(argReg, argReg, 1.0f, maskRight);
206+ 
207+ // result = log(arg) = log1p(-erfc/2)
208+ Reg::Log(resultReg, argReg, maskRight);
209+}
210+ 
211+// ---------------------------------------------------------------------------
212+// Special cases: NaN, +inf, -inf
213+// ---------------------------------------------------------------------------
214+__simd_callee__ inline void LogNdtrHandleSpecialCases(Reg::RegTensor<float> &dstReg, Reg::RegTensor<float> &srcReg,
215+ Reg::MaskReg &mask) {
216+ Reg::RegTensor<float> nanReg, constReg, negZeroReg;
217+ Reg::MaskReg nanMask, posInfMask, negInfMask, posUnderMask;
218+ 
219+ // NaN detection: x != x
220+ Reg::Compare<float, CMPMODE::NE>(nanMask, srcReg, srcReg, mask);
221+ // AscendC convention: float-from-bits via reference (TIK compiler lacks memcpy/bit_cast)
222+ Reg::Duplicate(nanReg, (float &)LOG_NDTR_NAN_UINT, mask);
223+ Reg::Select(dstReg, nanReg, dstReg, nanMask);
224+ 
225+ // +inf: result = -0.0 (compute via IEEE 754: 0.0 * -1.0 = -0.0)
226+ Reg::Duplicate(constReg, (float &)LOG_NDTR_POS_INF_UINT, mask);
227+ Reg::Compare<float, CMPMODE::EQ>(posInfMask, srcReg, constReg, mask);
228+ Reg::Duplicate(negZeroReg, 0.0f, mask);
229+ Reg::Muls(negZeroReg, negZeroReg, -1.0f, mask); // +0.0 * -1.0 → -0.0
230+ Reg::Select(dstReg, negZeroReg, dstReg, posInfMask);
231+ 
232+ // -inf: result = -inf
233+ Reg::Duplicate(constReg, (float &)LOG_NDTR_NEG_INF_UINT, mask);
234+ Reg::Compare<float, CMPMODE::EQ>(negInfMask, srcReg, constReg, mask);
235+ Reg::Select(dstReg, constReg, dstReg, negInfMask);
236+ 
237+ // Large positive x underflows to -0.0 (log_ndtr approaches 0 from below)
238+ // Detect: result is +0.0 but input > 0 → force to -0.0
239+ Reg::Compares<float, CMPMODE::GT>(posUnderMask, srcReg, 0.0f, mask);
240+ Reg::RegTensor<float> zeroReg;
241+ Reg::Duplicate(zeroReg, 0.0f, mask);
242+ Reg::MaskReg resZeroMask;
243+ Reg::Compare<float, CMPMODE::EQ>(resZeroMask, dstReg, zeroReg, mask);
244+ Reg::And(posUnderMask, posUnderMask, resZeroMask, mask);
245+ Reg::Select(dstReg, negZeroReg, dstReg, posUnderMask);
246+}
247+ 
248+// ---------------------------------------------------------------------------
249+// LogNdtrCoreImpl: per-tile SIMD core loop
250+// ---------------------------------------------------------------------------
251+template <typename T>
252+__simd_vf__ inline void LogNdtrCoreImpl(__ubuf__ T *dstUb, __ubuf__ T *srcUb, uint32_t calCount, uint16_t repeatTimes) {
253+ static_assert((std::is_same_v<T, float>), "LogNdtr only supports float on current device!");
254+ constexpr uint32_t oneRepSize = static_cast<uint32_t>(GetVecLen() / sizeof(float));
255+ uint32_t sreg = calCount;
256+ for (uint16_t i = 0; i < repeatTimes; ++i) {
257+ Reg::MaskReg mask = Reg::UpdateMask<float>(sreg);
258+ Reg::RegTensor<float> srcReg, tReg, resultReg, resultLeft, resultRight;
259+ Reg::MaskReg maskLeft, maskRight;
260+ 
261+ Reg::LoadAlign(srcReg, srcUb + i * oneRepSize);
262+ 
263+ // t = x / sqrt(2)
264+ Reg::Muls(tReg, srcReg, LOG_NDTR_INV_SQRT_2, mask);
265+ 
266+ // Branch: x < -1.0 → left tail (erfcx path), else → right tail (erfc+log1p path)
267+ Reg::Compares<float, CMPMODE::LT>(maskLeft, srcReg, LOG_NDTR_BRANCH_THRESHOLD, mask);
268+ Reg::Not(maskRight, maskLeft, mask);
269+ 
270+ // Compute both branches
271+ Reg::Duplicate(resultLeft, 0.0f, mask);
272+ LogNdtrComputeLeftTail(resultLeft, tReg, maskLeft);
273+ 
274+ Reg::Duplicate(resultRight, 0.0f, mask);
275+ LogNdtrComputeRightTail(resultRight, tReg, maskRight);
276+ 
277+ // Merge results: select left or right based on maskLeft
278+ Reg::Select(resultReg, resultLeft, resultRight, maskLeft);
279+ 
280+ // Handle special values (NaN, +/-inf)
281+ LogNdtrHandleSpecialCases(resultReg, srcReg, mask);
282+ 
283+ Reg::StoreAlign(dstUb + i * oneRepSize, resultReg, mask);
284+ }
285+}
286+ 
287+} // namespace LOG_NDTR
288+ 
289+// ---------------------------------------------------------------------------
290+// __aicore__ entry function
291+// ---------------------------------------------------------------------------
292+template <typename T>
293+__aicore__ inline void LogNdtrExtend(const LocalTensor<T> &dst, const LocalTensor<T> &src,
294+ const LocalTensor<uint8_t> &tmpBuffer, const uint32_t calCount) {
295+ static_assert((std::is_same_v<T, float>), "LogNdtr only supports float on current device!");
296+ if ASCEND_IS_AIC {
297+ return;
298+ }
299+ 
300+ __ubuf__ T *dstUb = (__ubuf__ T *)dst.GetPhyAddr();
301+ __ubuf__ T *srcUb = (__ubuf__ T *)src.GetPhyAddr();
302+ 
303+ constexpr uint32_t oneRepSize = static_cast<uint32_t>(GetVecLen() / sizeof(T));
304+ uint16_t repeatTimes = CeilDivision(calCount, oneRepSize);
305+ 
306+ LOG_NDTR::LogNdtrCoreImpl<T>(dstUb, srcUb, calCount, repeatTimes);
307+}
308+ 
309+#endif // __ASCENDC_API_REGBASE_LOG_NDTR_H__
Mautofuse/v35/ascendc/api_regbase/transpose.h+3-3
@@ -232,8 +232,8 @@ inline __simd_vf__ void TransposeOneOuterDimExtendImpl(__ubuf__ T *dst, __ubuf__
232 MicroAPI::MaskReg mask;232 MicroAPI::MaskReg mask;
233 for (uint16_t i = 0U; i < repeat_time; i++) {233 for (uint16_t i = 0U; i < repeat_time; i++) {
234 mask = MicroAPI::UpdateMask<T>(cal_cnt);234 mask = MicroAPI::UpdateMask<T>(cal_cnt);
235+ MicroAPI::LoadAlign(idx_reg, index + i * vl_size);
235 for (uint16_t j = 0U; j < dst_dim0; j++) {236 for (uint16_t j = 0U; j < dst_dim0; j++) {
236- MicroAPI::LoadAlign(idx_reg, index + i * vl_size);
237 MicroAPI::Gather(dst_reg, src + j * src_stride0, (MicroAPI::RegTensor<IdxType<T>> &)idx_reg, mask);237 MicroAPI::Gather(dst_reg, src + j * src_stride0, (MicroAPI::RegTensor<IdxType<T>> &)idx_reg, mask);
238 MicroAPI::StoreAlign(dst + j * dst_stride0 + i * vl_size, dst_reg, mask);238 MicroAPI::StoreAlign(dst + j * dst_stride0 + i * vl_size, dst_reg, mask);
239 }239 }
@@ -255,9 +255,9 @@ inline __simd_vf__ void TransposeTwoOuterDimExtendImpl(__ubuf__ T *dst, __ubuf__
255 MicroAPI::MaskReg mask;255 MicroAPI::MaskReg mask;
256 for (uint16_t i = 0U; i < repeat_time; i++) {256 for (uint16_t i = 0U; i < repeat_time; i++) {
257 mask = MicroAPI::UpdateMask<T>(cal_cnt);257 mask = MicroAPI::UpdateMask<T>(cal_cnt);
258+ MicroAPI::LoadAlign(idx_reg, index + i * vl_size);
258 for (uint16_t j = 0U; j < dst_dim0; j++) {259 for (uint16_t j = 0U; j < dst_dim0; j++) {
259 for (uint16_t k = 0U; k < dst_dim1; k++) {260 for (uint16_t k = 0U; k < dst_dim1; k++) {
260- MicroAPI::LoadAlign(idx_reg, index + i * vl_size);
261 MicroAPI::Gather(dst_reg, src + j * src_stride0 + k * src_stride1, (MicroAPI::RegTensor<IdxType<T>> &)idx_reg,261 MicroAPI::Gather(dst_reg, src + j * src_stride0 + k * src_stride1, (MicroAPI::RegTensor<IdxType<T>> &)idx_reg,
262 mask);262 mask);
263 MicroAPI::StoreAlign(dst + i * vl_size + j * dst_stride0 + k * dst_stride1, dst_reg, mask);263 MicroAPI::StoreAlign(dst + i * vl_size + j * dst_stride0 + k * dst_stride1, dst_reg, mask);
@@ -282,10 +282,10 @@ inline __simd_vf__ void TransposeThreeOuterDimExtendImpl(__ubuf__ T *dst, __ubuf
282 MicroAPI::MaskReg mask;282 MicroAPI::MaskReg mask;
283 for (uint16_t i = 0U; i < repeat_time; i++) {283 for (uint16_t i = 0U; i < repeat_time; i++) {
284 mask = MicroAPI::UpdateMask<T>(cal_cnt);284 mask = MicroAPI::UpdateMask<T>(cal_cnt);
285+ MicroAPI::LoadAlign(idx_reg, index + i * vl_size);
285 for (uint16_t j = 0U; j < dst_dim0; j++) {286 for (uint16_t j = 0U; j < dst_dim0; j++) {
286 for (uint16_t k = 0U; k < dst_dim1; k++) {287 for (uint16_t k = 0U; k < dst_dim1; k++) {
287 for (uint16_t m = 0U; m < dst_dim2; m++) {288 for (uint16_t m = 0U; m < dst_dim2; m++) {
288- MicroAPI::LoadAlign(idx_reg, index + i * vl_size);
289 MicroAPI::Gather(dst_reg, src + j * src_stride0 + k * src_stride1 + m * src_stride2,289 MicroAPI::Gather(dst_reg, src + j * src_stride0 + k * src_stride1 + m * src_stride2,
290 (MicroAPI::RegTensor<IdxType<T>> &)idx_reg, mask);290 (MicroAPI::RegTensor<IdxType<T>> &)idx_reg, mask);
291 MicroAPI::StoreAlign(dst + i * vl_size + j * dst_stride0 + k * dst_stride1 + m * dst_stride2, dst_reg, mask);291 MicroAPI::StoreAlign(dst + i * vl_size + j * dst_stride0 + k * dst_stride1 + m * dst_stride2, dst_reg, mask);
Adocs/en/precommit_guide.md+600-0
@@ -0,0 +1,600 @@
1+# pre-commit Usage Guide
2+ 
3+[TOC]
4+--
5+ 
6+## 1 Background
7+ 
8+This guide is mainly for guiding how to use the pre-commit capabilities deployed in the code repository locally (mainly including code formatting and OAT scanning capabilities).
9+ 
10+## 2 Feature Overview
11+ 
12+1. After installing pre-commit, code formatting processing and OAT checks will be automatically performed before git commits.
13+ 
14+2. Compliance issues will block commits and prompt for modifications. Blocking is not forced - you can ignore the modifications.
15+ 
16+## 3 Community Contributors Using pre-commit Capabilities
17+ 
18+### 3.1 pre-commit Installation Steps
19+ 
20+Step 1: Install pre-commit framework
21+ 
22+```bash
23+# Using pip (recommended)
24+pip install pre-commit
25+ 
26+# Verify installation
27+pre-commit --version
28+# Output: pre-commit 3.x.x
29+```
30+ 
31+**Windows Users**: Make sure Python and pip are installed.
32+ 
33+Step 2: Enter project directory
34+ 
35+```bash
36+cd /path/to/your/project
37+ 
38+# For example
39+cd d:\complianceRepo\CANN
40+```
41+ 
42+Step 3: Install Git Hooks
43+ 
44+```bash
45+# Run in project root directory
46+pre-commit install
47+```
48+ 
49+Step 4: Verify installation (optional)
50+ 
51+```bash
52+# Test hook (won't actually commit)
53+git commit --allow-empty -m "test pre-commit"
54+```
55+ 
56+Subsequently, code formatting processing and OAT checks will be automatically performed before committing code.
57+ 
58+### 3.2 OAT Usage Guide
59+ 
60+**OAT (Open Source Audit Tool)** is an open source compliance checking tool, automatically integrated into the Git commit workflow.
61+ 
62+#### 3.2.1 Check Content
63+ 
64+**File Type Check** - Binary files (.so, .dll, .exe, etc.) are prohibited from being submitted
65+**License Header Check** - Verifies source code files contain compliant license declarations
66+ 
67+#### 3.2.2 Core Features
68+ 
69+- **Incremental Check** - Only checks files to be committed, fast (< 5 seconds)
70+- **Automatic Trigger** - Runs automatically on every `git commit`
71+- **Detailed Reports** - Automatically generates `result.txt` summary and full report
72+- **Zero Configuration** - Java and Maven are automatically installed (Linux/macOS)
73+- **Cross-Platform** - Full support for Windows/Linux/macOS
74+ 
75+#### 3.2.3 Required Software
76+ 
77+| Software | Version Requirement | Purpose | Installation Method |
78+|------|---------|------|----------|
79+| **Java** | JRE 8+ | Run OAT | **Auto-install** (Linux/macOS)<br> Manual install (Windows)|
80+| **Maven** | 3.5+ | Package OAT | **Auto-install** (Linux/macOS)<br> Manual install (Windows)|
81+| **Git** | 2.0+ | Version Control | Usually already installed |
82+| **pre-commit** | 2.0+ | Hook Framework | `pip install pre-commit` |
83+ 
84+#### 3.2.4 Auto-Installation Support
85+ 
86+| Platform | Java | Maven | Package Manager | First Install Time |
87+|------|------|-------|---------|-------------|
88+| **Linux (Ubuntu/Debian)** | Auto | Auto | apt | 5-8 minutes |
89+| **Linux (CentOS/RHEL)** | Auto | Auto | yum | 5-8 minutes |
90+| **macOS** | Auto | Auto | Homebrew | 8-10 minutes |
91+| **Windows** | Manual | Manual | - | Requires manual install |
92+ 
93+#### 3.2.5 Important Note: Auto-Skip on Environment Issues
94+ 
95+**Friendly Design**: If Java/Maven cannot be installed or environment issues are encountered, OAT check will **automatically skip**, and commit will continue.
96+ 
97+**Scenarios That Will Auto-Skip**
98+ 
99+| Scenario | Behavior | Prompt |
100+|------|------|------|
101+| Java/Maven not installed (Windows) | Skip check, allow commit | Provides manual installation guide |
102+| Java/Maven auto-install fails | Skip check, allow commit | Prompts manual installation method |
103+| Maven packaging fails | Skip check, allow commit | Provides solution |
104+| OAT scan execution fails | Skip check, allow commit | Prompts to repackage |
105+ 
106+**Scenarios That Will Still Block Commits**
107+ 
108+| Scenario | Behavior | Reason |
109+|------|------|------|
110+| **Binary files found** | Block commit | Real compliance issue |
111+| **License header missing/incorrect** | Block commit | Real compliance issue |
112+ 
113+**Skip Check Prompt Example**
114+ 
115+```
116+[OAT] Windows cannot auto-install Java
117+[OAT] Please manually download and install:
118+ ... (installation steps) ...
119+ 
120+[OAT] Skipping OAT check, continuing commit...
121+[OAT] Recommend installing Java and running check again
122+```
123+ 
124+**Manually Run Check Later**
125+ 
126+After configuring the environment, you can manually run the check:
127+ 
128+```bash
129+# Recommended method
130+pre-commit run oat-check
131+ 
132+# Or run script directly
133+bash scripts/oat_check.sh
134+```
135+ 
136+#### 3.2.6 Compliance Issues (Block Commit)
137+ 
138+**Important**: The following issues will **block commits** and must be fixed.
139+ 
140+**1) Invalid File Type Found**
141+ 
142+**Scenario**: Attempting to commit binary files (.so, .dll, .exe, etc.).
143+ 
144+**Output**:
145+```
146+====================================================================
147+ Compliance Issues Found
148+====================================================================
149+ 
150+[OAT] Found 1 compliance issue(s):
151+ - Invalid File Type: 1
152+ - License Header Invalid: 0
153+ 
154+[OAT] Details saved to: oat_reports/single/result.txt
155+[OAT] Please check the report and fix the issues.
156+ 
157+To view the summary:
158+ cat oat_reports/single/result.txt
159+ 
160+To skip this check temporarily:
161+ git commit --no-verify
162+```
163+ 
164+**Behavior:** **Blocks commit, must fix**
165+ 
166+**View Details**:
167+```bash
168+cat oat_reports/single/result.txt
169+```
170+ 
171+**Report Content Example**:
172+```
173+===================================
174+OAT Scan Result Summary
175+===================================
176+Scan Time: 2026-03-25 14:30:15
177+Project: CANN
178+Files Checked: 1
179+ 
180+-----------------------------------
181+Invalid File Type Total Count: 1
182+lib/libtest.so: BINARY_FILE_TYPE
183+ 
184+-----------------------------------
185+License Header Invalid Total Count: 0
186+ 
187+===================================
188+Full report: oat_reports/single/PlainReport_CANN.txt
189+===================================
190+```
191+ 
192+**Solution**:
193+```bash
194+# Method 1: Remove binary file
195+git reset HEAD lib/libtest.so
196+ 
197+# Method 2: Add binary files to .gitignore
198+echo "*.so" >> .gitignore
199+echo "*.dll" >> .gitignore
200+echo "*.exe" >> .gitignore
201+ 
202+# Re-commit
203+git add .gitignore
204+git commit -m "update: add binary files to gitignore"
205+```
206+ 
207+**2) Invalid License Header**
208+ 
209+**Scenario**: Source code file is missing or has incorrect license header format.
210+ 
211+**Output**:
212+```
213+====================================================================
214+ Compliance Issues Found
215+====================================================================
216+ 
217+[OAT] Found 2 compliance issue(s):
218+ - Invalid File Type: 0
219+ - License Header Invalid: 2
220+ 
221+[OAT] Details saved to: oat_reports/single/result.txt
222+```
223+ 
224+**Behavior**: **Blocks commit, must fix**
225+ 
226+**View Details**:
227+```bash
228+cat oat_reports/single/result.txt
229+```
230+ 
231+**Report Content Example**:
232+```
233+===================================
234+OAT Scan Result Summary
235+===================================
236+ 
237+-----------------------------------
238+Invalid File Type Total Count: 0
239+ 
240+-----------------------------------
241+License Header Invalid Total Count: 2
242+src/main.cpp: MISSING_LICENSE_HEADER
243+src/utils.cpp: MISSING_LICENSE_HEADER
244+ 
245+===================================
246+```
247+ 
248+**Solution**:
249+ 
250+Add license header at the top of the file, for example CANN-2.0:
251+ 
252+```cpp
253+/**
254+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
255+ * CANN Open Software License Agreement Version 2.0 (the "License").
256+ * Please refer to the License for details. You may not use this file except in compliance with the License.
257+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
258+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
259+ * See LICENSE in the root of the software repository for the full text of the License.
260+ */
261+ 
262+```
263+ 
264+**Re-commit**:
265+```bash
266+git add src/main.cpp src/utils.cpp
267+git commit -m "fix: add license headers"
268+```
269+ 
270+---
271+ 
272+#### 3.2.7 Report Viewing
273+ 
274+**Report File Locations**
275+ 
276+| Report Type | File Path | Content |
277+|---------|---------|------|
278+| **Summary Report** | `oat_reports/single/result.txt` | Key issue summary |
279+ 
280+**View Commands**
281+ 
282+```bash
283+# View report
284+cat oat_reports/single/result.txt
285+ 
286+# View with editor
287+code oat_reports/single/result.txt
288+vim oat_reports/single/result.txt
289+```
290+ 
291+**Summary Report Content**
292+ 
293+```
294+===================================
295+OAT Scan Result Summary
296+===================================
297+Scan Time: 2026-03-25 14:30:15
298+Project: CANN
299+Files Checked: 3
300+ 
301+-----------------------------------
302+Invalid File Type Total Count: 0
303+ 
304+-----------------------------------
305+License Header Invalid Total Count: 0
306+ 
307+===================================
308+Full report: oat_reports/single/PlainReport_CANN.txt
309+===================================
310+```
311+ 
312+#### 3.2.8 Environment Issues
313+ 
314+**1) Java Not Installed (Linux/macOS Auto-Install)**
315+ 
316+**Scenario**: First commit, Java not installed on system.
317+ 
318+**Output**:
319+```
320+====================================================================
321+ Java Not Installed - Attempting Auto-Install
322+====================================================================
323+ 
324+[OAT] Detected Java not installed, starting auto-install...
325+[OAT] Installing OpenJDK 11 using apt...
326+[OAT] [OK] OpenJDK 11 installed successfully
327+```
328+ 
329+**Handling**: Auto-install, may require sudo password.
330+ 
331+---
332+ 
333+**2) Java Not Installed (Windows Manual Install)**
334+ 
335+**Scenario**: Windows system cannot auto-install Java.
336+ 
337+**Output**:
338+```
339+[OAT] Windows cannot auto-install Java
340+[OAT] Please manually download and install:
341+ 
342+ 1. Visit: https://adoptium.net/
343+ 2. Download: Eclipse Temurin JRE 11 (x64)
344+ 3. Restart Git Bash after installation
345+ 4. Verify: java -version
346+ 
347+[OAT] Skipping OAT check, continuing commit...
348+[OAT] Recommend installing Java and running check again
349+```
350+ 
351+**Behavior**: **Skip check, allow commit**
352+ 
353+**Follow-up Actions**:
354+1. Install Java manually as prompted
355+2. Restart terminal
356+3. Run `pre-commit run oat-check` to verify environment
357+ 
358+---
359+ 
360+**3) Java Auto-Install Fails**
361+ 
362+**Scenario**: Java auto-install fails on Linux/macOS.
363+ 
364+**Output**:
365+```
366+[OAT] [ERROR] Auto-install failed
367+ 
368+[OAT] Auto-install failed, skipping OAT check
369+ 
370+Manual installation method:
371+ Linux: sudo apt install openjdk-11-jre
372+ macOS: brew install openjdk@11
373+ Windows: https://adoptium.net/
374+ 
375+[OAT] Continuing commit (compliance check not performed)...
376+[OAT] Recommend installing Java and running: pre-commit run oat-check
377+```
378+ 
379+**Behavior**: **Skip check, allow commit**
380+ 
381+**Possible Reasons**:
382+- Network connection issues
383+- Package manager not configured
384+- Insufficient permissions
385+- Homebrew not installed on macOS
386+ 
387+**Solution**:
388+```bash
389+# Linux
390+sudo apt update
391+sudo apt install openjdk-11-jre
392+ 
393+# macOS - Install Homebrew first
394+/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
395+brew install openjdk@11
396+ 
397+# Verify
398+java -version
399+ 
400+# Manually run check
401+pre-commit run oat-check
402+```
403+ 
404+---
405+ 
406+**4) Maven Not Installed (Linux/macOS Auto-Install)**
407+ 
408+**Scenario**: First commit, Maven not installed on system.
409+ 
410+**Output**:
411+```
412+====================================================================
413+ Maven Not Installed - Attempting Auto-Install
414+====================================================================
415+ 
416+[OAT] Installing Maven using apt...
417+[OAT] [OK] Maven installed successfully
418+```
419+ 
420+**Handling**: Auto-install, may require sudo password.
421+ 
422+---
423+ 
424+**5) Maven Not Installed (Windows Manual Install)**
425+ 
426+**Scenario**: Windows system cannot auto-install Maven.
427+ 
428+**Output**:
429+```
430+[OAT] Windows cannot auto-install Maven
431+[OAT] Please manually download and install:
432+ 
433+ 1. Visit: https://maven.apache.org/download.cgi
434+ 2. Download: apache-maven-3.x.x-bin.zip
435+ 3. Extract to C:\Program Files\apache-maven-3.x.x
436+ 4. Add to system PATH
437+ 5. Restart Git Bash
438+ 6. Verify: mvn -version
439+ 
440+[OAT] Skipping OAT check, continuing commit...
441+[OAT] Recommend installing Maven and running check again
442+```
443+ 
444+**Behavior**: **Skip check, allow commit**
445+ 
446+**Follow-up Actions**: Install Maven manually as prompted, then run `pre-commit run oat-check`
447+ 
448+---
449+ 
450+**6) Maven Packaging Fails**
451+ 
452+**Scenario**: Maven fails to package OAT JAR.
453+ 
454+**Output**:
455+```
456+====================================================================
457+ Maven Packaging Failed
458+====================================================================
459+ 
460+[OAT] Cannot package OAT JAR, skipping OAT check
461+ 
462+Possible reasons:
463+ 1. Maven configuration issues
464+ 2. Network connection issues (cannot download dependencies)
465+ 3. pom.xml configuration errors
466+ 
467+Suggested solutions:
468+ 1. Manual packaging:
469+ cd ../tools_oat
470+ mvn clean package -DskipTests
471+ 
472+ 2. Configure Maven mirror (China network):
473+ Edit ~/.m2/settings.xml to add Aliyun mirror
474+ 
475+[OAT] Continuing commit (compliance check not performed)...
476+[OAT] Recommend fixing packaging issues and running: pre-commit run oat-check
477+```
478+ 
479+**Behavior**: **Skip check, allow commit**
480+ 
481+**Solution**:
482+ 
483+**Method 1: Manual Packaging**
484+```bash
485+cd ../tools_oat
486+mvn clean package -DskipTests
487+ 
488+# View output, should see BUILD SUCCESS
489+```
490+ 
491+**Method 2: Configure Aliyun Mirror (China Network)**
492+```bash
493+mkdir -p ~/.m2
494+cat > ~/.m2/settings.xml <<'EOF'
495+<settings>
496+ <mirrors>
497+ <mirror>
498+ <id>aliyun</id>
499+ <mirrorOf>central</mirrorOf>
500+ <name>Aliyun Maven Mirror</name>
501+ <url>https://maven.aliyun.com/repository/public</url>
502+ </mirror>
503+ </mirrors>
504+</settings>
505+EOF
506+ 
507+# Re-package
508+cd ../tools_oat
509+mvn clean package -DskipTests
510+```
511+ 
512+**Method 3: Get JAR from Team**
513+```bash
514+# If team already has compiled JAR, copy directly
515+# Copy JAR file to ../tools_oat/target/ directory
516+```
517+ 
518+**Verify Fix**:
519+```bash
520+pre-commit run oat-check
521+```
522+ 
523+---
524+ 
525+**7) tools_oat Clone Fails**
526+ 
527+**Output**:
528+```
529+[OAT] tools_oat not found. Cloning...
530+[OAT] [ERROR] Failed to clone tools_oat.
531+[OAT] You can manually clone from: https://gitcode.com/openharmony-sig/tools_oat.git
532+```
533+ 
534+**Reason**: Network connection issues.
535+ 
536+**Solution**:
537+```bash
538+# Method 1: Check network
539+ping gitcode.com
540+ 
541+# Method 2: Manual clone
542+cd ..
543+git clone https://gitcode.com/openharmony-sig/tools_oat.git
544+ 
545+# Method 3: Configure proxy
546+git config --global http.proxy http://proxy.example.com:8080
547+ 
548+# Method 4: Copy from team member
549+# Have a colleague who already cloned package the tools_oat folder for you
550+```
551+ 
552+---
553+ 
554+**8) OAT Scan Execution Fails**
555+ 
556+**Scenario**: OAT JAR fails to run.
557+ 
558+**Output**:
559+```
560+====================================================================
561+ OAT Scan Execution Failed
562+====================================================================
563+ 
564+[OAT] Scan failed, skipping OAT check
565+ 
566+Possible reasons:
567+ 1. JAR file corrupted
568+ 2. Java version incompatible
569+ 3. OAT configuration issues
570+ 
571+Suggested solutions:
572+ 1. Delete and re-package JAR:
573+ rm ../tools_oat/target/ohos_ossaudittool-*.jar
574+ cd ../tools_oat && mvn clean package -DskipTests
575+ 
576+ 2. Check Java version (requires Java 8+):
577+ java -version
578+ 
579+[OAT] Continuing commit (compliance check not performed)...
580+[OAT] Recommend fixing scan issues and running: pre-commit run oat-check
581+```
582+ 
583+**Behavior**: **Skip check, allow commit**
584+ 
585+**Solution**:
586+```bash
587+# Step 1: Delete old JAR
588+rm ../tools_oat/target/ohos_ossaudittool-*.jar
589+ 
590+# Step 2: Re-package
591+cd ../tools_oat
592+mvn clean package -DskipTests
593+ 
594+# Step 3: Verify JAR
595+ls -lh target/ohos_ossaudittool-*.jar
596+ 
597+# Step 4: Run check
598+cd -
599+pre-commit run oat-check
600+```
Adocs/zh/precommit_guide.md+600-0
@@ -0,0 +1,600 @@
1+# pre-commit使用指导书
2+ 
3+[TOC]
4+--
5+ 
6+## 1 使用背景
7+ 
8+本指导书主要用于指导如何在本地使用代码仓中部署的pre-commit能力(主要包括代码格式化及OAT扫描能力)。
9+ 
10+## 2 功能概述
11+ 
12+1、安装pre-commit后,git提交代码前会自动进行代码格式化处理及触发OAT检查。
13+ 
14+2、合规性问题会阻止提交并提示修改,阻止并非强制修改,可以忽略修改。
15+ 
16+## 3 社区贡献者使用pre-commit能力
17+ 
18+### 3.1 pre-commit安装步骤
19+ 
20+步骤 1: 安装 pre-commit 框架
21+ 
22+```bash
23+# 使用 pip(推荐)
24+pip install pre-commit
25+ 
26+# 验证安装
27+pre-commit --version
28+# 输出: pre-commit 3.x.x
29+```
30+ 
31+**Windows 用户**: 确保已安装 Python 和 pip。
32+ 
33+步骤 2: 进入项目目录
34+ 
35+```bash
36+cd /path/to/your/project
37+ 
38+# 例如
39+cd d:\complianceRepo\CANN
40+```
41+ 
42+步骤 3: 安装 Git Hooks
43+ 
44+```bash
45+# 在项目根目录运行
46+pre-commit install
47+```
48+ 
49+步骤 4: 验证安装(可选)
50+ 
51+```bash
52+# 测试 hook(不会真正提交)
53+git commit --allow-empty -m "test pre-commit"
54+```
55+ 
56+后续在提交代码前会自动进行代码格式化处理及触发OAT检查。
57+ 
58+### 3.2 OAT使用指导
59+ 
60+**OAT(Open Source Audit Tool)** 是一个开源合规性检查工具,自动集成到 Git 提交流程中。
61+ 
62+#### 3.2.1 检查内容
63+ 
64+**文件类型检查** - 禁止提交二进制文件(.so, .dll, .exe 等)
65+**许可证头检查** - 验证源代码文件包含合规的许可证声明
66+ 
67+#### 3.2.2 核心特点
68+ 
69+- **增量检查** - 仅检查待提交文件,速度快(< 5 秒)
70+- **自动触发** - 每次 `git commit` 自动运行
71+- **详细报告** - 自动生成 `result.txt` 摘要和完整报告
72+- **零配置** - Java 和 Maven 自动安装(Linux/macOS)
73+- **跨平台** - Windows/Linux/macOS 全支持
74+ 
75+#### 3.2.3 必需软件
76+ 
77+| 软件 | 版本要求 | 用途 | 安装方式 |
78+|------|---------|------|----------|
79+| **Java** | JRE 8+ | 运行 OAT | **自动安装**(Linux/macOS)<br> 手动安装(Windows)|
80+| **Maven** | 3.5+ | 打包 OAT | **自动安装**(Linux/macOS)<br> 手动安装(Windows)|
81+| **Git** | 2.0+ | 版本控制 | 通常已安装 |
82+| **pre-commit** | 2.0+ | Hook 框架 | `pip install pre-commit` |
83+ 
84+#### 3.2.4 自动安装支持
85+ 
86+| 平台 | Java | Maven | 包管理器 | 首次安装时间 |
87+|------|------|-------|---------|-------------|
88+| **Linux (Ubuntu/Debian)** | 自动 | 自动 | apt | 5-8 分钟 |
89+| **Linux (CentOS/RHEL)** | 自动 | 自动 | yum | 5-8 分钟 |
90+| **macOS** | 自动 | 自动 | Homebrew | 8-10 分钟 |
91+| **Windows** | 手动 | 手动 | - | 需手动安装 |
92+ 
93+#### 3.2.5 重要提示:环境问题自动跳过
94+ 
95+**友好的设计**:如果无法安装 Java/Maven 或遇到环境问题,OAT 检查会**自动跳过**,提交仍会继续。
96+ 
97+**会自动跳过的场景**
98+ 
99+| 场景 | 行为 | 提示 |
100+|------|------|------|
101+| Java/Maven 未安装(Windows) | 跳过检查,允许提交 | 提供手动安装指引 |
102+| Java/Maven 自动安装失败 | 跳过检查,允许提交 | 提示手动安装方法 |
103+| Maven 打包失败 | 跳过检查,允许提交 | 提供解决方案 |
104+| OAT 扫描执行失败 | 跳过检查,允许提交 | 提示重新打包 |
105+ 
106+** 仍会阻止提交的场景**
107+ 
108+| 场景 | 行为 | 原因 |
109+|------|------|------|
110+| **发现二进制文件** | 阻止提交 | 真正的合规性问题 |
111+| **许可证头缺失/错误** | 阻止提交 | 真正的合规性问题 |
112+ 
113+**跳过检查的提示示例**
114+ 
115+```
116+[OAT] Windows 系统无法自动安装 Java
117+[OAT] 请手动下载并安装:
118+ ...(安装步骤)...
119+ 
120+[OAT] 跳过 OAT 检查,继续提交...
121+[OAT] 建议安装 Java 后再次运行检查
122+```
123+ 
124+**后续手动运行检查**
125+ 
126+配置好环境后,可以手动运行检查:
127+ 
128+```bash
129+# 推荐方式
130+pre-commit run oat-check
131+ 
132+# 或直接运行脚本
133+bash scripts/oat_check.sh
134+```
135+ 
136+#### 3.2.6 合规性问题(阻止提交)
137+ 
138+**重要**: 以下问题会**阻止提交**,必须修复。
139+ 
140+**1) 发现无效文件类型**
141+ 
142+**场景**: 尝试提交二进制文件(.so, .dll, .exe 等)。
143+ 
144+**输出**:
145+```
146+====================================================================
147+ 发现合规性问题
148+====================================================================
149+ 
150+[OAT] Found 1 compliance issue(s):
151+ - Invalid File Type: 1
152+ - License Header Invalid: 0
153+ 
154+[OAT] Details saved to: oat_reports/single/result.txt
155+[OAT] Please check the report and fix the issues.
156+ 
157+To view the summary:
158+ cat oat_reports/single/result.txt
159+ 
160+To skip this check temporarily:
161+ git commit --no-verify
162+```
163+ 
164+**行为**:**阻止提交,必须修复**
165+ 
166+**查看详情**:
167+```bash
168+cat oat_reports/single/result.txt
169+```
170+ 
171+**报告内容示例**:
172+```
173+===================================
174+OAT Scan Result Summary
175+===================================
176+Scan Time: 2026-03-25 14:30:15
177+Project: CANN
178+Files Checked: 1
179+ 
180+-----------------------------------
181+Invalid File Type Total Count: 1
182+lib/libtest.so: BINARY_FILE_TYPE
183+ 
184+-----------------------------------
185+License Header Invalid Total Count: 0
186+ 
187+===================================
188+Full report: oat_reports/single/PlainReport_CANN.txt
189+===================================
190+```
191+ 
192+**解决方案**:
193+```bash
194+# 方法 1: 移除二进制文件
195+git reset HEAD lib/libtest.so
196+ 
197+# 方法 2: 将二进制文件添加到 .gitignore
198+echo "*.so" >> .gitignore
199+echo "*.dll" >> .gitignore
200+echo "*.exe" >> .gitignore
201+ 
202+# 重新提交
203+git add .gitignore
204+git commit -m "update: add binary files to gitignore"
205+```
206+ 
207+**2) 许可证头无效**
208+ 
209+**场景**: 源代码文件缺少或许可证头格式不正确。
210+ 
211+**输出**:
212+```
213+====================================================================
214+ 发现合规性问题
215+====================================================================
216+ 
217+[OAT] Found 2 compliance issue(s):
218+ - Invalid File Type: 0
219+ - License Header Invalid: 2
220+ 
221+[OAT] Details saved to: oat_reports/single/result.txt
222+```
223+ 
224+**行为**: **阻止提交,必须修复**
225+ 
226+**查看详情**:
227+```bash
228+cat oat_reports/single/result.txt
229+```
230+ 
231+**报告内容示例**:
232+```
233+===================================
234+OAT Scan Result Summary
235+===================================
236+ 
237+-----------------------------------
238+Invalid File Type Total Count: 0
239+ 
240+-----------------------------------
241+License Header Invalid Total Count: 2
242+src/main.cpp: MISSING_LICENSE_HEADER
243+src/utils.cpp: MISSING_LICENSE_HEADER
244+ 
245+===================================
246+```
247+ 
248+**解决方案**:
249+ 
250+在文件顶部添加许可证头,例如 CANN-2.0:
251+ 
252+```cpp
253+/**
254+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
255+ * CANN Open Software License Agreement Version 2.0 (the "License").
256+ * Please refer to the License for details. You may not use this file except in compliance with the License.
257+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
258+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
259+ * See LICENSE in the root of the software repository for the full text of the License.
260+ */
261+ 
262+```
263+ 
264+**重新提交**:
265+```bash
266+git add src/main.cpp src/utils.cpp
267+git commit -m "fix: add license headers"
268+```
269+ 
270+---
271+ 
272+#### 3.2.7 报告查看
273+ 
274+**报告文件位置**
275+ 
276+| 报告类型 | 文件路径 | 内容 |
277+|---------|---------|------|
278+| **摘要报告** | `oat_reports/single/result.txt` | 关键问题汇总 |
279+ 
280+**查看命令**
281+ 
282+```bash
283+# 查看报告
284+cat oat_reports/single/result.txt
285+ 
286+# 使用编辑器查看
287+code oat_reports/single/result.txt
288+vim oat_reports/single/result.txt
289+```
290+ 
291+**摘要报告内容**
292+ 
293+```
294+===================================
295+OAT Scan Result Summary
296+===================================
297+Scan Time: 2026-03-25 14:30:15
298+Project: CANN
299+Files Checked: 3
300+ 
301+-----------------------------------
302+Invalid File Type Total Count: 0
303+ 
304+-----------------------------------
305+License Header Invalid Total Count: 0
306+ 
307+===================================
308+Full report: oat_reports/single/PlainReport_CANN.txt
309+===================================
310+```
311+ 
312+#### 3.2.8 环境问题
313+ 
314+**1) Java 未安装(Linux/macOS 自动安装)**
315+ 
316+**场景**: 首次提交,系统未安装 Java。
317+ 
318+**输出**:
319+```
320+====================================================================
321+ Java 未安装 - 正在尝试自动安装
322+====================================================================
323+ 
324+[OAT] 检测到系统未安装 Java,开始自动安装...
325+[OAT] 使用 apt 安装 OpenJDK 11...
326+[OAT] [OK] OpenJDK 11 安装成功
327+```
328+ 
329+**处理**: 自动安装,可能需要输入 sudo 密码。
330+ 
331+---
332+ 
333+**2) Java 未安装(Windows 手动安装)**
334+ 
335+**场景**: Windows 系统无法自动安装 Java。
336+ 
337+**输出**:
338+```
339+[OAT] Windows 系统无法自动安装 Java
340+[OAT] 请手动下载并安装:
341+ 
342+ 1. 访问: https://adoptium.net/
343+ 2. 下载: Eclipse Temurin JRE 11 (x64)
344+ 3. 安装后重启 Git Bash
345+ 4. 验证: java -version
346+ 
347+[OAT] 跳过 OAT 检查,继续提交...
348+[OAT] 建议安装 Java 后再次运行检查
349+```
350+ 
351+**行为**: **跳过检查,允许提交**
352+ 
353+**后续操作**:
354+1. 按提示手动安装 Java
355+2. 重启终端
356+3. 运行 `pre-commit run oat-check` 验证环境
357+ 
358+---
359+ 
360+**3) Java 自动安装失败**
361+ 
362+**场景**: Linux/macOS 自动安装 Java 失败。
363+ 
364+**输出**:
365+```
366+[OAT] [ERROR] 自动安装失败
367+ 
368+[OAT] 自动安装失败,跳过 OAT 检查
369+ 
370+手动安装方法:
371+ Linux: sudo apt install openjdk-11-jre
372+ macOS: brew install openjdk@11
373+ Windows: https://adoptium.net/
374+ 
375+[OAT] 继续提交(未进行合规性检查)...
376+[OAT] 建议安装 Java 后再次运行: pre-commit run oat-check
377+```
378+ 
379+**行为**: **跳过检查,允许提交**
380+ 
381+**可能原因**:
382+- 网络连接问题
383+- 包管理器未配置
384+- 权限不足
385+- macOS 未安装 Homebrew
386+ 
387+**解决方案**:
388+```bash
389+# Linux
390+sudo apt update
391+sudo apt install openjdk-11-jre
392+ 
393+# macOS - 先安装 Homebrew
394+/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
395+brew install openjdk@11
396+ 
397+# 验证
398+java -version
399+ 
400+# 手动运行检查
401+pre-commit run oat-check
402+```
403+ 
404+---
405+ 
406+**4) Maven 未安装(Linux/macOS 自动安装)**
407+ 
408+**场景**: 首次提交,系统未安装 Maven。
409+ 
410+**输出**:
411+```
412+====================================================================
413+ Maven 未安装 - 正在尝试自动安装
414+====================================================================
415+ 
416+[OAT] 使用 apt 安装 Maven...
417+[OAT] [OK] Maven 安装成功
418+```
419+ 
420+**处理**: 自动安装,可能需要输入 sudo 密码。
421+ 
422+---
423+ 
424+**5) Maven 未安装(Windows 手动安装)**
425+ 
426+**场景**: Windows 系统无法自动安装 Maven。
427+ 
428+**输出**:
429+```
430+[OAT] Windows 系统无法自动安装 Maven
431+[OAT] 请手动下载并安装:
432+ 
433+ 1. 访问: https://maven.apache.org/download.cgi
434+ 2. 下载: apache-maven-3.x.x-bin.zip
435+ 3. 解压到 C:\Program Files\apache-maven-3.x.x
436+ 4. 添加到系统 PATH
437+ 5. 重启 Git Bash
438+ 6. 验证: mvn -version
439+ 
440+[OAT] 跳过 OAT 检查,继续提交...
441+[OAT] 建议安装 Maven 后再次运行检查
442+```
443+ 
444+**行为**: **跳过检查,允许提交**
445+ 
446+**后续操作**: 按提示手动安装 Maven,然后运行 `pre-commit run oat-check`
447+ 
448+---
449+ 
450+**6) Maven 打包失败**
451+ 
452+**场景**: Maven 打包 OAT JAR 失败。
453+ 
454+**输出**:
455+```
456+====================================================================
457+ Maven 打包失败
458+====================================================================
459+ 
460+[OAT] 无法打包 OAT JAR,跳过 OAT 检查
461+ 
462+可能原因:
463+ 1. Maven 配置问题
464+ 2. 网络连接问题(无法下载依赖)
465+ 3. pom.xml 配置错误
466+ 
467+建议解决方案:
468+ 1. 手动打包:
469+ cd ../tools_oat
470+ mvn clean package -DskipTests
471+ 
472+ 2. 配置 Maven 镜像(国内网络):
473+ 编辑 ~/.m2/settings.xml 添加阿里云镜像
474+ 
475+[OAT] 继续提交(未进行合规性检查)...
476+[OAT] 建议修复打包问题后运行: pre-commit run oat-check
477+```
478+ 
479+**行为**: **跳过检查,允许提交**
480+ 
481+**解决方案**:
482+ 
483+**方法 1: 手动打包**
484+```bash
485+cd ../tools_oat
486+mvn clean package -DskipTests
487+ 
488+# 查看输出,应该看到 BUILD SUCCESS
489+```
490+ 
491+**方法 2: 配置阿里云镜像(国内网络)**
492+```bash
493+mkdir -p ~/.m2
494+cat > ~/.m2/settings.xml <<'EOF'
495+<settings>
496+ <mirrors>
497+ <mirror>
498+ <id>aliyun</id>
499+ <mirrorOf>central</mirrorOf>
500+ <name>Aliyun Maven Mirror</name>
501+ <url>https://maven.aliyun.com/repository/public</url>
502+ </mirror>
503+ </mirrors>
504+</settings>
505+EOF
506+ 
507+# 重新打包
508+cd ../tools_oat
509+mvn clean package -DskipTests
510+```
511+ 
512+**方法 3: 从团队获取 JAR**
513+```bash
514+# 如果团队已有编译好的 JAR,直接复制
515+# 将 JAR 文件复制到 ../tools_oat/target/ 目录
516+```
517+ 
518+**验证修复**:
519+```bash
520+pre-commit run oat-check
521+```
522+ 
523+---
524+ 
525+**7) tools_oat 克隆失败**
526+ 
527+**输出**:
528+```
529+[OAT] tools_oat not found. Cloning...
530+[OAT] [ERROR] Failed to clone tools_oat.
531+[OAT] You can manually clone from: https://gitcode.com/openharmony-sig/tools_oat.git
532+```
533+ 
534+**原因**: 网络连接问题。
535+ 
536+**解决方案**:
537+```bash
538+# 方法 1: 检查网络
539+ping gitcode.com
540+ 
541+# 方法 2: 手动克隆
542+cd ..
543+git clone https://gitcode.com/openharmony-sig/tools_oat.git
544+ 
545+# 方法 3: 配置代理
546+git config --global http.proxy http://proxy.example.com:8080
547+ 
548+# 方法 4: 从团队成员复制
549+# 让已克隆的同事打包 tools_oat 文件夹给你
550+```
551+ 
552+---
553+ 
554+**8) OAT 扫描执行失败**
555+ 
556+**场景**: OAT JAR 运行失败。
557+ 
558+**输出**:
559+```
560+====================================================================
561+ OAT 扫描执行失败
562+====================================================================
563+ 
564+[OAT] 扫描失败,跳过 OAT 检查
565+ 
566+可能原因:
567+ 1. JAR 文件损坏
568+ 2. Java 版本不兼容
569+ 3. OAT 配置问题
570+ 
571+建议解决方案:
572+ 1. 删除并重新打包 JAR:
573+ rm ../tools_oat/target/ohos_ossaudittool-*.jar
574+ cd ../tools_oat && mvn clean package -DskipTests
575+ 
576+ 2. 检查 Java 版本(需要 Java 8+):
577+ java -version
578+ 
579+[OAT] 继续提交(未进行合规性检查)...
580+[OAT] 建议修复扫描问题后运行: pre-commit run oat-check
581+```
582+ 
583+**行为**: **跳过检查,允许提交**
584+ 
585+**解决方案**:
586+```bash
587+# 步骤 1: 删除旧 JAR
588+rm ../tools_oat/target/ohos_ossaudittool-*.jar
589+ 
590+# 步骤 2: 重新打包
591+cd ../tools_oat
592+mvn clean package -DskipTests
593+ 
594+# 步骤 3: 验证 JAR
595+ls -lh target/ohos_ossaudittool-*.jar
596+ 
597+# 步骤 4: 运行检查
598+cd -
599+pre-commit run oat-check
600+```