已合并
fix: 整改责任田算子日志质量(修复日志规范问题) #5023
fix: 整改责任田算子日志质量(修复日志规范问题) #5023
已合并
StoneChan_创建于 13 天前
106 个文件变更+4436-4856
@@ -33,71 +33,74 @@
33#define FAILED -133#define FAILED -1
34#define SUCCESS 034#define SUCCESS 0
35 35 
36+#define LOG_PRINT(message, ...) \
37+ do { \
38+ printf(message, ##__VA_ARGS__); \
39+ } while (0)
40+ 
36using namespace ge;41using namespace ge;
37using std::map;42using std::map;
38using std::string;43using std::string;
39using std::vector;44using std::vector;
40-#define ADD_INPUT(intputIndex, intputName, intputDtype, inputShape) \45+#define ADD_INPUT(intputIndex, intputName, intputDtype, inputShape) \
41- vector<int64_t> placeholder##intputIndex##_shape = inputShape; \46+ vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
42- auto placeholder##intputIndex = op::Data("placeholder" + intputIndex).set_attr_index(0); \47+ auto placeholder##intputIndex = op::Data("placeholder" + intputIndex).set_attr_index(0); \
43- TensorDesc placeholder##intputIndex##_desc = \48+ TensorDesc placeholder##intputIndex##_desc = TensorDesc(ge::Shape(placeholder##intputIndex##_shape), FORMAT_ND, \
44- TensorDesc(ge::Shape(placeholder##intputIndex##_shape), FORMAT_ND, intputDtype); \49+ intputDtype); \
45- placeholder##intputIndex##_desc.SetPlacement(ge::kPlacementHost); \50+ placeholder##intputIndex##_desc.SetPlacement(ge::kPlacementHost); \
46- placeholder##intputIndex##_desc.SetFormat(FORMAT_ND); \51+ placeholder##intputIndex##_desc.SetFormat(FORMAT_ND); \
47- Tensor tensor_placeholder##intputIndex; \52+ Tensor tensor_placeholder##intputIndex; \
48- ret = GenOnesDataFloat32( \53+ ret = GenOnesDataFloat32(placeholder##intputIndex##_shape, tensor_placeholder##intputIndex, \
49- placeholder##intputIndex##_shape, tensor_placeholder##intputIndex, placeholder##intputIndex##_desc, 2); \54+ placeholder##intputIndex##_desc, 2); \
50- if (ret != SUCCESS) { \55+ if (ret != SUCCESS) { \
51- printf("%s - ERROR - [XIR]: Generate input data failed\n", GetTime().c_str()); \56+ LOG_PRINT("%s - ERROR - [AS_STRIDED_GE_IR]: Generate input data failed\n", GetTime().c_str()); \
52- return FAILED; \57+ return FAILED; \
53- } \58+ } \
54- placeholder##intputIndex.update_input_desc_x(placeholder##intputIndex##_desc); \59+ placeholder##intputIndex.update_input_desc_x(placeholder##intputIndex##_desc); \
55- input.push_back(tensor_placeholder##intputIndex); \60+ input.push_back(tensor_placeholder##intputIndex); \
56- graph.AddOp(placeholder##intputIndex); \61+ graph.AddOp(placeholder##intputIndex); \
57- node.set_input_##intputName(placeholder##intputIndex); \62+ node.set_input_##intputName(placeholder##intputIndex); \
58 inputs.push_back(placeholder##intputIndex);63 inputs.push_back(placeholder##intputIndex);
59 64 
60-#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \65+#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \
61- vector<int64_t> placeholder##intputIndex##_shape = inputShape; \66+ vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
62- auto placeholder##intputIndex = op::Data("placeholder" + intputIndex).set_attr_index(0); \67+ auto placeholder##intputIndex = op::Data("placeholder" + intputIndex).set_attr_index(0); \
63- TensorDesc placeholder##intputIndex##_desc = \68+ TensorDesc placeholder##intputIndex##_desc = TensorDesc(ge::Shape(placeholder##intputIndex##_shape), FORMAT_ND, \
64- TensorDesc(ge::Shape(placeholder##intputIndex##_shape), FORMAT_ND, intputDtype); \69+ intputDtype); \
65- placeholder##intputIndex##_desc.SetPlacement(ge::kPlacementHost); \70+ placeholder##intputIndex##_desc.SetPlacement(ge::kPlacementHost); \
66- placeholder##intputIndex##_desc.SetFormat(FORMAT_ND); \71+ placeholder##intputIndex##_desc.SetFormat(FORMAT_ND); \
67- Tensor tensor_placeholder##intputIndex; \72+ Tensor tensor_placeholder##intputIndex; \
68- ret = GenOnesData( \73+ ret = GenOnesData(placeholder##intputIndex##_shape, tensor_placeholder##intputIndex, \
69- placeholder##intputIndex##_shape, tensor_placeholder##intputIndex, placeholder##intputIndex##_desc, \74+ placeholder##intputIndex##_desc, intputDtype, value); \
70- intputDtype, value); \75+ if (ret != SUCCESS) { \
71- if (ret != SUCCESS) { \76+ LOG_PRINT("%s - ERROR - [AS_STRIDED_GE_IR]: Generate input data failed\n", GetTime().c_str()); \
72- printf("%s - ERROR - [XIR]: Generate input data failed\n", GetTime().c_str()); \77+ return FAILED; \
73- return FAILED; \78+ } \
74- } \79+ placeholder##intputIndex.update_input_desc_x(placeholder##intputIndex##_desc); \
75- placeholder##intputIndex.update_input_desc_x(placeholder##intputIndex##_desc); \80+ input.push_back(tensor_placeholder##intputIndex); \
76- input.push_back(tensor_placeholder##intputIndex); \81+ graph.AddOp(placeholder##intputIndex); \
77- graph.AddOp(placeholder##intputIndex); \82+ node.set_input_##intputName(placeholder##intputIndex); \
78- node.set_input_##intputName(placeholder##intputIndex); \
79 inputs.push_back(placeholder##intputIndex);83 inputs.push_back(placeholder##intputIndex);
80 84 
81-#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \85+#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \
82- vector<int64_t> placeholder##intputIndex##_shape = inputShape; \86+ vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
83- auto placeholder##intputIndex = op::Const("placeholder" + intputIndex); \87+ auto placeholder##intputIndex = op::Const("placeholder" + intputIndex); \
84- TensorDesc placeholder##intputIndex##_desc = \88+ TensorDesc placeholder##intputIndex##_desc = TensorDesc(ge::Shape(placeholder##intputIndex##_shape), FORMAT_ND, \
85- TensorDesc(ge::Shape(placeholder##intputIndex##_shape), FORMAT_ND, intputDtype); \89+ intputDtype); \
86- placeholder##intputIndex##_desc.SetPlacement(ge::kPlacementHost); \90+ placeholder##intputIndex##_desc.SetPlacement(ge::kPlacementHost); \
87- placeholder##intputIndex##_desc.SetFormat(FORMAT_ND); \91+ placeholder##intputIndex##_desc.SetFormat(FORMAT_ND); \
88- Tensor tensor_placeholder##intputIndex; \92+ Tensor tensor_placeholder##intputIndex; \
89- ret = GenOnesData( \93+ ret = GenOnesData(placeholder##intputIndex##_shape, tensor_placeholder##intputIndex, \
90- placeholder##intputIndex##_shape, tensor_placeholder##intputIndex, placeholder##intputIndex##_desc, \94+ placeholder##intputIndex##_desc, intputDtype, 2); \
91- intputDtype, 2); \95+ if (ret != SUCCESS) { \
92- if (ret != SUCCESS) { \96+ LOG_PRINT("%s - ERROR - [AS_STRIDED_GE_IR]: Generate input data failed\n", GetTime().c_str()); \
93- printf("%s - ERROR - [XIR]: Generate input data failed\n", GetTime().c_str()); \97+ return FAILED; \
94- return FAILED; \98+ } \
95- } \99+ placeholder##intputIndex.SetAttr("value", tensor_placeholder##intputIndex); \
96- placeholder##intputIndex.SetAttr("value", tensor_placeholder##intputIndex); \100+ placeholder##intputIndex.update_output_desc_y(placeholder##intputIndex##_desc); \
97- placeholder##intputIndex.update_output_desc_y(placeholder##intputIndex##_desc); \101+ graph.AddOp(placeholder##intputIndex); \
98- graph.AddOp(placeholder##intputIndex); \102+ node.set_input_##intputName(placeholder##intputIndex); \
99- node.set_input_##intputName(placeholder##intputIndex); \103+ node.update_input_desc_##intputName(placeholder##intputIndex##_desc); \
100- node.update_input_desc_##intputName(placeholder##intputIndex##_desc); \
101 inputs.push_back(placeholder##intputIndex);104 inputs.push_back(placeholder##intputIndex);
102 105 
103#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \106#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \
@@ -168,8 +171,8 @@ int32_t GenOnesDataFloat32(vector<int64_t> shapes, Tensor& input_tensor, TensorD
168 return SUCCESS;171 return SUCCESS;
169}172}
170 173 
171-int32_t GenOnesData(174+int32_t GenOnesData(vector<int64_t> shapes, Tensor& input_tensor, TensorDesc& input_tensor_desc, DataType data_type,
172- vector<int64_t> shapes, Tensor& input_tensor, TensorDesc& input_tensor_desc, DataType data_type, int value)175+ int value)
173{176{
174 input_tensor_desc.SetRealDimCnt(shapes.size());177 input_tensor_desc.SetRealDimCnt(shapes.size());
175 size_t size = 1;178 size_t size = 1;
@@ -185,9 +188,8 @@ int32_t GenOnesData(
185 return SUCCESS;188 return SUCCESS;
186}189}
187 190 
188-int32_t GenOnesData(191+int32_t GenOnesData(vector<int64_t> shapes, Tensor& input_tensor, TensorDesc& input_tensor_desc, DataType data_type,
189- vector<int64_t> shapes, Tensor& input_tensor, TensorDesc& input_tensor_desc, DataType data_type,192+ const vector<int32_t>& value)
190- const vector<int32_t>& value)
191{193{
192 input_tensor_desc.SetRealDimCnt(shapes.size());194 input_tensor_desc.SetRealDimCnt(shapes.size());
193 size_t size = 1;195 size_t size = 1;
@@ -211,9 +213,8 @@ int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t* inputData)
211 return SUCCESS;213 return SUCCESS;
212}214}
213 215 
214-int CreateOppInGraph(216+int CreateOppInGraph(DataType inDtype, std::vector<ge::Tensor>& input, std::vector<Operator>& inputs,
215- DataType inDtype, std::vector<ge::Tensor>& input, std::vector<Operator>& inputs, std::vector<Operator>& outputs,217+ std::vector<Operator>& outputs, Graph& graph)
216- Graph& graph)
217{218{
218 Status ret = SUCCESS;219 Status ret = SUCCESS;
219 // 自定义代码:添加单算子定义到图中220 // 自定义代码:添加单算子定义到图中
@@ -245,27 +246,27 @@ int main(int argc, char* argv[])
245 Graph graph(graph_name);246 Graph graph(graph_name);
246 std::vector<ge::Tensor> input;247 std::vector<ge::Tensor> input;
247 248 
248- printf("%s - INFO - [XIR]: Start to initialize ge using ge global options\n", GetTime().c_str());249+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: Start to initialize ge using ge global options\n", GetTime().c_str());
249 std::map<AscendString, AscendString> global_options = {{"ge.exec.deviceId", "0"}, {"ge.graphRunMode", "1"}};250 std::map<AscendString, AscendString> global_options = {{"ge.exec.deviceId", "0"}, {"ge.graphRunMode", "1"}};
250 Status ret = ge::GEInitialize(global_options);251 Status ret = ge::GEInitialize(global_options);
251 if (ret != SUCCESS) {252 if (ret != SUCCESS) {
252- printf("%s - INFO - [XIR]: Initialize ge using ge global options failed\n", GetTime().c_str());253+ LOG_PRINT("%s - ERROR - [AS_STRIDED_GE_IR]: Initialize ge using ge global options failed\n", GetTime().c_str());
253 return FAILED;254 return FAILED;
254 }255 }
255- printf("%s - INFO - [XIR]: Initialize ge using ge global options success\n", GetTime().c_str());256+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: Initialize ge using ge global options success\n", GetTime().c_str());
256 257 
257 std::vector<Operator> inputs{};258 std::vector<Operator> inputs{};
258 std::vector<Operator> outputs{};259 std::vector<Operator> outputs{};
259 260 
260- std::cout << argv[1] << std::endl;261+ LOG_PRINT("argv[1] = %s\n", argv[1]);
261 char* endptr;262 char* endptr;
262 263 
263 DataType inDtype = DT_FLOAT;264 DataType inDtype = DT_FLOAT;
264- std::cout << inDtype << std::endl;265+ LOG_PRINT("inDtype: %d\n", static_cast<int>(inDtype));
265 266 
266 ret = CreateOppInGraph(inDtype, input, inputs, outputs, graph);267 ret = CreateOppInGraph(inDtype, input, inputs, outputs, graph);
267 if (ret != SUCCESS) {268 if (ret != SUCCESS) {
268- printf("%s - ERROR - [XIR]: Create ir session using build options failed\n", GetTime().c_str());269+ LOG_PRINT("%s - ERROR - [AS_STRIDED_GE_IR]: Create ir session using build options failed\n", GetTime().c_str());
269 return FAILED;270 return FAILED;
270 }271 }
271 272 
@@ -276,15 +277,15 @@ int main(int argc, char* argv[])
276 std::map<AscendString, AscendString> build_options = {277 std::map<AscendString, AscendString> build_options = {
277 278 
278 };279 };
279- printf("%s - INFO - [XIR]: Start to create ir session using build options\n", GetTime().c_str());280+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: Start to create ir session using build options\n", GetTime().c_str());
280 ge::Session* session = new Session(build_options);281 ge::Session* session = new Session(build_options);
281 282 
282 if (session == nullptr) {283 if (session == nullptr) {
283- printf("%s - ERROR - [XIR]: Create ir session using build options failed\n", GetTime().c_str());284+ LOG_PRINT("%s - ERROR - [AS_STRIDED_GE_IR]: Create ir session using build options failed\n", GetTime().c_str());
284 return FAILED;285 return FAILED;
285 }286 }
286- printf("%s - INFO - [XIR]: Create ir session using build options success\n", GetTime().c_str());287+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: Create ir session using build options success\n", GetTime().c_str());
287- printf("%s - INFO - [XIR]: Start to add compute graph to ir session\n", GetTime().c_str());288+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: Start to add compute graph to ir session\n", GetTime().c_str());
288 289 
289 std::map<AscendString, AscendString> graph_options = {290 std::map<AscendString, AscendString> graph_options = {
290 291 
@@ -292,39 +293,40 @@ int main(int argc, char* argv[])
292 uint32_t graph_id = 0;293 uint32_t graph_id = 0;
293 ret = session->AddGraph(graph_id, graph, graph_options);294 ret = session->AddGraph(graph_id, graph, graph_options);
294 295 
295- printf("%s - INFO - [XIR]: Session add ir compute graph to ir session success\n", GetTime().c_str());296+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: Session add ir compute graph to ir session success\n",
296- printf("%s - INFO - [XIR]: dump graph to txt\n", GetTime().c_str());297+ GetTime().c_str());
298+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: dump graph to txt\n", GetTime().c_str());
297 std::string file_path = "./dump";299 std::string file_path = "./dump";
298 aclgrphDumpGraph(graph, file_path.c_str(), file_path.length());300 aclgrphDumpGraph(graph, file_path.c_str(), file_path.length());
299- printf("%s - INFO - [XIR]: Start to run ir compute graph\n", GetTime().c_str());301+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: Start to run ir compute graph\n", GetTime().c_str());
300 std::vector<ge::Tensor> output;302 std::vector<ge::Tensor> output;
301 ret = session->RunGraph(graph_id, input, output);303 ret = session->RunGraph(graph_id, input, output);
302 if (ret != SUCCESS) {304 if (ret != SUCCESS) {
303- printf("%s - INFO - [XIR]: Run graph failed\n", GetTime().c_str());305+ LOG_PRINT("%s - ERROR - [AS_STRIDED_GE_IR]: Run graph failed\n", GetTime().c_str());
304 delete session;306 delete session;
305 GEFinalize();307 GEFinalize();
306 return FAILED;308 return FAILED;
307 }309 }
308- printf("%s - INFO - [XIR]: Session run ir compute graph success\n", GetTime().c_str());310+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: Session run ir compute graph success\n", GetTime().c_str());
309 311 
310 int input_num = input.size();312 int input_num = input.size();
311 for (int i = 0; i < input_num; i++) {313 for (int i = 0; i < input_num; i++) {
312- std::cout << "input " << i << " dtype : " << input[i].GetTensorDesc().GetDataType() << std::endl;314+ LOG_PRINT("input %d dtype: %d\n", i, static_cast<int>(input[i].GetTensorDesc().GetDataType()));
313 string input_file = "./tc_ge_irrun_test_0008_npu_input_" + std::to_string(i) + ".bin";315 string input_file = "./tc_ge_irrun_test_0008_npu_input_" + std::to_string(i) + ".bin";
314 uint8_t* input_data_i = input[i].GetData();316 uint8_t* input_data_i = input[i].GetData();
315 int64_t input_shape = input[i].GetTensorDesc().GetShape().GetShapeSize();317 int64_t input_shape = input[i].GetTensorDesc().GetShape().GetShapeSize();
316- std::cout << "this is " << i << "th input, input shape size =" << input_shape << std::endl;318+ LOG_PRINT("input %d shape size: %ld\n", i, input_shape);
317 uint32_t data_size = input_shape * GetDataTypeSize(input[i].GetTensorDesc().GetDataType());319 uint32_t data_size = input_shape * GetDataTypeSize(input[i].GetTensorDesc().GetDataType());
318 WriteDataToFile((const char*)input_file.c_str(), data_size, input_data_i);320 WriteDataToFile((const char*)input_file.c_str(), data_size, input_data_i);
319 }321 }
320 322 
321 int output_num = output.size();323 int output_num = output.size();
322 for (int i = 0; i < output_num; i++) {324 for (int i = 0; i < output_num; i++) {
323- std::cout << "output " << i << " dtype : " << output[i].GetTensorDesc().GetDataType() << std::endl;325+ LOG_PRINT("output %d dtype: %d\n", i, static_cast<int>(output[i].GetTensorDesc().GetDataType()));
324 string output_file = "./tc_ge_irrun_test_0008_npu_output_" + std::to_string(i) + ".bin";326 string output_file = "./tc_ge_irrun_test_0008_npu_output_" + std::to_string(i) + ".bin";
325 uint8_t* output_data_i = output[i].GetData();327 uint8_t* output_data_i = output[i].GetData();
326 int64_t output_shape = output[i].GetTensorDesc().GetShape().GetShapeSize();328 int64_t output_shape = output[i].GetTensorDesc().GetShape().GetShapeSize();
327- std::cout << "this is " << i << "th output, output shape size =" << output_shape << std::endl;329+ LOG_PRINT("output %d shape size: %ld\n", i, output_shape);
328 uint32_t data_size = output_shape * GetDataTypeSize(output[i].GetTensorDesc().GetDataType());330 uint32_t data_size = output_shape * GetDataTypeSize(output[i].GetTensorDesc().GetDataType());
329 WriteDataToFile((const char*)output_file.c_str(), data_size, output_data_i);331 WriteDataToFile((const char*)output_file.c_str(), data_size, output_data_i);
330 uint8_t* resultData = (uint8_t*)output_data_i;332 uint8_t* resultData = (uint8_t*)output_data_i;
@@ -335,16 +337,16 @@ int main(int argc, char* argv[])
335 337 
336 ge::AscendString error_msg = ge::GEGetErrorMsgV2();338 ge::AscendString error_msg = ge::GEGetErrorMsgV2();
337 std::string error_str(error_msg.GetString());339 std::string error_str(error_msg.GetString());
338- std::cout << "Error message: " << error_str << std::endl;340+ LOG_PRINT("Error message: %s\n", error_str.c_str());
339 ge::AscendString warning_msg = ge::GEGetWarningMsgV2();341 ge::AscendString warning_msg = ge::GEGetWarningMsgV2();
340 std::string warning_str(warning_msg.GetString());342 std::string warning_str(warning_msg.GetString());
341- std::cout << "Warning message: " << warning_str << std::endl;343+ LOG_PRINT("Warning message: %s\n", warning_str.c_str());
342- printf("%s - INFO - [XIR]: Start to finalize ir graph session\n", GetTime().c_str());344+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: Start to finalize ir graph session\n", GetTime().c_str());
343 ret = ge::GEFinalize();345 ret = ge::GEFinalize();
344 if (ret != SUCCESS) {346 if (ret != SUCCESS) {
345- printf("%s - INFO - [XIR]: Finalize ir graph session failed\n", GetTime().c_str());347+ LOG_PRINT("%s - ERROR - [AS_STRIDED_GE_IR]: Finalize ir graph session failed\n", GetTime().c_str());
346 return FAILED;348 return FAILED;
347 }349 }
348- printf("%s - INFO - [XIR]: Finalize ir graph session success\n", GetTime().c_str());350+ LOG_PRINT("%s - INFO - [AS_STRIDED_GE_IR]: Finalize ir graph session success\n", GetTime().c_str());
349 return SUCCESS;351 return SUCCESS;
350-}352+}
@@ -27,8 +27,7 @@ constexpr int64_t BLOCK_BYTES = 32;
27struct AxisInf {27struct AxisInf {
28 AxisInf(int64_t dim_, int64_t stride_, int64_t idx_, gert::TilingContext* context)28 AxisInf(int64_t dim_, int64_t stride_, int64_t idx_, gert::TilingContext* context)
29 : context_(context), dim(dim_), stride(stride_), idx(idx_), code(1 << idx_), conter(0)29 : context_(context), dim(dim_), stride(stride_), idx(idx_), code(1 << idx_), conter(0)
30- {30+ {}
31- }
32 31 
33 void PrintDebug()32 void PrintDebug()
34 {33 {
@@ -70,8 +69,8 @@ public:
70 if (axisList_[i].idx < this->initDimNums - 1) {69 if (axisList_[i].idx < this->initDimNums - 1) {
71 this->axisList.push_back(axisList_[i]);70 this->axisList.push_back(axisList_[i]);
72 } else {71 } else {
73- int64_t alignedFinalDim =72+ int64_t alignedFinalDim = (axisList_[i].dim + this->alignedFactor - 1) / this->alignedFactor *
74- (axisList_[i].dim + this->alignedFactor - 1) / this->alignedFactor * this->alignedFactor;73+ this->alignedFactor;
75 this->originFinalDim = axisList_[i].dim;74 this->originFinalDim = axisList_[i].dim;
76 this->axisList.push_back(AxisInf(alignedFinalDim, axisList_[i].stride, axisList_[i].idx, context));75 this->axisList.push_back(AxisInf(alignedFinalDim, axisList_[i].stride, axisList_[i].idx, context));
77 }76 }
@@ -149,10 +148,7 @@ void AxisCutter::PrintDebug()
149 this->conter += 1;148 this->conter += 1;
150}149}
151 150 
152-AxisInf* AxisCutter::GetCutAxis()151+AxisInf* AxisCutter::GetCutAxis() { return &this->axisList[this->cutIdx]; }
153-{
154- return &this->axisList[this->cutIdx];
155-}
156 152 
157class DualCutAxisSeeker {153class DualCutAxisSeeker {
158public:154public:
@@ -160,10 +156,9 @@ public:
160 {156 {
161 context_ = context;157 context_ = context;
162 this->dtSize = dtSize_;158 this->dtSize = dtSize_;
163- if(dtSize_ <= 0) {159+ if (dtSize_ <= 0) {
164- OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(context_->GetNodeName(), "input",160+ OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(context_->GetNodeName(), "input", std::to_string(dtSize_).c_str(),
165- std::to_string(dtSize_).c_str(),161+ "The dtype size of input must be greater than 0.");
166- "The dtype size of input must be greater than 0.");
167 dtSize_ = 1;162 dtSize_ = 1;
168 }163 }
169 this->alignedFactor = BLOCK_BYTES / dtSize_;164 this->alignedFactor = BLOCK_BYTES / dtSize_;
@@ -197,10 +192,10 @@ public:
197 void UpdateCommonAxis(unsigned int commonSet);192 void UpdateCommonAxis(unsigned int commonSet);
198 193 
199 bool CutAxis(unsigned int ubAxisSet, int64_t remainNums);194 bool CutAxis(unsigned int ubAxisSet, int64_t remainNums);
200- bool CutTwoAxis(195+ bool CutTwoAxis(unsigned int ubAxisSet, int64_t remainNums, std::vector<AxisInf>& innerAxis,
201- unsigned int ubAxisSet, int64_t remainNums, std::vector<AxisInf>& innerAxis, std::vector<AxisInf>& outerAxis);196+ std::vector<AxisInf>& outerAxis);
202- bool CutOneAxis(197+ bool CutOneAxis(unsigned int ubAxisSet, int64_t remainNums, std::vector<AxisInf>& innerAxis,
203- unsigned int ubAxisSet, int64_t remainNums, std::vector<AxisInf>& innerAxis, std::vector<AxisInf>& outerAxis);198+ std::vector<AxisInf>& outerAxis);
204 void SetCutAxisIdx();199 void SetCutAxisIdx();
205 void GenTilingData();200 void GenTilingData();
206 void ComputeBlockTiling(int coreNum);201 void ComputeBlockTiling(int coreNum);
@@ -276,8 +271,8 @@ void DualCutAxisSeeker::SetCutAxisIdx()
276 for (uint32_t j = 0; j < this->ubAxis.size(); j++) {271 for (uint32_t j = 0; j < this->ubAxis.size(); j++) {
277 if (this->ubAxis[j].idx == outerCutAxisPtr->idx) {272 if (this->ubAxis[j].idx == outerCutAxisPtr->idx) {
278 cutAxisIdx[i] = j + baseIdx;273 cutAxisIdx[i] = j + baseIdx;
279- cutAxisTail[i] =274+ cutAxisTail[i] = this->outputAxis[outerCutAxisPtr->idx].dim -
280- this->outputAxis[outerCutAxisPtr->idx].dim - (outerCutAxisPtr->dim - 1) * this->ubAxis[j].dim;275+ (outerCutAxisPtr->dim - 1) * this->ubAxis[j].dim;
281 break;276 break;
282 }277 }
283 }278 }
@@ -339,8 +334,8 @@ int DualCutAxisSeeker::ComputeOutputShape(AxisInf& axis)
339 334 
340bool DualCutAxisSeeker::FindDualCutAxis(int ubSize, int bufferNum)335bool DualCutAxisSeeker::FindDualCutAxis(int ubSize, int bufferNum)
341{336{
342- if(bufferNum == 0) {337+ if (bufferNum == 0) {
343- OP_LOGE(context_, "the bufferNum is equal zero");338+ OP_LOGE(context_, "the bufferNum is equal to zero");
344 bufferNum = 2;339 bufferNum = 2;
345 }340 }
346 int ubNum = ubSize / this->dtSize / bufferNum;341 int ubNum = ubSize / this->dtSize / bufferNum;
@@ -348,7 +343,7 @@ bool DualCutAxisSeeker::FindDualCutAxis(int ubSize, int bufferNum)
348 unsigned int ubAxisSet = 0;343 unsigned int ubAxisSet = 0;
349 unsigned int joinUbAxisSet = 0;344 unsigned int joinUbAxisSet = 0;
350 if (this->outputAxis[dimNums - 1].dim <= alignedFactor) {345 if (this->outputAxis[dimNums - 1].dim <= alignedFactor) {
351- OP_LOGW(context_, "Last dim is smaller than 32B, no need do dual cut!");346+ OP_LOGW(context_, "Last dim is smaller than 32B, no need to do dual cut!");
352 return false;347 return false;
353 }348 }
354 for (int findLoops = SHAPE_ARRAY_LEN; findLoops >= 0; findLoops--) {349 for (int findLoops = SHAPE_ARRAY_LEN; findLoops >= 0; findLoops--) {
@@ -447,8 +442,8 @@ bool DualCutAxisSeeker::CutAxis(unsigned int ubAxisSet, int64_t remainNums)
447 return true;442 return true;
448}443}
449 444 
450-bool DualCutAxisSeeker::CutTwoAxis(445+bool DualCutAxisSeeker::CutTwoAxis(unsigned int ubAxisSet, int64_t remainNums, std::vector<AxisInf>& innerAxis,
451- unsigned int ubAxisSet, int64_t remainNums, std::vector<AxisInf>& innerAxis, std::vector<AxisInf>& outerAxis)446+ std::vector<AxisInf>& outerAxis)
452{447{
453 OP_LOGI(context_, "cutTwo ubAxisSet: 0x%x", ubAxisSet);448 OP_LOGI(context_, "cutTwo ubAxisSet: 0x%x", ubAxisSet);
454 AxisInf outputCutOuterAixs(0, 0, 0, context_);449 AxisInf outputCutOuterAixs(0, 0, 0, context_);
@@ -456,44 +451,36 @@ bool DualCutAxisSeeker::CutTwoAxis(
456 AxisInf inputCutOuterAixs(0, 0, 0, context_);451 AxisInf inputCutOuterAixs(0, 0, 0, context_);
457 AxisInf inputCutInnerAixs(0, 0, 0, context_);452 AxisInf inputCutInnerAixs(0, 0, 0, context_);
458 453 
459- outputCutOuterAixs.ResetInf(454+ outputCutOuterAixs.ResetInf(this->outputCutter->outerCutAxis.dim, this->outputCutter->outerCutAxis.stride,
460- this->outputCutter->outerCutAxis.dim, this->outputCutter->outerCutAxis.stride,455+ this->outputCutter->outerCutAxis.idx);
461- this->outputCutter->outerCutAxis.idx);456+ outputCutInnerAixs.ResetInf(this->outputCutter->innerCutAxis.dim, this->outputCutter->innerCutAxis.stride,
462- outputCutInnerAixs.ResetInf(457+ this->outputCutter->innerCutAxis.idx);
463- this->outputCutter->innerCutAxis.dim, this->outputCutter->innerCutAxis.stride,458+ inputCutOuterAixs.ResetInf(this->inputCutter->outerCutAxis.dim, this->inputCutter->outerCutAxis.stride,
464- this->outputCutter->innerCutAxis.idx);459+ this->inputCutter->outerCutAxis.idx);
465- inputCutOuterAixs.ResetInf(460+ inputCutInnerAixs.ResetInf(this->inputCutter->innerCutAxis.dim, this->inputCutter->innerCutAxis.stride,
466- this->inputCutter->outerCutAxis.dim, this->inputCutter->outerCutAxis.stride,461+ this->inputCutter->innerCutAxis.idx);
467- this->inputCutter->outerCutAxis.idx);
468- inputCutInnerAixs.ResetInf(
469- this->inputCutter->innerCutAxis.dim, this->inputCutter->innerCutAxis.stride,
470- this->inputCutter->innerCutAxis.idx);
471 462 
472 if (this->inputCutter->cutFinal || this->outputCutter->cutFinal) {463 if (this->inputCutter->cutFinal || this->outputCutter->cutFinal) {
473 if (this->inputCutter->cutFinal) {464 if (this->inputCutter->cutFinal) {
474 inputCutInnerAixs.dim = (inputCutInnerAixs.dim < alignedFactor) ?465 inputCutInnerAixs.dim = (inputCutInnerAixs.dim < alignedFactor) ?
475 ((inputCutInnerAixs.dim + alignedFactor - 1) / alignedFactor * alignedFactor) :466 ((inputCutInnerAixs.dim + alignedFactor - 1) / alignedFactor * alignedFactor) :
476 (inputCutInnerAixs.dim / alignedFactor * alignedFactor);467 (inputCutInnerAixs.dim / alignedFactor * alignedFactor);
477- OP_CHECK_IF(468+ OP_CHECK_IF((inputCutInnerAixs.dim == 0),
478- (inputCutInnerAixs.dim == 0),469+ OP_LOGW(context_, "input cut inner axis dim becomes 0, back to sole cut."), return false);
479- OP_LOGW(context_, "inputCutInnerAixs.dim get 0, back to Sole Cut."),
480- return false);
481 outputCutInnerAixs.dim = remainNums / inputCutInnerAixs.dim; // If get zero back to single cut470 outputCutInnerAixs.dim = remainNums / inputCutInnerAixs.dim; // If get zero back to single cut
482 } else if (this->outputCutter->cutFinal) {471 } else if (this->outputCutter->cutFinal) {
483- outputCutInnerAixs.dim =472+ outputCutInnerAixs.dim = (outputCutInnerAixs.dim < alignedFactor) ?
484- (outputCutInnerAixs.dim < alignedFactor) ?473+ ((outputCutInnerAixs.dim + alignedFactor - 1) / alignedFactor *
485- ((outputCutInnerAixs.dim + alignedFactor - 1) / alignedFactor * alignedFactor) :474+ alignedFactor) :
486- (outputCutInnerAixs.dim / alignedFactor * alignedFactor);475+ (outputCutInnerAixs.dim / alignedFactor * alignedFactor);
487- OP_CHECK_IF(476+ OP_CHECK_IF((outputCutInnerAixs.dim == 0),
488- (outputCutInnerAixs.dim == 0),477+ OP_LOGW(context_, "output cut inner axis dim becomes 0, back to sole cut."), return false);
489- OP_LOGW(context_, "outputCutInnerAixs.dim get 0, back to Sole Cut."),
490- return false);
491 inputCutInnerAixs.dim = remainNums / outputCutInnerAixs.dim; // If get zero back to single cut478 inputCutInnerAixs.dim = remainNums / outputCutInnerAixs.dim; // If get zero back to single cut
492 }479 }
493- inputCutOuterAixs.dim =480+ inputCutOuterAixs.dim = (this->inputCutter->cutAxisPtr->dim + inputCutInnerAixs.dim - 1) /
494- (this->inputCutter->cutAxisPtr->dim + inputCutInnerAixs.dim - 1) / inputCutInnerAixs.dim;481+ inputCutInnerAixs.dim;
495- outputCutOuterAixs.dim =482+ outputCutOuterAixs.dim = (this->outputCutter->cutAxisPtr->dim + outputCutInnerAixs.dim - 1) /
496- (this->outputCutter->cutAxisPtr->dim + outputCutInnerAixs.dim - 1) / outputCutInnerAixs.dim;483+ outputCutInnerAixs.dim;
497 inputCutOuterAixs.stride = inputCutInnerAixs.dim * inputCutInnerAixs.stride;484 inputCutOuterAixs.stride = inputCutInnerAixs.dim * inputCutInnerAixs.stride;
498 outputCutOuterAixs.stride = outputCutInnerAixs.dim * outputCutInnerAixs.stride;485 outputCutOuterAixs.stride = outputCutInnerAixs.dim * outputCutInnerAixs.stride;
499 }486 }
@@ -507,15 +494,14 @@ bool DualCutAxisSeeker::CutTwoAxis(
507 return true;494 return true;
508}495}
509 496 
510-bool DualCutAxisSeeker::CutOneAxis(497+bool DualCutAxisSeeker::CutOneAxis(unsigned int ubAxisSet, int64_t remainNums, std::vector<AxisInf>& innerAxis,
511- unsigned int ubAxisSet, int64_t remainNums, std::vector<AxisInf>& innerAxis, std::vector<AxisInf>& outerAxis)498+ std::vector<AxisInf>& outerAxis)
512{499{
513 OP_LOGI(context_, "cutOne ubAxisSet: 0x%x", ubAxisSet);500 OP_LOGI(context_, "cutOne ubAxisSet: 0x%x", ubAxisSet);
514 int64_t innerDim = (this->inputCutter->cutFinal) ? (remainNums / alignedFactor * alignedFactor) : remainNums;501 int64_t innerDim = (this->inputCutter->cutFinal) ? (remainNums / alignedFactor * alignedFactor) : remainNums;
515- 502+ 
516 // If zero, throw bad cut.503 // If zero, throw bad cut.
517- OP_CHECK_IF(504+ OP_CHECK_IF((innerDim == 0), OP_LOGW(context_, "innerDim becomes 0, back to sole cut."), return false);
518- (innerDim == 0), OP_LOGW(context_, "innerDim get 0, back to Sole Cut."), return false);
519 int64_t innerStride = this->inputCutter->cutAxisPtr->stride;505 int64_t innerStride = this->inputCutter->cutAxisPtr->stride;
520 int64_t axisIdx = this->inputCutter->cutAxisPtr->idx;506 int64_t axisIdx = this->inputCutter->cutAxisPtr->idx;
521 507 
@@ -95,7 +95,7 @@ ge::graphStatus AsStridedTilingClass::AsStridedSetTilingData(AsStridedTilingData
95 tilingData_->loopsPerCore = tilingData.loopsPerCore;95 tilingData_->loopsPerCore = tilingData.loopsPerCore;
96 tilingData_->en32BAligned = tilingData.en32BAligned;96 tilingData_->en32BAligned = tilingData.en32BAligned;
97 97 
98- for(int64_t i = 0; i < TILING_ARRAY_LEN; i++) {98+ for (int64_t i = 0; i < TILING_ARRAY_LEN; i++) {
99 tilingData_->outStrideArr[i] = tilingData.outStrideArr[i];99 tilingData_->outStrideArr[i] = tilingData.outStrideArr[i];
100 tilingData_->innerAxis[i] = tilingData.innerAxis[i];100 tilingData_->innerAxis[i] = tilingData.innerAxis[i];
101 tilingData_->outLoopArr[i] = tilingData.outLoopArr[i];101 tilingData_->outLoopArr[i] = tilingData.outLoopArr[i];
@@ -104,7 +104,7 @@ ge::graphStatus AsStridedTilingClass::AsStridedSetTilingData(AsStridedTilingData
104 tilingData_->gmOutStride[i] = tilingData.gmOutStride[i];104 tilingData_->gmOutStride[i] = tilingData.gmOutStride[i];
105 }105 }
106 106 
107- for(int64_t j = 0; j < TILING_NDDMA_LEN; j++) {107+ for (int64_t j = 0; j < TILING_NDDMA_LEN; j++) {
108 tilingData_->nddmaLoop[j] = tilingData.nddmaLoop[j];108 tilingData_->nddmaLoop[j] = tilingData.nddmaLoop[j];
109 tilingData_->nddmaDstStride[j] = tilingData.nddmaDstStride[j];109 tilingData_->nddmaDstStride[j] = tilingData.nddmaDstStride[j];
110 tilingData_->nddmaTailLoop[j] = tilingData.nddmaTailLoop[j];110 tilingData_->nddmaTailLoop[j] = tilingData.nddmaTailLoop[j];
@@ -114,10 +114,10 @@ ge::graphStatus AsStridedTilingClass::AsStridedSetTilingData(AsStridedTilingData
114 return ge::GRAPH_SUCCESS;114 return ge::GRAPH_SUCCESS;
115}115}
116 116 
117-template<typename T, typename U>117+template <typename T, typename U>
118void copyArrForTiling(T& tiling, const U& tilingParam, int64_t arrLen, int64_t nddmaLen)118void copyArrForTiling(T& tiling, const U& tilingParam, int64_t arrLen, int64_t nddmaLen)
119{119{
120- for(int64_t i = 0; i < arrLen; i++) {120+ for (int64_t i = 0; i < arrLen; i++) {
121 tiling.outStrideArr[i] = tilingParam.outStrideArr[i];121 tiling.outStrideArr[i] = tilingParam.outStrideArr[i];
122 tiling.innerAxis[i] = tilingParam.innerAxis[i];122 tiling.innerAxis[i] = tilingParam.innerAxis[i];
123 tiling.outLoopArr[i] = tilingParam.outLoopArr[i];123 tiling.outLoopArr[i] = tilingParam.outLoopArr[i];
@@ -125,7 +125,7 @@ void copyArrForTiling(T& tiling, const U& tilingParam, int64_t arrLen, int64_t n
125 tiling.gmShape[i] = tilingParam.gmShape[i];125 tiling.gmShape[i] = tilingParam.gmShape[i];
126 }126 }
127 127 
128- for(int64_t j = 0; j < nddmaLen; j++) {128+ for (int64_t j = 0; j < nddmaLen; j++) {
129 tiling.nddmaLoop[j] = tilingParam.nddmaLoop[j];129 tiling.nddmaLoop[j] = tilingParam.nddmaLoop[j];
130 tiling.nddmaDstStride[j] = tilingParam.nddmaDstStride[j];130 tiling.nddmaDstStride[j] = tilingParam.nddmaDstStride[j];
131 tiling.nddmaTailLoop[j] = tilingParam.nddmaTailLoop[j];131 tiling.nddmaTailLoop[j] = tilingParam.nddmaTailLoop[j];
@@ -133,8 +133,7 @@ void copyArrForTiling(T& tiling, const U& tilingParam, int64_t arrLen, int64_t n
133 }133 }
134}134}
135 135 
136-ge::graphStatus AsStridedTilingClass::SetTilingData(AsStridedTilingData& tiling,136+ge::graphStatus AsStridedTilingClass::SetTilingData(AsStridedTilingData& tiling, AsStridedTilingParam& tilingParam)
137- AsStridedTilingParam& tilingParam)
138{137{
139 if (tilingParam.tilingKey != ALL_STRIDES_ZERO_KEY && tilingParam.tilingKey != SIMT_KEY &&138 if (tilingParam.tilingKey != ALL_STRIDES_ZERO_KEY && tilingParam.tilingKey != SIMT_KEY &&
140 tilingParam.tilingKey != WITH_GATHER_KEY) {139 tilingParam.tilingKey != WITH_GATHER_KEY) {
@@ -151,7 +150,8 @@ ge::graphStatus AsStridedTilingClass::SetTilingData(AsStridedTilingData& tiling,
151 tiling.ubFactorTail = tilingParam.ubFactorTail;150 tiling.ubFactorTail = tilingParam.ubFactorTail;
152 tiling.loopsPerCore = tilingParam.loopsPerCore;151 tiling.loopsPerCore = tilingParam.loopsPerCore;
153 tiling.en32BAligned = tilingParam.en32BAligned;152 tiling.en32BAligned = tilingParam.en32BAligned;
154- copyArrForTiling<AsStridedTilingData, AsStridedTilingParam>(tiling, tilingParam, TILING_ARRAY_LEN, TILING_NDDMA_LEN);153+ copyArrForTiling<AsStridedTilingData, AsStridedTilingParam>(tiling, tilingParam, TILING_ARRAY_LEN,
154+ TILING_NDDMA_LEN);
155 this->AsStridedSetTilingData(tiling);155 this->AsStridedSetTilingData(tiling);
156 }156 }
157 return ge::GRAPH_SUCCESS;157 return ge::GRAPH_SUCCESS;
@@ -168,8 +168,8 @@ void AsStridedTilingClass::SetZeroStrideTilingData(AsStridedTilingParam& tilingP
168 168 
169 OP_LOGI(context_, "[SetZeroStrideTilingData]blockNum:%u, ubSizePlatForm:%lu, storageOffset:%ld, \169 OP_LOGI(context_, "[SetZeroStrideTilingData]blockNum:%u, ubSizePlatForm:%lu, storageOffset:%ld, \
170 mainBlockFactor:%ld, tailBlockFactor:%ld.",170 mainBlockFactor:%ld, tailBlockFactor:%ld.",
171- tilingParam.blockNum, tilingParam.ubSizePlatForm, tilingParam.storageOffset,171+ tilingParam.blockNum, tilingParam.ubSizePlatForm, tilingParam.storageOffset, tilingParam.mainBlockFactor,
172- tilingParam.mainBlockFactor, tilingParam.tailBlockFactor);172+ tilingParam.tailBlockFactor);
173}173}
174 174 
175void AsStridedTilingClass::SetSimtTilingData(AsStridedTilingParam& tilingParam)175void AsStridedTilingClass::SetSimtTilingData(AsStridedTilingParam& tilingParam)
@@ -181,7 +181,7 @@ void AsStridedTilingClass::SetSimtTilingData(AsStridedTilingParam& tilingParam)
181 simtTilingData_->mainBlockFactor = tilingParam.mainBlockFactor;181 simtTilingData_->mainBlockFactor = tilingParam.mainBlockFactor;
182 simtTilingData_->tailBlockFactor = tilingParam.tailBlockFactor;182 simtTilingData_->tailBlockFactor = tilingParam.tailBlockFactor;
183 183 
184- for(int64_t i = 0; i < TILING_ARRAY_LEN; i++) {184+ for (int64_t i = 0; i < TILING_ARRAY_LEN; i++) {
185 simtTilingData_->sizeArr[i] = tilingParam.sizeArr[i];185 simtTilingData_->sizeArr[i] = tilingParam.sizeArr[i];
186 simtTilingData_->strideArr[i] = tilingParam.strideArr[i];186 simtTilingData_->strideArr[i] = tilingParam.strideArr[i];
187 simtTilingData_->outSizeStride[i] = tilingParam.outSizeStride[i];187 simtTilingData_->outSizeStride[i] = tilingParam.outSizeStride[i];
@@ -189,8 +189,8 @@ void AsStridedTilingClass::SetSimtTilingData(AsStridedTilingParam& tilingParam)
189 189 
190 OP_LOGI(context_, "[SetSimtTilingData]outDimNum:%u, blockNum:%u, storageOffset:%ld, \190 OP_LOGI(context_, "[SetSimtTilingData]outDimNum:%u, blockNum:%u, storageOffset:%ld, \
191 mainBlockFactor:%ld, tailBlockFactor:%ld.",191 mainBlockFactor:%ld, tailBlockFactor:%ld.",
192- tilingParam.outDimNum, tilingParam.blockNum, tilingParam.storageOffset,192+ tilingParam.outDimNum, tilingParam.blockNum, tilingParam.storageOffset, tilingParam.mainBlockFactor,
193- tilingParam.mainBlockFactor, tilingParam.tailBlockFactor);193+ tilingParam.tailBlockFactor);
194}194}
195 195 
196static void SetWithGatherUbParam(UbParam& tilingDataUbParam, UbParam& ubParam)196static void SetWithGatherUbParam(UbParam& tilingDataUbParam, UbParam& ubParam)
@@ -222,7 +222,7 @@ void AsStridedTilingClass::SetWithGatherTilingData(AsStridedUbGatherParam& ubGat
222 gatherTilingData_->coreOuterAxisFactor = ubGatherParam.coreOuterAxisFactor;222 gatherTilingData_->coreOuterAxisFactor = ubGatherParam.coreOuterAxisFactor;
223 SetWithGatherUbParam(gatherTilingData_->mainBlockUbParam, ubGatherParam.mainBlockUbParam);223 SetWithGatherUbParam(gatherTilingData_->mainBlockUbParam, ubGatherParam.mainBlockUbParam);
224 SetWithGatherUbParam(gatherTilingData_->tailBlockUbParam, ubGatherParam.tailBlockUbParam);224 SetWithGatherUbParam(gatherTilingData_->tailBlockUbParam, ubGatherParam.tailBlockUbParam);
225- for(int64_t i = 0; i < TILING_ARRAY_LEN; i++) {225+ for (int64_t i = 0; i < TILING_ARRAY_LEN; i++) {
226 gatherTilingData_->sizeArr[i] = ubGatherParam.sizeArr[i];226 gatherTilingData_->sizeArr[i] = ubGatherParam.sizeArr[i];
227 gatherTilingData_->strideArr[i] = ubGatherParam.strideArr[i];227 gatherTilingData_->strideArr[i] = ubGatherParam.strideArr[i];
228 gatherTilingData_->idxStrideArr[i] = ubGatherParam.idxStrideArr[i];228 gatherTilingData_->idxStrideArr[i] = ubGatherParam.idxStrideArr[i];
@@ -230,11 +230,12 @@ void AsStridedTilingClass::SetWithGatherTilingData(AsStridedUbGatherParam& ubGat
230 230 
231 OP_LOGI(context_, "[SetWithGatherTilingData]outDimNum:%u, blockNum:%u, mainBlockCnt:%u, storageOffset:%ld, \231 OP_LOGI(context_, "[SetWithGatherTilingData]outDimNum:%u, blockNum:%u, mainBlockCnt:%u, storageOffset:%ld, \
232 ubSizePlatForm:%lu, inUbSize:%u.",232 ubSizePlatForm:%lu, inUbSize:%u.",
233- ubGatherParam.outDimNum, ubGatherParam.blockNum, ubGatherParam.mainBlockCnt, ubGatherParam.storageOffset,233+ ubGatherParam.outDimNum, ubGatherParam.blockNum, ubGatherParam.mainBlockCnt, ubGatherParam.storageOffset,
234- ubGatherParam.ubSizePlatForm, ubGatherParam.inUbSize);234+ ubGatherParam.ubSizePlatForm, ubGatherParam.inUbSize);
235}235}
236 236 
237-void AsStridedTilingClass::NoTilingMergeAxis(AsStridedTilingData& tiling, AsStridedTilingParam& tilingParam, gert::Shape outSize)237+void AsStridedTilingClass::NoTilingMergeAxis(AsStridedTilingData& tiling, AsStridedTilingParam& tilingParam,
238+ gert::Shape outSize)
238{239{
239 OP_LOGD(context_, "NoTilingMergeAxis");240 OP_LOGD(context_, "NoTilingMergeAxis");
240 tilingParam.ubUseFactor = 1;241 tilingParam.ubUseFactor = 1;
@@ -258,8 +259,8 @@ void AsStridedTilingClass::NoTilingMergeAxis(AsStridedTilingData& tiling, AsStri
258 tiling.ubFactor = tilingParam.ubUseFactor;259 tiling.ubFactor = tilingParam.ubUseFactor;
259}260}
260 261 
261-void AsStridedTilingClass::MergeAxisAfterTiling(262+void AsStridedTilingClass::MergeAxisAfterTiling([[maybe_unused]] const AsStridedTilingData& tiling,
262- [[maybe_unused]] const AsStridedTilingData& tiling, AsStridedTilingParam& tilingParam, gert::Shape outSize)263+ AsStridedTilingParam& tilingParam, gert::Shape outSize)
263{264{
264 OP_LOGD(context_, "Start fusing");265 OP_LOGD(context_, "Start fusing");
265 tilingParam.axisOutTotalFactor = tilingParam.outerAxisFactor;266 tilingParam.axisOutTotalFactor = tilingParam.outerAxisFactor;
@@ -292,9 +293,9 @@ void AsStridedTilingClass::MergeAxisAfterTiling(
292 }293 }
293 } else {294 } else {
294 for (uint32_t i = 1; i < tilingParam.innerAxisNum; i++) {295 for (uint32_t i = 1; i < tilingParam.innerAxisNum; i++) {
295- tilingParam.nddmaDstStride[TILING_NDDMA_LEN - 1 - i] =296+ tilingParam.nddmaDstStride[TILING_NDDMA_LEN - 1 - i] = tilingParam.innerAxis[tilingParam.innerAxisNum - i] *
296- tilingParam.innerAxis[tilingParam.innerAxisNum - i] *297+ tilingParam
297- tilingParam.nddmaDstStride[TILING_NDDMA_LEN - 1 - i + 1];298+ .nddmaDstStride[TILING_NDDMA_LEN - 1 - i + 1];
298 }299 }
299 for (uint32_t i = 0; i < tilingParam.innerAxisNum; i++) {300 for (uint32_t i = 0; i < tilingParam.innerAxisNum; i++) {
300 tilingParam.nddmaLoop[i + TILING_NDDMA_LEN - tilingParam.innerAxisNum] = tilingParam.innerAxis[i];301 tilingParam.nddmaLoop[i + TILING_NDDMA_LEN - tilingParam.innerAxisNum] = tilingParam.innerAxis[i];
@@ -304,8 +305,8 @@ void AsStridedTilingClass::MergeAxisAfterTiling(
304 }305 }
305}306}
306 307 
307-static void MergeAxis4MoveAlign(gert::TilingContext* context, 308+static void MergeAxis4MoveAlign(gert::TilingContext* context, AsStridedTilingParam& tilingParam, gert::Shape outSize,
308- AsStridedTilingParam& tilingParam, gert::Shape outSize, gert::Shape outStride, AsStridedTilingData& tiling)309+ gert::Shape outStride, AsStridedTilingData& tiling)
309{310{
310 OP_LOGD(context, "MergeAxis4MoveAlign");311 OP_LOGD(context, "MergeAxis4MoveAlign");
311 tilingParam.axisOutTotalFactor = 1;312 tilingParam.axisOutTotalFactor = 1;
@@ -317,8 +318,8 @@ static void MergeAxis4MoveAlign(gert::TilingContext* context,
317 tilingParam.axisOutTotalFactor *= outSize[i];318 tilingParam.axisOutTotalFactor *= outSize[i];
318 tilingParam.outStrideArr[TILING_ARRAY_LEN - tilingParam.outerAxisNum + i] = outStride[i];319 tilingParam.outStrideArr[TILING_ARRAY_LEN - tilingParam.outerAxisNum + i] = outStride[i];
319 }320 }
320- tilingParam.blockNum =321+ tilingParam.blockNum = tilingParam.axisOutTotalFactor > tilingParam.numCore ? tilingParam.numCore :
321- tilingParam.axisOutTotalFactor > tilingParam.numCore ? tilingParam.numCore : tilingParam.axisOutTotalFactor;322+ tilingParam.axisOutTotalFactor;
322 OP_LOGD(context, "BlockNum: %u", tilingParam.blockNum);323 OP_LOGD(context, "BlockNum: %u", tilingParam.blockNum);
323 324 
324 tilingParam.loopsPerCore = (tilingParam.axisOutTotalFactor + tilingParam.blockNum - 1) / tilingParam.blockNum;325 tilingParam.loopsPerCore = (tilingParam.axisOutTotalFactor + tilingParam.blockNum - 1) / tilingParam.blockNum;
@@ -334,15 +335,17 @@ static void MergeAxis4MoveAlign(gert::TilingContext* context,
334 tilingParam.ubFactorTail = 0;335 tilingParam.ubFactorTail = 0;
335 tilingParam.innerAxisFactorTail = 0;336 tilingParam.innerAxisFactorTail = 0;
336 if ((tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.sizeofDtype) % UB_ALIGN_SIZE != 0) {337 if ((tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.sizeofDtype) % UB_ALIGN_SIZE != 0) {
337- tilingParam.nddmaDstStride[MOVEALIGN_DIM2] =338+ tilingParam.nddmaDstStride[MOVEALIGN_DIM2] = Ops::Base::CeilDiv(tilingParam.nddmaDstStride[MOVEALIGN_DIM2] *
338- Ops::Base::CeilDiv(tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.sizeofDtype, UB_ALIGN_SIZE) *339+ tilingParam.sizeofDtype,
339- UB_ALIGN_SIZE;340+ UB_ALIGN_SIZE) *
340- tilingParam.nddmaDstStride[1] =341+ UB_ALIGN_SIZE;
341- tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.nddmaLoop[MOVEALIGN_DIM2];342+ tilingParam.nddmaDstStride[1] = tilingParam.nddmaDstStride[MOVEALIGN_DIM2] *
343+ tilingParam.nddmaLoop[MOVEALIGN_DIM2];
342 tilingParam.en32BAligned = 1;344 tilingParam.en32BAligned = 1;
343 } else if ((tilingParam.nddmaDstStride[1] * tilingParam.sizeofDtype) % UB_ALIGN_SIZE != 0) {345 } else if ((tilingParam.nddmaDstStride[1] * tilingParam.sizeofDtype) % UB_ALIGN_SIZE != 0) {
344- tilingParam.nddmaDstStride[1] =346+ tilingParam.nddmaDstStride[1] = Ops::Base::CeilDiv(tilingParam.nddmaDstStride[1] * tilingParam.sizeofDtype,
345- Ops::Base::CeilDiv(tilingParam.nddmaDstStride[1] * tilingParam.sizeofDtype, UB_ALIGN_SIZE) * UB_ALIGN_SIZE;347+ UB_ALIGN_SIZE) *
348+ UB_ALIGN_SIZE;
346 tilingParam.en32BAligned = 1;349 tilingParam.en32BAligned = 1;
347 }350 }
348}351}
@@ -352,8 +355,8 @@ inline bool HasDuplicate(gert::TilingContext* context, gert::Shape outStride)
352 // MoveAlign Condition 3355 // MoveAlign Condition 3
353 OP_CHECK_IF(356 OP_CHECK_IF(
354 (outStride.GetDimNum() > VALID_DIM),357 (outStride.GetDimNum() > VALID_DIM),
355- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(context->GetNodeName(), "outStride",358+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(
356- std::to_string(outStride.GetDimNum()).c_str(),359+ context->GetNodeName(), "outStride", std::to_string(outStride.GetDimNum()).c_str(),
357 ("The shape dim of outStride must be within the range [0, " + std::to_string(VALID_DIM) + "].").c_str()),360 ("The shape dim of outStride must be within the range [0, " + std::to_string(VALID_DIM) + "].").c_str()),
358 return false);361 return false);
359 int32_t numStride[VALID_DIM] = {0};362 int32_t numStride[VALID_DIM] = {0};
@@ -405,7 +408,8 @@ inline static bool CheckLastDim(gert::Shape outSize, gert::Shape outStride, cons
405 * 2. The outStride range is larger than 32B.408 * 2. The outStride range is larger than 32B.
406 * 3. The outStride doesn' t have duplicate value.409 * 3. The outStride doesn' t have duplicate value.
407 */410 */
408-inline static bool IsMoveAlign(gert::TilingContext* context, gert::Shape outSize, gert::Shape outStride, AsStridedTilingParam& tilingParam)411+inline static bool IsMoveAlign(gert::TilingContext* context, gert::Shape outSize, gert::Shape outStride,
412+ AsStridedTilingParam& tilingParam)
409{413{
410 if (CheckLastDim(outSize, outStride, tilingParam) && CalStrideRange(outStride, tilingParam) &&414 if (CheckLastDim(outSize, outStride, tilingParam) && CalStrideRange(outStride, tilingParam) &&
411 (!HasDuplicate(context, outStride))) {415 (!HasDuplicate(context, outStride))) {
@@ -440,7 +444,8 @@ inline static bool IsSmallShape(gert::TilingContext* context, gert::Shape outSiz
440}444}
441 445 
442inline static bool CheckBndryForUint16GatherIdx(gert::Shape outSize, gert::Shape outStride,446inline static bool CheckBndryForUint16GatherIdx(gert::Shape outSize, gert::Shape outStride,
443- const AsStridedTilingParam& tilingParam, const AsStridedUbGatherParam& ubGatherParam)447+ const AsStridedTilingParam& tilingParam,
448+ const AsStridedUbGatherParam& ubGatherParam)
444{449{
445 uint32_t dimNum = ubGatherParam.outDimNum - ubGatherParam.tilingAxisIdx;450 uint32_t dimNum = ubGatherParam.outDimNum - ubGatherParam.tilingAxisIdx;
446 if (tilingParam.sizeofDtype > CONST_TWO) {451 if (tilingParam.sizeofDtype > CONST_TWO) {
@@ -462,7 +467,8 @@ inline static bool CheckBndryForUint16GatherIdx(gert::Shape outSize, gert::Shape
462 467 
463inline static bool IsUbGather(gert::TilingContext* context, const AsStridedTilingParam& tilingParam)468inline static bool IsUbGather(gert::TilingContext* context, const AsStridedTilingParam& tilingParam)
464{469{
465- if ((static_cast<uint64_t>(tilingParam.inputSize) * static_cast<uint64_t>(tilingParam.sizeofDtype) < tilingParam.ubSizePlatForm / CONST_FOUR)) {470+ if ((static_cast<uint64_t>(tilingParam.inputSize) * static_cast<uint64_t>(tilingParam.sizeofDtype) <
471+ tilingParam.ubSizePlatForm / CONST_FOUR)) {
466 OP_LOGD(context, "Need UbGather.");472 OP_LOGD(context, "Need UbGather.");
467 return true;473 return true;
468 }474 }
@@ -476,7 +482,7 @@ inline static uint32_t CalcblockNum(const gert::TilingContext* context, uint64_t
476 OP_LOGD(context, "[CalcblockNum]cacheLineSize:%u.", cacheLineSize);482 OP_LOGD(context, "[CalcblockNum]cacheLineSize:%u.", cacheLineSize);
477 return std::min(tilingParam.numCore,483 return std::min(tilingParam.numCore,
478 static_cast<uint32_t>(Ops::Base::CeilDiv(totalOutElement * tilingParam.sizeofDtype,484 static_cast<uint32_t>(Ops::Base::CeilDiv(totalOutElement * tilingParam.sizeofDtype,
479- static_cast<uint64_t>(cacheLineSize))));485+ static_cast<uint64_t>(cacheLineSize))));
480}486}
481 487 
482inline static void SetAllStridesZeroTilingParam(const gert::TilingContext* context, gert::Shape outSize,488inline static void SetAllStridesZeroTilingParam(const gert::TilingContext* context, gert::Shape outSize,
@@ -485,18 +491,17 @@ inline static void SetAllStridesZeroTilingParam(const gert::TilingContext* conte
485 int64_t shapeSize = outSize.GetShapeSize();491 int64_t shapeSize = outSize.GetShapeSize();
486 OP_CHECK_IF(492 OP_CHECK_IF(
487 (shapeSize <= 0),493 (shapeSize <= 0),
488- OP_LOGE_FOR_INVALID_SHAPESIZE_WITH_REASON(context->GetNodeName(), "size",494+ OP_LOGE_FOR_INVALID_SHAPESIZE_WITH_REASON(context->GetNodeName(), "size", std::to_string(shapeSize).c_str(),
489- std::to_string(shapeSize).c_str(),495+ "The shape size of this parameter must be greater than 0."),
490- "The shape size of this parameter must be greater than 0."),
491 return);496 return);
492 uint64_t totalOutElement = static_cast<uint64_t>(shapeSize);497 uint64_t totalOutElement = static_cast<uint64_t>(shapeSize);
493 tilingParam.blockNum = CalcblockNum(context, totalOutElement, tilingParam);498 tilingParam.blockNum = CalcblockNum(context, totalOutElement, tilingParam);
494- tilingParam.mainBlockFactor = static_cast<int64_t>(Ops::Base::CeilDiv(totalOutElement,499+ tilingParam.mainBlockFactor = static_cast<int64_t>(
495- static_cast<uint64_t>(tilingParam.blockNum)));500+ Ops::Base::CeilDiv(totalOutElement, static_cast<uint64_t>(tilingParam.blockNum)));
496- tilingParam.blockNum = static_cast<uint32_t>(Ops::Base::CeilDiv(totalOutElement,501+ tilingParam.blockNum = static_cast<uint32_t>(
497- static_cast<uint64_t>(tilingParam.mainBlockFactor)));502+ Ops::Base::CeilDiv(totalOutElement, static_cast<uint64_t>(tilingParam.mainBlockFactor)));
498 tilingParam.tailBlockFactor = static_cast<int64_t>(totalOutElement) -503 tilingParam.tailBlockFactor = static_cast<int64_t>(totalOutElement) -
499- static_cast<int64_t>(tilingParam.blockNum - 1) * tilingParam.mainBlockFactor;504+ static_cast<int64_t>(tilingParam.blockNum - 1) * tilingParam.mainBlockFactor;
500}505}
501 506 
502inline static void SetSimtTilingParam(const gert::TilingContext* context, gert::Shape outSize, gert::Shape outStride,507inline static void SetSimtTilingParam(const gert::TilingContext* context, gert::Shape outSize, gert::Shape outStride,
@@ -506,12 +511,12 @@ inline static void SetSimtTilingParam(const gert::TilingContext* context, gert::
506 tilingParam.blockNum = CalcblockNum(context, totalOutElement, tilingParam);511 tilingParam.blockNum = CalcblockNum(context, totalOutElement, tilingParam);
507 512 
508 tilingParam.outDimNum = outSize.GetDimNum();513 tilingParam.outDimNum = outSize.GetDimNum();
509- tilingParam.mainBlockFactor = static_cast<int64_t>(Ops::Base::CeilDiv(totalOutElement,514+ tilingParam.mainBlockFactor = static_cast<int64_t>(
510- static_cast<uint64_t>(tilingParam.blockNum)));515+ Ops::Base::CeilDiv(totalOutElement, static_cast<uint64_t>(tilingParam.blockNum)));
511- tilingParam.blockNum = static_cast<uint32_t>(Ops::Base::CeilDiv(totalOutElement,516+ tilingParam.blockNum = static_cast<uint32_t>(
512- static_cast<uint64_t>(tilingParam.mainBlockFactor)));517+ Ops::Base::CeilDiv(totalOutElement, static_cast<uint64_t>(tilingParam.mainBlockFactor)));
513 tilingParam.tailBlockFactor = static_cast<int64_t>(totalOutElement) -518 tilingParam.tailBlockFactor = static_cast<int64_t>(totalOutElement) -
514- static_cast<int64_t>(tilingParam.blockNum - 1) * tilingParam.mainBlockFactor;519+ static_cast<int64_t>(tilingParam.blockNum - 1) * tilingParam.mainBlockFactor;
515 for (uint32_t i = 0; i < tilingParam.outDimNum; i++) {520 for (uint32_t i = 0; i < tilingParam.outDimNum; i++) {
516 tilingParam.sizeArr[i] = outSize[i];521 tilingParam.sizeArr[i] = outSize[i];
517 tilingParam.strideArr[i] = outStride[i];522 tilingParam.strideArr[i] = outStride[i];
@@ -521,14 +526,14 @@ inline static void SetSimtTilingParam(const gert::TilingContext* context, gert::
521 }526 }
522}527}
523 528 
524-inline static void CalcTilingCore(const gert::TilingContext* context, gert::Shape outSize, AsStridedUbGatherParam& ubGatherParam)529+inline static void CalcTilingCore(const gert::TilingContext* context, gert::Shape outSize,
530+ AsStridedUbGatherParam& ubGatherParam)
525{531{
526- OP_CHECK_IF(532+ OP_CHECK_IF((outSize.GetDimNum() <= 0),
527- (outSize.GetDimNum() <= 0),533+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(context->GetNodeName(), "size",
528- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(context->GetNodeName(), "size",534+ std::to_string(outSize.GetDimNum()).c_str(),
529- std::to_string(outSize.GetDimNum()).c_str(),535+ "The shape dim of size must be greater than 0."),
530- "The shape dim of size must be greater than 0."),536+ return);
531- return);
532 uint32_t preSize = 1;537 uint32_t preSize = 1;
533 if (ubGatherParam.blockNum == 1) {538 if (ubGatherParam.blockNum == 1) {
534 ubGatherParam.blockAxisIdx = 0;539 ubGatherParam.blockAxisIdx = 0;
@@ -548,14 +553,15 @@ inline static void CalcTilingCore(const gert::TilingContext* context, gert::Shap
548 ubGatherParam.blockNum = Ops::Base::CeilDiv(ubGatherParam.coreCurAxisFactor, ubGatherParam.coreInnerAxisFactor);553 ubGatherParam.blockNum = Ops::Base::CeilDiv(ubGatherParam.coreCurAxisFactor, ubGatherParam.coreInnerAxisFactor);
549 ubGatherParam.coreInnerAxisTailFactor = ubGatherParam.coreCurAxisFactor -554 ubGatherParam.coreInnerAxisTailFactor = ubGatherParam.coreCurAxisFactor -
550 (ubGatherParam.blockNum - 1) * ubGatherParam.coreInnerAxisFactor;555 (ubGatherParam.blockNum - 1) * ubGatherParam.coreInnerAxisFactor;
551- ubGatherParam.coreOuterAxisFactor = static_cast<uint32_t>(Ops::Base::CeilDiv(outSize[ubGatherParam.blockAxisIdx],556+ ubGatherParam.coreOuterAxisFactor = static_cast<uint32_t>(Ops::Base::CeilDiv(
552- static_cast<int64_t>(ubGatherParam.coreInnerAxisFactor)));557+ outSize[ubGatherParam.blockAxisIdx], static_cast<int64_t>(ubGatherParam.coreInnerAxisFactor)));
553 }558 }
554 559 
555- OP_LOGD(context, "[CalcTilingCore]blockAxisIdx:%u, blockNum:%u.",560+ OP_LOGD(context, "[CalcTilingCore]blockAxisIdx:%u, blockNum:%u.", ubGatherParam.blockAxisIdx,
556- ubGatherParam.blockAxisIdx, ubGatherParam.blockNum);561+ ubGatherParam.blockNum);
557 OP_LOGD(context, "[CalcTilingCore]coreInnerAxisFactor:%u, coreInnerAxisTailFactor:%u, coreOuterAxisFactor:%u",562 OP_LOGD(context, "[CalcTilingCore]coreInnerAxisFactor:%u, coreInnerAxisTailFactor:%u, coreOuterAxisFactor:%u",
558- ubGatherParam.coreInnerAxisFactor, ubGatherParam.coreInnerAxisTailFactor, ubGatherParam.coreOuterAxisFactor);563+ ubGatherParam.coreInnerAxisFactor, ubGatherParam.coreInnerAxisTailFactor,
564+ ubGatherParam.coreOuterAxisFactor);
559}565}
560 566 
561inline static void CalcMaxUbFactor(AsStridedTilingParam& tilingParam, AsStridedUbGatherParam& ubGatherParam,567inline static void CalcMaxUbFactor(AsStridedTilingParam& tilingParam, AsStridedUbGatherParam& ubGatherParam,
@@ -566,7 +572,8 @@ inline static void CalcMaxUbFactor(AsStridedTilingParam& tilingParam, AsStridedU
566 requiredStorageSize += (outSize[i] - 1) * outStride[i];572 requiredStorageSize += (outSize[i] - 1) * outStride[i];
567 }573 }
568 ubGatherParam.inDataLen = requiredStorageSize + 1;574 ubGatherParam.inDataLen = requiredStorageSize + 1;
569- ubGatherParam.inUbSize = Ops::Base::CeilDiv(ubGatherParam.inDataLen * tilingParam.sizeofDtype, UB_ALIGN_SIZE) * UB_ALIGN_SIZE;575+ ubGatherParam.inUbSize = Ops::Base::CeilDiv(ubGatherParam.inDataLen * tilingParam.sizeofDtype, UB_ALIGN_SIZE) *
576+ UB_ALIGN_SIZE;
570 uint32_t outUbAlign = ((tilingParam.ubSizePlatForm - ubGatherParam.inUbSize) / UB_ALIGN_SIZE) * UB_ALIGN_SIZE;577 uint32_t outUbAlign = ((tilingParam.ubSizePlatForm - ubGatherParam.inUbSize) / UB_ALIGN_SIZE) * UB_ALIGN_SIZE;
571 if (tilingParam.sizeofDtype == INPUT_DTYPE_B8) {578 if (tilingParam.sizeofDtype == INPUT_DTYPE_B8) {
572 // b8对应的索引类型是uint16579 // b8对应的索引类型是uint16
@@ -583,14 +590,12 @@ inline static void SetubParamWhenOutAxesLimit(gert::Shape outSize, uint32_t core
583 AsStridedUbGatherParam& ubGatherParam, UbParam& ubParam)590 AsStridedUbGatherParam& ubGatherParam, UbParam& ubParam)
584{591{
585 // 切分思路:ub全载后三根轴,三根轴外到核切分内轴为ub循环次数592 // 切分思路:ub全载后三根轴,三根轴外到核切分内轴为ub循环次数
586- OP_CHECK_IF(593+ OP_CHECK_IF((ubGatherParam.tilingAxisIdx >= TILING_ARRAY_LEN),
587- (ubGatherParam.tilingAxisIdx >= TILING_ARRAY_LEN),594+ OP_LOGE("as_strided", "the axis idx is out of range"), return);
588- OP_LOGE("as_trided", "the axis idx is more than range"), return);
589 OP_CHECK_IF(595 OP_CHECK_IF(
590 (outSize.GetDimNum() == 0),596 (outSize.GetDimNum() == 0),
591- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON("as_strided", "size",597+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON("as_strided", "size", std::to_string(outSize.GetDimNum()).c_str(),
592- std::to_string(outSize.GetDimNum()).c_str(),598+ "The shape dim of size must be greater than 0."),
593- "The shape dim of size must be greater than 0."),
594 return);599 return);
595 ubParam.innerAxisFactor = outSize[ubGatherParam.tilingAxisIdx];600 ubParam.innerAxisFactor = outSize[ubGatherParam.tilingAxisIdx];
596 ubParam.outerAxisFactor = 1;601 ubParam.outerAxisFactor = 1;
@@ -598,7 +603,8 @@ inline static void SetubParamWhenOutAxesLimit(gert::Shape outSize, uint32_t core
598 ubParam.ubFactor = ubGatherParam.preSize;603 ubParam.ubFactor = ubGatherParam.preSize;
599 ubParam.ubFactorTail = ubGatherParam.preSize;604 ubParam.ubFactorTail = ubGatherParam.preSize;
600 ubParam.loopsPerCore = coreInnerAxisFactor;605 ubParam.loopsPerCore = coreInnerAxisFactor;
601- for (int32_t j = static_cast<int32_t>(ubGatherParam.tilingAxisIdx) - 1; j > static_cast<int32_t>(ubGatherParam.blockAxisIdx); j--) {606+ for (int32_t j = static_cast<int32_t>(ubGatherParam.tilingAxisIdx) - 1;
607+ j > static_cast<int32_t>(ubGatherParam.blockAxisIdx); j--) {
602 ubParam.loopsPerCore *= outSize[j];608 ubParam.loopsPerCore *= outSize[j];
603 }609 }
604}610}
@@ -610,15 +616,14 @@ inline static void SetubParamWhenAxesSame(uint32_t coreInnerAxisFactor, uint32_t
610 ubParam.innerAxisFactor = maxUbFactor / ubGatherParam.preSize;616 ubParam.innerAxisFactor = maxUbFactor / ubGatherParam.preSize;
611 ubParam.innerAxisFactor = std::min(coreInnerAxisFactor, ubParam.innerAxisFactor);617 ubParam.innerAxisFactor = std::min(coreInnerAxisFactor, ubParam.innerAxisFactor);
612 ubParam.outerAxisFactor = Ops::Base::CeilDiv(coreInnerAxisFactor, ubParam.innerAxisFactor);618 ubParam.outerAxisFactor = Ops::Base::CeilDiv(coreInnerAxisFactor, ubParam.innerAxisFactor);
613- ubParam.innerAxisFactorTail = coreInnerAxisFactor -619+ ubParam.innerAxisFactorTail = coreInnerAxisFactor - ubParam.innerAxisFactor * (ubParam.outerAxisFactor - 1);
614- ubParam.innerAxisFactor * (ubParam.outerAxisFactor - 1);
615 ubParam.ubFactor = ubGatherParam.preSize * ubParam.innerAxisFactor;620 ubParam.ubFactor = ubGatherParam.preSize * ubParam.innerAxisFactor;
616 ubParam.ubFactorTail = ubGatherParam.preSize * ubParam.innerAxisFactorTail;621 ubParam.ubFactorTail = ubGatherParam.preSize * ubParam.innerAxisFactorTail;
617 ubParam.loopsPerCore = ubParam.outerAxisFactor;622 ubParam.loopsPerCore = ubParam.outerAxisFactor;
618}623}
619 624 
620-inline static void CalctilingCoreWithInAxis(const gert::TilingContext* context, gert::Shape outSize, uint32_t maxUbFactor,625+inline static void CalctilingCoreWithInAxis(const gert::TilingContext* context, gert::Shape outSize,
621- AsStridedUbGatherParam& ubGatherParam)626+ uint32_t maxUbFactor, AsStridedUbGatherParam& ubGatherParam)
622{627{
623 if (ubGatherParam.tilingAxisIdx == 0) {628 if (ubGatherParam.tilingAxisIdx == 0) {
624 SetubParamWhenAxesSame(ubGatherParam.coreInnerAxisFactor, maxUbFactor, ubGatherParam,629 SetubParamWhenAxesSame(ubGatherParam.coreInnerAxisFactor, maxUbFactor, ubGatherParam,
@@ -631,32 +636,33 @@ inline static void CalctilingCoreWithInAxis(const gert::TilingContext* context,
631 outerCoreNum *= outSize[i];636 outerCoreNum *= outSize[i];
632 }637 }
633 uint32_t innerCoreNum = ubGatherParam.blockNumMin / outerCoreNum;638 uint32_t innerCoreNum = ubGatherParam.blockNumMin / outerCoreNum;
634- ubGatherParam.coreInnerAxisFactor = static_cast<uint32_t>(Ops::Base::CeilDiv(outSize[ubGatherParam.blockAxisIdx],639+ ubGatherParam.coreInnerAxisFactor = static_cast<uint32_t>(
635- static_cast<int64_t>(innerCoreNum)));640+ Ops::Base::CeilDiv(outSize[ubGatherParam.blockAxisIdx], static_cast<int64_t>(innerCoreNum)));
636- innerCoreNum = static_cast<uint32_t>(Ops::Base::CeilDiv(outSize[ubGatherParam.blockAxisIdx],641+ innerCoreNum = static_cast<uint32_t>(Ops::Base::CeilDiv(
637- static_cast<int64_t>(ubGatherParam.coreInnerAxisFactor)));642+ outSize[ubGatherParam.blockAxisIdx], static_cast<int64_t>(ubGatherParam.coreInnerAxisFactor)));
638 643 
639 UbParam& ubParam = ubGatherParam.mainBlockUbParam;644 UbParam& ubParam = ubGatherParam.mainBlockUbParam;
640 ubParam.innerAxisFactor = maxUbFactor / ubGatherParam.preSize;645 ubParam.innerAxisFactor = maxUbFactor / ubGatherParam.preSize;
641 ubParam.innerAxisFactor = std::min(ubGatherParam.coreInnerAxisFactor, ubParam.innerAxisFactor);646 ubParam.innerAxisFactor = std::min(ubGatherParam.coreInnerAxisFactor, ubParam.innerAxisFactor);
642 ubParam.outerAxisFactor = Ops::Base::CeilDiv(ubGatherParam.coreInnerAxisFactor, ubParam.innerAxisFactor);647 ubParam.outerAxisFactor = Ops::Base::CeilDiv(ubGatherParam.coreInnerAxisFactor, ubParam.innerAxisFactor);
643 648 
644- ubGatherParam.coreInnerAxisFactor =649+ ubGatherParam.coreInnerAxisFactor = ubParam.innerAxisFactor * ubParam.outerAxisFactor >
645- ubParam.innerAxisFactor * ubParam.outerAxisFactor > outSize[ubGatherParam.blockAxisIdx] ?650+ outSize[ubGatherParam.blockAxisIdx] ?
646- ubGatherParam.coreInnerAxisFactor :651+ ubGatherParam.coreInnerAxisFactor :
647- ubParam.innerAxisFactor * ubParam.outerAxisFactor; // 按主核均分UB修正652+ ubParam.innerAxisFactor * ubParam.outerAxisFactor; // 按主核均分UB修正
648 SetubParamWhenAxesSame(ubGatherParam.coreInnerAxisFactor, maxUbFactor, ubGatherParam,653 SetubParamWhenAxesSame(ubGatherParam.coreInnerAxisFactor, maxUbFactor, ubGatherParam,
649 ubGatherParam.mainBlockUbParam);654 ubGatherParam.mainBlockUbParam);
650- innerCoreNum = std::min(innerCoreNum,655+ innerCoreNum = std::min(innerCoreNum, static_cast<uint32_t>(Ops::Base::CeilDiv(
651- static_cast<uint32_t>(Ops::Base::CeilDiv(outSize[ubGatherParam.blockAxisIdx],656+ outSize[ubGatherParam.blockAxisIdx],
652- static_cast<int64_t>(ubGatherParam.coreInnerAxisFactor))));657+ static_cast<int64_t>(ubGatherParam.coreInnerAxisFactor))));
653 ubGatherParam.coreOuterAxisFactor = innerCoreNum;658 ubGatherParam.coreOuterAxisFactor = innerCoreNum;
654- ubGatherParam.blockNum = innerCoreNum * outerCoreNum; // 再次修正核数659+ ubGatherParam.blockNum = innerCoreNum * outerCoreNum; // 再次修正核数
655 ubGatherParam.mainBlockCnt = (innerCoreNum - 1) * outerCoreNum;660 ubGatherParam.mainBlockCnt = (innerCoreNum - 1) * outerCoreNum;
656 ubGatherParam.coreInnerAxisTailFactor = outSize[ubGatherParam.blockAxisIdx] -661 ubGatherParam.coreInnerAxisTailFactor = outSize[ubGatherParam.blockAxisIdx] -
657 (innerCoreNum - 1) * ubGatherParam.coreInnerAxisFactor;662 (innerCoreNum - 1) * ubGatherParam.coreInnerAxisFactor;
658 if (ubGatherParam.coreInnerAxisTailFactor > ubGatherParam.coreInnerAxisFactor) {663 if (ubGatherParam.coreInnerAxisTailFactor > ubGatherParam.coreInnerAxisFactor) {
659- OP_LOGE(context,664+ OP_LOGE(
665+ context,
660 "[CalctilingCoreWithInAxis]coreInnerAxisTailFactor is larger than coreInnerAxisFactor, unexpected!!");666 "[CalctilingCoreWithInAxis]coreInnerAxisTailFactor is larger than coreInnerAxisFactor, unexpected!!");
661 }667 }
662 SetubParamWhenAxesSame(ubGatherParam.coreInnerAxisTailFactor, maxUbFactor, ubGatherParam,668 SetubParamWhenAxesSame(ubGatherParam.coreInnerAxisTailFactor, maxUbFactor, ubGatherParam,
@@ -668,37 +674,38 @@ inline static void SetubParamWhenAxesDiff(gert::Shape outSize, uint32_t coreInne
668 AsStridedUbGatherParam& ubGatherParam, UbParam& ubParam)674 AsStridedUbGatherParam& ubGatherParam, UbParam& ubParam)
669{675{
670 ubParam.innerAxisFactor = maxUbFactor / ubGatherParam.preSize;676 ubParam.innerAxisFactor = maxUbFactor / ubGatherParam.preSize;
671- ubParam.outerAxisFactor = static_cast<uint32_t>(Ops::Base::CeilDiv(outSize[ubGatherParam.tilingAxisIdx],677+ ubParam.outerAxisFactor = static_cast<uint32_t>(
672- static_cast<int64_t>(ubParam.innerAxisFactor)));678+ Ops::Base::CeilDiv(outSize[ubGatherParam.tilingAxisIdx], static_cast<int64_t>(ubParam.innerAxisFactor)));
673 ubParam.innerAxisFactorTail = outSize[ubGatherParam.tilingAxisIdx] -679 ubParam.innerAxisFactorTail = outSize[ubGatherParam.tilingAxisIdx] -
674 ubParam.innerAxisFactor * (ubParam.outerAxisFactor - 1);680 ubParam.innerAxisFactor * (ubParam.outerAxisFactor - 1);
675 ubParam.ubFactor = ubGatherParam.preSize * ubParam.innerAxisFactor;681 ubParam.ubFactor = ubGatherParam.preSize * ubParam.innerAxisFactor;
676 ubParam.ubFactorTail = ubGatherParam.preSize * ubParam.innerAxisFactorTail;682 ubParam.ubFactorTail = ubGatherParam.preSize * ubParam.innerAxisFactorTail;
677 // 核内部轴到ub外部轴的累乘683 // 核内部轴到ub外部轴的累乘
678 ubParam.loopsPerCore = coreInnerAxisFactor * ubParam.outerAxisFactor;684 ubParam.loopsPerCore = coreInnerAxisFactor * ubParam.outerAxisFactor;
679- for (int32_t j = static_cast<int32_t>(ubGatherParam.tilingAxisIdx) - 1; j > static_cast<int32_t>(ubGatherParam.blockAxisIdx); j--) {685+ for (int32_t j = static_cast<int32_t>(ubGatherParam.tilingAxisIdx) - 1;
686+ j > static_cast<int32_t>(ubGatherParam.blockAxisIdx); j--) {
680 ubParam.loopsPerCore *= outSize[j];687 ubParam.loopsPerCore *= outSize[j];
681 }688 }
682}689}
683 690 
684inline static void PrintUbGatherParam(const gert::TilingContext* context, AsStridedUbGatherParam& ubGatherParam)691inline static void PrintUbGatherParam(const gert::TilingContext* context, AsStridedUbGatherParam& ubGatherParam)
685{692{
686- OP_LOGI(context, "[CalcTilingUb]tilingAxisIdx:%u, blockAxisIdx:%u, preSize:%u.",693+ OP_LOGI(context, "[CalcTilingUb]tilingAxisIdx:%u, blockAxisIdx:%u, preSize:%u.", ubGatherParam.tilingAxisIdx,
687- ubGatherParam.tilingAxisIdx, ubGatherParam.blockAxisIdx, ubGatherParam.preSize);694+ ubGatherParam.blockAxisIdx, ubGatherParam.preSize);
688 OP_LOGI(context, "[CalcTilingUb]mainBlockUbParam, innerAxisFactor:%u, innerAxisFactorTail:%u, \695 OP_LOGI(context, "[CalcTilingUb]mainBlockUbParam, innerAxisFactor:%u, innerAxisFactorTail:%u, \
689 outerAxisFactor:%u, ubFactor:%u, ubFactorTail:%u, loopsPerCore:%u.",696 outerAxisFactor:%u, ubFactor:%u, ubFactorTail:%u, loopsPerCore:%u.",
690- ubGatherParam.mainBlockUbParam.innerAxisFactor, ubGatherParam.mainBlockUbParam.innerAxisFactorTail,697+ ubGatherParam.mainBlockUbParam.innerAxisFactor, ubGatherParam.mainBlockUbParam.innerAxisFactorTail,
691- ubGatherParam.mainBlockUbParam.outerAxisFactor, ubGatherParam.mainBlockUbParam.ubFactor,698+ ubGatherParam.mainBlockUbParam.outerAxisFactor, ubGatherParam.mainBlockUbParam.ubFactor,
692- ubGatherParam.mainBlockUbParam.ubFactorTail, ubGatherParam.mainBlockUbParam.loopsPerCore);699+ ubGatherParam.mainBlockUbParam.ubFactorTail, ubGatherParam.mainBlockUbParam.loopsPerCore);
693 OP_LOGI(context, "[CalcTilingUb]tailBlockUbParam, innerAxisFactor:%u, innerAxisFactorTail:%u, \700 OP_LOGI(context, "[CalcTilingUb]tailBlockUbParam, innerAxisFactor:%u, innerAxisFactorTail:%u, \
694 outerAxisFactor:%u, ubFactor:%u, ubFactorTail:%u, loopsPerCore:%u.",701 outerAxisFactor:%u, ubFactor:%u, ubFactorTail:%u, loopsPerCore:%u.",
695- ubGatherParam.tailBlockUbParam.innerAxisFactor, ubGatherParam.tailBlockUbParam.innerAxisFactorTail,702+ ubGatherParam.tailBlockUbParam.innerAxisFactor, ubGatherParam.tailBlockUbParam.innerAxisFactorTail,
696- ubGatherParam.tailBlockUbParam.outerAxisFactor, ubGatherParam.tailBlockUbParam.ubFactor,703+ ubGatherParam.tailBlockUbParam.outerAxisFactor, ubGatherParam.tailBlockUbParam.ubFactor,
697- ubGatherParam.tailBlockUbParam.ubFactorTail, ubGatherParam.tailBlockUbParam.loopsPerCore);704+ ubGatherParam.tailBlockUbParam.ubFactorTail, ubGatherParam.tailBlockUbParam.loopsPerCore);
698}705}
699 706 
700-inline static void CalcTilingUb(const gert::TilingContext* context, gert::Shape outSize, gert::Shape outStride, AsStridedTilingParam& tilingParam,707+inline static void CalcTilingUb(const gert::TilingContext* context, gert::Shape outSize, gert::Shape outStride,
701- AsStridedUbGatherParam& ubGatherParam)708+ AsStridedTilingParam& tilingParam, AsStridedUbGatherParam& ubGatherParam)
702{709{
703 uint32_t maxUbFactor = 0;710 uint32_t maxUbFactor = 0;
704 CalcMaxUbFactor(tilingParam, ubGatherParam, maxUbFactor, outSize, outStride);711 CalcMaxUbFactor(tilingParam, ubGatherParam, maxUbFactor, outSize, outStride);
@@ -746,9 +753,8 @@ inline static void ComputeUbGatherParam(const gert::TilingContext* context, gert
746 int64_t shapeSize = outSize.GetShapeSize();753 int64_t shapeSize = outSize.GetShapeSize();
747 OP_CHECK_IF(754 OP_CHECK_IF(
748 (shapeSize <= 0),755 (shapeSize <= 0),
749- OP_LOGE_FOR_INVALID_SHAPESIZE_WITH_REASON(context->GetNodeName(), "size",756+ OP_LOGE_FOR_INVALID_SHAPESIZE_WITH_REASON(context->GetNodeName(), "size", std::to_string(shapeSize).c_str(),
750- std::to_string(shapeSize).c_str(),757+ "The shape size of this parameter must be greater than 0."),
751- "The shape size of this parameter must be greater than 0."),
752 return);758 return);
753 uint64_t totalOutElement = static_cast<uint64_t>(shapeSize);759 uint64_t totalOutElement = static_cast<uint64_t>(shapeSize);
754 ubGatherParam.blockNum = CalcblockNum(context, totalOutElement, tilingParam);760 ubGatherParam.blockNum = CalcblockNum(context, totalOutElement, tilingParam);
@@ -760,7 +766,8 @@ inline static void ComputeUbGatherParam(const gert::TilingContext* context, gert
760}766}
761 767 
762inline static void SetUbGatherTilingParam(gert::Shape outSize, gert::Shape outStride,768inline static void SetUbGatherTilingParam(gert::Shape outSize, gert::Shape outStride,
763- const AsStridedTilingParam& tilingParam, AsStridedUbGatherParam& ubGatherParam)769+ const AsStridedTilingParam& tilingParam,
770+ AsStridedUbGatherParam& ubGatherParam)
764{771{
765 ubGatherParam.storageOffset = tilingParam.storageOffset;772 ubGatherParam.storageOffset = tilingParam.storageOffset;
766 ubGatherParam.ubSizePlatForm = tilingParam.ubSizePlatForm;773 ubGatherParam.ubSizePlatForm = tilingParam.ubSizePlatForm;
@@ -770,39 +777,38 @@ inline static void SetUbGatherTilingParam(gert::Shape outSize, gert::Shape outSt
770 }777 }
771 778 
772 // 当coreInnerAxisTailFactor大于coreInnerAxisFactor时,此结果非预期779 // 当coreInnerAxisTailFactor大于coreInnerAxisFactor时,此结果非预期
773- ubGatherParam.idxStrideArr[ubGatherParam.tilingAxisIdx] =780+ ubGatherParam.idxStrideArr[ubGatherParam.tilingAxisIdx] = static_cast<uint32_t>(Ops::Base::CeilDiv(
774- static_cast<uint32_t>(Ops::Base::CeilDiv(outSize[ubGatherParam.tilingAxisIdx],781+ outSize[ubGatherParam.tilingAxisIdx], static_cast<int64_t>(ubGatherParam.mainBlockUbParam.innerAxisFactor)));
775- static_cast<int64_t>(ubGatherParam.mainBlockUbParam.innerAxisFactor)));
776 for (int32_t i = ubGatherParam.tilingAxisIdx - 1; i >= 0; i--) {782 for (int32_t i = ubGatherParam.tilingAxisIdx - 1; i >= 0; i--) {
777 ubGatherParam.idxStrideArr[i] = ubGatherParam.idxStrideArr[i + 1] * outSize[i];783 ubGatherParam.idxStrideArr[i] = ubGatherParam.idxStrideArr[i + 1] * outSize[i];
778 }784 }
779}785}
780 786 
781-inline static void MoveAlignForAsStrided(gert::TilingContext* context, 787+inline static void MoveAlignForAsStrided(gert::TilingContext* context, AsStridedTilingParam& tilingParam,
782- AsStridedTilingParam& tilingParam, gert::Shape outSize, gert::Shape outStride, AsStridedTilingData& tiling)788+ gert::Shape outSize, gert::Shape outStride, AsStridedTilingData& tiling)
783{789{
784 if (tilingParam.innerAxisNum == MOVEALIGN_DIM3) {790 if (tilingParam.innerAxisNum == MOVEALIGN_DIM3) {
785 if ((tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.sizeofDtype) % UB_ALIGN_SIZE != 0) {791 if ((tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.sizeofDtype) % UB_ALIGN_SIZE != 0) {
786- tilingParam.nddmaDstStride[MOVEALIGN_DIM2] =792+ tilingParam.nddmaDstStride[MOVEALIGN_DIM2] = Ops::Base::CeilDiv(tilingParam.nddmaDstStride[MOVEALIGN_DIM2] *
787- Ops::Base::CeilDiv(793+ tilingParam.sizeofDtype,
788- tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.sizeofDtype, UB_ALIGN_SIZE) *794+ UB_ALIGN_SIZE) *
789- UB_ALIGN_SIZE;795+ UB_ALIGN_SIZE;
790 tilingParam.nddmaDstStride[1] = 0;796 tilingParam.nddmaDstStride[1] = 0;
791 tilingParam.en32BAligned = 1;797 tilingParam.en32BAligned = 1;
792 }798 }
793 } else if (tilingParam.innerAxisNum == MOVEALIGN_DIM4) {799 } else if (tilingParam.innerAxisNum == MOVEALIGN_DIM4) {
794 if ((tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.sizeofDtype) % UB_ALIGN_SIZE != 0) {800 if ((tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.sizeofDtype) % UB_ALIGN_SIZE != 0) {
795- tilingParam.nddmaDstStride[MOVEALIGN_DIM2] =801+ tilingParam.nddmaDstStride[MOVEALIGN_DIM2] = Ops::Base::CeilDiv(tilingParam.nddmaDstStride[MOVEALIGN_DIM2] *
796- Ops::Base::CeilDiv(802+ tilingParam.sizeofDtype,
797- tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.sizeofDtype, UB_ALIGN_SIZE) *803+ UB_ALIGN_SIZE) *
798- UB_ALIGN_SIZE;804+ UB_ALIGN_SIZE;
799- tilingParam.nddmaDstStride[1] =805+ tilingParam.nddmaDstStride[1] = tilingParam.nddmaDstStride[MOVEALIGN_DIM2] *
800- tilingParam.nddmaDstStride[MOVEALIGN_DIM2] * tilingParam.nddmaLoop[MOVEALIGN_DIM2];806+ tilingParam.nddmaLoop[MOVEALIGN_DIM2];
801 tilingParam.en32BAligned = 1;807 tilingParam.en32BAligned = 1;
802 } else if ((tilingParam.nddmaDstStride[1] * tilingParam.sizeofDtype) % UB_ALIGN_SIZE != 0) {808 } else if ((tilingParam.nddmaDstStride[1] * tilingParam.sizeofDtype) % UB_ALIGN_SIZE != 0) {
803- tilingParam.nddmaDstStride[1] =809+ tilingParam.nddmaDstStride[1] = Ops::Base::CeilDiv(tilingParam.nddmaDstStride[1] * tilingParam.sizeofDtype,
804- Ops::Base::CeilDiv(tilingParam.nddmaDstStride[1] * tilingParam.sizeofDtype, UB_ALIGN_SIZE) *810+ UB_ALIGN_SIZE) *
805- UB_ALIGN_SIZE;811+ UB_ALIGN_SIZE;
806 tilingParam.en32BAligned = 1;812 tilingParam.en32BAligned = 1;
807 }813 }
808 } else if (tilingParam.innerAxisNum >= MOVEALIGN_DIM5) {814 } else if (tilingParam.innerAxisNum >= MOVEALIGN_DIM5) {
@@ -832,11 +838,12 @@ inline static bool CheckDualCut(gert::Shape& outStride, const AsStridedTilingPar
832 ((minimumStrideAxisIdx == tilingParam.tilingAxisIdx) && (minimumStridedByte <= DUAL_CUT_CONDITION2)),838 ((minimumStrideAxisIdx == tilingParam.tilingAxisIdx) && (minimumStridedByte <= DUAL_CUT_CONDITION2)),
833 OP_LOGW("CheckDualCut", "Case#1: Minimum Stride Axis cutted by Sole cut and smaller than 128B, do dual cut"),839 OP_LOGW("CheckDualCut", "Case#1: Minimum Stride Axis cutted by Sole cut and smaller than 128B, do dual cut"),
834 return true);840 return true);
835- 841+ 
836 for (uint32_t i = 0; i < tilingParam.tilingAxisIdx; i++) {842 for (uint32_t i = 0; i < tilingParam.tilingAxisIdx; i++) {
837- OP_CHECK_IF((byteStrides[i] <= DUAL_CUT_CONDITION1),843+ OP_CHECK_IF(
838- OP_LOGW("CheckDualCut", "Case#2: Sole cut outer axis have axis stride smaller than 64 Byte, do dual cut"),844+ (byteStrides[i] <= DUAL_CUT_CONDITION1),
839- return true);845+ OP_LOGW("CheckDualCut", "Case#2: Sole cut outer axis have axis stride smaller than 64 Byte, do dual cut"),
846+ return true);
840 }847 }
841 848 
842 return false;849 return false;
@@ -875,22 +882,21 @@ inline static void SetTilingDataForDualCutting(AsStridedTilingParam& tilingParam
875 tilingParam.nddmaTailLoop[3] = seeker.cutAxisTail02;882 tilingParam.nddmaTailLoop[3] = seeker.cutAxisTail02;
876}883}
877 884 
878-void ProcessB64Data(gert::TilingContext* context, gert::Shape& outSize, gert::Shape& outStride, AsStridedTilingParam& tilingParam) 885+void ProcessB64Data(gert::TilingContext* context, gert::Shape& outSize, gert::Shape& outStride,
886+ AsStridedTilingParam& tilingParam)
879{887{
880 auto outShapeSize = outSize.GetDimNum();888 auto outShapeSize = outSize.GetDimNum();
881 auto outStrideSize = outStride.GetDimNum();889 auto outStrideSize = outStride.GetDimNum();
882 890 
883 // 情况一:不需要进行处理:891 // 情况一:不需要进行处理:
884- OP_CHECK_IF(892+ OP_CHECK_IF((outShapeSize < TILING_NDDMA_LEN), OP_LOGD(context, "the outShape size is less 5, do not process"),
885- (outShapeSize < TILING_NDDMA_LEN),893+ return);
886- OP_LOGD(context, "the outShape size is less 5, do not process"), return);894+ 
887- 895+ OP_CHECK_IF((outShapeSize >= TILING_ARRAY_LEN - 2),
888- OP_CHECK_IF(896+ OP_LOGD(context, "the outShape size is more than or equal 8, do not process"), return);
889- (outShapeSize >= TILING_ARRAY_LEN - 2),
890- OP_LOGD(context, "the outShape size is more than or equal 8, do not process"), return);
891 897 
892 // 情况二:最后一维stride不为1,并且shape大于等于5维,补充一维size=1, stride=1898 // 情况二:最后一维stride不为1,并且shape大于等于5维,补充一维size=1, stride=1
893- if(outStrideSize > 0 && outStride[outStrideSize - 1] != 1) {899+ if (outStrideSize > 0 && outStride[outStrideSize - 1] != 1) {
894 OP_LOGD(context, "#case2: the last outStride is not 1, first add one dim and process");900 OP_LOGD(context, "#case2: the last outStride is not 1, first add one dim and process");
895 outSize.SetDimNum(outShapeSize + 1);901 outSize.SetDimNum(outShapeSize + 1);
896 outSize.SetDim(outShapeSize, 1);902 outSize.SetDim(outShapeSize, 1);
@@ -904,7 +910,7 @@ void ProcessB64Data(gert::TilingContext* context, gert::Shape& outSize, gert::Sh
904 tilingParam.ubSize = (tilingParam.ubSizePlatForm / BUFFER_NUM) / tilingParam.sizeofDtype;910 tilingParam.ubSize = (tilingParam.ubSizePlatForm / BUFFER_NUM) / tilingParam.sizeofDtype;
905 outShapeSize = outSize.GetDimNum();911 outShapeSize = outSize.GetDimNum();
906 outStrideSize = outStride.GetDimNum();912 outStrideSize = outStride.GetDimNum();
907- for(size_t i = 0; i < outStrideSize - 1; i++) {913+ for (size_t i = 0; i < outStrideSize - 1; i++) {
908 outStride[i] *= 2;914 outStride[i] *= 2;
909 }915 }
910 outSize[outShapeSize - 1] *= 2;916 outSize[outShapeSize - 1] *= 2;
@@ -913,7 +919,8 @@ void ProcessB64Data(gert::TilingContext* context, gert::Shape& outSize, gert::Sh
913 return;919 return;
914}920}
915 921 
916-static bool IsStrideAffect(gert::TilingContext* context, const AsStridedTilingParam& tilingParam, gert::Shape outStride, const DualCutAxisSeeker& seeker) 922+static bool IsStrideAffect(gert::TilingContext* context, const AsStridedTilingParam& tilingParam, gert::Shape outStride,
923+ const DualCutAxisSeeker& seeker)
917{924{
918 // 条件一,双切分后的stride小于64B的多于单切分925 // 条件一,双切分后的stride小于64B的多于单切分
919 // 条件二,单切分轴的右侧大的stride更靠近尾轴,假设尾轴之前存在stride小于尾轴,排序的影响926 // 条件二,单切分轴的右侧大的stride更靠近尾轴,假设尾轴之前存在stride小于尾轴,排序的影响
@@ -923,40 +930,42 @@ static bool IsStrideAffect(gert::TilingContext* context, const AsStridedTilingPa
923 bool singleConditionTailMore64 = false;930 bool singleConditionTailMore64 = false;
924 bool singleConditionNotTailLess64 = false;931 bool singleConditionNotTailLess64 = false;
925 932 
926- OP_CHECK_IF(933+ OP_CHECK_IF((outStride.GetDimNum() == 0),
927- (outStride.GetDimNum() == 0),934+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(context->GetNodeName(), "stride",
928- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(context->GetNodeName(), "stride",935+ std::to_string(outStride.GetDimNum()).c_str(),
929- std::to_string(outStride.GetDimNum()).c_str(),936+ "The shape dim of stride must be greater than 0."),
930- "The shape dim of stride must be greater than 0."),937+ return false);
931- return false);
932 938 
933- if((outStride[outStride.GetDimNum() - 1] * tilingParam.sizeofDtype) > DUAL_CUT_CONDITION1) {939+ if ((outStride[outStride.GetDimNum() - 1] * tilingParam.sizeofDtype) > DUAL_CUT_CONDITION1) {
934 singleConditionTailMore64 = true;940 singleConditionTailMore64 = true;
935 }941 }
936 942 
937- for(size_t i = tilingParam.tilingAxisIdx; i < outStride.GetDimNum(); i++) {943+ for (size_t i = tilingParam.tilingAxisIdx; i < outStride.GetDimNum(); i++) {
938- if((outStride[i] * tilingParam.sizeofDtype) > DUAL_CUT_CONDITION1) {944+ if ((outStride[i] * tilingParam.sizeofDtype) > DUAL_CUT_CONDITION1) {
939 singleStrideMore64++;945 singleStrideMore64++;
940- } else if(i != outStride.GetDimNum() - 1) {946+ } else if (i != outStride.GetDimNum() - 1) {
941- singleConditionNotTailLess64 = true;947+ singleConditionNotTailLess64 = true;
942 }948 }
943 }949 }
944 950 
945- for(size_t i = 0; i < seeker.ubAxis.size(); i++) {951+ for (size_t i = 0; i < seeker.ubAxis.size(); i++) {
946- if((seeker.ubInStride[SHAPE_NDDMA_LEN - seeker.ubAxis.size() + i] * tilingParam.sizeofDtype) > DUAL_CUT_CONDITION1) {952+ if ((seeker.ubInStride[SHAPE_NDDMA_LEN - seeker.ubAxis.size() + i] * tilingParam.sizeofDtype) >
953+ DUAL_CUT_CONDITION1) {
947 dualStrideMore64++;954 dualStrideMore64++;
948 }955 }
949 }956 }
950- 957+ 
951- OP_LOGD(958+ OP_LOGD(context,
952- context, "dualStrideMore64: %d, singleStrideMore64 : %d, singleConditionTailMore64 : %d, singleConditionNotTailLess64 : %d", 959+ "dualStrideMore64: %d, singleStrideMore64 : %d, singleConditionTailMore64 : %d, "
960+ "singleConditionNotTailLess64 : %d",
953 dualStrideMore64, singleStrideMore64, singleConditionTailMore64, singleConditionNotTailLess64);961 dualStrideMore64, singleStrideMore64, singleConditionTailMore64, singleConditionNotTailLess64);
954- 962+ 
955- return ( (dualStrideMore64 < singleStrideMore64) || (singleConditionTailMore64 && singleConditionNotTailLess64) );963+ return ((dualStrideMore64 < singleStrideMore64) || (singleConditionTailMore64 && singleConditionNotTailLess64));
956}964}
957 965 
958-ge::graphStatus AsStridedTilingClass::SingleCutOfNDDMAForAsStrided(AsStridedTilingParam& tilingParam, gert::Shape outSize, gert::Shape outStride,966+ge::graphStatus AsStridedTilingClass::SingleCutOfNDDMAForAsStrided(AsStridedTilingParam& tilingParam,
959- AsStridedTilingData& tiling)967+ gert::Shape outSize, gert::Shape outStride,
968+ AsStridedTilingData& tiling)
960{969{
961 auto outShapeSize = outSize.GetDimNum();970 auto outShapeSize = outSize.GetDimNum();
962 auto outStrideSize = outStride.GetDimNum();971 auto outStrideSize = outStride.GetDimNum();
@@ -976,7 +985,10 @@ ge::graphStatus AsStridedTilingClass::SingleCutOfNDDMAForAsStrided(AsStridedTili
976 tilingParam.curAxisFactor = outSize[i] * tilingParam.preSize;985 tilingParam.curAxisFactor = outSize[i] * tilingParam.preSize;
977 curProd = outSize[i] * tilingParam.preSize;986 curProd = outSize[i] * tilingParam.preSize;
978 if (outSize[outShapeSize - 1] % (UB_ALIGN_SIZE / tilingParam.sizeofDtype)) {987 if (outSize[outShapeSize - 1] % (UB_ALIGN_SIZE / tilingParam.sizeofDtype)) {
979- curProd = tilingParam.curAxisFactor / outSize[outShapeSize - 1] * Ops::Base::CeilDiv(static_cast<uint32_t>(outSize[outShapeSize - 1]), (UB_ALIGN_SIZE / tilingParam.sizeofDtype)) * (UB_ALIGN_SIZE / tilingParam.sizeofDtype);988+ curProd = tilingParam.curAxisFactor / outSize[outShapeSize - 1] *
989+ Ops::Base::CeilDiv(static_cast<uint32_t>(outSize[outShapeSize - 1]),
990+ (UB_ALIGN_SIZE / tilingParam.sizeofDtype)) *
991+ (UB_ALIGN_SIZE / tilingParam.sizeofDtype);
980 }992 }
981 if (curProd >= tilingParam.ubSize) {993 if (curProd >= tilingParam.ubSize) {
982 tilingParam.tilingAxisIdx = i;994 tilingParam.tilingAxisIdx = i;
@@ -1003,19 +1015,21 @@ ge::graphStatus AsStridedTilingClass::SingleCutOfNDDMAForAsStrided(AsStridedTili
1003 if ((tilingParam.curAxisFactor % j) == 0) {1015 if ((tilingParam.curAxisFactor % j) == 0) {
1004 tilingParam.outerAxisFactor = tilingParam.curAxisFactor / j;1016 tilingParam.outerAxisFactor = tilingParam.curAxisFactor / j;
1005 if (outSize[i] % tilingParam.outerAxisFactor == 0) {1017 if (outSize[i] % tilingParam.outerAxisFactor == 0) {
1006- 
1007 // 考虑对齐后的size可能会超过可用ub1018 // 考虑对齐后的size可能会超过可用ub
1008 uint32_t tempSize = 0;1019 uint32_t tempSize = 0;
1009 if (i == static_cast<int32_t>(outShapeSize - 1)) {1020 if (i == static_cast<int32_t>(outShapeSize - 1)) {
1010- tempSize = Ops::Base::CeilDiv(j, (UB_ALIGN_SIZE / tilingParam.sizeofDtype)) * (UB_ALIGN_SIZE / tilingParam.sizeofDtype);1021+ tempSize = Ops::Base::CeilDiv(j, (UB_ALIGN_SIZE / tilingParam.sizeofDtype)) *
1022+ (UB_ALIGN_SIZE / tilingParam.sizeofDtype);
1011 } else {1023 } else {
1012 tempSize = j / outSize[outShapeSize - 1];1024 tempSize = j / outSize[outShapeSize - 1];
1013- tempSize *= Ops::Base::CeilDiv(static_cast<uint32_t>(outSize[outShapeSize - 1]), (UB_ALIGN_SIZE / tilingParam.sizeofDtype)) * (UB_ALIGN_SIZE / tilingParam.sizeofDtype);1025+ tempSize *= Ops::Base::CeilDiv(static_cast<uint32_t>(outSize[outShapeSize - 1]),
1026+ (UB_ALIGN_SIZE / tilingParam.sizeofDtype)) *
1027+ (UB_ALIGN_SIZE / tilingParam.sizeofDtype);
1014 }1028 }
1015 if (tilingParam.ubSize < tempSize) {1029 if (tilingParam.ubSize < tempSize) {
1016 continue;1030 continue;
1017 }1031 }
1018- 1032+ 
1019 OP_LOGD(context_, "UB can use %u", j);1033 OP_LOGD(context_, "UB can use %u", j);
1020 OP_LOGD(context_, "Can be total tiling");1034 OP_LOGD(context_, "Can be total tiling");
1021 tilingParam.innerAxisFactor = outSize[i] / tilingParam.outerAxisFactor;1035 tilingParam.innerAxisFactor = outSize[i] / tilingParam.outerAxisFactor;
@@ -1033,12 +1047,13 @@ ge::graphStatus AsStridedTilingClass::SingleCutOfNDDMAForAsStrided(AsStridedTili
1033 if (i != static_cast<int32_t>(outShapeSize - 1)) {1047 if (i != static_cast<int32_t>(outShapeSize - 1)) {
1034 tilingParam.innerAxisFactor = tilingParam.ubSize / (curProd / outSize[i]);1048 tilingParam.innerAxisFactor = tilingParam.ubSize / (curProd / outSize[i]);
1035 }1049 }
1036- tilingParam.outerAxisFactor =1050+ tilingParam.outerAxisFactor = (outSize[i] + tilingParam.innerAxisFactor - 1) /
1037- (outSize[i] + tilingParam.innerAxisFactor - 1) / tilingParam.innerAxisFactor;1051+ tilingParam.innerAxisFactor;
1038- tilingParam.innerAxisFactorTail =1052+ tilingParam.innerAxisFactorTail = (tilingParam.innerAxisFactor * tilingParam.outerAxisFactor ==
1039- (tilingParam.innerAxisFactor * tilingParam.outerAxisFactor == outSize[i]) ?1053+ outSize[i]) ?
1040- 0 :1054+ 0 :
1041- outSize[i] - tilingParam.innerAxisFactor * (tilingParam.outerAxisFactor - 1);1055+ outSize[i] - tilingParam.innerAxisFactor *
1056+ (tilingParam.outerAxisFactor - 1);
1042 tilingParam.ubFactor = tilingParam.preSize * tilingParam.innerAxisFactor;1057 tilingParam.ubFactor = tilingParam.preSize * tilingParam.innerAxisFactor;
1043 tilingParam.ubFactorTail = tilingParam.preSize * tilingParam.innerAxisFactorTail;1058 tilingParam.ubFactorTail = tilingParam.preSize * tilingParam.innerAxisFactorTail;
1044 tilingParam.tilingFlag = 1;1059 tilingParam.tilingFlag = 1;
@@ -1097,23 +1112,22 @@ ge::graphStatus AsStridedTilingClass::SingleCutOfNDDMAForAsStrided(AsStridedTili
1097 return ge::GRAPH_SUCCESS;1112 return ge::GRAPH_SUCCESS;
1098}1113}
1099 1114 
1100-ge::graphStatus AsStridedTilingClass::NDDMAForAsStrided(1115+ge::graphStatus AsStridedTilingClass::NDDMAForAsStrided(AsStridedTilingParam& tilingParam, gert::Shape outSize,
1101- AsStridedTilingParam& tilingParam, gert::Shape outSize, gert::Shape outStride,1116+ gert::Shape outStride, AsStridedTilingData& tiling)
1102- AsStridedTilingData& tiling)
1103{1117{
1104 OP_LOGD(context_, "Enter SingleTilingForAsStrided");1118 OP_LOGD(context_, "Enter SingleTilingForAsStrided");
1105 1119 
1106- AsStridedTilingParam tempTilingParam = tilingParam; //先保存1120+ AsStridedTilingParam tempTilingParam = tilingParam; // 先保存
1107 1121 
1108 // stride all zero1122 // stride all zero
1109 if (IsAllStridesZero(context_, outStride)) {1123 if (IsAllStridesZero(context_, outStride)) {
1110 SetAllStridesZeroTilingParam(context_, outSize, tilingParam);1124 SetAllStridesZeroTilingParam(context_, outSize, tilingParam);
1111 SetZeroStrideTilingData(tilingParam);1125 SetZeroStrideTilingData(tilingParam);
1112 tilingParam.tilingKey = ALL_STRIDES_ZERO_KEY;1126 tilingParam.tilingKey = ALL_STRIDES_ZERO_KEY;
1113- return ge::GRAPH_SUCCESS; 1127+ return ge::GRAPH_SUCCESS;
1114 }1128 }
1115 1129 
1116- SingleCutOfNDDMAForAsStrided(tilingParam, outSize, outStride, tiling);1130+ SingleCutOfNDDMAForAsStrided(tilingParam, outSize, outStride, tiling);
1117 1131 
1118 // move_align1132 // move_align
1119 tilingParam.movealignFlag = IsMoveAlign(context_, outSize, outStride, tilingParam);1133 tilingParam.movealignFlag = IsMoveAlign(context_, outSize, outStride, tilingParam);
@@ -1128,15 +1142,16 @@ ge::graphStatus AsStridedTilingClass::NDDMAForAsStrided(
1128 if (IsUbGather(context_, tilingParam)) {1142 if (IsUbGather(context_, tilingParam)) {
1129 AsStridedUbGatherParam ubGatherParam;1143 AsStridedUbGatherParam ubGatherParam;
1130 ComputeUbGatherParam(context_, outSize, outStride, tilingParam, ubGatherParam);1144 ComputeUbGatherParam(context_, outSize, outStride, tilingParam, ubGatherParam);
1131- if (CheckBndryForUint16GatherIdx(outSize, outStride, tilingParam, ubGatherParam) && 1145+ if (CheckBndryForUint16GatherIdx(outSize, outStride, tilingParam, ubGatherParam) &&
1132- (ubGatherParam.mainBlockUbParam.ubFactor * tilingParam.sizeofDtype > GATHER_UB_SIZE_LOWER_LIMIT) ) {1146+ (ubGatherParam.mainBlockUbParam.ubFactor * tilingParam.sizeofDtype > GATHER_UB_SIZE_LOWER_LIMIT)) {
1133 SetUbGatherTilingParam(outSize, outStride, tilingParam, ubGatherParam);1147 SetUbGatherTilingParam(outSize, outStride, tilingParam, ubGatherParam);
1134 SetWithGatherTilingData(ubGatherParam);1148 SetWithGatherTilingData(ubGatherParam);
1135 tilingParam.blockNum = ubGatherParam.blockNum;1149 tilingParam.blockNum = ubGatherParam.blockNum;
1136 tilingParam.tilingKey = WITH_GATHER_KEY;1150 tilingParam.tilingKey = WITH_GATHER_KEY;
1137 return ge::GRAPH_SUCCESS;1151 return ge::GRAPH_SUCCESS;
1138 } else {1152 } else {
1139- OP_LOGD(context_, "Exit ubGather template, because gather index exceeds uint16 boundary, or UB factor < 2048B.");1153+ OP_LOGD(context_,
1154+ "Exit ubGather template, because gather index exceeds uint16 boundary, or UB factor < 2048B.");
1140 }1155 }
1141 }1156 }
1142 1157 
@@ -1145,18 +1160,18 @@ ge::graphStatus AsStridedTilingClass::NDDMAForAsStrided(
1145 SetSimtTilingParam(context_, outSize, outStride, tilingParam);1160 SetSimtTilingParam(context_, outSize, outStride, tilingParam);
1146 SetSimtTilingData(tilingParam);1161 SetSimtTilingData(tilingParam);
1147 tilingParam.tilingKey = SIMT_KEY;1162 tilingParam.tilingKey = SIMT_KEY;
1148- return ge::GRAPH_SUCCESS; 1163+ return ge::GRAPH_SUCCESS;
1149 }1164 }
1150 1165 
1151 // 走NDDMA时对b64数据进行处理1166 // 走NDDMA时对b64数据进行处理
1152- if(tilingParam.sizeofDtype == INPUT_DTYPE_B64) {1167+ if (tilingParam.sizeofDtype == INPUT_DTYPE_B64) {
1153- if(outSize.GetDimNum() < TILING_NDDMA_LEN) {1168+ if (outSize.GetDimNum() < TILING_NDDMA_LEN) {
1154 return ge::GRAPH_SUCCESS;1169 return ge::GRAPH_SUCCESS;
1155 }1170 }
1156 tilingParam = tempTilingParam;1171 tilingParam = tempTilingParam;
1157 ProcessB64Data(context_, outSize, outStride, tilingParam);1172 ProcessB64Data(context_, outSize, outStride, tilingParam);
1158 // 重新进行单切分1173 // 重新进行单切分
1159- SingleCutOfNDDMAForAsStrided(tilingParam, outSize, outStride, tiling);1174+ SingleCutOfNDDMAForAsStrided(tilingParam, outSize, outStride, tiling);
1160 return ge::GRAPH_SUCCESS;1175 return ge::GRAPH_SUCCESS;
1161 }1176 }
1162 1177 
@@ -1166,10 +1181,9 @@ ge::graphStatus AsStridedTilingClass::NDDMAForAsStrided(
1166 // DualCut1181 // DualCut
1167 tilingParam.dualCutFlag = CheckDualCut(outStride, tilingParam);1182 tilingParam.dualCutFlag = CheckDualCut(outStride, tilingParam);
1168 bool dualFlag = (tilingParam.dualCutFlag) && (tilingParam.numCore > 0) && (tilingParam.tilingFlag != 0);1183 bool dualFlag = (tilingParam.dualCutFlag) && (tilingParam.numCore > 0) && (tilingParam.tilingFlag != 0);
1169- OP_LOGD(1184+ OP_LOGD(context_, "dualFlag: %d, dualCutFlag = %d, numCore = %u, tilingFlag = %u", dualFlag,
1170- context_, "dualFlag: %d, dualCutFlag = %d, numCore = %u, tilingFlag = %u", dualFlag,1185+ tilingParam.dualCutFlag, tilingParam.numCore, tilingParam.tilingFlag);
1171- tilingParam.dualCutFlag, tilingParam.numCore, tilingParam.tilingFlag);1186+ 
1172-
1173 if (dualFlag) {1187 if (dualFlag) {
1174 int64_t shape[outShapeSize];1188 int64_t shape[outShapeSize];
1175 int64_t strides[outStrideSize];1189 int64_t strides[outStrideSize];
@@ -1180,8 +1194,7 @@ ge::graphStatus AsStridedTilingClass::NDDMAForAsStrided(
1180 1194 
1181 DualCutAxisSeeker seeker(shape, strides, outShapeSize, tilingParam.sizeofDtype, context_);1195 DualCutAxisSeeker seeker(shape, strides, outShapeSize, tilingParam.sizeofDtype, context_);
1182 bool cutSuccess = seeker.FindDualCutAxis(tilingParam.ubSizePlatForm, BUFFER_NUM);1196 bool cutSuccess = seeker.FindDualCutAxis(tilingParam.ubSizePlatForm, BUFFER_NUM);
1183- OP_LOGD(1197+ OP_LOGD(context_, "DualCutSuccess: %d", cutSuccess);
1184- context_, "DualCutSuccess: %d", cutSuccess);
1185 if (cutSuccess) {1198 if (cutSuccess) {
1186 seeker.GenTilingData();1199 seeker.GenTilingData();
1187 seeker.ComputeBlockTiling(tilingParam.numCore);1200 seeker.ComputeBlockTiling(tilingParam.numCore);
@@ -1192,30 +1205,36 @@ ge::graphStatus AsStridedTilingClass::NDDMAForAsStrided(
1192 dualTileSize *= static_cast<int64_t>(seeker.ubShape[i]);1205 dualTileSize *= static_cast<int64_t>(seeker.ubShape[i]);
1193 }1206 }
1194 1207 
1195- int64_t singleTileSize = tilingParam.sizeofDtype; // 单切分tileSize1208+ int64_t singleTileSize = tilingParam.sizeofDtype; // 单切分tileSize
1196 for (int64_t i = 0; i < TILING_NDDMA_LEN; i++) {1209 for (int64_t i = 0; i < TILING_NDDMA_LEN; i++) {
1197 singleTileSize *= static_cast<int64_t>(tilingParam.nddmaLoop[i]);1210 singleTileSize *= static_cast<int64_t>(tilingParam.nddmaLoop[i]);
1198 }1211 }
1199 1212 
1200- bool singleTailMoreDualTail = static_cast<int32_t>(tilingParam.nddmaLoop[TILING_NDDMA_LEN - 1]) > seeker.ubShape[TILING_NDDMA_LEN - 1]; // 单切分尾轴大于双切分尾轴,否则只可能相等1213+ bool singleTailMoreDualTail = static_cast<int32_t>(tilingParam.nddmaLoop[TILING_NDDMA_LEN - 1]) >
1201- bool isStrideAffect = IsStrideAffect(context_, tilingParam, outStride, seeker); // stride对单双切分是否有影响1214+ seeker.ubShape[TILING_NDDMA_LEN -
1202- bool dualTileSizeSatifyCondition = dualTileSize >= singleTileSize || dualTileSize >= DUAL_CUT_CONDITION3; // 双切分是否满足基本的搬运tileSize更好的利用搬运带宽1215+ 1]; // 单切分尾轴大于双切分尾轴否则只可能相等
1216+ bool isStrideAffect = IsStrideAffect(context_, tilingParam, outStride,
1217+ seeker); // stride对单双切分是否有影响
1218+ bool dualTileSizeSatifyCondition =
1219+ dualTileSize >= singleTileSize ||
1220+ dualTileSize >= DUAL_CUT_CONDITION3; // 双切分是否满足基本的搬运tileSize,更好的利用搬运带宽
1203 1221 
1204- if(!dualTileSizeSatifyCondition) {1222+ if (!dualTileSizeSatifyCondition) {
1205- OP_LOGD(1223+ OP_LOGD(context_, "dualTileSizeSatifyCondition: %d, dualTileSize = %ld, singleTileSize = %ld",
1206- context_, "dualTileSizeSatifyCondition: %d, dualTileSize = %ld, singleTileSize = %ld", dualTileSizeSatifyCondition, dualTileSize, singleTileSize);1224+ dualTileSizeSatifyCondition, dualTileSize, singleTileSize);
1207 return ge::GRAPH_SUCCESS;1225 return ge::GRAPH_SUCCESS;
1208 }1226 }
1209- 1227+ 
1210- if(!isStrideAffect && !singleTailMoreDualTail) { // stride对搬运无影响并且单切分的尾轴不大于双切分,考虑连续搬出,走单切分方式1228+ if (!isStrideAffect &&
1211- OP_LOGD(1229+ !singleTailMoreDualTail) { // stride对搬运无影响并且单切分的尾轴不大于双切分,考虑连续搬出,走单切分方式
1212- context_, "isStrideAffect: %d, singleTailMoreDualTail = %d", isStrideAffect, singleTailMoreDualTail);1230+ OP_LOGD(context_, "isStrideAffect: %d, singleTailMoreDualTail = %d", isStrideAffect,
1231+ singleTailMoreDualTail);
1213 return ge::GRAPH_SUCCESS;1232 return ge::GRAPH_SUCCESS;
1214 }1233 }
1215 1234 
1216 tilingParam.tilingKey = DUAL_CUT_KEY;1235 tilingParam.tilingKey = DUAL_CUT_KEY;
1217 SetTilingDataForDualCutting(tilingParam, seeker);1236 SetTilingDataForDualCutting(tilingParam, seeker);
1218- for(int64_t idx = 0; idx < TILING_ARRAY_LEN; idx++) {1237+ for (int64_t idx = 0; idx < TILING_ARRAY_LEN; idx++) {
1219 tiling.gmOutStride[idx] = tilingParam.gmOutStride[idx];1238 tiling.gmOutStride[idx] = tilingParam.gmOutStride[idx];
1220 }1239 }
1221 return ge::GRAPH_SUCCESS;1240 return ge::GRAPH_SUCCESS;
@@ -1224,39 +1243,39 @@ ge::graphStatus AsStridedTilingClass::NDDMAForAsStrided(
1224 return ge::GRAPH_SUCCESS;1243 return ge::GRAPH_SUCCESS;
1225}1244}
1226 1245 
1227-bool CheckInputInfo(gert::TilingContext *context, gert::Shape outSize, gert::Shape outStride, const gert::Shape& xShape,1246+bool CheckInputInfo(gert::TilingContext* context, gert::Shape outSize, gert::Shape outStride, const gert::Shape& xShape,
1228 AsStridedTilingParam& tilingParam)1247 AsStridedTilingParam& tilingParam)
1229{1248{
1230 uint32_t requiredStorageSize = 0;1249 uint32_t requiredStorageSize = 0;
1231 uint32_t originalTensorStorageSize = 1;1250 uint32_t originalTensorStorageSize = 1;
1232 for (size_t i = 0; i < outSize.GetDimNum(); i++) {1251 for (size_t i = 0; i < outSize.GetDimNum(); i++) {
1233 OP_CHECK_IF(outSize[i] < 0,1252 OP_CHECK_IF(outSize[i] < 0,
1234- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "output_size",1253+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(
1235- std::to_string(outSize.GetDim(i)).c_str(),1254+ context->GetNodeName(), "output_size", std::to_string(outSize.GetDim(i)).c_str(),
1236 "The value of output_size must be greater than or equal to 0."),1255 "The value of output_size must be greater than or equal to 0."),
1237 return false);1256 return false);
1238- 1257+ 
1239 OP_CHECK_IF(outStride[i] < 0,1258 OP_CHECK_IF(outStride[i] < 0,
1240- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "output_stride",1259+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(
1241- std::to_string(outStride.GetDim(i)).c_str(),1260+ context->GetNodeName(), "output_stride", std::to_string(outStride.GetDim(i)).c_str(),
1242 "The value of output_stride must be greater than or equal to 0."),1261 "The value of output_stride must be greater than or equal to 0."),
1243 return false);1262 return false);
1244- 1263+ 
1245 requiredStorageSize += (outSize[i] - 1) * outStride[i];1264 requiredStorageSize += (outSize[i] - 1) * outStride[i];
1246 }1265 }
1247 for (uint32_t i = 0; i < xShape.GetDimNum(); i++) {1266 for (uint32_t i = 0; i < xShape.GetDimNum(); i++) {
1248 OP_CHECK_IF(xShape[i] < 0,1267 OP_CHECK_IF(xShape[i] < 0,
1249- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "input_size",1268+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(
1250- std::to_string(xShape.GetDim(i)).c_str(),1269+ context->GetNodeName(), "input_size", std::to_string(xShape.GetDim(i)).c_str(),
1251 "The value of input_size must be greater than or equal to 0."),1270 "The value of input_size must be greater than or equal to 0."),
1252 return false);1271 return false);
1253 originalTensorStorageSize *= xShape.GetDim(i);1272 originalTensorStorageSize *= xShape.GetDim(i);
1254 }1273 }
1255 1274 
1256- OP_CHECK_IF((tilingParam.storageOffset + static_cast<int64_t>(requiredStorageSize)) >= static_cast<int64_t>(originalTensorStorageSize),1275+ OP_CHECK_IF((tilingParam.storageOffset + static_cast<int64_t>(requiredStorageSize)) >=
1257- OP_LOGE(context,1276+ static_cast<int64_t>(originalTensorStorageSize),
1258- "The output element is out of input range!"), return false);1277+ OP_LOGE(context, "The output element is out of input range!"), return false);
1259- 1278+ 
1260 tilingParam.inputSize = originalTensorStorageSize;1279 tilingParam.inputSize = originalTensorStorageSize;
1261 return true;1280 return true;
1262}1281}
@@ -1277,29 +1296,28 @@ ge::graphStatus AsStridedTilingClass::GetAndValidateDataType(AsStridedTilingPara
1277 auto xTensorType = context_->GetInputDesc(0);1296 auto xTensorType = context_->GetInputDesc(0);
1278 OP_CHECK_NULL_WITH_CONTEXT(context_, xTensorType);1297 OP_CHECK_NULL_WITH_CONTEXT(context_, xTensorType);
1279 auto dataType = xTensorType->GetDataType();1298 auto dataType = xTensorType->GetDataType();
1280- OP_CHECK_IF(1299+ OP_CHECK_IF(tilingTypeKeyMap.count(dataType) == 0,
1281- tilingTypeKeyMap.count(dataType) == 0, 1300+ OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(
1282- OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(context_->GetNodeName(), "x",1301+ context_->GetNodeName(), "x", Ops::Base::ToString(dataType).c_str(),
1283- Ops::Base::ToString(dataType).c_str(),1302+ "The dtype of x must be within the range [DT_INT64, DT_UINT64, DT_INT32, DT_UINT32, DT_FLOAT, "
1284- "The dtype of x must be within the range [DT_INT64, DT_UINT64, DT_INT32, DT_UINT32, DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_BF16, DT_INT16, DT_UINT16, DT_BOOL, DT_COMPLEX32, DT_COMPLEX64, DT_HIFLOAT8, DT_FLOAT8_E5M2, DT_FLOAT8_E4M3FN]."),1303+ "DT_FLOAT16, DT_INT8, DT_UINT8, DT_BF16, DT_INT16, DT_UINT16, DT_BOOL, DT_COMPLEX32, DT_COMPLEX64, "
1285- return ge::GRAPH_FAILED);1304+ "DT_HIFLOAT8, DT_FLOAT8_E5M2, DT_FLOAT8_E4M3FN]."),
1305+ return ge::GRAPH_FAILED);
1286 tilingParam.ubSize = (ubSizePlatform / BUFFER_NUM) / tilingTypeKeyMap[dataType];1306 tilingParam.ubSize = (ubSizePlatform / BUFFER_NUM) / tilingTypeKeyMap[dataType];
1287 tilingParam.sizeofDtype = tilingTypeKeyMap[dataType];1307 tilingParam.sizeofDtype = tilingTypeKeyMap[dataType];
1288 tilingParam.tilingKey = tilingTypeKeyMap[dataType];1308 tilingParam.tilingKey = tilingTypeKeyMap[dataType];
1289 return ge::GRAPH_SUCCESS;1309 return ge::GRAPH_SUCCESS;
1290}1310}
1291 1311 
1292-ge::graphStatus AsStridedTilingClass::ExecuteTilingAndSetWorkspace(1312+ge::graphStatus AsStridedTilingClass::ExecuteTilingAndSetWorkspace(AsStridedTilingParam& tilingParam,
1293- AsStridedTilingParam& tilingParam, AsStridedTilingData& tilingData,1313+ AsStridedTilingData& tilingData,
1294- AsStridedRunInfo& runInfo)1314+ AsStridedRunInfo& runInfo)
1295{1315{
1296 ge::graphStatus resOfTiling = NDDMAForAsStrided(tilingParam, runInfo.outputSize, runInfo.outputStride, tilingData);1316 ge::graphStatus resOfTiling = NDDMAForAsStrided(tilingParam, runInfo.outputSize, runInfo.outputStride, tilingData);
1297- OP_CHECK_IF(1317+ OP_CHECK_IF(resOfTiling != ge::GRAPH_SUCCESS, OP_LOGE(context_, "Tiling failed."), return ge::GRAPH_FAILED);
1298- resOfTiling != ge::GRAPH_SUCCESS, OP_LOGE(context_, "Tiling fail."), return ge::GRAPH_FAILED);
1299 1318 
1300 resOfTiling = SetTilingData(tilingData, tilingParam);1319 resOfTiling = SetTilingData(tilingData, tilingParam);
1301- OP_CHECK_IF(resOfTiling != ge::GRAPH_SUCCESS,1320+ OP_CHECK_IF(resOfTiling != ge::GRAPH_SUCCESS, OP_LOGE(context_, "SetTilingData failed."), return ge::GRAPH_FAILED);
1302- OP_LOGE(context_, "SetTilingData fail."), return ge::GRAPH_FAILED);
1303 1321 
1304 size_t usrSize = 0;1322 size_t usrSize = 0;
1305 size_t sysWorkspaceSize = 16 * 1024 * 1024;1323 size_t sysWorkspaceSize = 16 * 1024 * 1024;
@@ -1307,13 +1325,13 @@ ge::graphStatus AsStridedTilingClass::ExecuteTilingAndSetWorkspace(
1307 currentWorkspace[0] = usrSize + sysWorkspaceSize;1325 currentWorkspace[0] = usrSize + sysWorkspaceSize;
1308 context_->SetBlockDim(tilingParam.blockNum);1326 context_->SetBlockDim(tilingParam.blockNum);
1309 context_->SetTilingKey(tilingParam.tilingKey);1327 context_->SetTilingKey(tilingParam.tilingKey);
1310- OP_LOGI(context_, "TilingForAsStridedOfAsc success, blockNum:%u, tilingKey:%u.",1328+ OP_LOGI(context_, "TilingForAsStridedOfAsc success, blockNum:%u, tilingKey:%u.", tilingParam.blockNum,
1311- tilingParam.blockNum, tilingParam.tilingKey);1329+ tilingParam.tilingKey);
1312 return ge::GRAPH_SUCCESS;1330 return ge::GRAPH_SUCCESS;
1313}1331}
1314 1332 
1315ge::graphStatus AsStridedTilingClass::TilingForAsStridedOfAsc(uint32_t maxCoreNum, uint32_t ubSizePlatform,1333ge::graphStatus AsStridedTilingClass::TilingForAsStridedOfAsc(uint32_t maxCoreNum, uint32_t ubSizePlatform,
1316- AsStridedRunInfo& runInfo, int64_t storageOffset)1334+ AsStridedRunInfo& runInfo, int64_t storageOffset)
1317{1335{
1318 OP_LOGD(context_, "Enter TilingForAsStridedOfAsc");1336 OP_LOGD(context_, "Enter TilingForAsStridedOfAsc");
1319 AsStridedTilingParam tilingParam;1337 AsStridedTilingParam tilingParam;
@@ -1325,18 +1343,19 @@ ge::graphStatus AsStridedTilingClass::TilingForAsStridedOfAsc(uint32_t maxCoreNu
1325 auto xTensorShape = context_->GetInputShape(0);1343 auto xTensorShape = context_->GetInputShape(0);
1326 OP_CHECK_NULL_WITH_CONTEXT(context_, xTensorShape);1344 OP_CHECK_NULL_WITH_CONTEXT(context_, xTensorShape);
1327 const gert::Shape& xShape = xTensorShape->GetStorageShape();1345 const gert::Shape& xShape = xTensorShape->GetStorageShape();
1328- OP_CHECK_IF(runInfo.outputSize.GetDimNum() > VALID_DIM, 1346+ OP_CHECK_IF(
1329- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(context_->GetNodeName(), "output_size",1347+ runInfo.outputSize.GetDimNum() > VALID_DIM,
1330- std::to_string(runInfo.outputSize.GetDimNum()).c_str(),1348+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(
1331- ("The shape dim of output_size must be within the range [0, " + std::to_string(VALID_DIM) + "].").c_str()),1349+ context_->GetNodeName(), "output_size", std::to_string(runInfo.outputSize.GetDimNum()).c_str(),
1332- return ge::GRAPH_FAILED);1350+ ("The shape dim of output_size must be within the range [0, " + std::to_string(VALID_DIM) + "].").c_str()),
1351+ return ge::GRAPH_FAILED);
1333 1352 
1334 if (runInfo.outputSize.GetShapeSize() == 0) {1353 if (runInfo.outputSize.GetShapeSize() == 0) {
1335 return HandleEmptyTensor();1354 return HandleEmptyTensor();
1336 }1355 }
1337 1356 
1338 OP_CHECK_IF(!CheckInputInfo(context_, runInfo.outputSize, runInfo.outputStride, xShape, tilingParam),1357 OP_CHECK_IF(!CheckInputInfo(context_, runInfo.outputSize, runInfo.outputStride, xShape, tilingParam),
1339- OP_LOGE(context_, "The input info check failed!"), return ge::GRAPH_FAILED);1358+ OP_LOGE(context_, "The input info check failed!"), return ge::GRAPH_FAILED);
1340 1359 
1341 if (GetAndValidateDataType(tilingParam, ubSizePlatform) != ge::GRAPH_SUCCESS) {1360 if (GetAndValidateDataType(tilingParam, ubSizePlatform) != ge::GRAPH_SUCCESS) {
1342 return ge::GRAPH_FAILED;1361 return ge::GRAPH_FAILED;
@@ -1358,25 +1377,24 @@ static ge::graphStatus TilingForAsStridedArch35(gert::TilingContext* context)
1358 // get const value of storage_offset1377 // get const value of storage_offset
1359 int64_t storage_offset = 0;1378 int64_t storage_offset = 0;
1360 if (Ops::Base::GetConstInt(context, IN_OFFSET, storage_offset)) {1379 if (Ops::Base::GetConstInt(context, IN_OFFSET, storage_offset)) {
1361- OP_LOGI(context, "the storage_offset is const, get value is %ld", storage_offset);1380+ OP_LOGI(context, "the storage_offset is const, get value is %ld", storage_offset);
1362- OP_CHECK_IF(1381+ OP_CHECK_IF(storage_offset < 0,
1363- storage_offset < 0,1382+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(
1364- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "storage_offset",1383+ context->GetNodeName(), "storage_offset", std::to_string(storage_offset).c_str(),
1365- std::to_string(storage_offset).c_str(),1384+ "The value of storage_offset must be greater than or equal to 0."),
1366- "The value of storage_offset must be greater than or equal to 0."),1385+ return ge::GRAPH_FAILED);
1367- return ge::GRAPH_FAILED);
1368 } else {1386 } else {
1369- OP_LOGI(context, "the storage_offset is not const, will use default value 0");1387+ OP_LOGI(context, "the storage_offset is not const, will use default value 0");
1370- storage_offset = 0;1388+ storage_offset = 0;
1371 }1389 }
1372 1390 
1373 AsStridedRunInfo runInfo;1391 AsStridedRunInfo runInfo;
1374- OP_CHECK_IF(!GetSizeAndStride(context, runInfo),1392+ OP_CHECK_IF(!GetSizeAndStride(context, runInfo), OP_LOGE(context, "get const of Size/Stride failed"),
1375- OP_LOGE(context, "get const of Size/Stride failed"),1393+ return ge::GRAPH_FAILED);
1376- return ge::GRAPH_FAILED);1394+ 
1377-
1378 OP_LOGI("AsStridedOutSizeInfoMath", "the out size is:[%s].", Ops::Base::ToString(runInfo.outputSize).c_str());1395 OP_LOGI("AsStridedOutSizeInfoMath", "the out size is:[%s].", Ops::Base::ToString(runInfo.outputSize).c_str());
1379- OP_LOGI("AsStridedOutStridedInfoMath", "the out strided is:[%s].", Ops::Base::ToString(runInfo.outputStride).c_str());1396+ OP_LOGI("AsStridedOutStridedInfoMath", "the out strided is:[%s].",
1397+ Ops::Base::ToString(runInfo.outputStride).c_str());
1380 OP_LOGI("AsStridedStorageOffset", "the storage offset is:[%ld].", storage_offset);1398 OP_LOGI("AsStridedStorageOffset", "the storage offset is:[%ld].", storage_offset);
1381 1399 
1382 // do merge, stride all zero do not merge1400 // do merge, stride all zero do not merge
@@ -1389,7 +1407,7 @@ static ge::graphStatus TilingForAsStridedArch35(gert::TilingContext* context)
1389 1407 
1390 uint32_t maxCoreNum = compile_info->maxCoreNum;1408 uint32_t maxCoreNum = compile_info->maxCoreNum;
1391 uint32_t ubSizePlatform = compile_info->ubSizePlatform;1409 uint32_t ubSizePlatform = compile_info->ubSizePlatform;
1392- AsStridedTilingClass tiling (context);1410+ AsStridedTilingClass tiling(context);
1393 return tiling.TilingForAsStridedOfAsc(maxCoreNum, ubSizePlatform, runInfo, storage_offset);1411 return tiling.TilingForAsStridedOfAsc(maxCoreNum, ubSizePlatform, runInfo, storage_offset);
1394}1412}
1395 1413 
@@ -1402,15 +1420,12 @@ static ge::graphStatus TilingPrepareForAsStridedArch35(gert::TilingParseContext*
1402 OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo);1420 OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo);
1403 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);1421 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);
1404 compile_info->maxCoreNum = ascendcPlatform.GetCoreNumAiv();1422 compile_info->maxCoreNum = ascendcPlatform.GetCoreNumAiv();
1405- OP_CHECK_IF(1423+ OP_CHECK_IF((compile_info->maxCoreNum <= 0), OP_LOGE(context, "The core num is invalid."), return ge::GRAPH_FAILED);
1406- (compile_info->maxCoreNum <= 0), OP_LOGE(context, "The core num is invalid."),
1407- return ge::GRAPH_FAILED);
1408 uint64_t ubSize;1424 uint64_t ubSize;
1409 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);1425 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);
1410 compile_info->ubSizePlatform = static_cast<uint32_t>(ubSize);1426 compile_info->ubSizePlatform = static_cast<uint32_t>(ubSize);
1411- OP_CHECK_IF(1427+ OP_CHECK_IF((compile_info->ubSizePlatform <= 0), OP_LOGE(context, "The ubSize is invalid."),
1412- (compile_info->ubSizePlatform <= 0), OP_LOGE(context, "The ubSize is invalid."),1428+ return ge::GRAPH_FAILED);
1413- return ge::GRAPH_FAILED);
1414 return ge::GRAPH_SUCCESS;1429 return ge::GRAPH_SUCCESS;
1415}1430}
1416 1431 
@@ -1419,4 +1434,4 @@ IMPL_OP_OPTILING(AsStrided)
1419 .TilingParse<AsStridedCompileInfo>(TilingPrepareForAsStridedArch35)1434 .TilingParse<AsStridedCompileInfo>(TilingPrepareForAsStridedArch35)
1420 .TilingInputsDataDependency({IN_SIZE, IN_STRIDE, IN_OFFSET});1435 .TilingInputsDataDependency({IN_SIZE, IN_STRIDE, IN_OFFSET});
1421 1436 
1422-} // namespace optiling1437+} // namespace optiling
@@ -22,33 +22,26 @@ using namespace std;
22 22 
23class AsStridedTiling : public testing::Test {23class AsStridedTiling : public testing::Test {
24protected:24protected:
25- static void SetUpTestCase()25+ static void SetUpTestCase() {}
26- {
27- std::cout << "AsStridedTiling SetUp" << std::endl;
28- }
29 26 
30- static void TearDownTestCase()27+ static void TearDownTestCase() {}
31- {
32- std::cout << "AsStridedTiling TearDown" << std::endl;
33- }
34};28};
35 29 
36TEST_F(AsStridedTiling, as_strided_tiling_test_case1)30TEST_F(AsStridedTiling, as_strided_tiling_test_case1)
37{31{
38 optiling::AsStridedCompileInfo compileInfo = {64, 262144};32 optiling::AsStridedCompileInfo compileInfo = {64, 262144};
39 std::vector<int64_t> inputSizeValues = {3, 2};33 std::vector<int64_t> inputSizeValues = {3, 2};
40- gert::TilingContextPara tilingContextPara(34+ gert::TilingContextPara tilingContextPara("AsStrided",
41- "AsStrided",35+ {{{{4, 4, 3, 3}, {4, 4, 3, 3}}, ge::DT_INT8, ge::FORMAT_ND},
42- {{{{4, 4, 3, 3}, {4, 4, 3, 3}}, ge::DT_INT8, ge::FORMAT_ND},36+ {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},
43- {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},37+ {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},
44- {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},38+ {{{3}, {3}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()}},
45- {{{3}, {3}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()}},39+ {
46- {40+ {
47- {41+ {{{3}, {3}}, ge::DT_INT8, ge::FORMAT_ND},
48- {{{3}, {3}}, ge::DT_INT8, ge::FORMAT_ND},42+ },
49- },43+ },
50- },44+ &compileInfo);
51- &compileInfo);
52 uint64_t expectTilingKey = 400;45 uint64_t expectTilingKey = 400;
53 std::vector<size_t> expectWorkspaces = {16777216};46 std::vector<size_t> expectWorkspaces = {16777216};
54 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);47 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
@@ -58,18 +51,17 @@ TEST_F(AsStridedTiling, as_strided_tiling_test_case2)
58{51{
59 optiling::AsStridedCompileInfo compileInfo = {64, 262144};52 optiling::AsStridedCompileInfo compileInfo = {64, 262144};
60 std::vector<int64_t> inputSizeValues = {3, 2};53 std::vector<int64_t> inputSizeValues = {3, 2};
61- gert::TilingContextPara tilingContextPara(54+ gert::TilingContextPara tilingContextPara("AsStrided",
62- "AsStrided",55+ {{{{4, 4, 3, 3}, {4, 4, 3, 3}}, ge::DT_FLOAT16, ge::FORMAT_ND},
63- {{{{4, 4, 3, 3}, {4, 4, 3, 3}}, ge::DT_FLOAT16, ge::FORMAT_ND},56+ {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},
64- {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},57+ {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},
65- {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},58+ {{{3}, {3}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()}},
66- {{{3}, {3}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()}},59+ {
67- {60+ {
68- {61+ {{{3}, {3}}, ge::DT_FLOAT16, ge::FORMAT_ND},
69- {{{3}, {3}}, ge::DT_FLOAT16, ge::FORMAT_ND},62+ },
70- },63+ },
71- },64+ &compileInfo);
72- &compileInfo);
73 uint64_t expectTilingKey = 400;65 uint64_t expectTilingKey = 400;
74 std::vector<size_t> expectWorkspaces = {16777216};66 std::vector<size_t> expectWorkspaces = {16777216};
75 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);67 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
@@ -79,18 +71,17 @@ TEST_F(AsStridedTiling, as_strided_tiling_test_case3)
79{71{
80 optiling::AsStridedCompileInfo compileInfo = {64, 262144};72 optiling::AsStridedCompileInfo compileInfo = {64, 262144};
81 std::vector<int64_t> inputSizeValues = {3, 2};73 std::vector<int64_t> inputSizeValues = {3, 2};
82- gert::TilingContextPara tilingContextPara(74+ gert::TilingContextPara tilingContextPara("AsStrided",
83- "AsStrided",75+ {{{{4, 4, 3, 3}, {4, 4, 3, 3}}, ge::DT_FLOAT16, ge::FORMAT_ND},
84- {{{{4, 4, 3, 3}, {4, 4, 3, 3}}, ge::DT_FLOAT16, ge::FORMAT_ND},76+ {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},
85- {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},77+ {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},
86- {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},78+ {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()}},
87- {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()}},79+ {
88- {80+ {
89- {81+ {{{3}, {3}}, ge::DT_FLOAT16, ge::FORMAT_ND},
90- {{{3}, {3}}, ge::DT_FLOAT16, ge::FORMAT_ND},82+ },
91- },83+ },
92- },84+ &compileInfo);
93- &compileInfo);
94 uint64_t expectTilingKey = 400;85 uint64_t expectTilingKey = 400;
95 std::vector<size_t> expectWorkspaces = {16777216};86 std::vector<size_t> expectWorkspaces = {16777216};
96 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);87 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
@@ -100,18 +91,17 @@ TEST_F(AsStridedTiling, as_strided_tiling_test_case4)
100{91{
101 optiling::AsStridedCompileInfo compileInfo = {64, 262144};92 optiling::AsStridedCompileInfo compileInfo = {64, 262144};
102 std::vector<int64_t> inputSizeValues = {3, 2, 6, 6};93 std::vector<int64_t> inputSizeValues = {3, 2, 6, 6};
103- gert::TilingContextPara tilingContextPara(94+ gert::TilingContextPara tilingContextPara("AsStrided",
104- "AsStrided",95+ {{{{4, 4, 3, 3}, {4, 4, 3, 3}}, ge::DT_FLOAT16, ge::FORMAT_ND},
105- {{{{4, 4, 3, 3}, {4, 4, 3, 3}}, ge::DT_FLOAT16, ge::FORMAT_ND},96+ {{{4}, {4}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},
106- {{{4}, {4}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},97+ {{{4}, {4}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},
107- {{{4}, {4}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()},98+ {{{3}, {3}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()}},
108- {{{3}, {3}}, ge::DT_INT64, ge::FORMAT_ND, true, inputSizeValues.data()}},99+ {
109- {100+ {
110- {101+ {{{3}, {3}}, ge::DT_FLOAT16, ge::FORMAT_ND},
111- {{{3}, {3}}, ge::DT_FLOAT16, ge::FORMAT_ND},102+ },
112- },103+ },
113- },104+ &compileInfo);
114- &compileInfo);
115 uint64_t expectTilingKey = 400;105 uint64_t expectTilingKey = 400;
116 std::vector<size_t> expectWorkspaces = {16777216};106 std::vector<size_t> expectWorkspaces = {16777216};
117 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);107 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
@@ -163,18 +153,17 @@ TEST_F(AsStridedTiling, as_strided_tiling_test_case7)
163{153{
164 optiling::AsStridedCompileInfo compileInfo = {64, 262144};154 optiling::AsStridedCompileInfo compileInfo = {64, 262144};
165 std::vector<int64_t> inputSizeValues = {3};155 std::vector<int64_t> inputSizeValues = {3};
166- gert::TilingContextPara tilingContextPara(156+ gert::TilingContextPara tilingContextPara("AsStrided",
167- "AsStrided",157+ {{{{1000, 1000, 512}, {1000, 1000, 512}}, ge::DT_FLOAT16, ge::FORMAT_ND},
168- {{{{1000, 1000, 512}, {1000, 1000, 512}}, ge::DT_FLOAT16, ge::FORMAT_ND},158+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},
169- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},159+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},
170- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},160+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()}},
171- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()}},161+ {
172- {162+ {
173- {163+ {{{124, 2, 80}, {124, 2, 80}}, ge::DT_FLOAT16, ge::FORMAT_ND},
174- {{{124, 2, 80}, {124, 2, 80}}, ge::DT_FLOAT16, ge::FORMAT_ND},164+ },
175- },165+ },
176- },166+ &compileInfo);
177- &compileInfo);
178 uint64_t expectTilingKey = 400;167 uint64_t expectTilingKey = 400;
179 std::vector<size_t> expectWorkspaces = {16777216};168 std::vector<size_t> expectWorkspaces = {16777216};
180 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);169 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
@@ -184,18 +173,17 @@ TEST_F(AsStridedTiling, as_strided_tiling_test_case8)
184{173{
185 optiling::AsStridedCompileInfo compileInfo = {64, 262144};174 optiling::AsStridedCompileInfo compileInfo = {64, 262144};
186 std::vector<int64_t> inputSizeValues = {3};175 std::vector<int64_t> inputSizeValues = {3};
187- gert::TilingContextPara tilingContextPara(176+ gert::TilingContextPara tilingContextPara("AsStrided",
188- "AsStrided",177+ {{{{1000, 1000, 512}, {1000, 1000, 512}}, ge::DT_FLOAT16, ge::FORMAT_ND},
189- {{{{1000, 1000, 512}, {1000, 1000, 512}}, ge::DT_FLOAT16, ge::FORMAT_ND},178+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},
190- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},179+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},
191- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},180+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()}},
192- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()}},181+ {
193- {182+ {
194- {183+ {{{124, 2, 80}, {124, 2, 80}}, ge::DT_FLOAT16, ge::FORMAT_ND},
195- {{{124, 2, 80}, {124, 2, 80}}, ge::DT_FLOAT16, ge::FORMAT_ND},184+ },
196- },185+ },
197- },186+ &compileInfo);
198- &compileInfo);
199 uint64_t expectTilingKey = 400;187 uint64_t expectTilingKey = 400;
200 std::vector<size_t> expectWorkspaces = {16777216};188 std::vector<size_t> expectWorkspaces = {16777216};
201 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);189 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
@@ -205,18 +193,17 @@ TEST_F(AsStridedTiling, as_strided_tiling_test_case9)
205{193{
206 optiling::AsStridedCompileInfo compileInfo = {64, 262144};194 optiling::AsStridedCompileInfo compileInfo = {64, 262144};
207 std::vector<int64_t> inputSizeValues = {1};195 std::vector<int64_t> inputSizeValues = {1};
208- gert::TilingContextPara tilingContextPara(196+ gert::TilingContextPara tilingContextPara("AsStrided",
209- "AsStrided",197+ {{{{3, 3, 3, 3}, {3, 3, 3, 3}}, ge::DT_INT32, ge::FORMAT_ND},
210- {{{{3, 3, 3, 3}, {3, 3, 3, 3}}, ge::DT_INT32, ge::FORMAT_ND},198+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},
211- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},199+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},
212- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()},200+ {{{3}, {3}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()}},
213- {{{3}, {3}}, ge::DT_INT32, ge::FORMAT_ND, true, inputSizeValues.data()}},201+ {
214- {202+ {
215- {203+ {{{1, 1, 1, 1}, {1, 1, 1, 1}}, ge::DT_INT32, ge::FORMAT_ND},
216- {{{1, 1, 1, 1}, {1, 1, 1, 1}}, ge::DT_INT32, ge::FORMAT_ND},204+ },
217- },205+ },
218- },206+ &compileInfo);
219- &compileInfo);
220 uint64_t expectTilingKey = 400;207 uint64_t expectTilingKey = 400;
221 std::vector<size_t> expectWorkspaces = {16777216};208 std::vector<size_t> expectWorkspaces = {16777216};
222 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);209 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
@@ -15,15 +15,9 @@
15 15 
16class AsStridedInfershape : public testing::Test {16class AsStridedInfershape : public testing::Test {
17protected:17protected:
18- static void SetUpTestCase()18+ static void SetUpTestCase() {}
19- {
20- std::cout << "as_strided_test_infershape SetUp" << std::endl;
21- }
22 19 
23- static void TearDownTestCase()20+ static void TearDownTestCase() {}
24- {
25- std::cout << "as_strided_test_infershape SetUp" << std::endl;
26- }
27};21};
28 22 
29TEST_F(AsStridedInfershape, as_strided_infershape_test1)23TEST_F(AsStridedInfershape, as_strided_infershape_test1)
@@ -72,4 +66,4 @@ TEST_F(AsStridedInfershape, as_strided_infershape_test3)
72 });66 });
73 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 0, 5}};67 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 0, 5}};
74 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);68 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
75-}69+}
@@ -37,47 +37,45 @@ using namespace ge;
37using std::map;37using std::map;
38using std::string;38using std::string;
39using std::vector;39using std::vector;
40-#define ADD_INPUT(inputIndex, inputName, inputDtype, inputShape) \40+#define ADD_INPUT(inputIndex, inputName, inputDtype, inputShape) \
41- vector<int64_t> placeholder##inputIndex##_shape = inputShape; \41+ vector<int64_t> placeholder##inputIndex##_shape = inputShape; \
42- auto placeholder##inputIndex = op::Data("placeholder" + inputIndex).set_attr_index(0); \42+ auto placeholder##inputIndex = op::Data("placeholder" + inputIndex).set_attr_index(0); \
43- TensorDesc placeholder##inputIndex##_desc = \43+ TensorDesc placeholder##inputIndex##_desc = TensorDesc(ge::Shape(placeholder##inputIndex##_shape), ge::FORMAT_ND, \
44- TensorDesc(ge::Shape(placeholder##inputIndex##_shape), ge::FORMAT_ND, inputDtype); \44+ inputDtype); \
45- placeholder##inputIndex##_desc.SetPlacement(ge::kPlacementHost); \45+ placeholder##inputIndex##_desc.SetPlacement(ge::kPlacementHost); \
46- placeholder##inputIndex##_desc.SetFormat(ge::FORMAT_ND); \46+ placeholder##inputIndex##_desc.SetFormat(ge::FORMAT_ND); \
47- Tensor tensor_placeholder##inputIndex; \47+ Tensor tensor_placeholder##inputIndex; \
48- ret = GenOnesData( \48+ ret = GenOnesData(placeholder##inputIndex##_shape, tensor_placeholder##inputIndex, placeholder##inputIndex##_desc, \
49- placeholder##inputIndex##_shape, tensor_placeholder##inputIndex, placeholder##inputIndex##_desc, inputDtype, \49+ inputDtype, 2); \
50- 2); \50+ if (ret != SUCCESS) { \
51- if (ret != SUCCESS) { \51+ LOG_PRINT("%s - ERROR - [ASSIGN_GE_IR]: Generate input data failed\n", GetTime().c_str()); \
52- printf("%s - ERROR - [XIR]: Generate input data failed\n", GetTime().c_str()); \52+ return FAILED; \
53- return FAILED; \53+ } \
54- } \54+ placeholder##inputIndex.update_input_desc_x(placeholder##inputIndex##_desc); \
55- placeholder##inputIndex.update_input_desc_x(placeholder##inputIndex##_desc); \55+ input.push_back(tensor_placeholder##inputIndex); \
56- input.push_back(tensor_placeholder##inputIndex); \56+ graph.AddOp(placeholder##inputIndex); \
57- graph.AddOp(placeholder##inputIndex); \57+ add1.set_input_##inputName(placeholder##inputIndex); \
58- add1.set_input_##inputName(placeholder##inputIndex); \
59 inputs.push_back(placeholder##inputIndex)58 inputs.push_back(placeholder##inputIndex)
60 59 
61-#define ADD_CONST_INPUT(inputIndex, inputName, inputDtype, inputShape) \60+#define ADD_CONST_INPUT(inputIndex, inputName, inputDtype, inputShape) \
62- vector<int64_t> placeholder##inputIndex##_shape = inputShape; \61+ vector<int64_t> placeholder##inputIndex##_shape = inputShape; \
63- auto placeholder##inputIndex = op::Const("placeholder" + inputIndex); \62+ auto placeholder##inputIndex = op::Const("placeholder" + inputIndex); \
64- TensorDesc placeholder##inputIndex##_desc = \63+ TensorDesc placeholder##inputIndex##_desc = TensorDesc(ge::Shape(placeholder##inputIndex##_shape), FORMAT_ND, \
65- TensorDesc(ge::Shape(placeholder##inputIndex##_shape), FORMAT_ND, inputDtype); \64+ inputDtype); \
66- placeholder##inputIndex##_desc.SetPlacement(ge::kPlacementHost); \65+ placeholder##inputIndex##_desc.SetPlacement(ge::kPlacementHost); \
67- placeholder##inputIndex##_desc.SetFormat(FORMAT_ND); \66+ placeholder##inputIndex##_desc.SetFormat(FORMAT_ND); \
68- Tensor tensor_placeholder##inputIndex; \67+ Tensor tensor_placeholder##inputIndex; \
69- ret = GenOnesData( \68+ ret = GenOnesData(placeholder##inputIndex##_shape, tensor_placeholder##inputIndex, placeholder##inputIndex##_desc, \
70- placeholder##inputIndex##_shape, tensor_placeholder##inputIndex, placeholder##inputIndex##_desc, inputDtype, \69+ inputDtype, 2); \
71- 2); \70+ if (ret != SUCCESS) { \
72- if (ret != SUCCESS) { \71+ LOG_PRINT("%s - ERROR - [ASSIGN_GE_IR]: Generate input data failed\n", GetTime().c_str()); \
73- printf("%s - ERROR - [XIR]: Generate input data failed\n", GetTime().c_str()); \72+ return FAILED; \
74- return FAILED; \73+ } \
75- } \74+ placeholder##inputIndex.SetAttr("value", tensor_placeholder##inputIndex); \
76- placeholder##inputIndex.SetAttr("value", tensor_placeholder##inputIndex); \75+ placeholder##inputIndex.update_output_desc_y(placeholder##inputIndex##_desc); \
77- placeholder##inputIndex.update_output_desc_y(placeholder##inputIndex##_desc); \76+ graph.AddOp(placeholder##inputIndex); \
78- graph.AddOp(placeholder##inputIndex); \77+ add1.set_input_##inputName(placeholder##inputIndex); \
79- add1.set_input_##inputName(placeholder##inputIndex); \78+ add1.update_input_desc_##inputName(placeholder##inputIndex##_desc); \
80- add1.update_input_desc_##inputName(placeholder##inputIndex##_desc); \
81 inputs.push_back(placeholder##inputIndex)79 inputs.push_back(placeholder##inputIndex)
82 80 
83#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \81#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \
@@ -150,8 +148,8 @@ int32_t GenOnesDataFloat32(vector<int64_t> shapes, Tensor& input_tensor, TensorD
150 return SUCCESS;148 return SUCCESS;
151}149}
152 150 
153-int32_t GenOnesData(151+int32_t GenOnesData(vector<int64_t> shapes, Tensor& input_tensor, TensorDesc& input_tensor_desc, DataType data_type,
154- vector<int64_t> shapes, Tensor& input_tensor, TensorDesc& input_tensor_desc, DataType data_type, int value)152+ int value)
155{153{
156 input_tensor_desc.SetRealDimCnt(shapes.size());154 input_tensor_desc.SetRealDimCnt(shapes.size());
157 size_t size = 1;155 size_t size = 1;
@@ -175,9 +173,8 @@ int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t* inputData)
175 return SUCCESS;173 return SUCCESS;
176}174}
177 175 
178-int CreateOppInGraph(176+int CreateOppInGraph(DataType inDtype, std::vector<ge::Tensor>& input, std::vector<Operator>& inputs,
179- DataType inDtype, std::vector<ge::Tensor>& input, std::vector<Operator>& inputs, std::vector<Operator>& outputs,177+ std::vector<Operator>& outputs, Graph& graph)
180- Graph& graph)
181{178{
182 Status ret = SUCCESS;179 Status ret = SUCCESS;
183 // 自定义代码:添加单算子定义到图中180 // 自定义代码:添加单算子定义到图中
@@ -195,29 +192,29 @@ int CreateOppInGraph(
195 192 
196bool InitEnv()193bool InitEnv()
197{194{
198- printf("%s - INFO - [XIR]: Start to initialize ge using ge global options\n", GetTime().c_str());195+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Start to initialize ge using ge global options\n", GetTime().c_str());
199 std::map<AscendString, AscendString> global_options = {{"ge.exec.deviceId", "0"}, {"ge.graphRunMode", "1"}};196 std::map<AscendString, AscendString> global_options = {{"ge.exec.deviceId", "0"}, {"ge.graphRunMode", "1"}};
200 Status ret = ge::GEInitialize(global_options);197 Status ret = ge::GEInitialize(global_options);
201 if (ret != SUCCESS) {198 if (ret != SUCCESS) {
202- printf("%s - INFO - [XIR]: Initialize ge using ge global options failed\n", GetTime().c_str());199+ LOG_PRINT("%s - ERROR - [ASSIGN_GE_IR]: Initialize ge using ge global options failed\n", GetTime().c_str());
203 return false;200 return false;
204 }201 }
205- printf("%s - INFO - [XIR]: Initialize ge using ge global options success\n", GetTime().c_str());202+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Initialize ge using ge global options success\n", GetTime().c_str());
206 return true;203 return true;
207}204}
208 205 
209bool CreateAndConfigGraph(Graph& graph, std::vector<ge::Tensor>& input)206bool CreateAndConfigGraph(Graph& graph, std::vector<ge::Tensor>& input)
210{207{
211- printf("%s - INFO - [XIR]: Start to CreateAndConfigGraph\n", GetTime().c_str());208+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Start to CreateAndConfigGraph\n", GetTime().c_str());
212 std::vector<Operator> inputs{};209 std::vector<Operator> inputs{};
213 std::vector<Operator> outputs{};210 std::vector<Operator> outputs{};
214 211 
215 DataType inDtype = DT_FLOAT;212 DataType inDtype = DT_FLOAT;
216- std::cout << inDtype << std::endl;213+ LOG_PRINT("inDtype: %d\n", static_cast<int>(inDtype));
217 214 
218 Status ret = CreateOppInGraph(inDtype, input, inputs, outputs, graph);215 Status ret = CreateOppInGraph(inDtype, input, inputs, outputs, graph);
219 if (ret != SUCCESS) {216 if (ret != SUCCESS) {
220- printf("%s - ERROR - [XIR]: Create ir session using build options failed\n", GetTime().c_str());217+ LOG_PRINT("%s - ERROR - [ASSIGN_GE_IR]: Create ir session using build options failed\n", GetTime().c_str());
221 return false;218 return false;
222 }219 }
223 220 
@@ -229,9 +226,9 @@ bool CreateAndConfigGraph(Graph& graph, std::vector<ge::Tensor>& input)
229 226 
230bool AddGraphToSession(ge::Session* session, Graph& graph, uint32_t graph_id)227bool AddGraphToSession(ge::Session* session, Graph& graph, uint32_t graph_id)
231{228{
232- printf("%s - INFO - [XIR]: Create ir session using build options success\n", GetTime().c_str());229+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Create ir session using build options success\n", GetTime().c_str());
233 230 
234- printf("%s - INFO - [XIR]: Start to add compute graph to ir session\n", GetTime().c_str());231+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Start to add compute graph to ir session\n", GetTime().c_str());
235 232 
236 std::map<AscendString, AscendString> graph_options = {233 std::map<AscendString, AscendString> graph_options = {
237 234 
@@ -239,34 +236,33 @@ bool AddGraphToSession(ge::Session* session, Graph& graph, uint32_t graph_id)
239 236 
240 Status ret = session->AddGraph(graph_id, graph, graph_options);237 Status ret = session->AddGraph(graph_id, graph, graph_options);
241 if (ret != SUCCESS) {238 if (ret != SUCCESS) {
242- printf("%s - INFO - [XIR]: Add graph failed\n", GetTime().c_str());239+ LOG_PRINT("%s - ERROR - [ASSIGN_GE_IR]: Add graph failed\n", GetTime().c_str());
243 delete session;240 delete session;
244 ge::GEFinalize();241 ge::GEFinalize();
245 return false;242 return false;
246 }243 }
247- printf("%s - INFO - [XIR]: Session add ir compute graph to ir session success\n", GetTime().c_str());244+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Session add ir compute graph to ir session success\n", GetTime().c_str());
248 245 
249 return true;246 return true;
250}247}
251 248 
252-bool DumpAndRunGraph(249+bool DumpAndRunGraph(ge::Session* session, Graph& graph, std::vector<ge::Tensor>& input,
253- ge::Session* session, Graph& graph, std::vector<ge::Tensor>& input, std::vector<ge::Tensor>& output,250+ std::vector<ge::Tensor>& output, uint32_t graph_id)
254- uint32_t graph_id)
255{251{
256- printf("%s - INFO - [XIR]: dump graph to txt\n", GetTime().c_str());252+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: dump graph to txt\n", GetTime().c_str());
257 std::string file_path = "./dump";253 std::string file_path = "./dump";
258 aclgrphDumpGraph(graph, file_path.c_str(), file_path.length());254 aclgrphDumpGraph(graph, file_path.c_str(), file_path.length());
259 255 
260- printf("%s - INFO - [XIR]: Start to run ir compute graph\n", GetTime().c_str());256+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Start to run ir compute graph\n", GetTime().c_str());
261 257 
262 Status ret = session->RunGraph(graph_id, input, output);258 Status ret = session->RunGraph(graph_id, input, output);
263 if (ret != SUCCESS) {259 if (ret != SUCCESS) {
264- printf("%s - INFO - [XIR]: Run graph failed\n", GetTime().c_str());260+ LOG_PRINT("%s - ERROR - [ASSIGN_GE_IR]: Run graph failed\n", GetTime().c_str());
265 delete session;261 delete session;
266 ge::GEFinalize();262 ge::GEFinalize();
267 return false;263 return false;
268 }264 }
269- printf("%s - INFO - [XIR]: Session run ir compute graph success\n", GetTime().c_str());265+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Session run ir compute graph success\n", GetTime().c_str());
270 return true;266 return true;
271}267}
272 268 
@@ -274,11 +270,11 @@ void ProcessInputData(std::vector<ge::Tensor>& input)
274{270{
275 int input_num = input.size();271 int input_num = input.size();
276 for (int i = 0; i < input_num; i++) {272 for (int i = 0; i < input_num; i++) {
277- std::cout << "input " << i << " dtype : " << input[i].GetTensorDesc().GetDataType() << std::endl;273+ LOG_PRINT("input %d dtype: %d\n", i, static_cast<int>(input[i].GetTensorDesc().GetDataType()));
278 string input_file = "./tc_ge_irrun_test_0008_npu_input_" + std::to_string(i) + ".bin";274 string input_file = "./tc_ge_irrun_test_0008_npu_input_" + std::to_string(i) + ".bin";
279 uint8_t* input_data_i = input[i].GetData();275 uint8_t* input_data_i = input[i].GetData();
280 int64_t input_shape = input[i].GetTensorDesc().GetShape().GetShapeSize();276 int64_t input_shape = input[i].GetTensorDesc().GetShape().GetShapeSize();
281- std::cout << "this is " << i << "th input, input shape size =" << input_shape << std::endl;277+ LOG_PRINT("input %d shape size: %ld\n", i, input_shape);
282 uint32_t data_size = input_shape * GetDataTypeSize(input[i].GetTensorDesc().GetDataType());278 uint32_t data_size = input_shape * GetDataTypeSize(input[i].GetTensorDesc().GetDataType());
283 WriteDataToFile((const char*)input_file.c_str(), data_size, input_data_i);279 WriteDataToFile((const char*)input_file.c_str(), data_size, input_data_i);
284 }280 }
@@ -288,11 +284,11 @@ void ProcessOutputData(std::vector<ge::Tensor>& output)
288{284{
289 int output_num = output.size();285 int output_num = output.size();
290 for (int i = 0; i < output_num; i++) {286 for (int i = 0; i < output_num; i++) {
291- std::cout << "output " << i << " dtype : " << output[i].GetTensorDesc().GetDataType() << std::endl;287+ LOG_PRINT("output %d dtype: %d\n", i, static_cast<int>(output[i].GetTensorDesc().GetDataType()));
292 string output_file = "./tc_ge_irrun_test_0008_npu_output_" + std::to_string(i) + ".bin";288 string output_file = "./tc_ge_irrun_test_0008_npu_output_" + std::to_string(i) + ".bin";
293 uint8_t* output_data_i = output[i].GetData();289 uint8_t* output_data_i = output[i].GetData();
294 int64_t output_shape = output[i].GetTensorDesc().GetShape().GetShapeSize();290 int64_t output_shape = output[i].GetTensorDesc().GetShape().GetShapeSize();
295- std::cout << "this is " << i << "th output, output shape size =" << output_shape << std::endl;291+ LOG_PRINT("output %d shape size: %ld\n", i, output_shape);
296 uint32_t data_size = output_shape * GetDataTypeSize(output[i].GetTensorDesc().GetDataType());292 uint32_t data_size = output_shape * GetDataTypeSize(output[i].GetTensorDesc().GetDataType());
297 WriteDataToFile((const char*)output_file.c_str(), data_size, output_data_i);293 WriteDataToFile((const char*)output_file.c_str(), data_size, output_data_i);
298 for (int64_t j = 0; j < output_shape; j++) {294 for (int64_t j = 0; j < output_shape; j++) {
@@ -305,18 +301,18 @@ int FinalizeRes()
305{301{
306 ge::AscendString error_msg = ge::GEGetErrorMsgV2();302 ge::AscendString error_msg = ge::GEGetErrorMsgV2();
307 std::string error_str(error_msg.GetString());303 std::string error_str(error_msg.GetString());
308- std::cout << "Error message: " << error_str << std::endl;304+ LOG_PRINT("Error message: %s\n", error_str.c_str());
309 ge::AscendString warning_msg = ge::GEGetWarningMsgV2();305 ge::AscendString warning_msg = ge::GEGetWarningMsgV2();
310 std::string warning_str(warning_msg.GetString());306 std::string warning_str(warning_msg.GetString());
311- std::cout << "Warning message: " << warning_str << std::endl;307+ LOG_PRINT("Warning message: %s\n", warning_str.c_str());
312- printf("%s - INFO - [XIR]: Precision is ok\n", GetTime().c_str());308+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Precision is ok\n", GetTime().c_str());
313- printf("%s - INFO - [XIR]: Start to finalize ir graph session\n", GetTime().c_str());309+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Start to finalize ir graph session\n", GetTime().c_str());
314 Status ret = ge::GEFinalize();310 Status ret = ge::GEFinalize();
315 if (ret != SUCCESS) {311 if (ret != SUCCESS) {
316- printf("%s - INFO - [XIR]: Finalize ir graph session failed\n", GetTime().c_str());312+ LOG_PRINT("%s - ERROR - [ASSIGN_GE_IR]: Finalize ir graph session failed\n", GetTime().c_str());
317 return FAILED;313 return FAILED;
318 }314 }
319- printf("%s - INFO - [XIR]: Finalize ir graph session success\n", GetTime().c_str());315+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Finalize ir graph session success\n", GetTime().c_str());
320 return SUCCESS;316 return SUCCESS;
321}317}
322 318 
@@ -339,7 +335,7 @@ int main(int argc, char* argv[])
339 std::map<AscendString, AscendString> build_options = {335 std::map<AscendString, AscendString> build_options = {
340 336 
341 };337 };
342- printf("%s - INFO - [XIR]: Start to create ir session using build options\n", GetTime().c_str());338+ LOG_PRINT("%s - INFO - [ASSIGN_GE_IR]: Start to create ir session using build options\n", GetTime().c_str());
343 ge::Session* session = new Session(build_options);339 ge::Session* session = new Session(build_options);
344 340 
345 uint32_t graph_id = 0;341 uint32_t graph_id = 0;
@@ -59,21 +59,23 @@ static ge::graphStatus CheckDtypeForAssign(const gert::TilingContext* context)
59 auto refPtr = context->GetInputDesc(INDEX_INPUT_REF);59 auto refPtr = context->GetInputDesc(INDEX_INPUT_REF);
60 OP_CHECK_NULL_WITH_CONTEXT(context, refPtr);60 OP_CHECK_NULL_WITH_CONTEXT(context, refPtr);
61 auto refDtype = refPtr->GetDataType();61 auto refDtype = refPtr->GetDataType();
62- OP_CHECK_IF(IsInvalidTypeForAssign(refDtype),62+ OP_CHECK_IF(
63- OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(context->GetNodeName(), "ref",63+ IsInvalidTypeForAssign(refDtype),
64- Ops::Base::ToString(refDtype).c_str(),64+ OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(
65- "The dtype of ref must be within the range [DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT64, DT_UINT64, DT_INT32, DT_UINT32, DT_INT16, DT_UINT16, DT_INT8, DT_UINT8, DT_DOUBLE, DT_BOOL, DT_COMPLEX32, DT_COMPLEX64]."),65+ context->GetNodeName(), "ref", Ops::Base::ToString(refDtype).c_str(),
66+ "The dtype of ref must be within the range [DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT64, DT_UINT64, DT_INT32, "
67+ "DT_UINT32, DT_INT16, DT_UINT16, DT_INT8, DT_UINT8, DT_DOUBLE, DT_BOOL, DT_COMPLEX32, DT_COMPLEX64]."),
66 return ge::GRAPH_FAILED);68 return ge::GRAPH_FAILED);
67 69 
68 auto valuePtr = context->GetInputDesc(INDEX_INPUT_VALUE);70 auto valuePtr = context->GetInputDesc(INDEX_INPUT_VALUE);
69 OP_CHECK_NULL_WITH_CONTEXT(context, valuePtr);71 OP_CHECK_NULL_WITH_CONTEXT(context, valuePtr);
70 auto valueDtype = valuePtr->GetDataType();72 auto valueDtype = valuePtr->GetDataType();
71- OP_CHECK_IF(73+ OP_CHECK_IF(valueDtype != refDtype,
72- valueDtype != refDtype,74+ OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON(
73- OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON(context->GetNodeName(), "ref, value",75+ context->GetNodeName(), "ref, value",
74- (Ops::Base::ToString(refDtype) + ", " + Ops::Base::ToString(valueDtype)).c_str(),76+ (Ops::Base::ToString(refDtype) + ", " + Ops::Base::ToString(valueDtype)).c_str(),
75- "The dtypes of ref and value must be the same."),77+ "The dtypes of ref and value must be the same."),
76- return ge::GRAPH_FAILED);78+ return ge::GRAPH_FAILED);
77 79 
78 return ge::GRAPH_SUCCESS;80 return ge::GRAPH_SUCCESS;
79}81}
@@ -94,10 +96,9 @@ static ge::graphStatus CheckShapeForAssign(const gert::TilingContext* context, A
94 96 
95 tilingParam.tilingKey = 0;97 tilingParam.tilingKey = 0;
96 OP_CHECK_IF(refShape != valueShape,98 OP_CHECK_IF(refShape != valueShape,
97- OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(context->GetNodeName(), "ref, value",99+ OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(context->GetNodeName(), "ref, value", "ref_shape, value_shape",
98- "ref_shape, value_shape",100+ "The shapes of ref and value must be the same."),
99- "The shapes of ref and value must be the same."),101+ return ge::GRAPH_FAILED);
100- return ge::GRAPH_FAILED);
101 102 
102 return ge::GRAPH_SUCCESS;103 return ge::GRAPH_SUCCESS;
103}104}
@@ -113,15 +114,17 @@ static void SetTilingData(TensorMoveTilingData& tilingData, const AssignTilingPa
113 tilingData.set_tilingKey(tilingParam.tilingKey);114 tilingData.set_tilingKey(tilingParam.tilingKey);
114}115}
115 116 
116-static void PrintTilingData(const gert::TilingContext *context, TensorMoveTilingData &tilingData)117+static void PrintTilingData(const gert::TilingContext* context, TensorMoveTilingData& tilingData)
117{118{
118- OP_LOGI(context->GetNodeName(), "Assign tilingData: totalCoreNum:%ld, usedCoreNum:%ld, ubFactor:%ld, tailBlockTailUbFactor:%ld, "119+ OP_LOGI(context->GetNodeName(),
119- "blockFactor:%ld, tailBlockFactor:%ld, tilingKey:%ld ", tilingData.get_totalCoreNum(), tilingData.get_usedCoreNum(),120+ "Assign tilingData: totalCoreNum:%ld, usedCoreNum:%ld, ubFactor:%ld, tailBlockTailUbFactor:%ld, "
120- tilingData.get_ubFactor(), tilingData.get_tailBlockTailUbFactor(), tilingData.get_blockFactor(),121+ "blockFactor:%ld, tailBlockFactor:%ld, tilingKey:%ld ",
121- tilingData.get_tailBlockFactor(), tilingData.get_tilingKey());122+ tilingData.get_totalCoreNum(), tilingData.get_usedCoreNum(), tilingData.get_ubFactor(),
123+ tilingData.get_tailBlockTailUbFactor(), tilingData.get_blockFactor(), tilingData.get_tailBlockFactor(),
124+ tilingData.get_tilingKey());
122}125}
123 126 
124-static void CalcBlockFactor(AssignTilingParam &tilingParam, int64_t numel)127+static void CalcBlockFactor(AssignTilingParam& tilingParam, int64_t numel)
125{128{
126 tilingParam.uo = CeilDiv(numel, tilingParam.ubFactor);129 tilingParam.uo = CeilDiv(numel, tilingParam.ubFactor);
127 tilingParam.tailBlockTailUbFactor = GetRemainder(numel, tilingParam.ubFactor);130 tilingParam.tailBlockTailUbFactor = GetRemainder(numel, tilingParam.ubFactor);
@@ -175,12 +178,12 @@ static ge::graphStatus AssignTilingForAscendC(gert::TilingContext* context)
175{178{
176 OP_LOGD(context->GetNodeName(), "AssignTilingForAscendC running begin.");179 OP_LOGD(context->GetNodeName(), "AssignTilingForAscendC running begin.");
177 180 
178- OP_CHECK_IF(CheckDtypeForAssign(context) != ge::GRAPH_SUCCESS, OP_LOGE(context->GetNodeName(), "The dtype check failed."),181+ OP_CHECK_IF(CheckDtypeForAssign(context) != ge::GRAPH_SUCCESS,
179- return ge::GRAPH_FAILED);182+ OP_LOGE(context->GetNodeName(), "The dtype check failed."), return ge::GRAPH_FAILED);
180 183 
181 AssignTilingParam tilingParam;184 AssignTilingParam tilingParam;
182 OP_CHECK_IF(CheckShapeForAssign(context, tilingParam) != ge::GRAPH_SUCCESS,185 OP_CHECK_IF(CheckShapeForAssign(context, tilingParam) != ge::GRAPH_SUCCESS,
183- OP_LOGE(context->GetNodeName(), "The shape check failed."), return ge::GRAPH_FAILED);186+ OP_LOGE(context->GetNodeName(), "The shape check failed."), return ge::GRAPH_FAILED);
184 187 
185 auto compileInfo = reinterpret_cast<const AssignCompileInfo*>(context->GetCompileInfo());188 auto compileInfo = reinterpret_cast<const AssignCompileInfo*>(context->GetCompileInfo());
186 OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo);189 OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo);
@@ -188,8 +191,8 @@ static ge::graphStatus AssignTilingForAscendC(gert::TilingContext* context)
188 tilingParam.totalCoreNum = compileInfo->coreNum;191 tilingParam.totalCoreNum = compileInfo->coreNum;
189 tilingParam.ubSize = compileInfo->ubSize;192 tilingParam.ubSize = compileInfo->ubSize;
190 193 
191- OP_CHECK_IF(DoTiling(context, tilingParam) != ge::GRAPH_SUCCESS, OP_LOGE(context->GetNodeName(), "Dotiling failed."),194+ OP_CHECK_IF(DoTiling(context, tilingParam) != ge::GRAPH_SUCCESS,
192- return ge::GRAPH_FAILED);195+ OP_LOGE(context->GetNodeName(), "Dotiling failed."), return ge::GRAPH_FAILED);
193 196 
194 // tilingkey由数据类型所占字节表示(1/2/4/8)197 // tilingkey由数据类型所占字节表示(1/2/4/8)
195 tilingParam.tilingKey += tilingParam.bytesForOneData;198 tilingParam.tilingKey += tilingParam.bytesForOneData;
@@ -197,7 +200,7 @@ static ge::graphStatus AssignTilingForAscendC(gert::TilingContext* context)
197 TensorMoveTilingData tilingData;200 TensorMoveTilingData tilingData;
198 SetTilingData(tilingData, tilingParam);201 SetTilingData(tilingData, tilingParam);
199 OP_CHECK_IF(tilingData.GetDataSize() > context->GetRawTilingData()->GetCapacity(),202 OP_CHECK_IF(tilingData.GetDataSize() > context->GetRawTilingData()->GetCapacity(),
200- OP_LOGE(context->GetNodeName(), "set tiling data fail."), return ge::GRAPH_FAILED);203+ OP_LOGE(context->GetNodeName(), "Failed to set tiling data."), return ge::GRAPH_FAILED);
201 tilingData.SaveToBuffer(context->GetRawTilingData()->GetData(), context->GetRawTilingData()->GetCapacity());204 tilingData.SaveToBuffer(context->GetRawTilingData()->GetData(), context->GetRawTilingData()->GetCapacity());
202 context->GetRawTilingData()->SetDataSize(tilingData.GetDataSize());205 context->GetRawTilingData()->SetDataSize(tilingData.GetDataSize());
203 context->SetBlockDim(tilingData.get_usedCoreNum());206 context->SetBlockDim(tilingData.get_usedCoreNum());
@@ -210,10 +213,7 @@ static ge::graphStatus AssignTilingForAscendC(gert::TilingContext* context)
210 return ge::GRAPH_SUCCESS;213 return ge::GRAPH_SUCCESS;
211}214}
212 215 
213-static ge::graphStatus Tiling4Assign(gert::TilingContext* context)216+static ge::graphStatus Tiling4Assign(gert::TilingContext* context) { return AssignTilingForAscendC(context); }
214-{
215- return AssignTilingForAscendC(context);
216-}
217 217 
218static ge::graphStatus TilingPrepare4Assign(gert::TilingParseContext* context)218static ge::graphStatus TilingPrepare4Assign(gert::TilingParseContext* context)
219{219{
@@ -224,11 +224,13 @@ static ge::graphStatus TilingPrepare4Assign(gert::TilingParseContext* context)
224 OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo);224 OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo);
225 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);225 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);
226 compileInfo->coreNum = ascendcPlatform.GetCoreNumAiv();226 compileInfo->coreNum = ascendcPlatform.GetCoreNumAiv();
227- OP_CHECK_IF((compileInfo->coreNum <= 0), OP_LOGE(context->GetNodeName(), "Failed to get core num."), return ge::GRAPH_FAILED);227+ OP_CHECK_IF((compileInfo->coreNum <= 0), OP_LOGE(context->GetNodeName(), "Failed to get core num."),
228+ return ge::GRAPH_FAILED);
228 uint64_t ubSize;229 uint64_t ubSize;
229 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);230 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);
230 compileInfo->ubSize = static_cast<int64_t>(ubSize);231 compileInfo->ubSize = static_cast<int64_t>(ubSize);
231- OP_CHECK_IF((compileInfo->ubSize <= 0), OP_LOGE(context->GetNodeName(), "Failed to get ub size."), return ge::GRAPH_FAILED);232+ OP_CHECK_IF((compileInfo->ubSize <= 0), OP_LOGE(context->GetNodeName(), "Failed to get ub size."),
233+ return ge::GRAPH_FAILED);
232 return ge::GRAPH_SUCCESS;234 return ge::GRAPH_SUCCESS;
233}235}
234 236 
@@ -18,29 +18,24 @@
18using namespace std;18using namespace std;
19 19 
20class AssignTilingTest : public testing::Test {20class AssignTilingTest : public testing::Test {
21- protected:21+protected:
22- static void SetUpTestCase() {22+ static void SetUpTestCase() {}
23- std::cout << "AssignTilingTest SetUp" << std::endl;
24- }
25 23 
26- static void TearDownTestCase() {24+ static void TearDownTestCase() {}
27- std::cout << "AssignTilingTest TearDown" << std::endl;
28- }
29};25};
30 26 
31TEST_F(AssignTilingTest, Assign_tiling_float)27TEST_F(AssignTilingTest, Assign_tiling_float)
32{28{
33 optiling::AssignCompileInfo compileInfo = {64, 253952};29 optiling::AssignCompileInfo compileInfo = {64, 253952};
34- gert::TilingContextPara tilingContextPara(30+ gert::TilingContextPara tilingContextPara("Assign",
35- "Assign",31+ {
36- {32+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
37- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},33+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
38- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},34+ },
39- },35+ {
40- {36+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
41- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},37+ },
42- },38+ &compileInfo);
43- &compileInfo);
44 uint64_t expectTilingKey = 4;39 uint64_t expectTilingKey = 4;
45 string expectTilingData = "64 1 1 1 512 256 4 ";40 string expectTilingData = "64 1 1 1 512 256 4 ";
46 std::vector<size_t> expectWorkspaces = {32};41 std::vector<size_t> expectWorkspaces = {32};
@@ -50,16 +45,15 @@ TEST_F(AssignTilingTest, Assign_tiling_float)
50TEST_F(AssignTilingTest, Assign_tiling_float16)45TEST_F(AssignTilingTest, Assign_tiling_float16)
51{46{
52 optiling::AssignCompileInfo compileInfo = {64, 253952};47 optiling::AssignCompileInfo compileInfo = {64, 253952};
53- gert::TilingContextPara tilingContextPara(48+ gert::TilingContextPara tilingContextPara("Assign",
54- "Assign",49+ {
55- {50+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
56- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},51+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
57- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},52+ },
58- },53+ {
59- {54+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
60- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},55+ },
61- },56+ &compileInfo);
62- &compileInfo);
63 uint64_t expectTilingKey = 2;57 uint64_t expectTilingKey = 2;
64 string expectTilingData = "64 1 1 1 1024 256 2 ";58 string expectTilingData = "64 1 1 1 1024 256 2 ";
65 std::vector<size_t> expectWorkspaces = {32};59 std::vector<size_t> expectWorkspaces = {32};
@@ -69,16 +63,15 @@ TEST_F(AssignTilingTest, Assign_tiling_float16)
69TEST_F(AssignTilingTest, Assign_tiling_int8)63TEST_F(AssignTilingTest, Assign_tiling_int8)
70{64{
71 optiling::AssignCompileInfo compileInfo = {64, 253952};65 optiling::AssignCompileInfo compileInfo = {64, 253952};
72- gert::TilingContextPara tilingContextPara(66+ gert::TilingContextPara tilingContextPara("Assign",
73- "Assign",67+ {
74- {68+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT8, ge::FORMAT_ND},
75- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT8, ge::FORMAT_ND},69+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT8, ge::FORMAT_ND},
76- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT8, ge::FORMAT_ND},70+ },
77- },71+ {
78- {72+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT8, ge::FORMAT_ND},
79- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT8, ge::FORMAT_ND},73+ },
80- },74+ &compileInfo);
81- &compileInfo);
82 uint64_t expectTilingKey = 1;75 uint64_t expectTilingKey = 1;
83 string expectTilingData = "64 1 1 1 2048 256 1 ";76 string expectTilingData = "64 1 1 1 2048 256 1 ";
84 std::vector<size_t> expectWorkspaces = {32};77 std::vector<size_t> expectWorkspaces = {32};
@@ -88,16 +81,15 @@ TEST_F(AssignTilingTest, Assign_tiling_int8)
88TEST_F(AssignTilingTest, Assign_tiling_uint8)81TEST_F(AssignTilingTest, Assign_tiling_uint8)
89{82{
90 optiling::AssignCompileInfo compileInfo = {64, 253952};83 optiling::AssignCompileInfo compileInfo = {64, 253952};
91- gert::TilingContextPara tilingContextPara(84+ gert::TilingContextPara tilingContextPara("Assign",
92- "Assign",85+ {
93- {86+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT8, ge::FORMAT_ND},
94- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT8, ge::FORMAT_ND},87+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT8, ge::FORMAT_ND},
95- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT8, ge::FORMAT_ND},88+ },
96- },89+ {
97- {90+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT8, ge::FORMAT_ND},
98- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT8, ge::FORMAT_ND},91+ },
99- },92+ &compileInfo);
100- &compileInfo);
101 uint64_t expectTilingKey = 1;93 uint64_t expectTilingKey = 1;
102 string expectTilingData = "64 1 1 1 2048 256 1 ";94 string expectTilingData = "64 1 1 1 2048 256 1 ";
103 std::vector<size_t> expectWorkspaces = {32};95 std::vector<size_t> expectWorkspaces = {32};
@@ -107,16 +99,15 @@ TEST_F(AssignTilingTest, Assign_tiling_uint8)
107TEST_F(AssignTilingTest, Assign_tiling_int32)99TEST_F(AssignTilingTest, Assign_tiling_int32)
108{100{
109 optiling::AssignCompileInfo compileInfo = {64, 253952};101 optiling::AssignCompileInfo compileInfo = {64, 253952};
110- gert::TilingContextPara tilingContextPara(102+ gert::TilingContextPara tilingContextPara("Assign",
111- "Assign",103+ {
112- {104+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT32, ge::FORMAT_ND},
113- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT32, ge::FORMAT_ND},105+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT32, ge::FORMAT_ND},
114- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT32, ge::FORMAT_ND},106+ },
115- },107+ {
116- {108+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT32, ge::FORMAT_ND},
117- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT32, ge::FORMAT_ND},109+ },
118- },110+ &compileInfo);
119- &compileInfo);
120 uint64_t expectTilingKey = 4;111 uint64_t expectTilingKey = 4;
121 string expectTilingData = "64 1 1 1 512 256 4 ";112 string expectTilingData = "64 1 1 1 512 256 4 ";
122 std::vector<size_t> expectWorkspaces = {32};113 std::vector<size_t> expectWorkspaces = {32};
@@ -126,16 +117,15 @@ TEST_F(AssignTilingTest, Assign_tiling_int32)
126TEST_F(AssignTilingTest, Assign_tiling_int64)117TEST_F(AssignTilingTest, Assign_tiling_int64)
127{118{
128 optiling::AssignCompileInfo compileInfo = {64, 253952};119 optiling::AssignCompileInfo compileInfo = {64, 253952};
129- gert::TilingContextPara tilingContextPara(120+ gert::TilingContextPara tilingContextPara("Assign",
130- "Assign",121+ {
131- {122+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT64, ge::FORMAT_ND},
132- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT64, ge::FORMAT_ND},123+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT64, ge::FORMAT_ND},
133- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT64, ge::FORMAT_ND},124+ },
134- },125+ {
135- {126+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT64, ge::FORMAT_ND},
136- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_INT64, ge::FORMAT_ND},127+ },
137- },128+ &compileInfo);
138- &compileInfo);
139 uint64_t expectTilingKey = 8;129 uint64_t expectTilingKey = 8;
140 string expectTilingData = "64 1 1 1 256 256 8 ";130 string expectTilingData = "64 1 1 1 256 256 8 ";
141 std::vector<size_t> expectWorkspaces = {32};131 std::vector<size_t> expectWorkspaces = {32};
@@ -145,16 +135,15 @@ TEST_F(AssignTilingTest, Assign_tiling_int64)
145TEST_F(AssignTilingTest, Assign_tiling_uint64)135TEST_F(AssignTilingTest, Assign_tiling_uint64)
146{136{
147 optiling::AssignCompileInfo compileInfo = {64, 253952};137 optiling::AssignCompileInfo compileInfo = {64, 253952};
148- gert::TilingContextPara tilingContextPara(138+ gert::TilingContextPara tilingContextPara("Assign",
149- "Assign",139+ {
150- {140+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT64, ge::FORMAT_ND},
151- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT64, ge::FORMAT_ND},141+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT64, ge::FORMAT_ND},
152- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT64, ge::FORMAT_ND},142+ },
153- },143+ {
154- {144+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT64, ge::FORMAT_ND},
155- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT64, ge::FORMAT_ND},145+ },
156- },146+ &compileInfo);
157- &compileInfo);
158 uint64_t expectTilingKey = 8;147 uint64_t expectTilingKey = 8;
159 string expectTilingData = "64 1 1 1 256 256 8 ";148 string expectTilingData = "64 1 1 1 256 256 8 ";
160 std::vector<size_t> expectWorkspaces = {32};149 std::vector<size_t> expectWorkspaces = {32};
@@ -164,16 +153,15 @@ TEST_F(AssignTilingTest, Assign_tiling_uint64)
164TEST_F(AssignTilingTest, Assign_tiling_invalid_dtype)153TEST_F(AssignTilingTest, Assign_tiling_invalid_dtype)
165{154{
166 optiling::AssignCompileInfo compileInfo = {64, 253952};155 optiling::AssignCompileInfo compileInfo = {64, 253952};
167- gert::TilingContextPara tilingContextPara(156+ gert::TilingContextPara tilingContextPara("Assign",
168- "Assign",157+ {
169- {158+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
170- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},159+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT64, ge::FORMAT_ND},
171- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT64, ge::FORMAT_ND},160+ },
172- },161+ {
173- {162+ {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT64, ge::FORMAT_ND},
174- {{{4, 4, 4, 4}, {4, 4, 4, 4}}, ge::DT_UINT64, ge::FORMAT_ND},163+ },
175- },164+ &compileInfo);
176- &compileInfo);
177 uint64_t expectTilingKey = 4;165 uint64_t expectTilingKey = 4;
178 string expectTilingData = "64 1 1 1 512 256 4 ";166 string expectTilingData = "64 1 1 1 512 256 4 ";
179 std::vector<size_t> expectWorkspaces = {32};167 std::vector<size_t> expectWorkspaces = {32};
@@ -14,27 +14,22 @@
14#include "infershape_case_executor.h"14#include "infershape_case_executor.h"
15 15 
16class AssignTest : public testing::Test {16class AssignTest : public testing::Test {
17- protected:17+protected:
18- static void SetUpTestCase() {18+ static void SetUpTestCase() {}
19- std::cout << "AssignTest SetUp" << std::endl;
20- }
21 19 
22- static void TearDownTestCase() {20+ static void TearDownTestCase() {}
23- std::cout << "AssignTest TearDown" << std::endl;
24- }
25};21};
26 22 
27TEST_F(AssignTest, InfershapeAssign_001)23TEST_F(AssignTest, InfershapeAssign_001)
28{24{
29- gert::InfershapeContextPara infershapeContextPara(25+ gert::InfershapeContextPara infershapeContextPara("Assign",
30- "Assign",26+ {
31- {27+ {{{2, 2}, {2, 2}}, ge::DT_FLOAT, ge::FORMAT_ND},
32- {{{2, 2}, {2, 2}}, ge::DT_FLOAT, ge::FORMAT_ND},28+ {{{2, 2}, {2, 2}}, ge::DT_FLOAT, ge::FORMAT_ND},
33- {{{2, 2}, {2, 2}}, ge::DT_FLOAT, ge::FORMAT_ND},29+ },
34- },30+ {
35- {31+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
36- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},32+ });
37- });
38 std::vector<std::vector<int64_t>> expectOutputShape = {33 std::vector<std::vector<int64_t>> expectOutputShape = {
39 {2, 2},34 {2, 2},
40 };35 };
@@ -20,14 +20,8 @@
20 20 
21class AssignTest : public testing::Test {21class AssignTest : public testing::Test {
22protected:22protected:
23- static void SetUpTestCase()23+ static void SetUpTestCase() {}
24- {24+ static void TearDownTestCase() {}
25- std::cout << "assign_test SetUp" << std::endl;
26- }
27- static void TearDownTestCase()
28- {
29- std::cout << "assign_test TearDown" << std::endl;
30- }
31};25};
32 26 
33// ============================================================================27// ============================================================================
@@ -33,6 +33,11 @@
33#define FAILED -133#define FAILED -1
34#define SUCCESS 034#define SUCCESS 0
35 35 
36+#define LOG_PRINT(message, ...) \
37+ do { \
38+ printf(message, ##__VA_ARGS__); \
39+ } while (0)
40+ 
36using namespace ge;41using namespace ge;
37using std::map;42using std::map;
38using std::string;43using std::string;
@@ -49,7 +54,7 @@ using std::vector;
49 Tensor tensor##dataName; \54 Tensor tensor##dataName; \
50 ret = GenOnesData(shape##dataName, tensor##dataName, desc##dataName, inputDtype, (inputIndex + 1)); \55 ret = GenOnesData(shape##dataName, tensor##dataName, desc##dataName, inputDtype, (inputIndex + 1)); \
51 if (ret != SUCCESS) { \56 if (ret != SUCCESS) { \
52- printf("%s - ERROR - [XIR]: Generate input data failed\n", GetTime().c_str()); \57+ LOG_PRINT("%s - ERROR - [CONCAT_GE_IR]: Generate input data failed\n", GetTime().c_str()); \
53 return FAILED; \58 return FAILED; \
54 } \59 } \
55 concat1.UpdateDynamicInputDesc("x", inputIndex, desc##dataName); \60 concat1.UpdateDynamicInputDesc("x", inputIndex, desc##dataName); \
@@ -59,27 +64,26 @@ using std::vector;
59 inputs.push_back(placeholder##dataName); \64 inputs.push_back(placeholder##dataName); \
60 } while (0)65 } while (0)
61 66 
62-#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \67+#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \
63- do { \68+ do { \
64- vector<int64_t> placeholder##intputIndex##_shape = inputShape; \69+ vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
65- auto placeholder##intputIndex = op::Data("placeholder" + intputIndex).set_attr_index(0); \70+ auto placeholder##intputIndex = op::Data("placeholder" + intputIndex).set_attr_index(0); \
66- TensorDesc placeholder##intputIndex##_desc = \71+ TensorDesc placeholder##intputIndex##_desc = TensorDesc(ge::Shape(placeholder##intputIndex##_shape), \
67- TensorDesc(ge::Shape(placeholder##intputIndex##_shape), FORMAT_ND, intputDtype); \72+ FORMAT_ND, intputDtype); \
68- placeholder##intputIndex##_desc.SetPlacement(ge::kPlacementHost); \73+ placeholder##intputIndex##_desc.SetPlacement(ge::kPlacementHost); \
69- placeholder##intputIndex##_desc.SetFormat(FORMAT_ND); \74+ placeholder##intputIndex##_desc.SetFormat(FORMAT_ND); \
70- Tensor tensor_placeholder##intputIndex; \75+ Tensor tensor_placeholder##intputIndex; \
71- ret = GenOnesData( \76+ ret = GenOnesData(placeholder##intputIndex##_shape, tensor_placeholder##intputIndex, \
72- placeholder##intputIndex##_shape, tensor_placeholder##intputIndex, placeholder##intputIndex##_desc, \77+ placeholder##intputIndex##_desc, intputDtype, value); \
73- intputDtype, value); \78+ if (ret != SUCCESS) { \
74- if (ret != SUCCESS) { \79+ LOG_PRINT("%s - ERROR - [CONCAT_GE_IR]: Generate input data failed\n", GetTime().c_str()); \
75- printf("%s - ERROR - [XIR]: Generate input data failed\n", GetTime().c_str()); \80+ return FAILED; \
76- return FAILED; \81+ } \
77- } \82+ placeholder##intputIndex.update_input_desc_x(placeholder##intputIndex##_desc); \
78- placeholder##intputIndex.update_input_desc_x(placeholder##intputIndex##_desc); \83+ input.push_back(tensor_placeholder##intputIndex); \
79- input.push_back(tensor_placeholder##intputIndex); \84+ graph.AddOp(placeholder##intputIndex); \
80- graph.AddOp(placeholder##intputIndex); \85+ concat1.set_input_##intputName(placeholder##intputIndex); \
81- concat1.set_input_##intputName(placeholder##intputIndex); \86+ inputs.push_back(placeholder##intputIndex); \
82- inputs.push_back(placeholder##intputIndex); \
83 } while (0)87 } while (0)
84 88 
85#define ADD_INPUT_ATTR(attrName, attrValue) \89#define ADD_INPUT_ATTR(attrName, attrValue) \
@@ -151,8 +155,8 @@ int32_t GenOnesDataFloat32(vector<int64_t> shapes, Tensor& input_tensor, TensorD
151 return SUCCESS;155 return SUCCESS;
152}156}
153 157 
154-int32_t GenOnesData(158+int32_t GenOnesData(vector<int64_t> shapes, Tensor& input_tensor, TensorDesc& input_tensor_desc, DataType data_type,
155- vector<int64_t> shapes, Tensor& input_tensor, TensorDesc& input_tensor_desc, DataType data_type, bool value)159+ bool value)
156{160{
157 input_tensor_desc.SetRealDimCnt(shapes.size());161 input_tensor_desc.SetRealDimCnt(shapes.size());
158 size_t size = 1;162 size_t size = 1;
@@ -182,9 +186,8 @@ int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t* inputData)
182 return SUCCESS;186 return SUCCESS;
183}187}
184 188 
185-int CreateOppInGraph(189+int CreateOppInGraph(DataType inDtype, std::vector<ge::Tensor>& input, std::vector<Operator>& inputs,
186- DataType inDtype, std::vector<ge::Tensor>& input, std::vector<Operator>& inputs, std::vector<Operator>& outputs,190+ std::vector<Operator>& outputs, Graph& graph)
187- Graph& graph)
188{191{
189 Status ret = SUCCESS;192 Status ret = SUCCESS;
190 auto concat1 = op::ConcatV2("concat1").create_dynamic_input_x(2, false);193 auto concat1 = op::ConcatV2("concat1").create_dynamic_input_x(2, false);
@@ -209,27 +212,27 @@ int main(int argc, char* argv[])
209 Graph graph(graph_name);212 Graph graph(graph_name);
210 std::vector<ge::Tensor> input;213 std::vector<ge::Tensor> input;
211 214 
212- printf("%s - INFO - [XIR]: Start to initialize ge using ge global options\n", GetTime().c_str());215+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Start to initialize ge using ge global options\n", GetTime().c_str());
213 std::map<AscendString, AscendString> global_options = {{"ge.exec.deviceId", "0"}, {"ge.graphRunMode", "1"}};216 std::map<AscendString, AscendString> global_options = {{"ge.exec.deviceId", "0"}, {"ge.graphRunMode", "1"}};
214 Status ret = ge::GEInitialize(global_options);217 Status ret = ge::GEInitialize(global_options);
215 if (ret != SUCCESS) {218 if (ret != SUCCESS) {
216- printf("%s - INFO - [XIR]: Initialize ge using ge global options failed\n", GetTime().c_str());219+ LOG_PRINT("%s - ERROR - [CONCAT_GE_IR]: Initialize ge using ge global options failed\n", GetTime().c_str());
217 return FAILED;220 return FAILED;
218 }221 }
219- printf("%s - INFO - [XIR]: Initialize ge using ge global options success\n", GetTime().c_str());222+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Initialize ge using ge global options success\n", GetTime().c_str());
220 223 
221 std::vector<Operator> inputs{};224 std::vector<Operator> inputs{};
222 std::vector<Operator> outputs{};225 std::vector<Operator> outputs{};
223 226 
224- std::cout << argv[1] << std::endl;227+ LOG_PRINT("argv[1] = %s\n", argv[1]);
225 228 
226 DataType inDtype = DT_BOOL;229 DataType inDtype = DT_BOOL;
227 230 
228- std::cout << inDtype << std::endl;231+ LOG_PRINT("inDtype: %d\n", static_cast<int>(inDtype));
229 232 
230 ret = CreateOppInGraph(inDtype, input, inputs, outputs, graph);233 ret = CreateOppInGraph(inDtype, input, inputs, outputs, graph);
231 if (ret != SUCCESS) {234 if (ret != SUCCESS) {
232- printf("%s - ERROR - [XIR]: Create ir session using build options failed\n", GetTime().c_str());235+ LOG_PRINT("%s - ERROR - [CONCAT_GE_IR]: Create ir session using build options failed\n", GetTime().c_str());
233 return FAILED;236 return FAILED;
234 }237 }
235 238 
@@ -240,15 +243,15 @@ int main(int argc, char* argv[])
240 std::map<AscendString, AscendString> build_options = {243 std::map<AscendString, AscendString> build_options = {
241 244 
242 };245 };
243- printf("%s - INFO - [XIR]: Start to create ir session using build options\n", GetTime().c_str());246+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Start to create ir session using build options\n", GetTime().c_str());
244 ge::Session* session = new Session(build_options);247 ge::Session* session = new Session(build_options);
245 248 
246 if (session == nullptr) {249 if (session == nullptr) {
247- printf("%s - ERROR - [XIR]: Create ir session using build options failed\n", GetTime().c_str());250+ LOG_PRINT("%s - ERROR - [CONCAT_GE_IR]: Create ir session using build options failed\n", GetTime().c_str());
248 return FAILED;251 return FAILED;
249 }252 }
250- printf("%s - INFO - [XIR]: Create ir session using build options success\n", GetTime().c_str());253+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Create ir session using build options success\n", GetTime().c_str());
251- printf("%s - INFO - [XIR]: Start to add compute graph to ir session\n", GetTime().c_str());254+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Start to add compute graph to ir session\n", GetTime().c_str());
252 255 
253 std::map<AscendString, AscendString> graph_options = {256 std::map<AscendString, AscendString> graph_options = {
254 257 
@@ -256,56 +259,56 @@ int main(int argc, char* argv[])
256 uint32_t graph_id = 0;259 uint32_t graph_id = 0;
257 ret = session->AddGraph(graph_id, graph, graph_options);260 ret = session->AddGraph(graph_id, graph, graph_options);
258 261 
259- printf("%s - INFO - [XIR]: Session add ir compute graph to ir session success\n", GetTime().c_str());262+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Session add ir compute graph to ir session success\n", GetTime().c_str());
260- printf("%s - INFO - [XIR]: dump graph to txt\n", GetTime().c_str());263+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: dump graph to txt\n", GetTime().c_str());
261 std::string file_path = "./dump";264 std::string file_path = "./dump";
262 aclgrphDumpGraph(graph, file_path.c_str(), file_path.length());265 aclgrphDumpGraph(graph, file_path.c_str(), file_path.length());
263- printf("%s - INFO - [XIR]: Start to run ir compute graph\n", GetTime().c_str());266+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Start to run ir compute graph\n", GetTime().c_str());
264 std::vector<ge::Tensor> output;267 std::vector<ge::Tensor> output;
265 ret = session->RunGraph(graph_id, input, output);268 ret = session->RunGraph(graph_id, input, output);
266 if (ret != SUCCESS) {269 if (ret != SUCCESS) {
267- printf("%s - INFO - [XIR]: Run graph failed\n", GetTime().c_str());270+ LOG_PRINT("%s - ERROR - [CONCAT_GE_IR]: Run graph failed\n", GetTime().c_str());
268 delete session;271 delete session;
269 GEFinalize();272 GEFinalize();
270 return FAILED;273 return FAILED;
271 }274 }
272- printf("%s - INFO - [XIR]: Session run ir compute graph success\n", GetTime().c_str());275+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Session run ir compute graph success\n", GetTime().c_str());
273 276 
274 int input_num = input.size();277 int input_num = input.size();
275 for (int i = 0; i < input_num; i++) {278 for (int i = 0; i < input_num; i++) {
276- std::cout << "input " << i << " dtype : " << input[i].GetTensorDesc().GetDataType() << std::endl;279+ LOG_PRINT("input %d dtype: %d\n", i, static_cast<int>(input[i].GetTensorDesc().GetDataType()));
277 string input_file = "./tc_ge_irrun_test_0008_npu_input_" + std::to_string(i) + ".bin";280 string input_file = "./tc_ge_irrun_test_0008_npu_input_" + std::to_string(i) + ".bin";
278 uint8_t* input_data_i = input[i].GetData();281 uint8_t* input_data_i = input[i].GetData();
279 int64_t input_shape = input[i].GetTensorDesc().GetShape().GetShapeSize();282 int64_t input_shape = input[i].GetTensorDesc().GetShape().GetShapeSize();
280- std::cout << "this is " << i << "th input, input shape size =" << input_shape << std::endl;283+ LOG_PRINT("input %d shape size: %ld\n", i, input_shape);
281 uint32_t data_size = input_shape * GetDataTypeSize(input[i].GetTensorDesc().GetDataType());284 uint32_t data_size = input_shape * GetDataTypeSize(input[i].GetTensorDesc().GetDataType());
282 WriteDataToFile((const char*)input_file.c_str(), data_size, input_data_i);285 WriteDataToFile((const char*)input_file.c_str(), data_size, input_data_i);
283 }286 }
284 287 
285 int output_num = output.size();288 int output_num = output.size();
286 for (int i = 0; i < output_num; i++) {289 for (int i = 0; i < output_num; i++) {
287- std::cout << "output " << i << " dtype : " << output[i].GetTensorDesc().GetDataType() << std::endl;290+ LOG_PRINT("output %d dtype: %d\n", i, static_cast<int>(output[i].GetTensorDesc().GetDataType()));
288 string output_file = "./tc_ge_irrun_test_0008_npu_output_" + std::to_string(i) + ".bin";291 string output_file = "./tc_ge_irrun_test_0008_npu_output_" + std::to_string(i) + ".bin";
289 uint8_t* output_data_i = output[i].GetData();292 uint8_t* output_data_i = output[i].GetData();
290 int64_t output_shape = output[i].GetTensorDesc().GetShape().GetShapeSize();293 int64_t output_shape = output[i].GetTensorDesc().GetShape().GetShapeSize();
291- std::cout << "this is " << i << "th output, output shape size =" << output_shape << std::endl;294+ LOG_PRINT("output %d shape size: %ld\n", i, output_shape);
292 uint32_t data_size = output_shape * GetDataTypeSize(output[i].GetTensorDesc().GetDataType());295 uint32_t data_size = output_shape * GetDataTypeSize(output[i].GetTensorDesc().GetDataType());
293 WriteDataToFile((const char*)output_file.c_str(), data_size, output_data_i);296 WriteDataToFile((const char*)output_file.c_str(), data_size, output_data_i);
294 }297 }
295 298 
296 ge::AscendString error_msg = ge::GEGetErrorMsgV2();299 ge::AscendString error_msg = ge::GEGetErrorMsgV2();
297 std::string error_str(error_msg.GetString());300 std::string error_str(error_msg.GetString());
298- std::cout << "Error message: " << error_str << std::endl;301+ LOG_PRINT("Error message: %s\n", error_str.c_str());
299 ge::AscendString warning_msg = ge::GEGetWarningMsgV2();302 ge::AscendString warning_msg = ge::GEGetWarningMsgV2();
300 std::string warning_str(warning_msg.GetString());303 std::string warning_str(warning_msg.GetString());
301- std::cout << "Warning message: " << warning_str << std::endl;304+ LOG_PRINT("Warning message: %s\n", warning_str.c_str());
302- printf("%s - INFO - [XIR]: Precision is ok\n", GetTime().c_str());305+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Precision is ok\n", GetTime().c_str());
303- printf("%s - INFO - [XIR]: Start to finalize ir graph session\n", GetTime().c_str());306+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Start to finalize ir graph session\n", GetTime().c_str());
304 ret = ge::GEFinalize();307 ret = ge::GEFinalize();
305 if (ret != SUCCESS) {308 if (ret != SUCCESS) {
306- printf("%s - INFO - [XIR]: Finalize ir graph session failed\n", GetTime().c_str());309+ LOG_PRINT("%s - ERROR - [CONCAT_GE_IR]: Finalize ir graph session failed\n", GetTime().c_str());
307 return FAILED;310 return FAILED;
308 }311 }
309- printf("%s - INFO - [XIR]: Finalize ir graph session success\n", GetTime().c_str());312+ LOG_PRINT("%s - INFO - [CONCAT_GE_IR]: Finalize ir graph session success\n", GetTime().c_str());
310 return SUCCESS;313 return SUCCESS;
311}314}
@@ -76,7 +76,7 @@ static Status ParseOpToGraphConcat(const ge::Operator& op, Graph& graph)
76 std::vector<std::pair<ge::Operator, std::vector<size_t>>> output_indexs;76 std::vector<std::pair<ge::Operator, std::vector<size_t>>> output_indexs;
77 77 
78 if (input_size == 0) {78 if (input_size == 0) {
79- OP_LOGE(GetOpName(op).c_str(), "input_size must ge 1");79+ OP_LOGE(GetOpName(op).c_str(), "input_size must be at least 1");
80 return FAILED;80 return FAILED;
81 } else if (input_size == 1) {81 } else if (input_size == 1) {
82 auto data_op = op::Data((ori_name + "_data").c_str()).set_attr_index(0);82 auto data_op = op::Data((ori_name + "_data").c_str()).set_attr_index(0);
@@ -69,14 +69,14 @@ static graphStatus ConcatExecuteFuncD(OpExecutePrepareContext* hostApiCtx)
69 OP_LOGI("aclnnfallback", "concatDim: %ld", *concatDim);69 OP_LOGI("aclnnfallback", "concatDim: %ld", *concatDim);
70 70 
71 auto apiRet = CANN_OPS_OPB_ASYN_EXEC_ACLNN(hostApiCtx, aclnnCat, geTenserList, *concatDim, outGe);71 auto apiRet = CANN_OPS_OPB_ASYN_EXEC_ACLNN(hostApiCtx, aclnnCat, geTenserList, *concatDim, outGe);
72- OP_CHECK_IF(apiRet != GRAPH_SUCCESS, OP_LOGE("aclnnfallback", "apiRet faild:%u", apiRet), return GRAPH_FAILED);72+ OP_CHECK_IF(apiRet != GRAPH_SUCCESS, OP_LOGE("aclnnfallback", "apiRet failed:%u", apiRet), return GRAPH_FAILED);
73 73 
74 return GRAPH_SUCCESS;74 return GRAPH_SUCCESS;
75}75}
76 76 
77static graphStatus ConcatExecuteFunc(OpExecutePrepareContext* hostApiCtx)77static graphStatus ConcatExecuteFunc(OpExecutePrepareContext* hostApiCtx)
78{78{
79- OP_CHECK_IF(hostApiCtx == nullptr, OP_LOGE("aclnnfallback", "hostApiCtx nullptr"), return GRAPH_FAILED);79+ OP_CHECK_IF(hostApiCtx == nullptr, OP_LOGE("aclnnfallback", "hostApiCtx is nullptr"), return GRAPH_FAILED);
80 80 
81 auto inputNum = hostApiCtx->GetComputeNodeInputNum();81 auto inputNum = hostApiCtx->GetComputeNodeInputNum();
82 OP_CHECK_IF(inputNum <= 1, OP_LOGE("aclnnfallback", "inputNum <=1"), return GRAPH_FAILED);82 OP_CHECK_IF(inputNum <= 1, OP_LOGE("aclnnfallback", "inputNum <=1"), return GRAPH_FAILED);
@@ -87,18 +87,18 @@ static graphStatus ConcatExecuteFunc(OpExecutePrepareContext* hostApiCtx)
87 geTenserList.push_back(geT);87 geTenserList.push_back(geT);
88 }88 }
89 auto outGe = hostApiCtx->GetOutputTensor(kConcatOut);89 auto outGe = hostApiCtx->GetOutputTensor(kConcatOut);
90- OP_CHECK_IF(outGe == nullptr, OP_LOGE("aclnnfallback", "outGe nullptr"), return GRAPH_FAILED);90+ OP_CHECK_IF(outGe == nullptr, OP_LOGE("aclnnfallback", "outGe is nullptr"), return GRAPH_FAILED);
91 91 
92 auto geT = hostApiCtx->GetInputTensor(inputNum - 1);92 auto geT = hostApiCtx->GetInputTensor(inputNum - 1);
93- OP_CHECK_IF(geT == nullptr, OP_LOGE("aclnnfallback", "geT nullptr"), return GRAPH_FAILED);93+ OP_CHECK_IF(geT == nullptr, OP_LOGE("aclnnfallback", "geT is nullptr"), return GRAPH_FAILED);
94 94 
95 const int64_t* concatDim = geT->GetData<int64_t>();95 const int64_t* concatDim = geT->GetData<int64_t>();
96- OP_CHECK_IF(concatDim == nullptr, OP_LOGE("aclnnfallback", "concatDim nullptr"), return GRAPH_FAILED);96+ OP_CHECK_IF(concatDim == nullptr, OP_LOGE("aclnnfallback", "concatDim is nullptr"), return GRAPH_FAILED);
97 97 
98 OP_LOGI("aclnnfallback", "concatDim: %ld", *concatDim);98 OP_LOGI("aclnnfallback", "concatDim: %ld", *concatDim);
99 99 
100 auto apiRet = CANN_OPS_OPB_ASYN_EXEC_ACLNN(hostApiCtx, aclnnCat, geTenserList, *concatDim, outGe);100 auto apiRet = CANN_OPS_OPB_ASYN_EXEC_ACLNN(hostApiCtx, aclnnCat, geTenserList, *concatDim, outGe);
101- OP_CHECK_IF(apiRet != GRAPH_SUCCESS, OP_LOGE("aclnnfallback", "apiRet faild:%u", apiRet), return GRAPH_FAILED);101+ OP_CHECK_IF(apiRet != GRAPH_SUCCESS, OP_LOGE("aclnnfallback", "apiRet failed:%u", apiRet), return GRAPH_FAILED);
102 102 
103 return GRAPH_SUCCESS;103 return GRAPH_SUCCESS;
104}104}
@@ -108,9 +108,9 @@ static inline void PrintTilingDataList(T& tilingData)
108template <typename T>108template <typename T>
109static inline void PrintTilingData(T& tilingData, int64_t tilingKey, int64_t usedCoreNum)109static inline void PrintTilingData(T& tilingData, int64_t tilingKey, int64_t usedCoreNum)
110{110{
111- OP_LOGI("[Concat]", "ubSplitDim1: %d, dim: %d, blockFactor: %ld,tailBlockFactor: %ld,\111+ OP_LOGI("[Concat]", "ubSplitDim1: %d, dim: %d, blockFactor: %ld, tailBlockFactor: %ld, \
112-ubFactorDim0: %d,ubFactorDim1: %d,tailUbFactorDim0: %d, tailUbFactorDim1: %d,uoDim0: %ld,uoDim1: %ld,\112+ubFactorDim0: %d, ubFactorDim1: %d, tailUbFactorDim0: %d, tailUbFactorDim1: %d, uoDim0: %ld, uoDim1: %ld, \
113-tensorNum: %d,catDim1: %ld,isnon: %d,tilingKey: %ld,usedCoreNum: %ld",113+tensorNum: %d, catDim1: %ld, isnon: %d, tilingKey: %ld, usedCoreNum: %ld",
114 tilingData.get_ubSplitDim1(), tilingData.get_dim(), tilingData.get_blockFactor(),114 tilingData.get_ubSplitDim1(), tilingData.get_dim(), tilingData.get_blockFactor(),
115 tilingData.get_tailBlockFactor(), tilingData.get_ubFactorDim0(), tilingData.get_ubFactorDim1(),115 tilingData.get_tailBlockFactor(), tilingData.get_ubFactorDim0(), tilingData.get_ubFactorDim1(),
116 tilingData.get_tailUbFactorDim0(), tilingData.get_tailUbFactorDim1(), tilingData.get_uoDim0(),116 tilingData.get_tailUbFactorDim0(), tilingData.get_tailUbFactorDim1(), tilingData.get_uoDim0(),
@@ -286,7 +286,7 @@ inline static ge::graphStatus CalcBaseTilingParam(const gert::TilingContext* con
286 OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo);286 OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo);
287 param.totalCoreNum = min(static_cast<int64_t>(compileInfo->totalCoreNum), TILING_ARRAY_LENGTH);287 param.totalCoreNum = min(static_cast<int64_t>(compileInfo->totalCoreNum), TILING_ARRAY_LENGTH);
288 if (compileInfo->totalCoreNum > TILING_ARRAY_LENGTH) {288 if (compileInfo->totalCoreNum > TILING_ARRAY_LENGTH) {
289- OP_LOGW("[Concat]", "Currently, more than 72 cores are not supported, Only 72 cores are used.");289+ OP_LOGW("[Concat]", "Currently, more than 72 cores are not supported; only 72 cores are used.");
290 }290 }
291 param.ubSize = compileInfo->ubSize;291 param.ubSize = compileInfo->ubSize;
292 param.tensorNum = param.tensorList.size();292 param.tensorNum = param.tensorList.size();
@@ -1629,18 +1629,18 @@ ge::graphStatus TilingPrepareForConcat(gert::TilingParseContext* context)
1629 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);1629 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);
1630 compileInfo->totalCoreNum = ascendcPlatform.GetCoreNumAiv();1630 compileInfo->totalCoreNum = ascendcPlatform.GetCoreNumAiv();
1631 OP_CHECK_IF((compileInfo->totalCoreNum <= 0),1631 OP_CHECK_IF((compileInfo->totalCoreNum <= 0),
1632- OP_LOGE(context->GetNodeName(), "TilingPrepareForConcat fail to get core num."),1632+ OP_LOGE(context->GetNodeName(), "TilingPrepareForConcat Failed to get core num."),
1633 return ge::GRAPH_FAILED);1633 return ge::GRAPH_FAILED);
1634 1634 
1635 uint64_t ubSize;1635 uint64_t ubSize;
1636 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);1636 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);
1637 compileInfo->ubSize = static_cast<int64_t>(ubSize);1637 compileInfo->ubSize = static_cast<int64_t>(ubSize);
1638 OP_CHECK_IF((compileInfo->ubSize <= 0),1638 OP_CHECK_IF((compileInfo->ubSize <= 0),
1639- OP_LOGE(context->GetNodeName(), "TilingPrepareForConcat fail to get ub size."),1639+ OP_LOGE(context->GetNodeName(), "TilingPrepareForConcat Failed to get ub size."),
1640 return ge::GRAPH_FAILED);1640 return ge::GRAPH_FAILED);
1641 compileInfo->vectorLen = static_cast<int64_t>(Ops::Base::GetVRegSize(context));1641 compileInfo->vectorLen = static_cast<int64_t>(Ops::Base::GetVRegSize(context));
1642 OP_CHECK_IF((compileInfo->vectorLen <= 0),1642 OP_CHECK_IF((compileInfo->vectorLen <= 0),
1643- OP_LOGE(context->GetNodeName(), "TilingPrepareForConcat fail to get vectorLen."),1643+ OP_LOGE(context->GetNodeName(), "TilingPrepareForConcat Failed to get vectorLen."),
1644 return ge::GRAPH_FAILED);1644 return ge::GRAPH_FAILED);
1645 return ge::GRAPH_SUCCESS;1645 return ge::GRAPH_SUCCESS;
1646}1646}
@@ -20,229 +20,195 @@
20using namespace std;20using namespace std;
21class ConcatForTilingTest : public testing::Test {21class ConcatForTilingTest : public testing::Test {
22protected:22protected:
23- static void SetUpTestCase() {23+ static void SetUpTestCase() {}
24- std::cout << "ConcatForTilingTest SetUp" << std::endl;
25- }
26 24 
27- static void TearDownTestCase() {25+ static void TearDownTestCase() {}
28- std::cout << "ConcatForTilingTest TearDown" << std::endl;
29- }
30};26};
31 27 
32-TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_diff_shape_align) {28+TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_diff_shape_align)
29+{
33 optiling::ConcatDCompileInfo compileInfo = {64, 253952};30 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
34- gert::TilingContextPara tilingContextPara(31+ gert::TilingContextPara tilingContextPara("Concat",
35- "Concat",32+ {
36- {33+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
37- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},34+ {{{31, 3, 2560}, {31, 3, 2560}}, ge::DT_FLOAT, ge::FORMAT_ND},
38- {{{31, 3, 2560}, {31, 3, 2560}}, ge::DT_FLOAT, ge::FORMAT_ND},35+ {{{31, 3, 1280}, {31, 3, 1280}}, ge::DT_FLOAT, ge::FORMAT_ND},
39- {{{31, 3, 1280}, {31, 3, 1280}}, ge::DT_FLOAT, ge::FORMAT_ND},36+ {{{31, 3, 9980}, {31, 3, 9980}}, ge::DT_FLOAT, ge::FORMAT_ND},
40- {{{31, 3, 9980}, {31, 3, 9980}}, ge::DT_FLOAT, ge::FORMAT_ND},37+ },
41- },38+ {
42- {39+ {{{31, 3, 13820}, {31, 3, 13820}}, ge::DT_INT32, ge::FORMAT_ND},
43- {{{31, 3, 13820}, {31, 3, 13820}}, ge::DT_INT32, ge::FORMAT_ND},40+ },
44- },41+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
45- {
46- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
47- },
48- &compileInfo);
49 uint64_t expectTilingKey = 2224;42 uint64_t expectTilingKey = 2224;
50 std::vector<size_t> expectWorkspaces = {16777216};43 std::vector<size_t> expectWorkspaces = {16777216};
51 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);44 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
52}45}
53 46 
54-TEST_F(ConcatForTilingTest, Concat_tiling_UT_pure_copy) {47+TEST_F(ConcatForTilingTest, Concat_tiling_UT_pure_copy)
48+{
55 optiling::ConcatDCompileInfo compileInfo = {64, 253952};49 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
56- gert::TilingContextPara tilingContextPara(50+ gert::TilingContextPara tilingContextPara("Concat",
57- "Concat",51+ {
58- {52+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
59- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},53+ {{{310, 3, 2560}, {310, 3, 2560}}, ge::DT_FLOAT, ge::FORMAT_ND},
60- {{{310, 3, 2560}, {310, 3, 2560}}, ge::DT_FLOAT, ge::FORMAT_ND},54+ {{{310, 3, 1280}, {310, 3, 1280}}, ge::DT_FLOAT, ge::FORMAT_ND},
61- {{{310, 3, 1280}, {310, 3, 1280}}, ge::DT_FLOAT, ge::FORMAT_ND},55+ {{{310, 3, 9980}, {310, 3, 9980}}, ge::DT_FLOAT, ge::FORMAT_ND},
62- {{{310, 3, 9980}, {310, 3, 9980}}, ge::DT_FLOAT, ge::FORMAT_ND},56+ },
63- },57+ {
64- {58+ {{{310, 3, 13820}, {310, 3, 13820}}, ge::DT_INT32, ge::FORMAT_ND},
65- {{{310, 3, 13820}, {310, 3, 13820}}, ge::DT_INT32, ge::FORMAT_ND},59+ },
66- },60+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
67- {
68- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
69- },
70- &compileInfo);
71 uint64_t expectTilingKey = 20002;61 uint64_t expectTilingKey = 20002;
72 std::vector<size_t> expectWorkspaces = {16777216};62 std::vector<size_t> expectWorkspaces = {16777216};
73 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);63 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
74}64}
75 65 
76-TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_diff_shape_align_int64) {66+TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_diff_shape_align_int64)
67+{
77 optiling::ConcatDCompileInfo compileInfo = {64, 253952};68 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
78- gert::TilingContextPara tilingContextPara(69+ gert::TilingContextPara tilingContextPara("Concat",
79- "Concat",70+ {
80- {71+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
81- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},72+ {{{16384, 512}, {16384, 512}}, ge::DT_INT64, ge::FORMAT_ND},
82- {{{16384, 512}, {16384, 512}}, ge::DT_INT64, ge::FORMAT_ND},73+ {{{16384, 4}, {16384, 4}}, ge::DT_INT64, ge::FORMAT_ND},
83- {{{16384, 4}, {16384, 4}}, ge::DT_INT64, ge::FORMAT_ND},74+ },
84- },75+ {
85- {76+ {{{16384, 516}, {16384, 516}}, ge::DT_INT64, ge::FORMAT_ND},
86- {{{16384, 516}, {16384, 516}}, ge::DT_INT64, ge::FORMAT_ND},77+ },
87- },78+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
88- {
89- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
90- },
91- &compileInfo);
92 uint64_t expectTilingKey = 12128;79 uint64_t expectTilingKey = 12128;
93 std::vector<size_t> expectWorkspaces = {16777216};80 std::vector<size_t> expectWorkspaces = {16777216};
94 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);81 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
95}82}
96 83 
97-TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_same_shape_align) {84+TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_same_shape_align)
85+{
98 optiling::ConcatDCompileInfo compileInfo = {64, 253952};86 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
99- gert::TilingContextPara tilingContextPara(87+ gert::TilingContextPara tilingContextPara("Concat",
100- "Concat",88+ {
101- {89+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
102- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},90+ {{{12, 2, 8, 128}, {12, 2, 8, 128}}, ge::DT_INT64, ge::FORMAT_ND},
103- {{{12, 2, 8, 128}, {12, 2, 8, 128}}, ge::DT_INT64, ge::FORMAT_ND},91+ {{{12, 2, 8, 128}, {12, 2, 8, 128}}, ge::DT_INT64, ge::FORMAT_ND},
104- {{{12, 2, 8, 128}, {12, 2, 8, 128}}, ge::DT_INT64, ge::FORMAT_ND},92+ },
105- },93+ {
106- {94+ {{{16384, 516}, {16384, 516}}, ge::DT_INT64, ge::FORMAT_ND},
107- {{{16384, 516}, {16384, 516}}, ge::DT_INT64, ge::FORMAT_ND},95+ },
108- },96+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
109- {
110- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
111- },
112- &compileInfo);
113 uint64_t expectTilingKey = 2118;97 uint64_t expectTilingKey = 2118;
114 std::vector<size_t> expectWorkspaces = {16777216};98 std::vector<size_t> expectWorkspaces = {16777216};
115 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);99 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
116}100}
117 101 
118-TEST_F(ConcatForTilingTest, Concat_tiling_UT_zero_axis_same_shape_align_float) {102+TEST_F(ConcatForTilingTest, Concat_tiling_UT_zero_axis_same_shape_align_float)
103+{
119 optiling::ConcatDCompileInfo compileInfo = {64, 253952};104 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
120- gert::TilingContextPara tilingContextPara(105+ gert::TilingContextPara tilingContextPara("Concat",
121- "Concat",106+ {
122- {107+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
123- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},108+ {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},
124- {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},109+ {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},
125- {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},110+ {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},
126- {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},111+ },
127- },112+ {
128- {113+ {{{16384, 516}, {16384, 516}}, ge::DT_FLOAT, ge::FORMAT_ND},
129- {{{16384, 516}, {16384, 516}}, ge::DT_FLOAT, ge::FORMAT_ND},114+ },
130- },115+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
131- {
132- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
133- },
134- &compileInfo);
135 uint64_t expectTilingKey = 2114;116 uint64_t expectTilingKey = 2114;
136 std::vector<size_t> expectWorkspaces = {16777216};117 std::vector<size_t> expectWorkspaces = {16777216};
137 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);118 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
138}119}
139 120 
140-TEST_F(ConcatForTilingTest, Concat_tiling_UT_zero_axis_diff_shape_align_float) {121+TEST_F(ConcatForTilingTest, Concat_tiling_UT_zero_axis_diff_shape_align_float)
122+{
141 optiling::ConcatDCompileInfo compileInfo = {64, 253952};123 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
142- gert::TilingContextPara tilingContextPara(124+ gert::TilingContextPara tilingContextPara("Concat",
143- "Concat",125+ {
144- {126+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
145- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},127+ {{{8256}, {8256}}, ge::DT_FLOAT, ge::FORMAT_ND},
146- {{{8256}, {8256}}, ge::DT_FLOAT, ge::FORMAT_ND},128+ {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND},
147- {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND},129+ {{{4112}, {4112}}, ge::DT_FLOAT, ge::FORMAT_ND},
148- {{{4112}, {4112}}, ge::DT_FLOAT, ge::FORMAT_ND},130+ },
149- },131+ {
150- {132+ {{{20602}, {20602}}, ge::DT_FLOAT, ge::FORMAT_ND},
151- {{{20602}, {20602}}, ge::DT_FLOAT, ge::FORMAT_ND},133+ },
152- },134+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
153- {
154- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
155- },
156- &compileInfo);
157 uint64_t expectTilingKey = 2124;135 uint64_t expectTilingKey = 2124;
158 std::vector<size_t> expectWorkspaces = {16777216};136 std::vector<size_t> expectWorkspaces = {16777216};
159 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);137 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
160}138}
161 139 
162-TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_concat_simt_same_shape_no_align_float) {140+TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_concat_simt_same_shape_no_align_float)
141+{
163 optiling::ConcatDCompileInfo compileInfo = {64, 253952};142 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
164- gert::TilingContextPara tilingContextPara(143+ gert::TilingContextPara tilingContextPara("Concat",
165- "Concat",144+ {
166- {145+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
167- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},146+ {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},
168- {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},147+ {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},
169- {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},148+ {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},
170- {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},149+ },
171- },150+ {
172- {151+ {{{36867}, {36867}}, ge::DT_FLOAT, ge::FORMAT_ND},
173- {{{36867}, {36867}}, ge::DT_FLOAT, ge::FORMAT_ND},152+ },
174- },153+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
175- {
176- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
177- },
178- &compileInfo);
179 uint64_t expectTilingKey = 2124;154 uint64_t expectTilingKey = 2124;
180 std::vector<size_t> expectWorkspaces = {16777216};155 std::vector<size_t> expectWorkspaces = {16777216};
181 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);156 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
182}157}
183 158 
184-TEST_F(ConcatForTilingTest, Concat_tiling_UT_zero_axis_diff_shape_no_align_float) {159+TEST_F(ConcatForTilingTest, Concat_tiling_UT_zero_axis_diff_shape_no_align_float)
160+{
185 optiling::ConcatDCompileInfo compileInfo = {64, 253952};161 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
186- gert::TilingContextPara tilingContextPara(162+ gert::TilingContextPara tilingContextPara("Concat",
187- "Concat",163+ {
188- {164+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
189- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},165+ {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND},
190- {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND},166+ {{{8223}, {8223}}, ge::DT_FLOAT, ge::FORMAT_ND},
191- {{{8223}, {8223}}, ge::DT_FLOAT, ge::FORMAT_ND},167+ {{{3223}, {3223}}, ge::DT_FLOAT, ge::FORMAT_ND},
192- {{{3223}, {3223}}, ge::DT_FLOAT, ge::FORMAT_ND},168+ },
193- },169+ {
194- {170+ {{{19670}, {19670}}, ge::DT_FLOAT, ge::FORMAT_ND},
195- {{{19670}, {19670}}, ge::DT_FLOAT, ge::FORMAT_ND},171+ },
196- },172+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
197- {
198- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
199- },
200- &compileInfo);
201 uint64_t expectTilingKey = 2224;173 uint64_t expectTilingKey = 2224;
202 std::vector<size_t> expectWorkspaces = {16777216};174 std::vector<size_t> expectWorkspaces = {16777216};
203 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);175 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
204}176}
205 177 
206-TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_diff_shape_no_align_float) {178+TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_diff_shape_no_align_float)
179+{
207 optiling::ConcatDCompileInfo compileInfo = {64, 253952};180 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
208- gert::TilingContextPara tilingContextPara(181+ gert::TilingContextPara tilingContextPara("Concat",
209- "Concat",182+ {
210- {183+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
211- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},184+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
212- {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},185+ {{{8223, 33}, {8223, 33}}, ge::DT_FLOAT, ge::FORMAT_ND},
213- {{{8223, 33}, {8223, 33}}, ge::DT_FLOAT, ge::FORMAT_ND},186+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
214- {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},187+ },
215- },188+ {
216- {189+ {{{24669, 94}, {24669, 94}}, ge::DT_FLOAT, ge::FORMAT_ND},
217- {{{24669, 94}, {24669, 94}}, ge::DT_FLOAT, ge::FORMAT_ND},190+ },
218- },191+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
219- {
220- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
221- },
222- &compileInfo);
223 uint64_t expectTilingKey = 12224;192 uint64_t expectTilingKey = 12224;
224 std::vector<size_t> expectWorkspaces = {16777216};193 std::vector<size_t> expectWorkspaces = {16777216};
225 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);194 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
226}195}
227 196 
228-TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_same_shape_no_align_float) {197+TEST_F(ConcatForTilingTest, Concat_tiling_UT_one_axis_same_shape_no_align_float)
198+{
229 optiling::ConcatDCompileInfo compileInfo = {64, 253952};199 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
230- gert::TilingContextPara tilingContextPara(200+ gert::TilingContextPara tilingContextPara("Concat",
231- "Concat",201+ {
232- {202+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
233- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},203+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
234- {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},204+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
235- {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},205+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
236- {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},206+ },
237- },207+ {
238- {208+ {{{24669, 93}, {24669, 93}}, ge::DT_FLOAT, ge::FORMAT_ND},
239- {{{24669, 93}, {24669, 93}}, ge::DT_FLOAT, ge::FORMAT_ND},209+ },
240- },210+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
241- {
242- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
243- },
244- &compileInfo);
245 uint64_t expectTilingKey = 12314;211 uint64_t expectTilingKey = 12314;
246 std::vector<size_t> expectWorkspaces = {16777216};212 std::vector<size_t> expectWorkspaces = {16777216};
247 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);213 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
248-}214+}
@@ -19,30 +19,23 @@
19 19 
20class ConcatTest : public testing::Test {20class ConcatTest : public testing::Test {
21protected:21protected:
22- static void SetUpTestCase()22+ static void SetUpTestCase() {}
23- {
24- std::cout << "ConcatTest SetUp" << std::endl;
25- }
26 23 
27- static void TearDownTestCase()24+ static void TearDownTestCase() {}
28- {
29- std::cout << "ConcatTest TearDown" << std::endl;
30- }
31};25};
32 26 
33TEST_F(ConcatTest, concat_d_infer_shape_fp16)27TEST_F(ConcatTest, concat_d_infer_shape_fp16)
34{28{
35- gert::InfershapeContextPara infershapeContextPara(29+ gert::InfershapeContextPara infershapeContextPara("Concat",
36- "Concat",30+ {
37- {31+ {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
38- {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},32+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
39- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},33+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
40- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},34+ },
41- },35+ {
42- {36+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
43- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},37+ },
44- },38+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
45- {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
46 std::vector<std::vector<int64_t>> expectOutputShape = {39 std::vector<std::vector<int64_t>> expectOutputShape = {
47 {2, 100, 4},40 {2, 100, 4},
48 };41 };
@@ -51,17 +44,16 @@ TEST_F(ConcatTest, concat_d_infer_shape_fp16)
51 44 
52TEST_F(ConcatTest, concat_d_infer_shape_fp16_n1)45TEST_F(ConcatTest, concat_d_infer_shape_fp16_n1)
53{46{
54- gert::InfershapeContextPara infershapeContextPara(47+ gert::InfershapeContextPara infershapeContextPara("Concat",
55- "Concat",48+ {
56- {49+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
57- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},50+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
58- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},51+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
59- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},52+ },
60- },53+ {
61- {54+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
62- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},55+ },
63- },56+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(1)}});
64- {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(1)}});
65 std::vector<std::vector<int64_t>> expectOutputShape = {57 std::vector<std::vector<int64_t>> expectOutputShape = {
66 {2, 100, 4},58 {2, 100, 4},
67 };59 };
@@ -70,18 +62,17 @@ TEST_F(ConcatTest, concat_d_infer_shape_fp16_n1)
70 62 
71TEST_F(ConcatTest, concat_d_infer_shape_fp16_shape)63TEST_F(ConcatTest, concat_d_infer_shape_fp16_shape)
72{64{
73- gert::InfershapeContextPara infershapeContextPara(65+ gert::InfershapeContextPara infershapeContextPara("Concat",
74- "Concat",66+ {
75- {67+ {{{3}, {3}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
76- {{{3}, {3}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},68+ {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
77- {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},69+ {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},
78- {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},70+ {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},
79- {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},71+ },
80- },72+ {
81- {73+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
82- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},74+ },
83- },75+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
84- {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
85 std::vector<std::vector<int64_t>> expectOutputShape = {76 std::vector<std::vector<int64_t>> expectOutputShape = {
86 {2, 100, 1},77 {2, 100, 1},
87 };78 };
@@ -90,18 +81,17 @@ TEST_F(ConcatTest, concat_d_infer_shape_fp16_shape)
90 81 
91TEST_F(ConcatTest, concat_d_infer_shape_fp16_errorshape)82TEST_F(ConcatTest, concat_d_infer_shape_fp16_errorshape)
92{83{
93- gert::InfershapeContextPara infershapeContextPara(84+ gert::InfershapeContextPara infershapeContextPara("Concat",
94- "Concat",85+ {
95- {86+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
96- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},87+ {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
97- {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},88+ {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},
98- {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},89+ {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},
99- {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},90+ },
100- },91+ {
101- {92+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
102- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},93+ },
103- },94+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
104- {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
105 std::vector<std::vector<int64_t>> expectOutputShape = {95 std::vector<std::vector<int64_t>> expectOutputShape = {
106 {2, 100, 1},96 {2, 100, 1},
107 };97 };
@@ -110,18 +100,17 @@ TEST_F(ConcatTest, concat_d_infer_shape_fp16_errorshape)
110 100 
111TEST_F(ConcatTest, concat_d_infer_shape_fp16_errordim)101TEST_F(ConcatTest, concat_d_infer_shape_fp16_errordim)
112{102{
113- gert::InfershapeContextPara infershapeContextPara(103+ gert::InfershapeContextPara infershapeContextPara("Concat",
114- "Concat",104+ {
115- {105+ {{{5}, {5}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
116- {{{5}, {5}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},106+ {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
117- {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},107+ {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},
118- {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},108+ {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},
119- {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},109+ },
120- },110+ {
121- {111+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
122- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},112+ },
123- },113+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
124- {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
125 std::vector<std::vector<int64_t>> expectOutputShape = {114 std::vector<std::vector<int64_t>> expectOutputShape = {
126 {2, 100, 1},115 {2, 100, 1},
127 };116 };
@@ -150,36 +139,34 @@ TEST_F(ConcatTest, concat_d_infer_shape_fp16_errorshapdim)
150 139 
151TEST_F(ConcatTest, concat_d_infer_shape_fp16_scalar)140TEST_F(ConcatTest, concat_d_infer_shape_fp16_scalar)
152{141{
153- gert::InfershapeContextPara infershapeContextPara(142+ gert::InfershapeContextPara infershapeContextPara("Concat",
154- "Concat",143+ {
155- {144+ {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
156- {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},145+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
157- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},146+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
158- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},147+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
159- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},148+ },
160- },149+ {
161- {150+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
162- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},151+ },
163- },152+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
164- {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
165 std::vector<std::vector<int64_t>> expectOutputShape = {};153 std::vector<std::vector<int64_t>> expectOutputShape = {};
166 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);154 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
167}155}
168 156 
169TEST_F(ConcatTest, concat_d_infer_shape_no_shape_range_fp16)157TEST_F(ConcatTest, concat_d_infer_shape_no_shape_range_fp16)
170{158{
171- gert::InfershapeContextPara infershapeContextPara(159+ gert::InfershapeContextPara infershapeContextPara("Concat",
172- "Concat",160+ {
173- {161+ {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
174- {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},162+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
175- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},163+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
176- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},164+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
177- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},165+ },
178- },166+ {
179- {167+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
180- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},168+ },
181- },169+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
182- {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
183 std::vector<std::vector<int64_t>> expectOutputShape = {170 std::vector<std::vector<int64_t>> expectOutputShape = {
184 {2, 100, 4},171 {2, 100, 4},
185 };172 };
@@ -188,39 +175,38 @@ TEST_F(ConcatTest, concat_d_infer_shape_no_shape_range_fp16)
188 175 
189TEST_F(ConcatTest, concat_d_infer_shape_no_shape_range_fp1612)176TEST_F(ConcatTest, concat_d_infer_shape_no_shape_range_fp1612)
190{177{
191- gert::InfershapeContextPara infershapeContextPara(178+ gert::InfershapeContextPara infershapeContextPara("Concat",
192- "Concat",179+ {
193- {180+ {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
194- {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},181+ {{{
195- {{{182+ -2,
196- -2,183+ },
197- },184+ {
198- {185+ -2,
199- -2,186+ }},
200- }},187+ ge::DT_FLOAT16,
201- ge::DT_FLOAT16,188+ ge::FORMAT_ND},
202- ge::FORMAT_ND},189+ {{{
203- {{{190+ -2,
204- -2,191+ },
205- },192+ {
206- {193+ -2,
207- -2,194+ }},
208- }},195+ ge::DT_FLOAT16,
209- ge::DT_FLOAT16,196+ ge::FORMAT_ND},
210- ge::FORMAT_ND},197+ {{{
211- {{{198+ -2,
212- -2,199+ },
213- },200+ {
214- {201+ -2,
215- -2,202+ }},
216- }},203+ ge::DT_FLOAT16,
217- ge::DT_FLOAT16,204+ ge::FORMAT_ND},
218- ge::FORMAT_ND},205+ },
219- },206+ {
220- {207+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
221- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},208+ },
222- },209+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
223- {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
224 std::vector<std::vector<int64_t>> expectOutputShape = {210 std::vector<std::vector<int64_t>> expectOutputShape = {
225 {-2},211 {-2},
226 };212 };
@@ -229,18 +215,17 @@ TEST_F(ConcatTest, concat_d_infer_shape_no_shape_range_fp1612)
229 215 
230TEST_F(ConcatTest, concat_d_infer_shape_no_shape_range_mix_fp16)216TEST_F(ConcatTest, concat_d_infer_shape_no_shape_range_mix_fp16)
231{217{
232- gert::InfershapeContextPara infershapeContextPara(218+ gert::InfershapeContextPara infershapeContextPara("Concat",
233- "Concat",219+ {
234- {220+ {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
235- {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},221+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
236- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},222+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
237- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},223+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
238- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},224+ },
239- },225+ {
240- {226+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
241- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},227+ },
242- },228+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
243- {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}});
244 std::vector<std::vector<int64_t>> expectOutputShape = {229 std::vector<std::vector<int64_t>> expectOutputShape = {
245 {2, 100, 4},230 {2, 100, 4},
246 };231 };
@@ -249,17 +234,16 @@ TEST_F(ConcatTest, concat_d_infer_shape_no_shape_range_mix_fp16)
249 234 
250TEST_F(ConcatTest, concat_d_infer_shape_multi_inputs)235TEST_F(ConcatTest, concat_d_infer_shape_multi_inputs)
251{236{
252- gert::InfershapeContextPara infershapeContextPara(237+ gert::InfershapeContextPara infershapeContextPara("Concat",
253- "Concat",238+ {
254- {239+ {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND},
255- {{{2}, {2}}, ge::DT_INT64, ge::FORMAT_ND},240+ {{{2, 3, 4}, {2, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
256- {{{2, 3, 4}, {2, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},241+ {{{2, 3, 5}, {2, 3, 5}}, ge::DT_FLOAT, ge::FORMAT_ND},
257- {{{2, 3, 5}, {2, 3, 5}}, ge::DT_FLOAT, ge::FORMAT_ND},242+ {{{2, 3, 6}, {2, 3, 6}}, ge::DT_FLOAT, ge::FORMAT_ND},
258- {{{2, 3, 6}, {2, 3, 6}}, ge::DT_FLOAT, ge::FORMAT_ND},243+ },
259- },244+ {
260- {245+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
261- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},246+ },
262- },247+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}}, {3}, {1});
263- {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)}}, {3}, {1});
264 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);248 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);
265}249}
@@ -121,8 +121,8 @@ using std::min;
121 121 
122class ConcatTest : public testing::Test {122class ConcatTest : public testing::Test {
123protected:123protected:
124- static void SetUpTestCase() { std::cout << "concat_test SetUp" << std::endl; }124+ static void SetUpTestCase() {}
125- static void TearDownTestCase() { std::cout << "concat_test TearDown" << std::endl; }125+ static void TearDownTestCase() {}
126};126};
127 127 
128// ============================================================================128// ============================================================================
@@ -128,7 +128,7 @@ static bool CheckFormat(const aclTensorList* tensors, const aclTensor* y)
128{128{
129 op::Format format = (*tensors)[0]->GetStorageFormat();129 op::Format format = (*tensors)[0]->GetStorageFormat();
130 if (op::IsPrivateFormat(format)) {130 if (op::IsPrivateFormat(format)) {
131- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support NDNCHWNHWCHWCNNDHWCNCDHW.");131+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only supports ND, NCHW, NHWC, HWCN, NDHWC, NCDHW.");
132 return false;132 return false;
133 }133 }
134 for (uint64_t i = 1; i < tensors->Size(); i++) {134 for (uint64_t i = 1; i < tensors->Size(); i++) {
@@ -156,7 +156,7 @@ static bool CheckShape(const aclTensorList* tensors, int64_t* realDim)
156 (*realDim) += dimNum;156 (*realDim) += dimNum;
157 }157 }
158 if ((*realDim) < 0 || (*realDim) >= dimNum) {158 if ((*realDim) < 0 || (*realDim) >= dimNum) {
159- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "dimnum %ld exceed the dim range of the tensor %ld.", orgDim, dimNum);159+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "dimnum %ld exceeds the dim range of the tensor %ld.", orgDim, dimNum);
160 return false;160 return false;
161 }161 }
162 for (uint64_t i = 1; i < tensors->Size(); i++) {162 for (uint64_t i = 1; i < tensors->Size(); i++) {
@@ -17,9 +17,9 @@
17 17 
18class ConcatDTiling : public testing::Test {18class ConcatDTiling : public testing::Test {
19protected:19protected:
20- static void SetUpTestCase() { std::cout << "ConcatDTiling SetUp" << std::endl; }20+ static void SetUpTestCase() {}
21 21 
22- static void TearDownTestCase() { std::cout << "ConcatDTiling TearDown" << std::endl; }22+ static void TearDownTestCase() {}
23};23};
24 24 
25TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_diff_shape_align)25TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_diff_shape_align)
@@ -16,34 +16,27 @@
16 16 
17class ConcatDInfershapeTest : public testing::Test {17class ConcatDInfershapeTest : public testing::Test {
18protected:18protected:
19- static void SetUpTestCase()19+ static void SetUpTestCase() {}
20- {
21- std::cout << "ConcatDInfershapeTest SetUp" << std::endl;
22- }
23 20 
24- static void TearDownTestCase()21+ static void TearDownTestCase() {}
25- {
26- std::cout << "ConcatDInfershapeTest TearDown" << std::endl;
27- }
28};22};
29 23 
30TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16)24TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16)
31{25{
32- gert::InfershapeContextPara infershapeContextPara(26+ gert::InfershapeContextPara infershapeContextPara("ConcatD",
33- "ConcatD",27+ {
34- {28+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
35- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},29+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
36- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},30+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
37- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},31+ },
38- },32+ {
39- {33+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
40- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},34+ },
41- },35+ {
42- {36+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
43- {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},37+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
44- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},38+ },
45- },39+ {3}, {1});
46- {3}, {1});
47 std::vector<std::vector<int64_t>> expectOutputShape = {40 std::vector<std::vector<int64_t>> expectOutputShape = {
48 {2, 100, 12},41 {2, 100, 12},
49 };42 };
@@ -52,19 +45,18 @@ TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16)
52 45 
53TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_n1)46TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_n1)
54{47{
55- gert::InfershapeContextPara infershapeContextPara(48+ gert::InfershapeContextPara infershapeContextPara("ConcatD",
56- "ConcatD",49+ {
57- {50+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
58- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},51+ },
59- },52+ {
60- {53+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
61- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},54+ },
62- },55+ {
63- {56+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
64- {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},57+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
65- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},58+ },
66- },59+ {1}, {1});
67- {1}, {1});
68 std::vector<std::vector<int64_t>> expectOutputShape = {60 std::vector<std::vector<int64_t>> expectOutputShape = {
69 {2, 100, 4},61 {2, 100, 4},
70 };62 };
@@ -73,21 +65,20 @@ TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_n1)
73 65 
74TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_shape)66TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_shape)
75{67{
76- gert::InfershapeContextPara infershapeContextPara(68+ gert::InfershapeContextPara infershapeContextPara("ConcatD",
77- "ConcatD",69+ {
78- {70+ {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
79- {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},71+ {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},
80- {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},72+ {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},
81- {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},73+ },
82- },74+ {
83- {75+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
84- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},76+ },
85- },77+ {
86- {78+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
87- {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},79+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
88- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},80+ },
89- },81+ {3}, {1});
90- {3}, {1});
91 std::vector<std::vector<int64_t>> expectOutputShape = {82 std::vector<std::vector<int64_t>> expectOutputShape = {
92 {2, 100, 59},83 {2, 100, 59},
93 };84 };
@@ -96,41 +87,39 @@ TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_shape)
96 87 
97TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_errorshape)88TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_errorshape)
98{89{
99- gert::InfershapeContextPara infershapeContextPara(90+ gert::InfershapeContextPara infershapeContextPara("ConcatD",
100- "ConcatD",91+ {
101- {92+ {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
102- {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},93+ {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},
103- {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},94+ {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},
104- {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},95+ },
105- },96+ {
106- {97+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
107- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},98+ },
108- },99+ {
109- {100+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
110- {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},101+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
111- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},102+ },
112- },103+ {3}, {1});
113- {3}, {1});
114 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);104 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);
115}105}
116 106 
117TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_errordim)107TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_errordim)
118{108{
119- gert::InfershapeContextPara infershapeContextPara(109+ gert::InfershapeContextPara infershapeContextPara("ConcatD",
120- "ConcatD",110+ {
121- {111+ {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
122- {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},112+ {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},
123- {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},113+ {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},
124- {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},114+ },
125- },115+ {
126- {116+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
127- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},117+ },
128- },118+ {
129- {119+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(5)},
130- {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(5)},120+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
131- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},121+ },
132- },122+ {3}, {1});
133- {3}, {1});
134 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);123 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);
135}124}
136 125 
@@ -156,42 +145,40 @@ TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_errorshapdim)
156 145 
157TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_scalar)146TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_scalar)
158{147{
159- gert::InfershapeContextPara infershapeContextPara(148+ gert::InfershapeContextPara infershapeContextPara("ConcatD",
160- "ConcatD",149+ {
161- {150+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
162- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},151+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
163- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},152+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
164- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},153+ },
165- },154+ {
166- {155+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
167- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},156+ },
168- },157+ {
169- {158+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
170- {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},159+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
171- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},160+ },
172- },161+ {3}, {1});
173- {3}, {1});
174 std::vector<std::vector<int64_t>> expectOutputShape = {};162 std::vector<std::vector<int64_t>> expectOutputShape = {};
175 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);163 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
176}164}
177 165 
178TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_no_shape_range_fp16)166TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_no_shape_range_fp16)
179{167{
180- gert::InfershapeContextPara infershapeContextPara(168+ gert::InfershapeContextPara infershapeContextPara("ConcatD",
181- "ConcatD",169+ {
182- {170+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
183- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},171+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
184- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},172+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
185- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},173+ },
186- },174+ {
187- {175+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
188- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},176+ },
189- },177+ {
190- {178+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
191- {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},179+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
192- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},180+ },
193- },181+ {3}, {1});
194- {3}, {1});
195 std::vector<std::vector<int64_t>> expectOutputShape = {182 std::vector<std::vector<int64_t>> expectOutputShape = {
196 {2, 100, 12},183 {2, 100, 12},
197 };184 };
@@ -200,21 +187,20 @@ TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_no_shape_range_fp16)
200 187 
201TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_no_shape_range_mix_fp16)188TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_no_shape_range_mix_fp16)
202{189{
203- gert::InfershapeContextPara infershapeContextPara(190+ gert::InfershapeContextPara infershapeContextPara("ConcatD",
204- "ConcatD",191+ {
205- {192+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
206- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},193+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
207- {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},194+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
208- {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},195+ },
209- },196+ {
210- {197+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
211- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},198+ },
212- },199+ {
213- {200+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
214- {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},201+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
215- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},202+ },
216- },203+ {3}, {1});
217- {3}, {1});
218 std::vector<std::vector<int64_t>> expectOutputShape = {204 std::vector<std::vector<int64_t>> expectOutputShape = {
219 {2, 100, 12},205 {2, 100, 12},
220 };206 };
@@ -223,21 +209,20 @@ TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_no_shape_range_mix_fp16)
223 209 
224TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_dynamic_fp16)210TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_dynamic_fp16)
225{211{
226- gert::InfershapeContextPara infershapeContextPara(212+ gert::InfershapeContextPara infershapeContextPara("ConcatD",
227- "ConcatD",213+ {
228- {214+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
229- {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},215+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
230- {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},216+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
231- {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},217+ },
232- },218+ {
233- {219+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
234- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},220+ },
235- },221+ {
236- {222+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
237- {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},223+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
238- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},224+ },
239- },225+ {3}, {1});
240- {3}, {1});
241 std::vector<std::vector<int64_t>> expectOutputShape = {226 std::vector<std::vector<int64_t>> expectOutputShape = {
242 {2, 100, 12},227 {2, 100, 12},
243 };228 };
@@ -246,21 +231,20 @@ TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_dynamic_fp16)
246 231 
247TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_dynamic2_fp16)232TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_dynamic2_fp16)
248{233{
249- gert::InfershapeContextPara infershapeContextPara(234+ gert::InfershapeContextPara infershapeContextPara("ConcatD",
250- "ConcatD",235+ {
251- {236+ {{{2, 100, 4}, {-1, -1, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},
252- {{{2, 100, 4}, {-1, -1, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},237+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
253- {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},238+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
254- {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},239+ },
255- },240+ {
256- {241+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
257- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},242+ },
258- },243+ {
259- {244+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
260- {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},245+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
261- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},246+ },
262- },247+ {3}, {1});
263- {3}, {1});
264 std::vector<std::vector<int64_t>> expectOutputShape = {248 std::vector<std::vector<int64_t>> expectOutputShape = {
265 {2, 100, 12},249 {2, 100, 12},
266 };250 };
@@ -121,8 +121,8 @@ using std::min;
121 121 
122class ConcatDTest : public testing::Test {122class ConcatDTest : public testing::Test {
123protected:123protected:
124- static void SetUpTestCase() { std::cout << "concat_d_test SetUp" << std::endl; }124+ static void SetUpTestCase() {}
125- static void TearDownTestCase() { std::cout << "concat_d_test TearDown" << std::endl; }125+ static void TearDownTestCase() {}
126};126};
127 127 
128// ============================================================================128// ============================================================================
@@ -33,6 +33,11 @@
33#define FAILED -133#define FAILED -1
34#define SUCCESS 034#define SUCCESS 0
35 35 
36+#define LOG_PRINT(message, ...) \
37+ do { \
38+ printf(message, ##__VA_ARGS__); \
39+ } while (0)
40+ 
36using namespace ge;41using namespace ge;
37using std::map;42using std::map;
38using std::string;43using std::string;
@@ -49,7 +54,7 @@ using std::vector;
49 Tensor tensor##dataName; \54 Tensor tensor##dataName; \
50 ret = GenOnesData(shape##dataName, tensor##dataName, desc##dataName, inputDtype, (inputIndex + 1)); \55 ret = GenOnesData(shape##dataName, tensor##dataName, desc##dataName, inputDtype, (inputIndex + 1)); \
51 if (ret != SUCCESS) { \56 if (ret != SUCCESS) { \
52- printf("%s - ERROR - [XIR]: Generate input data failed\n", GetTime().c_str()); \57+ LOG_PRINT("%s - ERROR - [CONCAT_V2_GE_IR]: Generate input data failed\n", GetTime().c_str()); \
53 return FAILED; \58 return FAILED; \
54 } \59 } \
55 concat1.UpdateDynamicInputDesc("x", inputIndex, desc##dataName); \60 concat1.UpdateDynamicInputDesc("x", inputIndex, desc##dataName); \
@@ -59,27 +64,26 @@ using std::vector;
59 inputs.push_back(placeholder##dataName); \64 inputs.push_back(placeholder##dataName); \
60 } while (0)65 } while (0)
61 66 
62-#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \67+#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \
63- do { \68+ do { \
64- vector<int64_t> placeholder##intputIndex##_shape = inputShape; \69+ vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
65- auto placeholder##intputIndex = op::Data("placeholder" + intputIndex).set_attr_index(0); \70+ auto placeholder##intputIndex = op::Data("placeholder" + intputIndex).set_attr_index(0); \
66- TensorDesc placeholder##intputIndex##_desc = \71+ TensorDesc placeholder##intputIndex##_desc = TensorDesc(ge::Shape(placeholder##intputIndex##_shape), \
67- TensorDesc(ge::Shape(placeholder##intputIndex##_shape), FORMAT_ND, intputDtype); \72+ FORMAT_ND, intputDtype); \
68- placeholder##intputIndex##_desc.SetPlacement(ge::kPlacementHost); \73+ placeholder##intputIndex##_desc.SetPlacement(ge::kPlacementHost); \
69- placeholder##intputIndex##_desc.SetFormat(FORMAT_ND); \74+ placeholder##intputIndex##_desc.SetFormat(FORMAT_ND); \
70- Tensor tensor_placeholder##intputIndex; \75+ Tensor tensor_placeholder##intputIndex; \
71- ret = GenOnesData( \76+ ret = GenOnesData(placeholder##intputIndex##_shape, tensor_placeholder##intputIndex, \
72- placeholder##intputIndex##_shape, tensor_placeholder##intputIndex, placeholder##intputIndex##_desc, \77+ placeholder##intputIndex##_desc, intputDtype, value); \
73- intputDtype, value); \78+ if (ret != SUCCESS) { \
74- if (ret != SUCCESS) { \79+ LOG_PRINT("%s - ERROR - [CONCAT_V2_GE_IR]: Generate input data failed\n", GetTime().c_str()); \
75- printf("%s - ERROR - [XIR]: Generate input data failed\n", GetTime().c_str()); \80+ return FAILED; \
76- return FAILED; \81+ } \
77- } \82+ placeholder##intputIndex.update_input_desc_x(placeholder##intputIndex##_desc); \
78- placeholder##intputIndex.update_input_desc_x(placeholder##intputIndex##_desc); \83+ input.push_back(tensor_placeholder##intputIndex); \
79- input.push_back(tensor_placeholder##intputIndex); \84+ graph.AddOp(placeholder##intputIndex); \
80- graph.AddOp(placeholder##intputIndex); \85+ concat1.set_input_##intputName(placeholder##intputIndex); \
81- concat1.set_input_##intputName(placeholder##intputIndex); \86+ inputs.push_back(placeholder##intputIndex); \
82- inputs.push_back(placeholder##intputIndex); \
83 } while (0)87 } while (0)
84 88 
85#define ADD_INPUT_ATTR(attrName, attrValue) \89#define ADD_INPUT_ATTR(attrName, attrValue) \
@@ -151,8 +155,8 @@ int32_t GenOnesDataFloat32(vector<int64_t> shapes, Tensor& input_tensor, TensorD
151 return SUCCESS;155 return SUCCESS;
152}156}
153 157 
154-int32_t GenOnesData(158+int32_t GenOnesData(vector<int64_t> shapes, Tensor& input_tensor, TensorDesc& input_tensor_desc, DataType data_type,
155- vector<int64_t> shapes, Tensor& input_tensor, TensorDesc& input_tensor_desc, DataType data_type, int value)159+ int value)
156{160{
157 input_tensor_desc.SetRealDimCnt(shapes.size());161 input_tensor_desc.SetRealDimCnt(shapes.size());
158 size_t size = 1;162 size_t size = 1;
@@ -182,9 +186,8 @@ int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t* inputData)
182 return SUCCESS;186 return SUCCESS;
183}187}
184 188 
185-int CreateOppInGraph(189+int CreateOppInGraph(DataType inDtype, std::vector<ge::Tensor>& input, std::vector<Operator>& inputs,
186- DataType inDtype, std::vector<ge::Tensor>& input, std::vector<Operator>& inputs, std::vector<Operator>& outputs,190+ std::vector<Operator>& outputs, Graph& graph)
187- Graph& graph)
188{191{
189 Status ret = SUCCESS;192 Status ret = SUCCESS;
190 auto concat1 = op::ConcatV2("concat1").create_dynamic_input_x(2, false);193 auto concat1 = op::ConcatV2("concat1").create_dynamic_input_x(2, false);
@@ -209,27 +212,27 @@ int main(int argc, char* argv[])
209 Graph graph(graph_name);212 Graph graph(graph_name);
210 std::vector<ge::Tensor> input;213 std::vector<ge::Tensor> input;
211 214 
212- printf("%s - INFO - [XIR]: Start to initialize ge using ge global options\n", GetTime().c_str());215+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Start to initialize ge using ge global options\n", GetTime().c_str());
213 std::map<AscendString, AscendString> global_options = {{"ge.exec.deviceId", "0"}, {"ge.graphRunMode", "1"}};216 std::map<AscendString, AscendString> global_options = {{"ge.exec.deviceId", "0"}, {"ge.graphRunMode", "1"}};
214 Status ret = ge::GEInitialize(global_options);217 Status ret = ge::GEInitialize(global_options);
215 if (ret != SUCCESS) {218 if (ret != SUCCESS) {
216- printf("%s - INFO - [XIR]: Initialize ge using ge global options failed\n", GetTime().c_str());219+ LOG_PRINT("%s - ERROR - [CONCAT_V2_GE_IR]: Initialize ge using ge global options failed\n", GetTime().c_str());
217 return FAILED;220 return FAILED;
218 }221 }
219- printf("%s - INFO - [XIR]: Initialize ge using ge global options success\n", GetTime().c_str());222+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Initialize ge using ge global options success\n", GetTime().c_str());
220 223 
221 std::vector<Operator> inputs{};224 std::vector<Operator> inputs{};
222 std::vector<Operator> outputs{};225 std::vector<Operator> outputs{};
223 226 
224- std::cout << argv[1] << std::endl;227+ LOG_PRINT("argv[1] = %s\n", argv[1]);
225 228 
226 DataType inDtype = DT_FLOAT;229 DataType inDtype = DT_FLOAT;
227 230 
228- std::cout << inDtype << std::endl;231+ LOG_PRINT("inDtype: %d\n", static_cast<int>(inDtype));
229 232 
230 ret = CreateOppInGraph(inDtype, input, inputs, outputs, graph);233 ret = CreateOppInGraph(inDtype, input, inputs, outputs, graph);
231 if (ret != SUCCESS) {234 if (ret != SUCCESS) {
232- printf("%s - ERROR - [XIR]: Create ir session using build options failed\n", GetTime().c_str());235+ LOG_PRINT("%s - ERROR - [CONCAT_V2_GE_IR]: Create ir session using build options failed\n", GetTime().c_str());
233 return FAILED;236 return FAILED;
234 }237 }
235 238 
@@ -240,15 +243,15 @@ int main(int argc, char* argv[])
240 std::map<AscendString, AscendString> build_options = {243 std::map<AscendString, AscendString> build_options = {
241 244 
242 };245 };
243- printf("%s - INFO - [XIR]: Start to create ir session using build options\n", GetTime().c_str());246+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Start to create ir session using build options\n", GetTime().c_str());
244 ge::Session* session = new Session(build_options);247 ge::Session* session = new Session(build_options);
245 248 
246 if (session == nullptr) {249 if (session == nullptr) {
247- printf("%s - ERROR - [XIR]: Create ir session using build options failed\n", GetTime().c_str());250+ LOG_PRINT("%s - ERROR - [CONCAT_V2_GE_IR]: Create ir session using build options failed\n", GetTime().c_str());
248 return FAILED;251 return FAILED;
249 }252 }
250- printf("%s - INFO - [XIR]: Create ir session using build options success\n", GetTime().c_str());253+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Create ir session using build options success\n", GetTime().c_str());
251- printf("%s - INFO - [XIR]: Start to add compute graph to ir session\n", GetTime().c_str());254+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Start to add compute graph to ir session\n", GetTime().c_str());
252 255 
253 std::map<AscendString, AscendString> graph_options = {256 std::map<AscendString, AscendString> graph_options = {
254 257 
@@ -256,56 +259,56 @@ int main(int argc, char* argv[])
256 uint32_t graph_id = 0;259 uint32_t graph_id = 0;
257 ret = session->AddGraph(graph_id, graph, graph_options);260 ret = session->AddGraph(graph_id, graph, graph_options);
258 261 
259- printf("%s - INFO - [XIR]: Session add ir compute graph to ir session success\n", GetTime().c_str());262+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Session add ir compute graph to ir session success\n", GetTime().c_str());
260- printf("%s - INFO - [XIR]: dump graph to txt\n", GetTime().c_str());263+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: dump graph to txt\n", GetTime().c_str());
261 std::string file_path = "./dump";264 std::string file_path = "./dump";
262 aclgrphDumpGraph(graph, file_path.c_str(), file_path.length());265 aclgrphDumpGraph(graph, file_path.c_str(), file_path.length());
263- printf("%s - INFO - [XIR]: Start to run ir compute graph\n", GetTime().c_str());266+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Start to run ir compute graph\n", GetTime().c_str());
264 std::vector<ge::Tensor> output;267 std::vector<ge::Tensor> output;
265 ret = session->RunGraph(graph_id, input, output);268 ret = session->RunGraph(graph_id, input, output);
266 if (ret != SUCCESS) {269 if (ret != SUCCESS) {
267- printf("%s - INFO - [XIR]: Run graph failed\n", GetTime().c_str());270+ LOG_PRINT("%s - ERROR - [CONCAT_V2_GE_IR]: Run graph failed\n", GetTime().c_str());
268 delete session;271 delete session;
269 GEFinalize();272 GEFinalize();
270 return FAILED;273 return FAILED;
271 }274 }
272- printf("%s - INFO - [XIR]: Session run ir compute graph success\n", GetTime().c_str());275+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Session run ir compute graph success\n", GetTime().c_str());
273 276 
274 int input_num = input.size();277 int input_num = input.size();
275 for (int i = 0; i < input_num; i++) {278 for (int i = 0; i < input_num; i++) {
276- std::cout << "input " << i << " dtype : " << input[i].GetTensorDesc().GetDataType() << std::endl;279+ LOG_PRINT("input %d dtype: %d\n", i, static_cast<int>(input[i].GetTensorDesc().GetDataType()));
277 string input_file = "./tc_ge_irrun_test_0008_npu_input_" + std::to_string(i) + ".bin";280 string input_file = "./tc_ge_irrun_test_0008_npu_input_" + std::to_string(i) + ".bin";
278 uint8_t* input_data_i = input[i].GetData();281 uint8_t* input_data_i = input[i].GetData();
279 int64_t input_shape = input[i].GetTensorDesc().GetShape().GetShapeSize();282 int64_t input_shape = input[i].GetTensorDesc().GetShape().GetShapeSize();
280- std::cout << "this is " << i << "th input, input shape size =" << input_shape << std::endl;283+ LOG_PRINT("input %d shape size: %ld\n", i, input_shape);
281 uint32_t data_size = input_shape * GetDataTypeSize(input[i].GetTensorDesc().GetDataType());284 uint32_t data_size = input_shape * GetDataTypeSize(input[i].GetTensorDesc().GetDataType());
282 WriteDataToFile((const char*)input_file.c_str(), data_size, input_data_i);285 WriteDataToFile((const char*)input_file.c_str(), data_size, input_data_i);
283 }286 }
284 287 
285 int output_num = output.size();288 int output_num = output.size();
286 for (int i = 0; i < output_num; i++) {289 for (int i = 0; i < output_num; i++) {
287- std::cout << "output " << i << " dtype : " << output[i].GetTensorDesc().GetDataType() << std::endl;290+ LOG_PRINT("output %d dtype: %d\n", i, static_cast<int>(output[i].GetTensorDesc().GetDataType()));
288 string output_file = "./tc_ge_irrun_test_0008_npu_output_" + std::to_string(i) + ".bin";291 string output_file = "./tc_ge_irrun_test_0008_npu_output_" + std::to_string(i) + ".bin";
289 uint8_t* output_data_i = output[i].GetData();292 uint8_t* output_data_i = output[i].GetData();
290 int64_t output_shape = output[i].GetTensorDesc().GetShape().GetShapeSize();293 int64_t output_shape = output[i].GetTensorDesc().GetShape().GetShapeSize();
291- std::cout << "this is " << i << "th output, output shape size =" << output_shape << std::endl;294+ LOG_PRINT("output %d shape size: %ld\n", i, output_shape);
292 uint32_t data_size = output_shape * GetDataTypeSize(output[i].GetTensorDesc().GetDataType());295 uint32_t data_size = output_shape * GetDataTypeSize(output[i].GetTensorDesc().GetDataType());
293 WriteDataToFile((const char*)output_file.c_str(), data_size, output_data_i);296 WriteDataToFile((const char*)output_file.c_str(), data_size, output_data_i);
294 }297 }
295 298 
296 ge::AscendString error_msg = ge::GEGetErrorMsgV2();299 ge::AscendString error_msg = ge::GEGetErrorMsgV2();
297 std::string error_str(error_msg.GetString());300 std::string error_str(error_msg.GetString());
298- std::cout << "Error message: " << error_str << std::endl;301+ LOG_PRINT("Error message: %s\n", error_str.c_str());
299 ge::AscendString warning_msg = ge::GEGetWarningMsgV2();302 ge::AscendString warning_msg = ge::GEGetWarningMsgV2();
300 std::string warning_str(warning_msg.GetString());303 std::string warning_str(warning_msg.GetString());
301- std::cout << "Warning message: " << warning_str << std::endl;304+ LOG_PRINT("Warning message: %s\n", warning_str.c_str());
302- printf("%s - INFO - [XIR]: Precision is ok\n", GetTime().c_str());305+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Precision is ok\n", GetTime().c_str());
303- printf("%s - INFO - [XIR]: Start to finalize ir graph session\n", GetTime().c_str());306+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Start to finalize ir graph session\n", GetTime().c_str());
304 ret = ge::GEFinalize();307 ret = ge::GEFinalize();
305 if (ret != SUCCESS) {308 if (ret != SUCCESS) {
306- printf("%s - INFO - [XIR]: Finalize ir graph session failed\n", GetTime().c_str());309+ LOG_PRINT("%s - ERROR - [CONCAT_V2_GE_IR]: Finalize ir graph session failed\n", GetTime().c_str());
307 return FAILED;310 return FAILED;
308 }311 }
309- printf("%s - INFO - [XIR]: Finalize ir graph session success\n", GetTime().c_str());312+ LOG_PRINT("%s - INFO - [CONCAT_V2_GE_IR]: Finalize ir graph session success\n", GetTime().c_str());
310 return SUCCESS;313 return SUCCESS;
311}314}
@@ -20,229 +20,195 @@
20using namespace std;20using namespace std;
21class ConcatV2ForTilingTest : public testing::Test {21class ConcatV2ForTilingTest : public testing::Test {
22protected:22protected:
23- static void SetUpTestCase() {23+ static void SetUpTestCase() {}
24- std::cout << "ConcatV2ForTilingTest SetUp" << std::endl;
25- }
26 24 
27- static void TearDownTestCase() {25+ static void TearDownTestCase() {}
28- std::cout << "ConcatV2ForTilingTest TearDown" << std::endl;
29- }
30};26};
31 27 
32-TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_diff_shape_align) {28+TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_diff_shape_align)
29+{
33 optiling::ConcatDCompileInfo compileInfo = {64, 253952};30 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
34- gert::TilingContextPara tilingContextPara(31+ gert::TilingContextPara tilingContextPara("ConcatV2",
35- "ConcatV2",32+ {
36- {33+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
37- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},34+ {{{31, 3, 2560}, {31, 3, 2560}}, ge::DT_FLOAT, ge::FORMAT_ND},
38- {{{31, 3, 2560}, {31, 3, 2560}}, ge::DT_FLOAT, ge::FORMAT_ND},35+ {{{31, 3, 1280}, {31, 3, 1280}}, ge::DT_FLOAT, ge::FORMAT_ND},
39- {{{31, 3, 1280}, {31, 3, 1280}}, ge::DT_FLOAT, ge::FORMAT_ND},36+ {{{31, 3, 9980}, {31, 3, 9980}}, ge::DT_FLOAT, ge::FORMAT_ND},
40- {{{31, 3, 9980}, {31, 3, 9980}}, ge::DT_FLOAT, ge::FORMAT_ND},37+ },
41- },38+ {
42- {39+ {{{31, 3, 13820}, {31, 3, 13820}}, ge::DT_INT32, ge::FORMAT_ND},
43- {{{31, 3, 13820}, {31, 3, 13820}}, ge::DT_INT32, ge::FORMAT_ND},40+ },
44- },41+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
45- {
46- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
47- },
48- &compileInfo);
49 uint64_t expectTilingKey = 2224;42 uint64_t expectTilingKey = 2224;
50 std::vector<size_t> expectWorkspaces = {16777216};43 std::vector<size_t> expectWorkspaces = {16777216};
51 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);44 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
52}45}
53 46 
54-TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_pure_copy) {47+TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_pure_copy)
48+{
55 optiling::ConcatDCompileInfo compileInfo = {64, 253952};49 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
56- gert::TilingContextPara tilingContextPara(50+ gert::TilingContextPara tilingContextPara("ConcatV2",
57- "ConcatV2",51+ {
58- {52+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
59- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},53+ {{{310, 3, 2560}, {310, 3, 2560}}, ge::DT_FLOAT, ge::FORMAT_ND},
60- {{{310, 3, 2560}, {310, 3, 2560}}, ge::DT_FLOAT, ge::FORMAT_ND},54+ {{{310, 3, 1280}, {310, 3, 1280}}, ge::DT_FLOAT, ge::FORMAT_ND},
61- {{{310, 3, 1280}, {310, 3, 1280}}, ge::DT_FLOAT, ge::FORMAT_ND},55+ {{{310, 3, 9980}, {310, 3, 9980}}, ge::DT_FLOAT, ge::FORMAT_ND},
62- {{{310, 3, 9980}, {310, 3, 9980}}, ge::DT_FLOAT, ge::FORMAT_ND},56+ },
63- },57+ {
64- {58+ {{{310, 3, 13820}, {310, 3, 13820}}, ge::DT_INT32, ge::FORMAT_ND},
65- {{{310, 3, 13820}, {310, 3, 13820}}, ge::DT_INT32, ge::FORMAT_ND},59+ },
66- },60+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
67- {
68- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
69- },
70- &compileInfo);
71 uint64_t expectTilingKey = 20002;61 uint64_t expectTilingKey = 20002;
72 std::vector<size_t> expectWorkspaces = {16777216};62 std::vector<size_t> expectWorkspaces = {16777216};
73 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);63 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
74}64}
75 65 
76-TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_diff_shape_align_int64) {66+TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_diff_shape_align_int64)
67+{
77 optiling::ConcatDCompileInfo compileInfo = {64, 253952};68 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
78- gert::TilingContextPara tilingContextPara(69+ gert::TilingContextPara tilingContextPara("ConcatV2",
79- "ConcatV2",70+ {
80- {71+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
81- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},72+ {{{16384, 512}, {16384, 512}}, ge::DT_INT64, ge::FORMAT_ND},
82- {{{16384, 512}, {16384, 512}}, ge::DT_INT64, ge::FORMAT_ND},73+ {{{16384, 4}, {16384, 4}}, ge::DT_INT64, ge::FORMAT_ND},
83- {{{16384, 4}, {16384, 4}}, ge::DT_INT64, ge::FORMAT_ND},74+ },
84- },75+ {
85- {76+ {{{16384, 516}, {16384, 516}}, ge::DT_INT64, ge::FORMAT_ND},
86- {{{16384, 516}, {16384, 516}}, ge::DT_INT64, ge::FORMAT_ND},77+ },
87- },78+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
88- {
89- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
90- },
91- &compileInfo);
92 uint64_t expectTilingKey = 12128;79 uint64_t expectTilingKey = 12128;
93 std::vector<size_t> expectWorkspaces = {16777216};80 std::vector<size_t> expectWorkspaces = {16777216};
94 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);81 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
95}82}
96 83 
97-TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_same_shape_align) {84+TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_same_shape_align)
85+{
98 optiling::ConcatDCompileInfo compileInfo = {64, 253952};86 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
99- gert::TilingContextPara tilingContextPara(87+ gert::TilingContextPara tilingContextPara("ConcatV2",
100- "ConcatV2",88+ {
101- {89+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
102- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},90+ {{{12, 2, 8, 128}, {12, 2, 8, 128}}, ge::DT_INT64, ge::FORMAT_ND},
103- {{{12, 2, 8, 128}, {12, 2, 8, 128}}, ge::DT_INT64, ge::FORMAT_ND},91+ {{{12, 2, 8, 128}, {12, 2, 8, 128}}, ge::DT_INT64, ge::FORMAT_ND},
104- {{{12, 2, 8, 128}, {12, 2, 8, 128}}, ge::DT_INT64, ge::FORMAT_ND},92+ },
105- },93+ {
106- {94+ {{{16384, 516}, {16384, 516}}, ge::DT_INT64, ge::FORMAT_ND},
107- {{{16384, 516}, {16384, 516}}, ge::DT_INT64, ge::FORMAT_ND},95+ },
108- },96+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
109- {
110- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
111- },
112- &compileInfo);
113 uint64_t expectTilingKey = 2118;97 uint64_t expectTilingKey = 2118;
114 std::vector<size_t> expectWorkspaces = {16777216};98 std::vector<size_t> expectWorkspaces = {16777216};
115 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);99 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
116}100}
117 101 
118-TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_zero_axis_same_shape_align_float) {102+TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_zero_axis_same_shape_align_float)
103+{
119 optiling::ConcatDCompileInfo compileInfo = {64, 253952};104 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
120- gert::TilingContextPara tilingContextPara(105+ gert::TilingContextPara tilingContextPara("ConcatV2",
121- "ConcatV2",106+ {
122- {107+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
123- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},108+ {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},
124- {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},109+ {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},
125- {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},110+ {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},
126- {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},111+ },
127- },112+ {
128- {113+ {{{16384, 516}, {16384, 516}}, ge::DT_FLOAT, ge::FORMAT_ND},
129- {{{16384, 516}, {16384, 516}}, ge::DT_FLOAT, ge::FORMAT_ND},114+ },
130- },115+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
131- {
132- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
133- },
134- &compileInfo);
135 uint64_t expectTilingKey = 2114;116 uint64_t expectTilingKey = 2114;
136 std::vector<size_t> expectWorkspaces = {16777216};117 std::vector<size_t> expectWorkspaces = {16777216};
137 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);118 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
138}119}
139 120 
140-TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_zero_axis_diff_shape_align_float) {121+TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_zero_axis_diff_shape_align_float)
122+{
141 optiling::ConcatDCompileInfo compileInfo = {64, 253952};123 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
142- gert::TilingContextPara tilingContextPara(124+ gert::TilingContextPara tilingContextPara("ConcatV2",
143- "ConcatV2",125+ {
144- {126+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
145- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},127+ {{{8256}, {8256}}, ge::DT_FLOAT, ge::FORMAT_ND},
146- {{{8256}, {8256}}, ge::DT_FLOAT, ge::FORMAT_ND},128+ {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND},
147- {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND},129+ {{{4112}, {4112}}, ge::DT_FLOAT, ge::FORMAT_ND},
148- {{{4112}, {4112}}, ge::DT_FLOAT, ge::FORMAT_ND},130+ },
149- },131+ {
150- {132+ {{{20602}, {20602}}, ge::DT_FLOAT, ge::FORMAT_ND},
151- {{{20602}, {20602}}, ge::DT_FLOAT, ge::FORMAT_ND},133+ },
152- },134+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
153- {
154- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
155- },
156- &compileInfo);
157 uint64_t expectTilingKey = 2124;135 uint64_t expectTilingKey = 2124;
158 std::vector<size_t> expectWorkspaces = {16777216};136 std::vector<size_t> expectWorkspaces = {16777216};
159 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);137 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
160}138}
161 139 
162-TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_concat_simt_same_shape_no_align_float) {140+TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_concat_simt_same_shape_no_align_float)
141+{
163 optiling::ConcatDCompileInfo compileInfo = {64, 253952};142 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
164- gert::TilingContextPara tilingContextPara(143+ gert::TilingContextPara tilingContextPara("ConcatV2",
165- "ConcatV2",144+ {
166- {145+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
167- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},146+ {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},
168- {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},147+ {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},
169- {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},148+ {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},
170- {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},149+ },
171- },150+ {
172- {151+ {{{36867}, {36867}}, ge::DT_FLOAT, ge::FORMAT_ND},
173- {{{36867}, {36867}}, ge::DT_FLOAT, ge::FORMAT_ND},152+ },
174- },153+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
175- {
176- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
177- },
178- &compileInfo);
179 uint64_t expectTilingKey = 2124;154 uint64_t expectTilingKey = 2124;
180 std::vector<size_t> expectWorkspaces = {16777216};155 std::vector<size_t> expectWorkspaces = {16777216};
181 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);156 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
182}157}
183 158 
184-TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_zero_axis_diff_shape_no_align_float) {159+TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_zero_axis_diff_shape_no_align_float)
160+{
185 optiling::ConcatDCompileInfo compileInfo = {64, 253952};161 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
186- gert::TilingContextPara tilingContextPara(162+ gert::TilingContextPara tilingContextPara("ConcatV2",
187- "ConcatV2",163+ {
188- {164+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
189- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},165+ {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND},
190- {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND},166+ {{{8223}, {8223}}, ge::DT_FLOAT, ge::FORMAT_ND},
191- {{{8223}, {8223}}, ge::DT_FLOAT, ge::FORMAT_ND},167+ {{{3223}, {3223}}, ge::DT_FLOAT, ge::FORMAT_ND},
192- {{{3223}, {3223}}, ge::DT_FLOAT, ge::FORMAT_ND},168+ },
193- },169+ {
194- {170+ {{{19670}, {19670}}, ge::DT_FLOAT, ge::FORMAT_ND},
195- {{{19670}, {19670}}, ge::DT_FLOAT, ge::FORMAT_ND},171+ },
196- },172+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
197- {
198- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
199- },
200- &compileInfo);
201 uint64_t expectTilingKey = 2224;173 uint64_t expectTilingKey = 2224;
202 std::vector<size_t> expectWorkspaces = {16777216};174 std::vector<size_t> expectWorkspaces = {16777216};
203 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);175 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
204}176}
205 177 
206-TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_diff_shape_no_align_float) {178+TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_diff_shape_no_align_float)
179+{
207 optiling::ConcatDCompileInfo compileInfo = {64, 253952};180 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
208- gert::TilingContextPara tilingContextPara(181+ gert::TilingContextPara tilingContextPara("ConcatV2",
209- "ConcatV2",182+ {
210- {183+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
211- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},184+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
212- {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},185+ {{{8223, 33}, {8223, 33}}, ge::DT_FLOAT, ge::FORMAT_ND},
213- {{{8223, 33}, {8223, 33}}, ge::DT_FLOAT, ge::FORMAT_ND},186+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
214- {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},187+ },
215- },188+ {
216- {189+ {{{24669, 94}, {24669, 94}}, ge::DT_FLOAT, ge::FORMAT_ND},
217- {{{24669, 94}, {24669, 94}}, ge::DT_FLOAT, ge::FORMAT_ND},190+ },
218- },191+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
219- {
220- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
221- },
222- &compileInfo);
223 uint64_t expectTilingKey = 12224;192 uint64_t expectTilingKey = 12224;
224 std::vector<size_t> expectWorkspaces = {16777216};193 std::vector<size_t> expectWorkspaces = {16777216};
225 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);194 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
226}195}
227 196 
228-TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_same_shape_no_align_float) {197+TEST_F(ConcatV2ForTilingTest, ConcatV2_tiling_UT_one_axis_same_shape_no_align_float)
198+{
229 optiling::ConcatDCompileInfo compileInfo = {64, 253952};199 optiling::ConcatDCompileInfo compileInfo = {64, 253952};
230- gert::TilingContextPara tilingContextPara(200+ gert::TilingContextPara tilingContextPara("ConcatV2",
231- "ConcatV2",201+ {
232- {202+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},
233- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND},203+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
234- {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},204+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
235- {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},205+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
236- {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},206+ },
237- },207+ {
238- {208+ {{{24669, 93}, {24669, 93}}, ge::DT_FLOAT, ge::FORMAT_ND},
239- {{{24669, 93}, {24669, 93}}, ge::DT_FLOAT, ge::FORMAT_ND},209+ },
240- },210+ {{"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}}, &compileInfo);
241- {
242- {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(0)}
243- },
244- &compileInfo);
245 uint64_t expectTilingKey = 12314;211 uint64_t expectTilingKey = 12314;
246 std::vector<size_t> expectWorkspaces = {16777216};212 std::vector<size_t> expectWorkspaces = {16777216};
247 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);213 ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED, expectTilingKey, expectWorkspaces);
248-}214+}