已合并
日志整改(im2col等算子) #5009
zhu-xun创建于 10 天前
日志整改(im2col等算子) #5009
已合并
zhu-xun创建于 10 天前
57 个文件变更+1666-1843
@@ -34,8 +34,8 @@ static constexpr size_t ARRAY_SIZE = 2;
34static constexpr size_t PADDING_SIZE = 4;34static constexpr size_t PADDING_SIZE = 4;
35 35 
36// 根据API定义,需要列出所能支持的所有dtype36// 根据API定义,需要列出所能支持的所有dtype
37-static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST = {37+static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST = {op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16,
38- op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_BF16};38+ op::DataType::DT_BF16};
39 39 
40static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST_REGBASE = {40static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST_REGBASE = {
41 op::DataType::DT_INT8, op::DataType::DT_UINT8, op::DataType::DT_INT16, op::DataType::DT_UINT16,41 op::DataType::DT_INT8, op::DataType::DT_UINT8, op::DataType::DT_INT16, op::DataType::DT_UINT16,
@@ -63,9 +63,8 @@ static inline auto div_rtn(T x, T y) -> T
63extern "C" {63extern "C" {
64#endif64#endif
65 65 
66-static inline bool CheckNotNull(66+static inline bool CheckNotNull(const aclTensor* self, const aclIntArray* kernelSize, const aclIntArray* dilation,
67- const aclTensor* self, const aclIntArray* kernelSize, const aclIntArray* dilation, const aclIntArray* padding,67+ const aclIntArray* padding, const aclIntArray* stride, const aclTensor* out)
68- const aclIntArray* stride, const aclTensor* out)
69{68{
70 OP_CHECK_NULL(self, return false);69 OP_CHECK_NULL(self, return false);
71 OP_CHECK_NULL(kernelSize, return false);70 OP_CHECK_NULL(kernelSize, return false);
@@ -80,9 +79,8 @@ static bool CheckInputDims(const aclTensor* self)
80{79{
81 auto selfDimNum = self->GetViewShape().GetDimNum();80 auto selfDimNum = self->GetViewShape().GetDimNum();
82 if (selfDimNum != NEED_SQUEEZE && selfDimNum != NO_NEED_SQUEEZE) {81 if (selfDimNum != NEED_SQUEEZE && selfDimNum != NO_NEED_SQUEEZE) {
83- OP_LOGE(82+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expected self dim [%zu] to be 3 or 4 but check failed.",
84- ACLNN_ERR_PARAM_INVALID, "Expected self dim [%zu] to be 3 or 4 but check failed.",83+ self->GetViewShape().GetDimNum());
85- self->GetViewShape().GetDimNum());
86 return false;84 return false;
87 }85 }
88 86 
@@ -91,59 +89,54 @@ static bool CheckInputDims(const aclTensor* self)
91 size_t index = selfDimNum == NO_NEED_SQUEEZE ? 1 : 0;89 size_t index = selfDimNum == NO_NEED_SQUEEZE ? 1 : 0;
92 for (size_t i = index; i < selfDimNum; i++) {90 for (size_t i = index; i < selfDimNum; i++) {
93 if (selfShape.GetDim(i) <= 0) {91 if (selfShape.GetDim(i) <= 0) {
94- OP_LOGE(92+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "self's dims is invalid, self No.[%lu] dim is [%ld].", i + 1,
95- ACLNN_ERR_PARAM_INVALID, "self'dims is invalid, self No.[%lu] dim is [%ld].", i + 1,93+ selfShape.GetDim(i));
96- selfShape.GetDim(i));
97 return false;94 return false;
98 }95 }
99 }96 }
100 return true;97 return true;
101}98}
102 99 
103-static bool CheckOutputDims(100+static bool CheckOutputDims(const aclTensor* self, const aclIntArray* kernelSize, const aclIntArray* dilation,
104- const aclTensor* self, const aclIntArray* kernelSize, const aclIntArray* dilation, const aclIntArray* padding,101+ const aclIntArray* padding, const aclIntArray* stride, const aclTensor* out)
105- const aclIntArray* stride, const aclTensor* out)
106{102{
107 bool isNeedSqueeze = (self->GetViewShape().GetDimNum() == NEED_SQUEEZE);103 bool isNeedSqueeze = (self->GetViewShape().GetDimNum() == NEED_SQUEEZE);
108 int64_t inputHeight = isNeedSqueeze ? self->GetViewShape().GetDim(1) : self->GetViewShape().GetDim(2);104 int64_t inputHeight = isNeedSqueeze ? self->GetViewShape().GetDim(1) : self->GetViewShape().GetDim(2);
109 int64_t inputWidth = isNeedSqueeze ? self->GetViewShape().GetDim(2) : self->GetViewShape().GetDim(3);105 int64_t inputWidth = isNeedSqueeze ? self->GetViewShape().GetDim(2) : self->GetViewShape().GetDim(3);
110- int64_t outputHeight =106+ int64_t outputHeight = div_rtn<int64_t>(
111- div_rtn<int64_t>(107+ (inputHeight + 2 * (*padding)[0] - ((*dilation)[0] * ((*kernelSize)[0] - 1) + 1)),
112- (inputHeight + 2 * (*padding)[0] - ((*dilation)[0] * ((*kernelSize)[0] - 1) + 1)), (*stride)[0]) +108+ (*stride)[0]) +
113- 1;109+ 1;
114- int64_t outputWidth =110+ int64_t outputWidth = div_rtn<int64_t>(
115- div_rtn<int64_t>(111+ (inputWidth + 2 * (*padding)[1] - ((*dilation)[1] * ((*kernelSize)[1] - 1) + 1)),
116- (inputWidth + 2 * (*padding)[1] - ((*dilation)[1] * ((*kernelSize)[1] - 1) + 1)), (*stride)[1]) +112+ (*stride)[1]) +
117- 1;113+ 1;
118 if (outputHeight < 1 || outputWidth < 1) {114 if (outputHeight < 1 || outputWidth < 1) {
119- OP_LOGE(115+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
120- ACLNN_ERR_PARAM_INVALID,116+ "The shape (%ld, %ld) of the array calculated by other parameters "
121- "The shape (%ld, %ld) of the array calculated by other parameters "117+ "must be at least one.",
122- "must be at least one.",118+ outputHeight, outputWidth);
123- outputHeight, outputWidth);
124 return false;119 return false;
125 }120 }
126- const op::Shape outShape =121+ const op::Shape outShape = isNeedSqueeze ?
127- isNeedSqueeze ?122+ op::Shape({self->GetViewShape().GetDim(0) * (*kernelSize)[0] * (*kernelSize)[1],
128- op::Shape(123+ outputHeight * outputWidth}) :
129- {self->GetViewShape().GetDim(0) * (*kernelSize)[0] * (*kernelSize)[1], outputHeight * outputWidth}) :124+ op::Shape({self->GetViewShape().GetDim(0),
130- op::Shape(125+ self->GetViewShape().GetDim(1) * (*kernelSize)[0] * (*kernelSize)[1],
131- {self->GetViewShape().GetDim(0), self->GetViewShape().GetDim(1) * (*kernelSize)[0] * (*kernelSize)[1],126+ outputHeight * outputWidth});
132- outputHeight * outputWidth});
133 if (outShape != out->GetViewShape()) {127 if (outShape != out->GetViewShape()) {
134- OP_LOGE(128+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expect out shape [%s], but got: [%s].", op::ToString(outShape).GetString(),
135- ACLNN_ERR_PARAM_INVALID, "Expect out shape [%s], but got: [%s].", op::ToString(outShape).GetString(),129+ op::ToString(out->GetViewShape()).GetString());
136- op::ToString(out->GetViewShape()).GetString());
137 return false;130 return false;
138 }131 }
139 return true;132 return true;
140}133}
141-static bool CheckArray(134+static bool CheckArray(const aclIntArray* kernelSize, const aclIntArray* dilation, const aclIntArray* padding,
142- const aclIntArray* kernelSize, const aclIntArray* dilation, const aclIntArray* padding, const aclIntArray* stride)135+ const aclIntArray* stride)
143{136{
144 if (kernelSize->Size() != ARRAY_SIZE) {137 if (kernelSize->Size() != ARRAY_SIZE) {
145- OP_LOGE(138+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "It is expected kernelSize equals to 2, but got size %lu.",
146- ACLNN_ERR_PARAM_INVALID, "It is expected kernelSize equals to 2, but got size %lu.", kernelSize->Size());139+ kernelSize->Size());
147 return false;140 return false;
148 }141 }
149 if (dilation->Size() != ARRAY_SIZE) {142 if (dilation->Size() != ARRAY_SIZE) {
@@ -160,41 +153,37 @@ static bool CheckArray(
160 }153 }
161 for (size_t i = 0; i < kernelSize->Size(); i++) {154 for (size_t i = 0; i < kernelSize->Size(); i++) {
162 if ((*kernelSize)[i] <= 0) {155 if ((*kernelSize)[i] <= 0) {
163- OP_LOGE(156+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
164- ACLNN_ERR_PARAM_INVALID,157+ "It is expected kernelSize be greater than zero, "
165- "It is expected kernelSize be greater than zero, "158+ "but kernelSize No.[%lu] dim is [%ld].",
166- "but kernelSize No.[%lu] dim is [%ld].",159+ i + 1, (*kernelSize)[i]);
167- i + 1, (*kernelSize)[i]);
168 return false;160 return false;
169 }161 }
170 }162 }
171 for (size_t i = 0; i < stride->Size(); i++) {163 for (size_t i = 0; i < stride->Size(); i++) {
172 if ((*stride)[i] <= 0) {164 if ((*stride)[i] <= 0) {
173- OP_LOGE(165+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
174- ACLNN_ERR_PARAM_INVALID,166+ "It is expected stride be greater than zero, "
175- "It is expected stride be greater than zero, "167+ "but stride No.[%lu] dim is [%ld].",
176- "but stride No.[%lu] dim is [%ld].",168+ i + 1, (*stride)[i]);
177- i + 1, (*stride)[i]);
178 return false;169 return false;
179 }170 }
180 }171 }
181 for (size_t i = 0; i < dilation->Size(); i++) {172 for (size_t i = 0; i < dilation->Size(); i++) {
182 if ((*dilation)[i] <= 0) {173 if ((*dilation)[i] <= 0) {
183- OP_LOGE(174+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
184- ACLNN_ERR_PARAM_INVALID,175+ "It is expected dilation be greater than zero, "
185- "It is expected dilation be greater than zero, "176+ "but dilation No.[%lu] dim is [%ld].",
186- "but dilation No.[%lu] dim is [%ld].",177+ i + 1, (*dilation)[i]);
187- i + 1, (*dilation)[i]);
188 return false;178 return false;
189 }179 }
190 }180 }
191 for (size_t i = 0; i < padding->Size(); i++) {181 for (size_t i = 0; i < padding->Size(); i++) {
192 if ((*padding)[i] < 0) {182 if ((*padding)[i] < 0) {
193- OP_LOGE(183+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
194- ACLNN_ERR_PARAM_INVALID,184+ "It is expected padding be greater than or equal to zero, "
195- "It is expected padding be greater than or equal to zero, "185+ "but padding No.[%lu] dim is [%ld].",
196- "but padding No.[%lu] dim is [%ld].",186+ i + 1, (*padding)[i]);
197- i + 1, (*padding)[i]);
198 return false;187 return false;
199 }188 }
200 }189 }
@@ -206,13 +195,12 @@ static void CheckFormat(const aclTensor* self)
206 // 检查format,若是NZ格式,则添加警告195 // 检查format,若是NZ格式,则添加警告
207 if (self->GetStorageFormat() == Format::FORMAT_FRACTAL_NZ) {196 if (self->GetStorageFormat() == Format::FORMAT_FRACTAL_NZ) {
208 OP_LOGW("Format of self gets [%s], this format may lead to precision failure.",197 OP_LOGW("Format of self gets [%s], this format may lead to precision failure.",
209- op::ToString(self->GetStorageFormat()).GetString());198+ op::ToString(self->GetStorageFormat()).GetString());
210 }199 }
211}200}
212 201 
213-static aclnnStatus CheckParams(202+static aclnnStatus CheckParams(const aclTensor* self, const aclIntArray* kernelSize, const aclIntArray* dilation,
214- const aclTensor* self, const aclIntArray* kernelSize, const aclIntArray* dilation, const aclIntArray* padding,203+ const aclIntArray* padding, const aclIntArray* stride, const aclTensor* out)
215- const aclIntArray* stride, const aclTensor* out)
216{204{
217 // 1. 检查参数是否为空指针205 // 1. 检查参数是否为空指针
218 CHECK_RET(CheckNotNull(self, kernelSize, dilation, padding, stride, out), ACLNN_ERR_PARAM_NULLPTR);206 CHECK_RET(CheckNotNull(self, kernelSize, dilation, padding, stride, out), ACLNN_ERR_PARAM_NULLPTR);
@@ -239,9 +227,10 @@ static aclnnStatus CheckParams(
239 return ACLNN_SUCCESS;227 return ACLNN_SUCCESS;
240}228}
241 229 
242-aclnnStatus aclnnIm2colGetWorkspaceSize(230+aclnnStatus aclnnIm2colGetWorkspaceSize(const aclTensor* self, const aclIntArray* kernelSize,
243- const aclTensor* self, const aclIntArray* kernelSize, const aclIntArray* dilation, const aclIntArray* padding,231+ const aclIntArray* dilation, const aclIntArray* padding,
244- const aclIntArray* stride, const aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)232+ const aclIntArray* stride, const aclTensor* out, uint64_t* workspaceSize,
233+ aclOpExecutor** executor)
245{234{
246 L2_DFX_PHASE_1(aclnnIm2col, DFX_IN(self, kernelSize, dilation, padding, stride), DFX_OUT(out));235 L2_DFX_PHASE_1(aclnnIm2col, DFX_IN(self, kernelSize, dilation, padding, stride), DFX_OUT(out));
247 // 固定写法,创建OpExecutor236 // 固定写法,创建OpExecutor
@@ -276,12 +265,12 @@ aclnnStatus aclnnIm2colGetWorkspaceSize(
276 auto im2colOut = l0op::Im2col(selfReFormat, kernelSize, dilation, newPadding, stride, uniqueExecutor.get());265 auto im2colOut = l0op::Im2col(selfReFormat, kernelSize, dilation, newPadding, stride, uniqueExecutor.get());
277 CHECK_RET(im2colOut != nullptr, ACLNN_ERR_INNER_NULLPTR);266 CHECK_RET(im2colOut != nullptr, ACLNN_ERR_INNER_NULLPTR);
278 267 
279- auto outSqueeze =268+ auto outSqueeze = isNeedSqueeze ? l0op::SqueezeNd(im2colOut, static_cast<int64_t>(0), uniqueExecutor.get()) :
280- isNeedSqueeze ? l0op::SqueezeNd(im2colOut, static_cast<int64_t>(0), uniqueExecutor.get()) : im2colOut;269+ im2colOut;
281 CHECK_RET(outSqueeze != nullptr, ACLNN_ERR_INNER_NULLPTR);270 CHECK_RET(outSqueeze != nullptr, ACLNN_ERR_INNER_NULLPTR);
282 271 
283- auto outView =272+ auto outView = uniqueExecutor.get()->CreateView(outSqueeze, outSqueeze->GetViewShape(),
284- uniqueExecutor.get()->CreateView(outSqueeze, outSqueeze->GetViewShape(), outSqueeze->GetViewOffset());273+ outSqueeze->GetViewOffset());
285 CHECK_RET(outView != nullptr, ACLNN_ERR_INNER_NULLPTR);274 CHECK_RET(outView != nullptr, ACLNN_ERR_INNER_NULLPTR);
286 auto outReFormat = l0op::ReFormat(outView, out->GetViewFormat());275 auto outReFormat = l0op::ReFormat(outView, out->GetViewFormat());
287 CHECK_RET(outReFormat != nullptr, ACLNN_ERR_INNER_NULLPTR);276 CHECK_RET(outReFormat != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -147,8 +147,7 @@ private:
147 void ShowSIMTTilingData();147 void ShowSIMTTilingData();
148};148};
149 149 
150-Im2ColTiling::~Im2ColTiling()150+Im2ColTiling::~Im2ColTiling() {}
151-{}
152 151 
153ge::graphStatus Im2ColTiling::DoTiling()152ge::graphStatus Im2ColTiling::DoTiling()
154{153{
@@ -168,9 +167,9 @@ ge::graphStatus Im2ColTiling::DoTiling()
168 OP_CHECK_IF(ret == ge::GRAPH_FAILED, OP_LOGE(context_, "DoTiling failed"), return ge::GRAPH_FAILED);167 OP_CHECK_IF(ret == ge::GRAPH_FAILED, OP_LOGE(context_, "DoTiling failed"), return ge::GRAPH_FAILED);
169 168 
170 const uint64_t tilingKey = GET_TPL_TILING_KEY(inputFormat_, ubAxis_, isPadding_, isSIMT_, isBigShape_);169 const uint64_t tilingKey = GET_TPL_TILING_KEY(inputFormat_, ubAxis_, isPadding_, isSIMT_, isBigShape_);
171- OP_LOGI(170+ OP_LOGI(context_->GetNodeName(),
172- context_->GetNodeName(), "tilingKey is %lu, inputFormat %d, ubAxis %d, isPadding %d, isSIMT %d, isBigShape %d",171+ "tilingKey is %lu, inputFormat %d, ubAxis %d, isPadding %d, isSIMT %d, isBigShape %d", tilingKey,
173- tilingKey, inputFormat_, ubAxis_, isPadding_, isSIMT_, isBigShape_);172+ inputFormat_, ubAxis_, isPadding_, isSIMT_, isBigShape_);
174 context_->SetTilingKey(tilingKey);173 context_->SetTilingKey(tilingKey);
175 context_->SetBlockDim(realCoreNum_);174 context_->SetBlockDim(realCoreNum_);
176 size_t* workSpaceSize = context_->GetWorkspaceSizes(1);175 size_t* workSpaceSize = context_->GetWorkspaceSizes(1);
@@ -187,55 +186,46 @@ inline T Im2ColTiling::AlignBlock(T elementCount)
187 186 
188void Im2ColTiling::ShowBaseTilingData()187void Im2ColTiling::ShowBaseTilingData()
189{188{
190- OP_LOGI(189+ OP_LOGI(context_,
191- context_,190+ "input: N %ld, C %ld, H %ld, W %ld,"
192- "input: N %ld, C %ld, H %ld, W %ld,"191+ " kernel (%ld, %ld), stride (%ld, %ld), dilation (%ld, %ld), pad (%ld, %ld, %ld, %ld)",
193- " kernel (%ld, %ld), stride (%ld, %ld), dilation (%ld, %ld), pad (%ld, %ld, %ld, %ld)",192+ input_.N, input_.C, input_.H, input_.W, input_.hKernelSize, input_.wKernelSize, input_.hStride,
194- input_.N, input_.C, input_.H, input_.W, input_.hKernelSize, input_.wKernelSize, input_.hStride, input_.wStride,193+ input_.wStride, input_.hDilation, input_.wDilation, input_.hPaddingBefore, input_.hPaddingAfter,
195- input_.hDilation, input_.wDilation, input_.hPaddingBefore, input_.hPaddingAfter, input_.wPaddingBefore,194+ input_.wPaddingBefore, input_.wPaddingAfter);
196- input_.wPaddingAfter);
197 // soc 信息195 // soc 信息
198- OP_LOGI(196+ OP_LOGI(context_, "soc info: ubSize %lu, coreNum %u, cacheLineSize %lu, ubBlockSize %lu ", ubSize_, coreNum_,
199- context_, "soc info: ubSize %lu, coreNum %u, cacheLineSize %lu, ubBlockSize %lu ", ubSize_, coreNum_,197+ cacheLineSize_, ubBlockSize_);
200- cacheLineSize_, ubBlockSize_);
201 // 中间计算结果198 // 中间计算结果
202- OP_LOGI(199+ OP_LOGI(context_,
203- context_,200+ "middle data: convKernelNumInWidth %ld, convKernelNumInHeight %ld, convKernelNum %ld, convKernelSize %ld",
204- "middle data: convKernelNumInWidth %ld, convKernelNumInHeight %ld, convKernelNum %ld, convKernelSize %ld",201+ convKernelNumInWidth_, convKernelNumInHeight_, convKernelNum_, convKernelSize_);
205- convKernelNumInWidth_, convKernelNumInHeight_, convKernelNum_, convKernelSize_);
206}202}
207 203 
208void Im2ColTiling::ShowNCHWTilingData()204void Im2ColTiling::ShowNCHWTilingData()
209{205{
210 ShowBaseTilingData();206 ShowBaseTilingData();
211 auto tilingData = context_->GetTilingData<Im2ColNCHWTilingData>();207 auto tilingData = context_->GetTilingData<Im2ColNCHWTilingData>();
212- OP_LOGI(208+ OP_LOGI(context_,
213- context_,209+ "tiling data: ubFactorH %d, ubFactorW %d, ubFactorNC %d, w4ubFactorW % d,"
214- "tiling data: ubFactorH %d, ubFactorW %d, ubFactorNC %d, w4ubFactorW % d,"210+ " lines4ubFactorW % d, lines4ubFactorH % d",
215- " lines4ubFactorW % d, lines4ubFactorH % d",211+ tilingData->ubFactorH, tilingData->ubFactorW, tilingData->ubFactorNC, tilingData->w4ubFactorW,
216- tilingData->ubFactorH, tilingData->ubFactorW, tilingData->ubFactorNC, tilingData->w4ubFactorW,212+ tilingData->lines4ubFactorW, tilingData->lines4ubFactorH);
217- tilingData->lines4ubFactorW, tilingData->lines4ubFactorH);213+ OP_LOGI(context_, "\t: convKernelNumInWidth %ld, convKernelNumInHeight %ld", tilingData->convKernelNumInWidth,
218- OP_LOGI(214+ tilingData->convKernelNumInHeight);
219- context_, "\t: convKernelNumInWidth %ld, convKernelNumInHeight %ld", tilingData->convKernelNumInWidth,215+ OP_LOGI(context_, "\t: totalRectAngles %ld, rectAnglesPerCore %d, outHWrectAngles %d", tilingData->totalRectAngles,
220- tilingData->convKernelNumInHeight);216+ tilingData->rectAnglesPerCore, tilingData->outHWrectAngles);
221- OP_LOGI(217+ OP_LOGI(context_, "\t: inputBufferSize %d, outputBufferSize %d", tilingData->inputBufferSize,
222- context_, "\t: totalRectAngles %ld, rectAnglesPerCore %d, outHWrectAngles %d", tilingData->totalRectAngles,218+ tilingData->outputBufferSize);
223- tilingData->rectAnglesPerCore, tilingData->outHWrectAngles);
224- OP_LOGI(
225- context_, "\t: inputBufferSize %d, outputBufferSize %d", tilingData->inputBufferSize,
226- tilingData->outputBufferSize);
227}219}
228 220 
229void Im2ColTiling::ShowNHWCTilingData()221void Im2ColTiling::ShowNHWCTilingData()
230{222{
231 ShowBaseTilingData();223 ShowBaseTilingData();
232 auto tilingData = context_->GetTilingData<Im2ColNHWCTilingData>();224 auto tilingData = context_->GetTilingData<Im2ColNHWCTilingData>();
233- OP_LOGI(225+ OP_LOGI(context_, "tiling data: ubFactorC %d, ubFactorW %d, ubFactorH %d, ubFactorN %d", tilingData->ubFactorC,
234- context_, "tiling data: ubFactorC %d, ubFactorW %d, ubFactorH %d, ubFactorN %d", tilingData->ubFactorC,226+ tilingData->ubFactorW, tilingData->ubFactorH, tilingData->ubFactorN);
235- tilingData->ubFactorW, tilingData->ubFactorH, tilingData->ubFactorN);227+ OP_LOGI(context_, "\t: convKernelNumInWidth %ld, convKernelNumInHeight %ld", tilingData->convKernelNumInWidth,
236- OP_LOGI(228+ tilingData->convKernelNumInHeight);
237- context_, "\t: convKernelNumInWidth %ld, convKernelNumInHeight %ld", tilingData->convKernelNumInWidth,
238- tilingData->convKernelNumInHeight);
239 OP_LOGI(context_, "\t: totalLines %ld, linesPerCore %d", tilingData->totalLines, tilingData->linesPerCore);229 OP_LOGI(context_, "\t: totalLines %ld, linesPerCore %d", tilingData->totalLines, tilingData->linesPerCore);
240 OP_LOGI(context_, "\t: outputBufferSize %d", tilingData->outputBufferSize);230 OP_LOGI(context_, "\t: outputBufferSize %d", tilingData->outputBufferSize);
241}231}
@@ -244,13 +234,11 @@ void Im2ColTiling::ShowSIMTTilingData()
244{234{
245 ShowBaseTilingData();235 ShowBaseTilingData();
246 auto tilingData = context_->GetTilingData<Im2ColSIMTTilingData>();236 auto tilingData = context_->GetTilingData<Im2ColSIMTTilingData>();
247- OP_LOGI(237+ OP_LOGI(context_, "tiling data: convKernelNumInHeight %ld, convKernelNumInWidth %ld",
248- context_, "tiling data: convKernelNumInHeight %ld, convKernelNumInWidth %ld", tilingData->convKernelNumInHeight,238+ tilingData->convKernelNumInHeight, tilingData->convKernelNumInWidth);
249- tilingData->convKernelNumInWidth);239+ OP_LOGI(context_, "\t: realCoreNum %ld, blockFactor %d, blockTailFactor: %u, mainCoreNum %d, threadNum %d",
250- OP_LOGI(240+ tilingData->realCoreNum, tilingData->blockFactor, tilingData->blockTailFactor, tilingData->mainCoreNum,
251- context_, "\t: realCoreNum %ld, blockFactor %d, blockTailFactor: %u, mainCoreNum %d, threadNum %d",241+ tilingData->threadNum);
252- tilingData->realCoreNum, tilingData->blockFactor, tilingData->blockTailFactor, tilingData->mainCoreNum,
253- tilingData->threadNum);
254}242}
255 243 
256ge::graphStatus Im2ColTiling::CheckKSizes(const gert::RuntimeAttrs* attrs)244ge::graphStatus Im2ColTiling::CheckKSizes(const gert::RuntimeAttrs* attrs)
@@ -285,9 +273,8 @@ ge::graphStatus Im2ColTiling::CheckDilations(const gert::RuntimeAttrs* attrs)
285 return ge::GRAPH_SUCCESS;273 return ge::GRAPH_SUCCESS;
286}274}
287 275 
288-static int64_t CalcNeedPadding(276+static int64_t CalcNeedPadding(const int64_t inputSize, const int64_t effectSize, const int64_t stride,
289- const int64_t inputSize, const int64_t effectSize, const int64_t stride, int64_t& paddingBefore,277+ int64_t& paddingBefore, int64_t& paddingAfter)
290- int64_t& paddingAfter)
291{278{
292 int64_t outputSize = Ops::Base::CeilDiv(inputSize, stride);279 int64_t outputSize = Ops::Base::CeilDiv(inputSize, stride);
293 int64_t needPadding = std::max(0L, (outputSize - 1) * stride + effectSize - inputSize);280 int64_t needPadding = std::max(0L, (outputSize - 1) * stride + effectSize - inputSize);
@@ -319,8 +306,8 @@ ge::graphStatus Im2ColTiling::CheckPadding(const gert::RuntimeAttrs* attrs)
319 CalcNeedPadding(input_.W, effectW_, input_.wStride, input_.wPaddingBefore, input_.wPaddingAfter);306 CalcNeedPadding(input_.W, effectW_, input_.wStride, input_.wPaddingBefore, input_.wPaddingAfter);
320 } else {307 } else {
321 std::string reasonMsg = "The value of mode must be in [CALCULATED , SYMMETRIC and VALID].";308 std::string reasonMsg = "The value of mode must be in [CALCULATED , SYMMETRIC and VALID].";
322- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(309+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context_->GetNodeName(), "mode", std::string(mode).c_str(),
323- context_->GetNodeName(), "mode", std::string(mode).c_str(), reasonMsg.c_str());310+ reasonMsg.c_str());
324 return ge::GRAPH_FAILED;311 return ge::GRAPH_FAILED;
325 }312 }
326 313 
@@ -339,8 +326,8 @@ ge::graphStatus Im2ColTiling::ParamCheck()
339 dSize_ = ge::GetSizeByDataType(inputDataType);326 dSize_ = ge::GetSizeByDataType(inputDataType);
340 if (dSize_ <= 0) {327 if (dSize_ <= 0) {
341 std::string reasonMsg = "The size of inputDataType must be greater than 0.";328 std::string reasonMsg = "The size of inputDataType must be greater than 0.";
342- OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(329+ OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(context_->GetNodeName(), "inputDataType", std::to_string(dSize_).c_str(),
343- context_->GetNodeName(), "inputDataType", std::to_string(dSize_).c_str(), reasonMsg.c_str());330+ reasonMsg.c_str());
344 return ge::GRAPH_FAILED;331 return ge::GRAPH_FAILED;
345 }332 }
346 333 
@@ -351,8 +338,8 @@ ge::graphStatus Im2ColTiling::ParamCheck()
351 // 获取 N/C/H/W338 // 获取 N/C/H/W
352 auto storageShape = inputShape->GetStorageShape();339 auto storageShape = inputShape->GetStorageShape();
353 inputFormat_ = inputValueDesc->GetStorageFormat();340 inputFormat_ = inputValueDesc->GetStorageFormat();
354- auto ret = Ops::Math::GetImgDataDimsByNCHWOrder(341+ auto ret = Ops::Math::GetImgDataDimsByNCHWOrder(context_, "x", storageShape, inputFormat_, input_.N, input_.C,
355- context_, "x", storageShape, inputFormat_, input_.N, input_.C, input_.H, input_.W);342+ input_.H, input_.W);
356 OP_CHECK_IF(ret == ge::GRAPH_FAILED, OP_LOGE(context_, "Param check failed"), return ge::GRAPH_FAILED);343 OP_CHECK_IF(ret == ge::GRAPH_FAILED, OP_LOGE(context_, "Param check failed"), return ge::GRAPH_FAILED);
357 344 
358 // 校验属性值是否合法345 // 校验属性值是否合法
@@ -366,8 +353,8 @@ ge::graphStatus Im2ColTiling::ParamCheck()
366 OP_CHECK_IF(ret == ge::GRAPH_FAILED, OP_LOGE(context_, "Param check failed"), return ge::GRAPH_FAILED);353 OP_CHECK_IF(ret == ge::GRAPH_FAILED, OP_LOGE(context_, "Param check failed"), return ge::GRAPH_FAILED);
367 ret = CheckPadding(attrs);354 ret = CheckPadding(attrs);
368 OP_CHECK_IF(ret == ge::GRAPH_FAILED, OP_LOGE(context_, "Param check failed"), return ge::GRAPH_FAILED);355 OP_CHECK_IF(ret == ge::GRAPH_FAILED, OP_LOGE(context_, "Param check failed"), return ge::GRAPH_FAILED);
369- isPadding_ =356+ isPadding_ = input_.hPaddingBefore > 0 || input_.hPaddingAfter > 0 || input_.wPaddingBefore > 0 ||
370- input_.hPaddingBefore > 0 || input_.hPaddingAfter > 0 || input_.wPaddingBefore > 0 || input_.wPaddingAfter > 0;357+ input_.wPaddingAfter > 0;
371 358 
372 OP_LOGI(context_, "effect HW is (%ld, %ld), padded HW is (%ld, %ld)", effectH_, effectW_, paddedH_, paddedW_);359 OP_LOGI(context_, "effect HW is (%ld, %ld), padded HW is (%ld, %ld)", effectH_, effectW_, paddedH_, paddedW_);
373 return ge::GRAPH_SUCCESS;360 return ge::GRAPH_SUCCESS;
@@ -412,10 +399,11 @@ std::tuple<int32_t, int32_t> Im2ColTiling::NCHWCalcBufSize(int32_t validBufSize)
412 // 当有需要考虑的左pad时,最大输入长度为 burstLen 拆分为左pad部分和剩余部分,两部分均block对齐399 // 当有需要考虑的左pad时,最大输入长度为 burstLen 拆分为左pad部分和剩余部分,两部分均block对齐
413 // 则最大为对齐block后再加一个block: (ceil(burstLen / block) + 1) * block400 // 则最大为对齐block后再加一个block: (ceil(burstLen / block) + 1) * block
414 int64_t inputWRectOffset = rectW * input_.wStride;401 int64_t inputWRectOffset = rectW * input_.wStride;
415- int64_t lastLeftPadEnd =402+ int64_t lastLeftPadEnd = input_.wPaddingBefore == 0 ?
416- input_.wPaddingBefore == 0 ? 0 : Ops::Base::FloorAlign(input_.wPaddingBefore, inputWRectOffset) + inputW;403+ 0 :
417- int64_t alignBurstLen =404+ Ops::Base::FloorAlign(input_.wPaddingBefore, inputWRectOffset) + inputW;
418- lastLeftPadEnd <= input_.wPaddingBefore ? AlignBlock(inputW) : AlignBlock(inputW + ubBlockElements_);405+ int64_t alignBurstLen = lastLeftPadEnd <= input_.wPaddingBefore ? AlignBlock(inputW) :
406+ AlignBlock(inputW + ubBlockElements_);
419 // 一行有几个分组407 // 一行有几个分组
420 int64_t groupCnt = groupW >= gatherVRegElements_ ?408 int64_t groupCnt = groupW >= gatherVRegElements_ ?
421 1 :409 1 :
@@ -536,8 +524,8 @@ bool Im2ColTiling::NCHWTryUnFullLoad(int32_t validBufSize)
536 // 计算输出行数,输出的每一行需要Block对齐524 // 计算输出行数,输出的每一行需要Block对齐
537 tilingData->ubFactorH = tilingData->outputBufferSize / dSize_ / AlignBlock(tilingData->ubFactorW);525 tilingData->ubFactorH = tilingData->outputBufferSize / dSize_ / AlignBlock(tilingData->ubFactorW);
538 // 对齐out_h,防止跨NC526 // 对齐out_h,防止跨NC
539- tilingData->ubFactorH =527+ tilingData->ubFactorH = static_cast<int32_t>(
540- static_cast<int32_t>(std::min(static_cast<int64_t>(tilingData->ubFactorH), convKernelSize_));528+ std::min(static_cast<int64_t>(tilingData->ubFactorH), convKernelSize_));
541 int64_t rectCntH;529 int64_t rectCntH;
542 if (tilingData->ubFactorH > groupH) {530 if (tilingData->ubFactorH > groupH) {
543 tilingData->ubFactorH = Ops::Base::FloorAlign(tilingData->ubFactorH, static_cast<int32_t>(groupH));531 tilingData->ubFactorH = Ops::Base::FloorAlign(tilingData->ubFactorH, static_cast<int32_t>(groupH));
@@ -551,9 +539,9 @@ bool Im2ColTiling::NCHWTryUnFullLoad(int32_t validBufSize)
551 // ceil(rect_h / out_h)539 // ceil(rect_h / out_h)
552 tilingData->ubFactorNC = Ops::Base::CeilDiv(static_cast<int64_t>(tilingData->ubFactorH), convKernelSize_);540 tilingData->ubFactorNC = Ops::Base::CeilDiv(static_cast<int64_t>(tilingData->ubFactorH), convKernelSize_);
553 // 输入一行的长度,截取到group大小来算541 // 输入一行的长度,截取到group大小来算
554- tilingData->w4ubFactorW = static_cast<int32_t>(NCHWCalcBurstLen(542+ tilingData->w4ubFactorW = static_cast<int32_t>(
555- std::min(static_cast<int64_t>(tilingData->ubFactorW), groupW),543+ NCHWCalcBurstLen(std::min(static_cast<int64_t>(tilingData->ubFactorW), groupW),
556- std::min(static_cast<int64_t>(tilingData->ubFactorH), groupH)));544+ std::min(static_cast<int64_t>(tilingData->ubFactorH), groupH)));
557 // ceil(rect_w / group_w),跨几个group545 // ceil(rect_w / group_w),跨几个group
558 tilingData->lines4ubFactorW = Ops::Base::CeilDiv(static_cast<int64_t>(tilingData->ubFactorW), groupW);546 tilingData->lines4ubFactorW = Ops::Base::CeilDiv(static_cast<int64_t>(tilingData->ubFactorW), groupW);
559 // ceil(rect_h / group_h),跨几个group547 // ceil(rect_h / group_h),跨几个group
@@ -587,8 +575,8 @@ ge::graphStatus Im2ColTiling::Tiling4NCHW()
587 tilingData->convKernelNumInWidth = convKernelNumInWidth_;575 tilingData->convKernelNumInWidth = convKernelNumInWidth_;
588 tilingData->convKernelNumInHeight = convKernelNumInHeight_;576 tilingData->convKernelNumInHeight = convKernelNumInHeight_;
589 // 设置核数577 // 设置核数
590- tilingData->rectAnglesPerCore =578+ tilingData->rectAnglesPerCore = static_cast<int32_t>(
591- static_cast<int32_t>(Ops::Base::CeilDiv(tilingData->totalRectAngles, static_cast<int64_t>(coreNum_)));579+ Ops::Base::CeilDiv(tilingData->totalRectAngles, static_cast<int64_t>(coreNum_)));
592 realCoreNum_ = static_cast<uint32_t>(580 realCoreNum_ = static_cast<uint32_t>(
593 Ops::Base::CeilDiv(tilingData->totalRectAngles, static_cast<int64_t>(tilingData->rectAnglesPerCore)));581 Ops::Base::CeilDiv(tilingData->totalRectAngles, static_cast<int64_t>(tilingData->rectAnglesPerCore)));
594 582 
@@ -612,23 +600,23 @@ void Im2ColTiling::NHWCSetTilingData(Im2ColNHWCTilingData* tilingData, const int
612 Ops::Base::CeilDiv(tilingData->totalLines, static_cast<int64_t>(tilingData->linesPerCore)));600 Ops::Base::CeilDiv(tilingData->totalLines, static_cast<int64_t>(tilingData->linesPerCore)));
613 601 
614 // 5. 计算输出缓冲区大小(适配新维度:N×HW×K×C)602 // 5. 计算输出缓冲区大小(适配新维度:N×HW×K×C)
615- tilingData->outputBufferSize = static_cast<int64_t>(603+ tilingData->outputBufferSize = static_cast<int64_t>(tilingData->ubFactorN * tilingData->ubFactorH *
616- tilingData->ubFactorN * tilingData->ubFactorH * tilingData->ubFactorW * tilingData->ubFactorC * dSize_ *604+ tilingData->ubFactorW * tilingData->ubFactorC * dSize_ *
617- NHWC_BUFFER_NUM);605+ NHWC_BUFFER_NUM);
618}606}
619 607 
620ge::graphStatus Im2ColTiling::Tiling4NHWC()608ge::graphStatus Im2ColTiling::Tiling4NHWC()
621{609{
622 auto tilingData = context_->GetTilingData<Im2ColNHWCTilingData>();610 auto tilingData = context_->GetTilingData<Im2ColNHWCTilingData>();
623 uint64_t UB_SIZE_LIMIT = std::min(ubSize_ / NHWC_BUFFER_NUM, NHWC_MIN_BUFFER_SIZE); // 64KB611 uint64_t UB_SIZE_LIMIT = std::min(ubSize_ / NHWC_BUFFER_NUM, NHWC_MIN_BUFFER_SIZE); // 64KB
624- auto remainingElem = static_cast<int64_t>(UB_SIZE_LIMIT / dSize_); // 剩余UB元素数,初始为最大值612+ auto remainingElem = static_cast<int64_t>(UB_SIZE_LIMIT / dSize_); // 剩余UB元素数,初始为最大值
625 613 
626 int64_t ubfactorAlign[4] = {1, convKernelNumInWidth_, input_.wKernelSize, ubBlockElements_}; // 0:N 1:W 2:Kw 3:C 32b614 int64_t ubfactorAlign[4] = {1, convKernelNumInWidth_, input_.wKernelSize, ubBlockElements_}; // 0:N 1:W 2:Kw 3:C 32b
627 int64_t ubfactor[4] = {1, 1, 1, 1}; // 对应索引:0=N 1=HW 2=Kw 3=C,初始全为1615 int64_t ubfactor[4] = {1, 1, 1, 1}; // 对应索引:0=N 1=HW 2=Kw 3=C,初始全为1
628 int64_t dimValuesAlign[4] = {input_.N, convKernelNum_, convKernelSize_, AlignBlock(input_.C)}; // 各维度判断条件616 int64_t dimValuesAlign[4] = {input_.N, convKernelNum_, convKernelSize_, AlignBlock(input_.C)}; // 各维度判断条件
629 size_t dim = std::size(dimValuesAlign);617 size_t dim = std::size(dimValuesAlign);
630- int64_t ubAxises[4] = {618+ int64_t ubAxises[4] = {TPL_UB_AXIS_NHWC_N, TPL_UB_AXIS_NHWC_H, TPL_UB_AXIS_NHWC_W,
631- TPL_UB_AXIS_NHWC_N, TPL_UB_AXIS_NHWC_H, TPL_UB_AXIS_NHWC_W, TPL_UB_AXIS_NHWC_C}; // 各维度对应的ubAxis_值619+ TPL_UB_AXIS_NHWC_C}; // 各维度对应的ubAxis_值
632 tilingData->totalLines = 1;620 tilingData->totalLines = 1;
633 621 
634 for (int i = dim - 1; i >= 0; i--) { // 3=C→2=Kw→1=HW→0=N622 for (int i = dim - 1; i >= 0; i--) { // 3=C→2=Kw→1=HW→0=N
@@ -646,8 +634,8 @@ ge::graphStatus Im2ColTiling::Tiling4NHWC()
646 tilingData->totalLines = Ops::Base::CeilDiv(currDimValue, ubfactor[i]);634 tilingData->totalLines = Ops::Base::CeilDiv(currDimValue, ubfactor[i]);
647 } else {635 } else {
648 ubfactor[i] = remainingElem;636 ubfactor[i] = remainingElem;
649- tilingData->totalLines =637+ tilingData->totalLines = Ops::Base::CeilDiv(currAlign, ubfactor[i]) *
650- Ops::Base::CeilDiv(currAlign, ubfactor[i]) * Ops::Base::CeilDiv(currDimValue, currAlign);638+ Ops::Base::CeilDiv(currDimValue, currAlign);
651 }639 }
652 ubAxis_ = currUbAxis; // 替换为ubAxis_640 ubAxis_ = currUbAxis; // 替换为ubAxis_
653 for (int j = 0; j < i; j++) {641 for (int j = 0; j < i; j++) {
@@ -690,8 +678,8 @@ ge::graphStatus Im2ColTiling::Tiling4SIMT()
690 uint64_t cores = std::min(static_cast<uint64_t>(coreNum_), alignEleBlockCount);678 uint64_t cores = std::min(static_cast<uint64_t>(coreNum_), alignEleBlockCount);
691 if (cores == 0) {679 if (cores == 0) {
692 std::string reasonMsg = "The value of realCoreNum cannot be 0.";680 std::string reasonMsg = "The value of realCoreNum cannot be 0.";
693- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(681+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context_->GetNodeName(), "realCoreNum", std::to_string(cores).c_str(),
694- context_->GetNodeName(), "realCoreNum", std::to_string(cores).c_str(), reasonMsg.c_str());682+ reasonMsg.c_str());
695 return ge::GRAPH_FAILED;683 return ge::GRAPH_FAILED;
696 }684 }
697 tilingData->realCoreNum = static_cast<uint64_t>(cores);685 tilingData->realCoreNum = static_cast<uint64_t>(cores);
@@ -724,11 +712,11 @@ ge::graphStatus Im2ColTiling::Tiling4Format()
724 if (inputFormat_ == ge::FORMAT_NHWC) {712 if (inputFormat_ == ge::FORMAT_NHWC) {
725 return Tiling4NHWC();713 return Tiling4NHWC();
726 }714 }
727- std::string reasonMsg =715+ std::string reasonMsg = "When the shapeSize is greater than MAX_SHAPE_SIZE_FOR_SIMT, the value of inputFormat must "
728- "When the shapeSize greater than MAX_SHAPE_SIZE_FOR_SIMT, the value of inputFormat must be in [NCHW and "716+ "be in [NCHW and "
729- "NHWC].";717+ "NHWC].";
730- OP_LOGE_FOR_INVALID_FORMATS_WITH_REASON(718+ OP_LOGE_FOR_INVALID_FORMATS_WITH_REASON(context_->GetNodeName(), "inputFormat",
731- context_->GetNodeName(), "inputFormat", Ops::Base::ToString(inputFormat_).c_str(), reasonMsg.c_str());719+ Ops::Base::ToString(inputFormat_).c_str(), reasonMsg.c_str());
732 return ge::GRAPH_FAILED;720 return ge::GRAPH_FAILED;
733}721}
734 722 
@@ -757,13 +745,12 @@ ge::graphStatus Im2ColTiling::InferOut()
757 convKernelNumInWidth_ = (paddedW_ - effectW_) / input_.wStride + 1;745 convKernelNumInWidth_ = (paddedW_ - effectW_) / input_.wStride + 1;
758 convKernelNumInHeight_ = (paddedH_ - effectH_) / input_.hStride + 1;746 convKernelNumInHeight_ = (paddedH_ - effectH_) / input_.hStride + 1;
759 if (convKernelNumInWidth_ <= 0 || convKernelNumInHeight_ <= 0) {747 if (convKernelNumInWidth_ <= 0 || convKernelNumInHeight_ <= 0) {
760- std::string shapeMsg =748+ std::string shapeMsg = std::to_string(convKernelNumInWidth_) + "," + std::to_string(convKernelNumInHeight_);
761- std::to_string(convKernelNumInWidth_) + "," + std::to_string(convKernelNumInHeight_);749+ std::string
762- std::string reasonMsg =750+ reasonMsg = "The value of the calculated shape of the array of sliding blocks must be greater than 0.";
763- "The value of the calculated shape of the array of sliding blocks must be greater than 0.";751+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context_->GetNodeName(),
764- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(752+ "convKernelNumInWidth_ and convKernelNumInHeight_", shapeMsg.c_str(),
765- context_->GetNodeName(), "convKernelNumInWidth_ and convKernelNumInHeight_", shapeMsg.c_str(),753+ reasonMsg.c_str());
766- reasonMsg.c_str());
767 return ge::GRAPH_FAILED;754 return ge::GRAPH_FAILED;
768 }755 }
769 convKernelNum_ = convKernelNumInWidth_ * convKernelNumInHeight_; // 输出W756 convKernelNum_ = convKernelNumInWidth_ * convKernelNumInHeight_; // 输出W
@@ -38,15 +38,14 @@ static constexpr size_t SUPPORTED_DIM_NUM = 4;
38static const std::map<char, size_t> NHWC_INPUT_IDX_MAP{{'N', 0}, {'H', 1}, {'W', 2}, {'C', 3}};38static const std::map<char, size_t> NHWC_INPUT_IDX_MAP{{'N', 0}, {'H', 1}, {'W', 2}, {'C', 3}};
39static const std::map<char, size_t> NCHW_INPUT_IDX_MAP{{'N', 0}, {'C', 1}, {'H', 2}, {'W', 3}};39static const std::map<char, size_t> NCHW_INPUT_IDX_MAP{{'N', 0}, {'C', 1}, {'H', 2}, {'W', 3}};
40 40 
41-static inline bool IsOutShapeInvalid(int64_t in, int64_t out)41+static inline bool IsOutShapeInvalid(int64_t in, int64_t out) { return (in > 0) && (out <= 0); }
42-{
43- return (in > 0) && (out <= 0);
44-}
45 42 
46-static ge::graphStatus InferShape4Im2colCalcOut(43+static ge::graphStatus InferShape4Im2colCalcOut(gert::InferShapeContext* context, const gert::Shape* shapeIn,
47- gert::InferShapeContext* context, const gert::Shape* shapeIn, gert::Shape* shapeOut, const Format dataFormat,44+ gert::Shape* shapeOut, const Format dataFormat,
48- const std::array<int64_t, 2>& ksizes, const std::array<int64_t, 2>& strides,45+ const std::array<int64_t, 2>& ksizes,
49- const std::array<int64_t, 2>& dilations, const std::string_view paddingMode)46+ const std::array<int64_t, 2>& strides,
47+ const std::array<int64_t, 2>& dilations,
48+ const std::string_view paddingMode)
50{49{
51 auto [ret, shapeNCHW] = Ops::Math::GetImgDataDimsByNCHWOrder(context, "x", *shapeIn, dataFormat);50 auto [ret, shapeNCHW] = Ops::Math::GetImgDataDimsByNCHWOrder(context, "x", *shapeIn, dataFormat);
52 OP_CHECK_IF(ret != ge::GRAPH_SUCCESS, OP_LOGE(context, "Get input shape failed"), return ret);51 OP_CHECK_IF(ret != ge::GRAPH_SUCCESS, OP_LOGE(context, "Get input shape failed"), return ret);
@@ -80,9 +79,8 @@ static ge::graphStatus InferShape4Im2colCalcOut(
80 79 
81 OP_CHECK_IF(80 OP_CHECK_IF(
82 (IsOutShapeInvalid(inH, outH) || IsOutShapeInvalid(inW, outW)),81 (IsOutShapeInvalid(inH, outH) || IsOutShapeInvalid(inW, outW)),
83- OP_LOGE(82+ OP_LOGE(context, "The calculated shape of the array of sliding blocks is (%ld, %ld), which must be positive",
84- context, "The calculated shape of the array of sliding blocks is (%ld, %ld), which must be positive", outH,83+ outH, outW),
85- outW),
86 return ge::GRAPH_FAILED);84 return ge::GRAPH_FAILED);
87 85 
88 outC = (inC == -1) ? -1 : inC * kernelH * kernelW;86 outC = (inC == -1) ? -1 : inC * kernelH * kernelW;
@@ -98,7 +96,7 @@ static ge::graphStatus InferShape4Im2colCalcOut(
98 96 
99static graphStatus InferShape4Im2col(gert::InferShapeContext* context)97static graphStatus InferShape4Im2col(gert::InferShapeContext* context)
100{98{
101- OP_LOGD(context, "Im2col infershape funtion start!");99+ OP_LOGD(context, "Im2col infershape function start!");
102 // Get input desc100 // Get input desc
103 const gert::CompileTimeTensorDesc* tensorDescIn = context->GetInputDesc(X_IDX);101 const gert::CompileTimeTensorDesc* tensorDescIn = context->GetInputDesc(X_IDX);
104 OP_CHECK_NULL_WITH_CONTEXT(context, tensorDescIn);102 OP_CHECK_NULL_WITH_CONTEXT(context, tensorDescIn);
@@ -133,9 +131,9 @@ static graphStatus InferShape4Im2col(gert::InferShapeContext* context)
133 const char* attrPaddingMode = attrs->GetStr(ATTR_IDX_PADDING_MODE);131 const char* attrPaddingMode = attrs->GetStr(ATTR_IDX_PADDING_MODE);
134 OP_CHECK_NULL_WITH_CONTEXT(context, attrPaddingMode);132 OP_CHECK_NULL_WITH_CONTEXT(context, attrPaddingMode);
135 const std::string_view paddingMode = std::string_view(attrPaddingMode);133 const std::string_view paddingMode = std::string_view(attrPaddingMode);
136- OP_CHECK_IF(134+ OP_CHECK_IF(paddingMode != "VALID" && paddingMode != "SAME" && paddingMode != "CALCULATED",
137- paddingMode != "VALID" && paddingMode != "SAME" && paddingMode != "CALCULATED",135+ OP_LOGE(context, "The padding_mode only supports VALID, SAME and CALCULATED."),
138- OP_LOGE(context, "The padding_mode only support VALID, SAME and CALCULATED."), return ge::GRAPH_FAILED);136+ return ge::GRAPH_FAILED);
139 137 
140 // Get input shape138 // Get input shape
141 const gert::Shape* shapeIn = context->GetInputShape(X_IDX);139 const gert::Shape* shapeIn = context->GetInputShape(X_IDX);
@@ -65,8 +65,8 @@ static const std::initializer_list<op::DataType> SELF_DTYPE_SUPPORT_LIST_SUPPORT
65 op::DataType::DT_INT8, op::DataType::DT_UINT8, op::DataType::DT_DOUBLE, op::DataType::DT_BOOL,65 op::DataType::DT_INT8, op::DataType::DT_UINT8, op::DataType::DT_DOUBLE, op::DataType::DT_BOOL,
66 op::DataType::DT_BF16};66 op::DataType::DT_BF16};
67 67 
68-static const std::initializer_list<op::DataType> MASK_DTYPE_SUPPORT_LIST = {68+static const std::initializer_list<op::DataType> MASK_DTYPE_SUPPORT_LIST = {op::DataType::DT_UINT8,
69- op::DataType::DT_UINT8, op::DataType::DT_BOOL};69+ op::DataType::DT_BOOL};
70} // namespace ACLNN_MASKED_SELECT70} // namespace ACLNN_MASKED_SELECT
71using namespace ACLNN_MASKED_SELECT;71using namespace ACLNN_MASKED_SELECT;
72inline static bool CheckNotNull(const aclTensor* self, const aclTensor* mask, const aclTensor* out)72inline static bool CheckNotNull(const aclTensor* self, const aclTensor* mask, const aclTensor* out)
@@ -137,10 +137,9 @@ static bool CheckShape(const aclTensor* self, const aclTensor* mask, const aclTe
137 OP_CHECK_WRONG_DIMENSION(y, 1, return false);137 OP_CHECK_WRONG_DIMENSION(y, 1, return false);
138 138 
139 if (!isOutSizeSameWithBroadcastShapeSize(y, broadcastShape)) {139 if (!isOutSizeSameWithBroadcastShapeSize(y, broadcastShape)) {
140- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The out shape size is not same with broadcastShapeSize.");140+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The out shape size is not the same as broadcastShapeSize.");
141- OP_LOGE(141+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "y.shape: %ld, broadcastShape.shape: %ld.", y->GetViewShape().GetShapeSize(),
142- ACLNN_ERR_PARAM_INVALID, "y.shape: %ld, broadcastShape.shape: %ld.", y->GetViewShape().GetShapeSize(),142+ broadcastShape.GetShapeSize());
143- broadcastShape.GetShapeSize());
144 return false;143 return false;
145 }144 }
146 return true;145 return true;
@@ -166,24 +165,24 @@ static bool IsAiCoreSupport(const aclTensor* self)
166{165{
167 if (IsRegBase()) {166 if (IsRegBase()) {
168 return CheckType(self->GetDataType(), SELF_DTYPE_SUPPORT_LIST_SUPPORT_REGBASE);167 return CheckType(self->GetDataType(), SELF_DTYPE_SUPPORT_LIST_SUPPORT_REGBASE);
169- } else if (168+ } else if (GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B &&
170- GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B &&169+ GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E) {
171- GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E) {
172 return CheckType(self->GetDataType(), SELF_DTYPE_SUPPORT_LIST_SUPPORT_BF16);170 return CheckType(self->GetDataType(), SELF_DTYPE_SUPPORT_LIST_SUPPORT_BF16);
173 }171 }
174 return false;172 return false;
175}173}
176 174 
177-static void CheckFormat(const aclTensor* self, const aclTensor* target){175+static void CheckFormat(const aclTensor* self, const aclTensor* target)
178- ge::Format selfStorageFormat = self->GetStorageFormat();176+{
179- ge::Format targetStorageFormat = target->GetStorageFormat();177+ ge::Format selfStorageFormat = self->GetStorageFormat();
180- if (selfStorageFormat != ge::Format::FORMAT_ND || targetStorageFormat != ge::Format::FORMAT_ND){178+ ge::Format targetStorageFormat = target->GetStorageFormat();
181- OP_LOGW("aclnnMaskedSelect only support format ND.");179+ if (selfStorageFormat != ge::Format::FORMAT_ND || targetStorageFormat != ge::Format::FORMAT_ND) {
182- }180+ OP_LOGW("aclnnMaskedSelect only supports format ND.");
181+ }
183}182}
184 183 
185-aclnnStatus aclnnMaskedSelectGetWorkspaceSize(184+aclnnStatus aclnnMaskedSelectGetWorkspaceSize(const aclTensor* self, const aclTensor* mask, aclTensor* out,
186- const aclTensor* self, const aclTensor* mask, aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)185+ uint64_t* workspaceSize, aclOpExecutor** executor)
187{186{
188 OP_CHECK_COMM_INPUT(workspaceSize, executor);187 OP_CHECK_COMM_INPUT(workspaceSize, executor);
189 188 
@@ -232,8 +231,8 @@ aclnnStatus aclnnMaskedSelectGetWorkspaceSize(
232 op::Shape broadcastShape;231 op::Shape broadcastShape;
233 if (BroadcastInferShape(self->GetViewShape(), mask->GetViewShape(), broadcastShape)) {232 if (BroadcastInferShape(self->GetViewShape(), mask->GetViewShape(), broadcastShape)) {
234 op::FVector<int64_t, op::MAX_DIM_NUM> broadcastDims = op::ToShapeVector(broadcastShape);233 op::FVector<int64_t, op::MAX_DIM_NUM> broadcastDims = op::ToShapeVector(broadcastShape);
235- auto broadcastShapeArray =234+ auto broadcastShapeArray = uniqueExecutor.get()->AllocIntArray(broadcastDims.data(),
236- uniqueExecutor.get()->AllocIntArray(broadcastDims.data(), broadcastDims.size());235+ broadcastDims.size());
237 CHECK_RET(broadcastShapeArray != nullptr, ACLNN_ERR_INNER_NULLPTR);236 CHECK_RET(broadcastShapeArray != nullptr, ACLNN_ERR_INNER_NULLPTR);
238 auto selfCastedAfterFormat = ResetFormatForRegBase(selfCasted, broadcastShapeArray);237 auto selfCastedAfterFormat = ResetFormatForRegBase(selfCasted, broadcastShapeArray);
239 selfBroadcast = l0op::BroadcastTo(selfCastedAfterFormat, broadcastShapeArray, uniqueExecutor.get());238 selfBroadcast = l0op::BroadcastTo(selfCastedAfterFormat, broadcastShapeArray, uniqueExecutor.get());
@@ -184,8 +184,8 @@ ge::graphStatus MaskedSelectV3Tiling::RunKernelTiling()
184 1); // 通过框架获取workspace的指针,GetWorkspaces入参所需workspace的块数。当前限制使用一块。184 1); // 通过框架获取workspace的指针,GetWorkspaces入参所需workspace的块数。当前限制使用一块。
185 size_t usrSize = totalLengthAlignedWithBlock * sizeOfDataType + numBlocks * 64u;185 size_t usrSize = totalLengthAlignedWithBlock * sizeOfDataType + numBlocks * 64u;
186 OP_LOGD(tilingContext->GetNodeName(), "usrWorkspaceSize: %lu.", usrSize);186 OP_LOGD(tilingContext->GetNodeName(), "usrWorkspaceSize: %lu.", usrSize);
187- currentWorkspace[0] =187+ currentWorkspace[0] = usrSize +
188- usrSize + sysWorkspaceSize; // 设置总的workspace的数值大小,总的workspace空间框架来申请并管理。188+ sysWorkspaceSize; // 设置总的workspace的数值大小,总的workspace空间框架来申请并管理。
189 TilingDataPrint();189 TilingDataPrint();
190 OP_LOGD(tilingContext->GetNodeName(), "Tiling end.");190 OP_LOGD(tilingContext->GetNodeName(), "Tiling end.");
191 return ge::GRAPH_SUCCESS;191 return ge::GRAPH_SUCCESS;
@@ -216,7 +216,7 @@ ge::graphStatus TilingForMaskedSelectV3(gert::TilingContext* context)
216 }216 }
217 MaskedSelectV3Tiling tilingObject(context);217 MaskedSelectV3Tiling tilingObject(context);
218 if (tilingObject.Init() != ge::GRAPH_SUCCESS) {218 if (tilingObject.Init() != ge::GRAPH_SUCCESS) {
219- OP_LOGE(context->GetNodeName(), "Init tiling object return failed.");219+ OP_LOGE(context->GetNodeName(), "Init tiling object returned failed.");
220 return ge::GRAPH_FAILED;220 return ge::GRAPH_FAILED;
221 }221 }
222 return tilingObject.RunKernelTiling();222 return tilingObject.RunKernelTiling();
@@ -260,4 +260,4 @@ ge::graphStatus TilingPrepareForMaskedSelectV3(gert::TilingParseContext* context
260IMPL_OP_OPTILING(MaskedSelectV3)260IMPL_OP_OPTILING(MaskedSelectV3)
261 .Tiling(TilingForMaskedSelectV3)261 .Tiling(TilingForMaskedSelectV3)
262 .TilingParse<MaskedSelectV3CompileInfo>(TilingPrepareForMaskedSelectV3);262 .TilingParse<MaskedSelectV3CompileInfo>(TilingPrepareForMaskedSelectV3);
263-} // namespace optiling263+} // namespace optiling
@@ -92,8 +92,8 @@ ge::graphStatus MaskedSelectV3IsRegbaseSocVersionTiling::Init()
92 dataType = tilingContext->GetInputDesc(0)->GetDataType();92 dataType = tilingContext->GetInputDesc(0)->GetDataType();
93 sizeOfDataType = ge::GetSizeByDataType(dataType);93 sizeOfDataType = ge::GetSizeByDataType(dataType);
94 if (sizeOfDataType == 0u) {94 if (sizeOfDataType == 0u) {
95- OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(tilingContext->GetNodeName(), "x",95+ OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(tilingContext->GetNodeName(), "x", Ops::Base::ToString(dataType).c_str(),
96- Ops::Base::ToString(dataType).c_str(), "The dtype size of x must be greater than 0");96+ "The dtype size of x must be greater than 0");
97 return ge::GRAPH_FAILED;97 return ge::GRAPH_FAILED;
98 }98 }
99 // 一个block存放的元素99 // 一个block存放的元素
@@ -103,7 +103,8 @@ ge::graphStatus MaskedSelectV3IsRegbaseSocVersionTiling::Init()
103 totalLength = EnsureNotScalar(tilingContext->GetInputShape(0)->GetStorageShape()).GetShapeSize();103 totalLength = EnsureNotScalar(tilingContext->GetInputShape(0)->GetStorageShape()).GetShapeSize();
104 if (totalLength == 0UL) {104 if (totalLength == 0UL) {
105 OP_LOGE_FOR_INVALID_SHAPESIZE_WITH_REASON(tilingContext->GetNodeName(), "x",105 OP_LOGE_FOR_INVALID_SHAPESIZE_WITH_REASON(tilingContext->GetNodeName(), "x",
106- std::to_string(totalLength).c_str(), "input shape_size must be greater than 0");106+ std::to_string(totalLength).c_str(),
107+ "input shape_size must be greater than 0");
107 return ge::GRAPH_FAILED;108 return ge::GRAPH_FAILED;
108 }109 }
109 totalLengthAlignedWithBlock = ((totalLength + alignNum - 1UL) / alignNum) * alignNum;110 totalLengthAlignedWithBlock = ((totalLength + alignNum - 1UL) / alignNum) * alignNum;
@@ -124,8 +125,7 @@ ge::graphStatus MaskedSelectV3IsRegbaseSocVersionTiling::Init()
124 tilingKey = sizeOfDataType;125 tilingKey = sizeOfDataType;
125 tilingContext->SetTilingKey(tilingKey);126 tilingContext->SetTilingKey(tilingKey);
126 OP_CHECK_IF(tilingContext->SetScheduleMode(1) != ge::GRAPH_SUCCESS,127 OP_CHECK_IF(tilingContext->SetScheduleMode(1) != ge::GRAPH_SUCCESS,
127- OP_LOGE(tilingContext->GetNodeName(), "Failed to set ScheduleMode!"),128+ OP_LOGE(tilingContext->GetNodeName(), "Failed to set ScheduleMode!"), return ge::GRAPH_FAILED);
128- return ge::GRAPH_FAILED);
129 // 切分流程129 // 切分流程
130 formerNum = totalLength % numBlocks;130 formerNum = totalLength % numBlocks;
131 if (formerNum == 0UL) {131 if (formerNum == 0UL) {
@@ -162,7 +162,7 @@ ge::graphStatus MaskedSelectV3IsRegbaseSocVersionTiling::RunKernelTiling()
162 if (!(storageShape0 == storageShape1)) {162 if (!(storageShape0 == storageShape1)) {
163 std::string shapesStr = Shape2String(storageShape0) + " and " + Shape2String(storageShape1);163 std::string shapesStr = Shape2String(storageShape0) + " and " + Shape2String(storageShape1);
164 OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(tilingContext->GetNodeName(), "x, mask", shapesStr.c_str(),164 OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(tilingContext->GetNodeName(), "x, mask", shapesStr.c_str(),
165- "The shapes of x, mask must be the same");165+ "The shapes of x, mask must be the same");
166 return ge::GRAPH_FAILED;166 return ge::GRAPH_FAILED;
167 }167 }
168 tiling.set_formerNum(formerNum);168 tiling.set_formerNum(formerNum);
@@ -184,8 +184,8 @@ ge::graphStatus MaskedSelectV3IsRegbaseSocVersionTiling::RunKernelTiling()
184 1); // 通过框架获取workspace的指针,GetWorkspaces入参所需workspace的块数。当前限制使用一块。184 1); // 通过框架获取workspace的指针,GetWorkspaces入参所需workspace的块数。当前限制使用一块。
185 size_t usrSize = totalLengthAlignedWithBlock * sizeOfDataType + numBlocks * 64UL;185 size_t usrSize = totalLengthAlignedWithBlock * sizeOfDataType + numBlocks * 64UL;
186 OP_LOGD(tilingContext->GetNodeName(), "usrWorkspaceSize: %lu.", usrSize);186 OP_LOGD(tilingContext->GetNodeName(), "usrWorkspaceSize: %lu.", usrSize);
187- currentWorkspace[0] =187+ currentWorkspace[0] = usrSize +
188- usrSize + sysWorkspaceSize; // 设置总的workspace的数值大小,总的workspace空间框架来申请并管理。188+ sysWorkspaceSize; // 设置总的workspace的数值大小,总的workspace空间框架来申请并管理。
189 TilingDataPrint();189 TilingDataPrint();
190 OP_LOGD(tilingContext->GetNodeName(), "Tiling end.");190 OP_LOGD(tilingContext->GetNodeName(), "Tiling end.");
191 return ge::GRAPH_SUCCESS;191 return ge::GRAPH_SUCCESS;
@@ -212,9 +212,9 @@ ge::graphStatus TilingForMaskedSelectV3IsRegbaseSocVersion(gert::TilingContext*
212 return ge::GRAPH_FAILED;212 return ge::GRAPH_FAILED;
213 }213 }
214 if (tilingObject.Init() != ge::GRAPH_SUCCESS) {214 if (tilingObject.Init() != ge::GRAPH_SUCCESS) {
215- OP_LOGE(context->GetNodeName(), "Init tiling object return failed.");215+ OP_LOGE(context->GetNodeName(), "Init tiling object returned failed.");
216 return ge::GRAPH_FAILED;216 return ge::GRAPH_FAILED;
217 }217 }
218 return tilingObject.RunKernelTiling();218 return tilingObject.RunKernelTiling();
219}219}
220-} // namespace optiling220+} // namespace optiling
@@ -62,8 +62,8 @@ std::string MatrixDiagTiling::PrintTilingData()
62 tdStr += std::to_string(tilingDataLarge_.blockFactor) + ",";62 tdStr += std::to_string(tilingDataLarge_.blockFactor) + ",";
63 tdStr += std::to_string(tilingDataLarge_.blockTailFactor) + ",";63 tdStr += std::to_string(tilingDataLarge_.blockTailFactor) + ",";
64 tdStr += std::to_string(tilingDataLarge_.blockMainCount) + ",";64 tdStr += std::to_string(tilingDataLarge_.blockMainCount) + ",";
65- } else if (65+ } else if (tilingKey_ == ::MatrixDiagAsc::TILING_SCATTER_HIGH ||
66- tilingKey_ == ::MatrixDiagAsc::TILING_SCATTER_HIGH || tilingKey_ == ::MatrixDiagAsc::TILING_SCATTER_LOW) {66+ tilingKey_ == ::MatrixDiagAsc::TILING_SCATTER_LOW) {
67 tdStr += std::to_string(tilingDataScatter_.realCoreNum) + ",";67 tdStr += std::to_string(tilingDataScatter_.realCoreNum) + ",";
68 tdStr += std::to_string(tilingDataScatter_.batchSize) + ",";68 tdStr += std::to_string(tilingDataScatter_.batchSize) + ",";
69 tdStr += std::to_string(tilingDataScatter_.nSize) + ",";69 tdStr += std::to_string(tilingDataScatter_.nSize) + ",";
@@ -87,9 +87,8 @@ ge::graphStatus MatrixDiagTiling::SetTilingStruct(T& tilingSturct)
87 OP_CHECK_NULL_WITH_CONTEXT(context_, ptrData);87 OP_CHECK_NULL_WITH_CONTEXT(context_, ptrData);
88 void* ptrStruct = static_cast<void*>(&tilingSturct);88 void* ptrStruct = static_cast<void*>(&tilingSturct);
89 OP_CHECK_NULL_WITH_CONTEXT(context_, ptrStruct);89 OP_CHECK_NULL_WITH_CONTEXT(context_, ptrStruct);
90- OP_CHECK_IF(90+ OP_CHECK_IF(memcpy_s(ptrData, capSize, ptrStruct, sizeof(tilingSturct)) != 0,
91- memcpy_s(ptrData, capSize, ptrStruct, sizeof(tilingSturct)) != 0,91+ OP_LOGE(context_->GetNodeName(), "Set tiling data failed!"), return ge::GRAPH_FAILED);
92- OP_LOGE(context_->GetNodeName(), "Set tiling data is failed!"), return ge::GRAPH_FAILED);
93 ptrTD->SetDataSize(sizeof(tilingSturct));92 ptrTD->SetDataSize(sizeof(tilingSturct));
94 return ge::GRAPH_SUCCESS;93 return ge::GRAPH_SUCCESS;
95}94}
@@ -98,27 +97,27 @@ ge::graphStatus MatrixDiagTiling::SetTilingData()
98{97{
99 switch (tilingKey_) {98 switch (tilingKey_) {
100 case ::MatrixDiagAsc::TILING_PURE_COPY:99 case ::MatrixDiagAsc::TILING_PURE_COPY:
101- OP_CHECK_IF(100+ OP_CHECK_IF(SetTilingStruct<::MatrixDiagAsc::MatrixDiagPureCopyTilingData>(tilingDataPureCopy_) !=
102- SetTilingStruct<::MatrixDiagAsc::MatrixDiagPureCopyTilingData>(tilingDataPureCopy_) !=101+ ge::GRAPH_SUCCESS,
103- ge::GRAPH_SUCCESS,102+ OP_LOGE(context_->GetNodeName(), "Set pure copy tiling struct failed!"),
104- OP_LOGE(context_->GetNodeName(), "Set pure copy tiling struct is failed!"), return ge::GRAPH_FAILED);103+ return ge::GRAPH_FAILED);
105 break;104 break;
106 case ::MatrixDiagAsc::TILING_SIMT:105 case ::MatrixDiagAsc::TILING_SIMT:
107 OP_CHECK_IF(106 OP_CHECK_IF(
108 SetTilingStruct<::MatrixDiagAsc::MatrixDiagSimtTilingData>(tilingDataSimt_) != ge::GRAPH_SUCCESS,107 SetTilingStruct<::MatrixDiagAsc::MatrixDiagSimtTilingData>(tilingDataSimt_) != ge::GRAPH_SUCCESS,
109- OP_LOGE(context_->GetNodeName(), "Set simt tiling struct is failed!"), return ge::GRAPH_FAILED);108+ OP_LOGE(context_->GetNodeName(), "Set simt tiling struct failed!"), return ge::GRAPH_FAILED);
110 break;109 break;
111 case ::MatrixDiagAsc::TILING_SCATTER_LARGE:110 case ::MatrixDiagAsc::TILING_SCATTER_LARGE:
112- OP_CHECK_IF(111+ OP_CHECK_IF(SetTilingStruct<::MatrixDiagAsc::MatrixDiagScatterLargeTilingData>(tilingDataLarge_) !=
113- SetTilingStruct<::MatrixDiagAsc::MatrixDiagScatterLargeTilingData>(tilingDataLarge_) !=112+ ge::GRAPH_SUCCESS,
114- ge::GRAPH_SUCCESS,113+ OP_LOGE(context_->GetNodeName(), "Set scatterLarge tiling struct failed!"),
115- OP_LOGE(context_->GetNodeName(), "Set scatterLarge tiling struct is failed!"), return ge::GRAPH_FAILED);114+ return ge::GRAPH_FAILED);
116 break;115 break;
117 case ::MatrixDiagAsc::TILING_SCATTER_HIGH:116 case ::MatrixDiagAsc::TILING_SCATTER_HIGH:
118 case ::MatrixDiagAsc::TILING_SCATTER_LOW:117 case ::MatrixDiagAsc::TILING_SCATTER_LOW:
119 OP_CHECK_IF(118 OP_CHECK_IF(
120 SetTilingStruct<::MatrixDiagAsc::MatrixDiagScatterTilingData>(tilingDataScatter_) != ge::GRAPH_SUCCESS,119 SetTilingStruct<::MatrixDiagAsc::MatrixDiagScatterTilingData>(tilingDataScatter_) != ge::GRAPH_SUCCESS,
121- OP_LOGE(context_->GetNodeName(), "Set scatterHigh tiling struct is failed!"), return ge::GRAPH_FAILED);120+ OP_LOGE(context_->GetNodeName(), "Set scatterHigh tiling struct failed!"), return ge::GRAPH_FAILED);
122 break;121 break;
123 default:122 default:
124 return ge::GRAPH_SUCCESS;123 return ge::GRAPH_SUCCESS;
@@ -129,16 +128,13 @@ ge::graphStatus MatrixDiagTiling::SetTilingData()
129 128 
130ge::graphStatus MatrixDiagTiling::WriteTilingData()129ge::graphStatus MatrixDiagTiling::WriteTilingData()
131{130{
132- OP_CHECK_IF(131+ OP_CHECK_IF(context_->SetTilingKey(tilingKey_) != ge::GRAPH_SUCCESS,
133- context_->SetTilingKey(tilingKey_) != ge::GRAPH_SUCCESS,132+ OP_LOGE(context_->GetNodeName(), "Set tiling key failed!"), return ge::GRAPH_FAILED);
134- OP_LOGE(context_->GetNodeName(), "Set tiling key is failed!"), return ge::GRAPH_FAILED);133+ OP_CHECK_IF(context_->SetBlockDim(static_cast<uint32_t>(compileInfo_->coreNum)) != ge::GRAPH_SUCCESS,
135- OP_CHECK_IF(134+ OP_LOGE(context_->GetNodeName(), "Set used core size failed!"), return ge::GRAPH_FAILED);
136- context_->SetBlockDim(static_cast<uint32_t>(compileInfo_->coreNum)) != ge::GRAPH_SUCCESS,
137- OP_LOGE(context_->GetNodeName(), "Set used core size is failed!"), return ge::GRAPH_FAILED);
138 135 
139- OP_CHECK_IF(136+ OP_CHECK_IF(SetTilingData() != ge::GRAPH_SUCCESS, OP_LOGE(context_->GetNodeName(), "set tiling data failed!"),
140- SetTilingData() != ge::GRAPH_SUCCESS, OP_LOGE(context_->GetNodeName(), "set tiling data failed!"),137+ return ge::GRAPH_FAILED);
141- return ge::GRAPH_FAILED);
142 size_t totalWorkspaceSize = SYS_WORKSPACE_SIZE;138 size_t totalWorkspaceSize = SYS_WORKSPACE_SIZE;
143 size_t* ptrWS = context_->GetWorkspaceSizes(1);139 size_t* ptrWS = context_->GetWorkspaceSizes(1);
144 OP_CHECK_NULL_WITH_CONTEXT(context_, ptrWS);140 OP_CHECK_NULL_WITH_CONTEXT(context_, ptrWS);
@@ -172,16 +168,16 @@ void MatrixDiagTiling::CalcScatterLowTilingData()
172 int64_t coreNum = compileInfo_->coreNum;168 int64_t coreNum = compileInfo_->coreNum;
173 int64_t batchSize = fusedShape_[0];169 int64_t batchSize = fusedShape_[0];
174 int64_t nSize = fusedShape_[1];170 int64_t nSize = fusedShape_[1];
175- int64_t ubEleNum =171+ int64_t ubEleNum = (xDtypeSize_ == 1) ? B8_MAX_SIZE / (nSize + 1) :
176- (xDtypeSize_ == 1) ? B8_MAX_SIZE / (nSize + 1) : (((ubSize_ - VL_LEN) / BASE_2) / (nSize + 1)) / xDtypeSize_;172+ (((ubSize_ - VL_LEN) / BASE_2) / (nSize + 1)) / xDtypeSize_;
177 tilingDataScatter_.batchUbFactor = ubEleNum / nSize;173 tilingDataScatter_.batchUbFactor = ubEleNum / nSize;
178 tilingDataScatter_.batchUbCount = Ops::Base::CeilDiv(batchSize, tilingDataScatter_.batchUbFactor);174 tilingDataScatter_.batchUbCount = Ops::Base::CeilDiv(batchSize, tilingDataScatter_.batchUbFactor);
179 if (tilingDataScatter_.batchUbCount < coreNum) {175 if (tilingDataScatter_.batchUbCount < coreNum) {
180 tilingDataScatter_.batchUbFactor = Ops::Base::CeilDiv(batchSize, coreNum);176 tilingDataScatter_.batchUbFactor = Ops::Base::CeilDiv(batchSize, coreNum);
181 tilingDataScatter_.batchUbCount = Ops::Base::CeilDiv(batchSize, tilingDataScatter_.batchUbFactor);177 tilingDataScatter_.batchUbCount = Ops::Base::CeilDiv(batchSize, tilingDataScatter_.batchUbFactor);
182 }178 }
183- tilingDataScatter_.batchUbTailFactor =179+ tilingDataScatter_.batchUbTailFactor = batchSize -
184- batchSize - (tilingDataScatter_.batchUbCount - 1) * tilingDataScatter_.batchUbFactor;180+ (tilingDataScatter_.batchUbCount - 1) * tilingDataScatter_.batchUbFactor;
185 tilingDataScatter_.nSize = nSize;181 tilingDataScatter_.nSize = nSize;
186 tilingDataScatter_.batchSize = batchSize;182 tilingDataScatter_.batchSize = batchSize;
187 int64_t blockCount = std::min(tilingDataScatter_.batchUbCount, coreNum);183 int64_t blockCount = std::min(tilingDataScatter_.batchUbCount, coreNum);
@@ -223,16 +219,16 @@ void MatrixDiagTiling::CalcScatterHighTilingData()
223 int64_t batchSize = fusedShape_[0];219 int64_t batchSize = fusedShape_[0];
224 int64_t nSize = fusedShape_[1];220 int64_t nSize = fusedShape_[1];
225 int64_t halfUbEleNum = (xDtypeSize_ == 1) ? B8_MAX_SIZE : (ubSize_ - VL_LEN) / BASE_2 / xDtypeSize_;221 int64_t halfUbEleNum = (xDtypeSize_ == 1) ? B8_MAX_SIZE : (ubSize_ - VL_LEN) / BASE_2 / xDtypeSize_;
226- int64_t ubEleNum =222+ int64_t ubEleNum = (xDtypeSize_ == 1) ? std::sqrt(B8_MAX_SIZE) :
227- (xDtypeSize_ == 1) ? std::sqrt(B8_MAX_SIZE) : (std::sqrt(1 + BASE_4 * halfUbEleNum) - 1) / BASE_2;223+ (std::sqrt(1 + BASE_4 * halfUbEleNum) - 1) / BASE_2;
228 tilingDataScatter_.batchUbFactor = ubEleNum / nSize;224 tilingDataScatter_.batchUbFactor = ubEleNum / nSize;
229 tilingDataScatter_.batchUbCount = Ops::Base::CeilDiv(batchSize, tilingDataScatter_.batchUbFactor);225 tilingDataScatter_.batchUbCount = Ops::Base::CeilDiv(batchSize, tilingDataScatter_.batchUbFactor);
230- tilingDataScatter_.batchUbTailFactor =226+ tilingDataScatter_.batchUbTailFactor = batchSize -
231- batchSize - (tilingDataScatter_.batchUbCount - 1) * tilingDataScatter_.batchUbFactor;227+ (tilingDataScatter_.batchUbCount - 1) * tilingDataScatter_.batchUbFactor;
232 tilingDataScatter_.nSize = nSize;228 tilingDataScatter_.nSize = nSize;
233 tilingDataScatter_.realCoreNum = std::min(tilingDataScatter_.batchUbCount, coreNum);229 tilingDataScatter_.realCoreNum = std::min(tilingDataScatter_.batchUbCount, coreNum);
234- tilingDataScatter_.blockFactor =230+ tilingDataScatter_.blockFactor = Ops::Base::CeilDiv(tilingDataScatter_.batchUbCount,
235- Ops::Base::CeilDiv(tilingDataScatter_.batchUbCount, tilingDataScatter_.realCoreNum);231+ tilingDataScatter_.realCoreNum);
236 if (tilingDataScatter_.realCoreNum > 0) {232 if (tilingDataScatter_.realCoreNum > 0) {
237 tilingDataScatter_.blockMainCount = (tilingDataScatter_.batchUbCount % tilingDataScatter_.realCoreNum == 0) ?233 tilingDataScatter_.blockMainCount = (tilingDataScatter_.batchUbCount % tilingDataScatter_.realCoreNum == 0) ?
238 tilingDataScatter_.realCoreNum :234 tilingDataScatter_.realCoreNum :
@@ -258,12 +254,11 @@ void MatrixDiagTiling::SetBlockSplitInfo(int64_t batchBlockCnt, int64_t nBlockCn
258 254 
259 realCoreNum_ = mBlockCount_ * nBlockCount_;255 realCoreNum_ = mBlockCount_ * nBlockCount_;
260 256 
261- OP_LOGI(257+ OP_LOGI(context_->GetNodeName(),
262- context_->GetNodeName(),258+ "Get block split TotalNum-BlockCnt-MainFactor-MainCnt-TailFactor, "
263- "Get block split TotalNum-BlockCnt-MainFactor-MainCnt-TailFactor, "259+ "Batch:%ld %ld %ld %ld %ld, N:%ld %ld %ld %ld %ld",
264- "Batch:%ld %ld %ld %ld %ld, N:%ld %ld %ld %ld %ld",260+ batchSize, mBlockCount_, mBlockFactor_, mBlockFactorCount_, mBlockFactorTail_, nSize, nBlockCount_,
265- batchSize, mBlockCount_, mBlockFactor_, mBlockFactorCount_, mBlockFactorTail_, nSize, nBlockCount_,261+ nBlockFactor_, nBlockFactorCount_, nBlockFactorTail_);
266- nBlockFactor_, nBlockFactorCount_, nBlockFactorTail_);
267}262}
268 263 
269void MatrixDiagTiling::CalcPureCopyTilingData()264void MatrixDiagTiling::CalcPureCopyTilingData()
@@ -329,18 +324,16 @@ ge::graphStatus MatrixDiagTiling::GetInputShapeAndType()
329 ge::DataType xDtype = xInputDesc->GetDataType();324 ge::DataType xDtype = xInputDesc->GetDataType();
330 xDtypeSize_ = ge::GetSizeByDataType(xDtype);325 xDtypeSize_ = ge::GetSizeByDataType(xDtype);
331 const gert::Shape& xInputShape = xInput->GetStorageShape();326 const gert::Shape& xInputShape = xInput->GetStorageShape();
332- OP_CHECK_IF(327+ OP_CHECK_IF(xInputShape.GetDimNum() == 0,
333- xInputShape.GetDimNum() == 0,328+ OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), "x",
334- OP_LOGE_FOR_INVALID_SHAPEDIM(329+ std::to_string(xInputShape.GetDimNum()).c_str(), "greater than 0"),
335- context_->GetNodeName(), "x", std::to_string(xInputShape.GetDimNum()).c_str(), "greater than 0"),330+ return ge::GRAPH_FAILED);
336- return ge::GRAPH_FAILED);
337 inputShape_ = xInputShape;331 inputShape_ = xInputShape;
338 FuseInputShape();332 FuseInputShape();
339 OP_CHECK_IF(333 OP_CHECK_IF(
340 fusedShape_[0] == 0 || fusedShape_[1] == 0,334 fusedShape_[0] == 0 || fusedShape_[1] == 0,
341- OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(335+ OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "x", Ops::Base::ToString(inputShape_).c_str(),
342- context_->GetNodeName(), "x", Ops::Base::ToString(inputShape_).c_str(),336+ "fused batch size and n size must both be non-zero"),
343- "fused batch size and n size must both be non-zero"),
344 return ge::GRAPH_FAILED);337 return ge::GRAPH_FAILED);
345 return ge::GRAPH_SUCCESS;338 return ge::GRAPH_SUCCESS;
346}339}
@@ -350,9 +343,8 @@ ge::graphStatus MatrixDiagTiling::DoTiling()
350 compileInfo_ = reinterpret_cast<const MatrixDiagCompileInfo*>(context_->GetCompileInfo());343 compileInfo_ = reinterpret_cast<const MatrixDiagCompileInfo*>(context_->GetCompileInfo());
351 OP_CHECK_NULL_WITH_CONTEXT(context_, compileInfo_);344 OP_CHECK_NULL_WITH_CONTEXT(context_, compileInfo_);
352 345 
353- OP_CHECK_IF(346+ OP_CHECK_IF(GetInputShapeAndType() != ge::GRAPH_SUCCESS, OP_LOGE(context_->GetNodeName(), "Do tiling failed!"),
354- GetInputShapeAndType() != ge::GRAPH_SUCCESS, OP_LOGE(context_->GetNodeName(), "Do tiling is failed!"),347+ return ge::GRAPH_FAILED);
355- return ge::GRAPH_FAILED);
356 CalcTilingData();348 CalcTilingData();
357 return WriteTilingData();349 return WriteTilingData();
358}350}
@@ -360,10 +352,9 @@ ge::graphStatus MatrixDiagTiling::DoTiling()
360 352 
361static ge::graphStatus Tiling4MatrixDiag(gert::TilingContext* context)353static ge::graphStatus Tiling4MatrixDiag(gert::TilingContext* context)
362{354{
363- OP_CHECK_IF(355+ OP_CHECK_IF(context == nullptr,
364- context == nullptr,356+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON("Tiling4MatrixDiag", "context", "nullptr", "must not be null"),
365- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON("Tiling4MatrixDiag", "context", "nullptr", "must not be null"),357+ return ge::GRAPH_FAILED);
366- return ge::GRAPH_FAILED);
367 358 
368 MatrixDiagAsc::MatrixDiagTiling op(context);359 MatrixDiagAsc::MatrixDiagTiling op(context);
369 return op.DoTiling();360 return op.DoTiling();
@@ -380,38 +371,34 @@ static ge::graphStatus TilingPrepare4MatrixDiagAscendC(gert::TilingParseContext*
380 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);371 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);
381 372 
382 compileInfo->coreNum = ascendcPlatform.GetCoreNumAiv();373 compileInfo->coreNum = ascendcPlatform.GetCoreNumAiv();
383- OP_CHECK_IF(374+ OP_CHECK_IF((compileInfo->coreNum < 1),
384- (compileInfo->coreNum < 1),375+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "core num",
385- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(376+ std::to_string(compileInfo->coreNum).c_str(),
386- context->GetNodeName(), "core num", std::to_string(compileInfo->coreNum).c_str(),377+ "must be greater than or equal to 1"),
387- "must be greater than or equal to 1"),378+ return ge::GRAPH_FAILED);
388- return ge::GRAPH_FAILED);
389 379 
390 uint64_t ubSize = 0;380 uint64_t ubSize = 0;
391 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);381 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);
392 compileInfo->ubSize = static_cast<uint32_t>(ubSize);382 compileInfo->ubSize = static_cast<uint32_t>(ubSize);
393- OP_CHECK_IF(383+ OP_CHECK_IF((compileInfo->ubSize < 1),
394- (compileInfo->ubSize < 1),384+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "ub size",
395- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(385+ std::to_string(compileInfo->ubSize).c_str(),
396- context->GetNodeName(), "ub size", std::to_string(compileInfo->ubSize).c_str(),386+ "must be greater than or equal to 1"),
397- "must be greater than or equal to 1"),387+ return ge::GRAPH_FAILED);
398- return ge::GRAPH_FAILED);
399 388 
400 compileInfo->clSize = Ops::Base::GetCacheLineSize(context);389 compileInfo->clSize = Ops::Base::GetCacheLineSize(context);
401- OP_CHECK_IF(390+ OP_CHECK_IF((compileInfo->clSize < 1),
402- (compileInfo->clSize < 1),391+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "cache line size",
403- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(392+ std::to_string(compileInfo->clSize).c_str(),
404- context->GetNodeName(), "cache line size", std::to_string(compileInfo->clSize).c_str(),393+ "must be greater than or equal to 1"),
405- "must be greater than or equal to 1"),394+ return ge::GRAPH_FAILED);
406- return ge::GRAPH_FAILED);
407 395 
408 compileInfo->blockSize = Ops::Base::GetUbBlockSize(context);396 compileInfo->blockSize = Ops::Base::GetUbBlockSize(context);
409- OP_CHECK_IF(397+ OP_CHECK_IF((compileInfo->blockSize < 1),
410- (compileInfo->blockSize < 1),398+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "block size",
411- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(399+ std::to_string(compileInfo->blockSize).c_str(),
412- context->GetNodeName(), "block size", std::to_string(compileInfo->blockSize).c_str(),400+ "must be greater than or equal to 1"),
413- "must be greater than or equal to 1"),401+ return ge::GRAPH_FAILED);
414- return ge::GRAPH_FAILED);
415 402 
416 OP_LOGD(context->GetNodeName(), "Exit TilingPrepare4MatrixDiagAscendC.");403 OP_LOGD(context->GetNodeName(), "Exit TilingPrepare4MatrixDiagAscendC.");
417 return ge::GRAPH_SUCCESS;404 return ge::GRAPH_SUCCESS;
@@ -18,9 +18,8 @@ ge::graphStatus MatrixSetDiagInferDataTypeFunc(gert::InferDataTypeContext* conte
18 auto inputDtype = context->GetInputDataType(0);18 auto inputDtype = context->GetInputDataType(0);
19 OP_LOGD(context, "input dtype: %s", Ops::Base::ToString(inputDtype).c_str());19 OP_LOGD(context, "input dtype: %s", Ops::Base::ToString(inputDtype).c_str());
20 auto diagDtype = context->GetInputDataType(1);20 auto diagDtype = context->GetInputDataType(1);
21- OP_CHECK_IF(21+ OP_CHECK_IF(inputDtype != diagDtype, OP_LOGE(context->GetNodeName(), "input and diag datatypes are not the same"),
22- inputDtype != diagDtype, OP_LOGE(context->GetNodeName(), "input and diag datatype are not the same"),22+ return ge::GRAPH_FAILED);
23- return ge::GRAPH_FAILED);
24 23 
25 context->SetOutputDataType(0, inputDtype);24 context->SetOutputDataType(0, inputDtype);
26 OP_LOGD(context, "MatrixSetDiagInferDataTypeFunc end");25 OP_LOGD(context, "MatrixSetDiagInferDataTypeFunc end");
@@ -34,19 +34,17 @@ ge::graphStatus MatrixSetDiagInferShapeFunc(gert::InferShapeContext* context)
34 34 
35 // check size35 // check size
36 size_t sizeIn = shapeIn->GetDimNum();36 size_t sizeIn = shapeIn->GetDimNum();
37- OP_CHECK_IF(37+ OP_CHECK_IF(sizeIn < 2, OP_LOGE(context->GetNodeName(), "input shape must at least 2 dims."),
38- sizeIn < 2, OP_LOGE(context->GetNodeName(), "input shape must at least 2 dims."), return ge::GRAPH_FAILED);38+ return ge::GRAPH_FAILED);
39 size_t sizeDiag = shapeDiag->GetDimNum();39 size_t sizeDiag = shapeDiag->GetDimNum();
40- OP_CHECK_IF(40+ OP_CHECK_IF(sizeDiag != sizeIn - 1, OP_LOGE(context->GetNodeName(), "diag dims must be input dims - 1"),
41- sizeDiag != sizeIn - 1, OP_LOGE(context->GetNodeName(), "diag dims must input dims-1"),41+ return ge::GRAPH_FAILED);
42- return ge::GRAPH_FAILED);
43 42 
44 int64_t smallDimInput = std::min(shapeIn->GetDim(sizeIn - 1), shapeIn->GetDim(sizeIn - 2));43 int64_t smallDimInput = std::min(shapeIn->GetDim(sizeIn - 1), shapeIn->GetDim(sizeIn - 2));
45 int64_t smallDimDiag = shapeDiag->GetDim(sizeDiag - 1);44 int64_t smallDimDiag = shapeDiag->GetDim(sizeDiag - 1);
46 if (smallDimInput != ge::UNKNOWN_DIM && smallDimDiag != ge::UNKNOWN_DIM) {45 if (smallDimInput != ge::UNKNOWN_DIM && smallDimDiag != ge::UNKNOWN_DIM) {
47- OP_CHECK_IF(46+ OP_CHECK_IF(smallDimInput != smallDimDiag, OP_LOGE(context->GetNodeName(), "diag check with input failed"),
48- smallDimInput != smallDimDiag, OP_LOGE(context->GetNodeName(), "diag check with input failed"),47+ return ge::GRAPH_FAILED);
49- return ge::GRAPH_FAILED);
50 }48 }
51 49 
52 *shapeOut = *shapeIn;50 *shapeOut = *shapeIn;
@@ -57,9 +55,8 @@ ge::graphStatus MatrixSetDiagInferShapeFunc(gert::InferShapeContext* context)
57 }55 }
58 } else {56 } else {
59 if (shapeDiag->GetDim(i) != ge::UNKNOWN_DIM) {57 if (shapeDiag->GetDim(i) != ge::UNKNOWN_DIM) {
60- OP_CHECK_IF(58+ OP_CHECK_IF(shapeIn->GetDim(i) != shapeDiag->GetDim(i),
61- shapeIn->GetDim(i) != shapeDiag->GetDim(i),59+ OP_LOGE(context->GetNodeName(), "dim %zu is not the same", i), return ge::GRAPH_FAILED);
62- OP_LOGE(context->GetNodeName(), "dim %zu not the same", i), return ge::GRAPH_FAILED);
63 }60 }
64 }61 }
65 }62 }
@@ -18,7 +18,7 @@ static ge::graphStatus MatrixSetDiagV2InferDataTypeFunc(gert::InferDataTypeConte
18 auto inputDtype = context->GetInputDataType(0);18 auto inputDtype = context->GetInputDataType(0);
19 OP_LOGD(context, "input dtype: %s", Ops::Base::ToString(inputDtype).c_str());19 OP_LOGD(context, "input dtype: %s", Ops::Base::ToString(inputDtype).c_str());
20 auto diagDtype = context->GetInputDataType(1);20 auto diagDtype = context->GetInputDataType(1);
21- OP_CHECK_IF(inputDtype != diagDtype, OP_LOGE(context->GetNodeName(), "input and diag data types are not the same"),21+ OP_CHECK_IF(inputDtype != diagDtype, OP_LOGE(context->GetNodeName(), "input and diag datatypes are not the same"),
22 return ge::GRAPH_FAILED);22 return ge::GRAPH_FAILED);
23 23 
24 context->SetOutputDataType(0, inputDtype);24 context->SetOutputDataType(0, inputDtype);
@@ -139,7 +139,7 @@ ge::graphStatus MatrixSetDiagV2Tiling::CheckDiag()
139 OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(139 OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(
140 context_->GetNodeName(), "input and diagonal",140 context_->GetNodeName(), "input and diagonal",
141 Ops::Math::Join(inputShapeVal_.GetDim(i), diagShapeVal_.GetDim(i)),141 Ops::Math::Join(inputShapeVal_.GetDim(i), diagShapeVal_.GetDim(i)),
142- std::to_string(i) + "th axis of diagonal must be equal to same axis of input"),142+ std::to_string(i) + "th axis of diagonal must be equal to the same axis of input"),
143 return ge::GRAPH_FAILED);143 return ge::GRAPH_FAILED);
144 }144 }
145 OP_CHECK_IF(145 OP_CHECK_IF(
@@ -136,7 +136,7 @@ ge::graphStatus RollTilingClass::CheckAndGetInputParam()
136 }136 }
137 137 
138 totalEmelents_ = xShape.GetShapeSize();138 totalEmelents_ = xShape.GetShapeSize();
139- OP_LOGD(context_, "total emelents is: %ld.", totalEmelents_);139+ OP_LOGD(context_, "total elements is: %ld.", totalEmelents_);
140 dtypeSize_ = static_cast<int64_t>(ge::GetSizeByDataType(context_->GetInputDesc(INPUT_X_IDX)->GetDataType()));140 dtypeSize_ = static_cast<int64_t>(ge::GetSizeByDataType(context_->GetInputDesc(INPUT_X_IDX)->GetDataType()));
141 OP_LOGD(context_, "Input x dtype size is: %ld.", dtypeSize_);141 OP_LOGD(context_, "Input x dtype size is: %ld.", dtypeSize_);
142 142 
@@ -611,8 +611,8 @@ void RollTilingClass::PrintTiling() const
611 OP_LOGD(611 OP_LOGD(
612 context_,612 context_,
613 "Roll tilingData->MoveParam: mte3Count = %ld, srcOffset[%ld] = %ld, blockCount[%ld] = %ld, blockLen[%ld] = "613 "Roll tilingData->MoveParam: mte3Count = %ld, srcOffset[%ld] = %ld, blockCount[%ld] = %ld, blockLen[%ld] = "
614- "%ld"614+ "%ld, "
615- "srcStride[%ld] = %ld, dstOffeset[%ld] = %ld",615+ "srcStride[%ld] = %ld, dstOffset[%ld] = %ld",
616 tilingData_->moveparam.mte3Count, i, tilingData_->moveparam.srcOffset[i], i,616 tilingData_->moveparam.mte3Count, i, tilingData_->moveparam.srcOffset[i], i,
617 tilingData_->moveparam.blockCount[i], i, tilingData_->moveparam.blockLen[i], i,617 tilingData_->moveparam.blockCount[i], i, tilingData_->moveparam.blockLen[i], i,
618 tilingData_->moveparam.srcStride[i], i, tilingData_->moveparam.dstOffset[i]);618 tilingData_->moveparam.srcStride[i], i, tilingData_->moveparam.dstOffset[i]);
@@ -639,7 +639,7 @@ ge::graphStatus RollTilingArch35(gert::TilingContext* context)
639 const RollCompileInfoArch35* compile_info = reinterpret_cast<const RollCompileInfoArch35*>(639 const RollCompileInfoArch35* compile_info = reinterpret_cast<const RollCompileInfoArch35*>(
640 context->GetCompileInfo());640 context->GetCompileInfo());
641 OP_CHECK_NULL_WITH_CONTEXT(context, compile_info);641 OP_CHECK_NULL_WITH_CONTEXT(context, compile_info);
642- OP_LOGD(context->GetNodeName(), "runing regbase soc version tiling func");642+ OP_LOGD(context->GetNodeName(), "running regbase soc version tiling func");
643 RollTilingClass tiling(context);643 RollTilingClass tiling(context);
644 return tiling.DoTiling();644 return tiling.DoTiling();
645}645}
@@ -12,4 +12,4 @@
12set(SUPPORT_COMPUTE_UNIT "ascend310p" "ascend910_93" "ascend910b" "ascend950" "mc62")12set(SUPPORT_COMPUTE_UNIT "ascend310p" "ascend910_93" "ascend910b" "ascend950" "mc62")
13# 设置每种芯片类型对应的tiling文件目录,即采用op_host目录下哪个文件夹下的tiling文件编译13# 设置每种芯片类型对应的tiling文件目录,即采用op_host目录下哪个文件夹下的tiling文件编译
14set(SUPPORT_TILING_DIR "arch22" "arch22" "arch22" "arch35" "arch35")14set(SUPPORT_TILING_DIR "arch22" "arch22" "arch22" "arch35" "arch35")
15-add_all_modules_sources(OPTYPE slice ACLNNTYPE aclnn_exclude COMPUTE_UNIT ${SUPPORT_COMPUTE_UNIT} TILING_DIR ${SUPPORT_TILING_DIR} DISABLE_IN_OPP TRUE DEPENDENCIES strided_slice)15+add_all_modules_sources(OPTYPE slice ACLNNTYPE aclnn_exclude COMPUTE_UNIT ${SUPPORT_COMPUTE_UNIT} TILING_DIR ${SUPPORT_TILING_DIR} DISABLE_IN_OPP TRUE DEPENDENCIES strided_slice strided_slice_v3)
@@ -47,7 +47,7 @@ static bool CheckDtypeValid(const aclTensor* self, const aclTensor* out)
47 OP_CHECK_DTYPE_NOT_MATCH(out, self->GetDataType(), return false);47 OP_CHECK_DTYPE_NOT_MATCH(out, self->GetDataType(), return false);
48 48 
49 if (!CheckSocVersionIsSupportBf16() && (self->GetDataType() == op::DataType::DT_BF16)) {49 if (!CheckSocVersionIsSupportBf16() && (self->GetDataType() == op::DataType::DT_BF16)) {
50- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Input dtype of aclnnSlice is not support bfloat16 in current socversion.");50+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Input dtype of aclnnSlice does not support bfloat16 in current socversion.");
51 return false;51 return false;
52 }52 }
53 53 
@@ -91,28 +91,26 @@ static bool CheckNotNull2TensorForSlice(const aclTensor* t0, const aclTensor* t1
91 return true;91 return true;
92}92}
93 93 
94-static bool CheckShape(94+static bool CheckShape(const aclTensor* self, int64_t dim, int64_t start, int64_t end, int64_t step,
95- const aclTensor* self, int64_t dim, int64_t start, int64_t end, int64_t step, const aclTensor* out)95+ const aclTensor* out)
96{96{
97 int64_t dimNum = self->GetViewShape().GetDimNum();97 int64_t dimNum = self->GetViewShape().GetDimNum();
98 // 校验输入的长度98 // 校验输入的长度
99 if (dimNum > MAX_DIM_LEN) {99 if (dimNum > MAX_DIM_LEN) {
100- OP_LOGE(100+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
101- ACLNN_ERR_PARAM_INVALID, "Expected aclnnSlice self len %ld to not be greater than %ld but check failed.",101+ "Expected aclnnSlice self len %ld to not be greater than %ld but check failed.", dimNum, MAX_DIM_LEN);
102- dimNum, MAX_DIM_LEN);
103 return false;102 return false;
104 }103 }
105 if (dimNum <= 0) {104 if (dimNum <= 0) {
106- OP_LOGE(105+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expected aclnnSlice self len %ld to not be less than one but check failed.",
107- ACLNN_ERR_PARAM_INVALID, "Expected aclnnSlice self len %ld to not be less than one but check failed.",106+ dimNum);
108- dimNum);
109 return false;107 return false;
110 }108 }
111 109 
112 if ((-dimNum > dim) || ((dimNum - 1) < dim)) {110 if ((-dimNum > dim) || ((dimNum - 1) < dim)) {
113- OP_LOGE(111+ OP_LOGE(ACLNN_ERR_PARAM_NULLPTR,
114- ACLNN_ERR_PARAM_NULLPTR, "Expected aclnnSlice dim value %ld to be in range [%ld, %ld] but check failed.",112+ "Expected aclnnSlice dim value %ld to be in range [%ld, %ld] but check failed.", dim, -dimNum,
115- dim, -dimNum, dimNum - 1);113+ dimNum - 1);
116 return false;114 return false;
117 }115 }
118 116 
@@ -128,16 +126,15 @@ static bool CheckShape(
128 auto outShape = out->GetViewShape();126 auto outShape = out->GetViewShape();
129 // 校验输出shape127 // 校验输出shape
130 if (sliceShape != outShape) {128 if (sliceShape != outShape) {
131- OP_LOGE(129+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Shape of out should be %s, but current is %s.",
132- ACLNN_ERR_PARAM_INVALID, "Shape of out should be %s, but current is %s.",130+ op::ToString(sliceShape).GetString(), op::ToString(outShape).GetString());
133- op::ToString(sliceShape).GetString(), op::ToString(outShape).GetString());
134 return false;131 return false;
135 }132 }
136 return true;133 return true;
137}134}
138 135 
139-inline static aclnnStatus CheckParams(136+inline static aclnnStatus CheckParams(const aclTensor* self, int64_t dim, int64_t start, int64_t end, int64_t step,
140- const aclTensor* self, int64_t dim, int64_t start, int64_t end, int64_t step, aclTensor* out)137+ aclTensor* out)
141{138{
142 // 1. 检查参数是否为空指针139 // 1. 检查参数是否为空指针
143 CHECK_RET(CheckNotNull2TensorForSlice(self, out), ACLNN_ERR_PARAM_NULLPTR);140 CHECK_RET(CheckNotNull2TensorForSlice(self, out), ACLNN_ERR_PARAM_NULLPTR);
@@ -150,9 +147,8 @@ inline static aclnnStatus CheckParams(
150 return ACLNN_SUCCESS;147 return ACLNN_SUCCESS;
151}148}
152 149 
153-aclnnStatus aclnnSliceGetWorkspaceSize(150+aclnnStatus aclnnSliceGetWorkspaceSize(const aclTensor* self, int64_t dim, int64_t start, int64_t end, int64_t step,
154- const aclTensor* self, int64_t dim, int64_t start, int64_t end, int64_t step, aclTensor* out,151+ aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)
155- uint64_t* workspaceSize, aclOpExecutor** executor)
156{152{
157 OP_CHECK_COMM_INPUT(workspaceSize, executor);153 OP_CHECK_COMM_INPUT(workspaceSize, executor);
158 154 
@@ -25,19 +25,17 @@ void SliceTiling::CalMaxSplitDim()
25 dimNum_ <= NUMBER_FOUR &&25 dimNum_ <= NUMBER_FOUR &&
26 (lastTwoInputDim_ - lastTwoOutputDim_) * lastOneInputDim_ * xDtypeSize_ <= MAX_UINT32_NUM &&26 (lastTwoInputDim_ - lastTwoOutputDim_) * lastOneInputDim_ * xDtypeSize_ <= MAX_UINT32_NUM &&
27 lastOneInputDim_ * lastTwoInputDim_ * lastThreeInputDim_ * xDtypeSize_ <= MAX_UINT32_NUM;27 lastOneInputDim_ * lastTwoInputDim_ * lastThreeInputDim_ * xDtypeSize_ <= MAX_UINT32_NUM;
28- if (dimNum_ == NUMBER_TWO && lastOneOutputDim_ * xDtypeSize_ < VL_SIZE && 28+ if (dimNum_ == NUMBER_TWO && lastOneOutputDim_ * xDtypeSize_ < VL_SIZE && lastTwoOutputDim_ == lastTwoInputDim_ &&
29- lastTwoOutputDim_ == lastTwoInputDim_ &&29+ VL_SIZE * lastTwoInputDim_ < coreNum_ * ubSize_ / NUMBER_FOUR &&
30- VL_SIZE * lastTwoInputDim_ < coreNum_ * ubSize_ / NUMBER_FOUR &&
31 (lastOneOutputDim_ != 1 || lastTwoOutputDim_ <= LAST_DIM_MIN_DATA_SIZE)) {30 (lastOneOutputDim_ != 1 || lastTwoOutputDim_ <= LAST_DIM_MIN_DATA_SIZE)) {
32 // 针对2维,仅尾轴切分的小shape场景的性能特化模板31 // 针对2维,仅尾轴切分的小shape场景的性能特化模板
33 // 尾轴输入大于等于1个VL长度或者尾轴输入小于1个VL长度,且尾轴为偏移0时,才进入本模板32 // 尾轴输入大于等于1个VL长度或者尾轴输入小于1个VL长度,且尾轴为偏移0时,才进入本模板
34 maxSplitDim_ = MAX_TWO_DIM_UB_SPLIT_AXIS_NUM;33 maxSplitDim_ = MAX_TWO_DIM_UB_SPLIT_AXIS_NUM;
35- } else if (34+ } else if ((lastOneInputDim_ * xDtypeSize_) % BLOCK_SIZE != 0 && lastOneInputDim_ * xDtypeSize_ <= VL_SIZE &&
36- (lastOneInputDim_ * xDtypeSize_) % BLOCK_SIZE != 0 && lastOneInputDim_ * xDtypeSize_ <= VL_SIZE &&35+ (lastOneInputDim_ * lastTwoOutputDim_ * xDtypeSize_ >= VL_SIZE ||
37- (lastOneInputDim_ * lastTwoOutputDim_ * xDtypeSize_ >= VL_SIZE ||36+ lastOneInputDim_ * lastTwoOutputDim_ * xDtypeSize_ % BLOCK_SIZE == 0) &&
38- lastOneInputDim_ * lastTwoOutputDim_ * xDtypeSize_ % BLOCK_SIZE == 0) &&37+ lastOneOutputDim_ * xDtypeSize_ >= RESERVE_LAST_DIM_SIZE && totalOutputSize_ > MIN_OUTPUT_SIZE &&
39- lastOneOutputDim_ * xDtypeSize_ >= RESERVE_LAST_DIM_SIZE && totalOutputSize_ > MIN_OUTPUT_SIZE &&38+ lastOneInputDim_ / lastOneOutputDim_ < DATA_COPY_SPARSITY_THRESHOLD && isUbinnerGather) {
40- lastOneInputDim_ / lastOneOutputDim_ < DATA_COPY_SPARSITY_THRESHOLD && isUbinnerGather) {
41 // 输入的尾轴非block对齐39 // 输入的尾轴非block对齐
42 // 输入尾轴<= 256B && 64B <= 输出尾轴 <= 256B40 // 输入尾轴<= 256B && 64B <= 输出尾轴 <= 256B
43 // 当连续搬入的burstlen小于256B且非block对齐时,性能比compact模式更差41 // 当连续搬入的burstlen小于256B且非block对齐时,性能比compact模式更差
@@ -46,12 +44,11 @@ void SliceTiling::CalMaxSplitDim()
46 isSliceGather_ = true;44 isSliceGather_ = true;
47 } else if (lastOneOutputDim_ * xDtypeSize_ >= RESERVE_LAST_DIM_SIZE) {45 } else if (lastOneOutputDim_ * xDtypeSize_ >= RESERVE_LAST_DIM_SIZE) {
48 maxSplitDim_ = MAX_MOV_ALIGN_V2_UB_SPLIT_AXIS_NUM;46 maxSplitDim_ = MAX_MOV_ALIGN_V2_UB_SPLIT_AXIS_NUM;
49- } else if (47+ } else if (lastOneInputDim_ * xDtypeSize_ < RESERVE_LAST_DIM_SIZE &&
50- lastOneInputDim_ * xDtypeSize_ < RESERVE_LAST_DIM_SIZE &&48+ lastOneInputDim_ / lastOneOutputDim_ < DATA_SPARSITY_THRESHOLD &&
51- lastOneInputDim_ / lastOneOutputDim_ < DATA_SPARSITY_THRESHOLD &&49+ totalOutputSize_ / lastOneOutputDim_ * lastOneInputDim_ >
52- totalOutputSize_ / lastOneOutputDim_ * lastOneInputDim_ >50+ ubSize_ * lastOneInputDim_ / (lastOneOutputDim_ + lastOneInputDim_) * coreNum_ &&
53- ubSize_ * lastOneInputDim_ / (lastOneOutputDim_ + lastOneInputDim_) * coreNum_ &&51+ xDtypeSize_ != 1 && isUbinnerGather) {
54- xDtypeSize_ != 1 && isUbinnerGather) {
55 // b8 性能不稳定52 // b8 性能不稳定
56 // 数据稀疏度越低,搬入的有效数据越少53 // 数据稀疏度越低,搬入的有效数据越少
57 // 数据太小,一次搬入就处理完,vf计算完全不能被MTE掩掉的场景54 // 数据太小,一次搬入就处理完,vf计算完全不能被MTE掩掉的场景
@@ -76,10 +73,7 @@ void SliceTiling::SetTilingMode()
76 }73 }
77}74}
78 75 
79-void SliceTiling::SetTwoDimSmallShapeTilingMode()76+void SliceTiling::SetTwoDimSmallShapeTilingMode() { tilingKey_ = SLICE_KEY_TWO_DIM_SMALL_SHAPE; }
80-{
81- tilingKey_ = SLICE_KEY_TWO_DIM_SMALL_SHAPE;
82-}
83 77 
84/*78/*
85input79input
@@ -167,10 +161,10 @@ nburst = c.i
167void SliceTiling::SliceGatherUbSplitLastThreeDim()161void SliceTiling::SliceGatherUbSplitLastThreeDim()
168{162{
169 mainMoveAlignV2Info_.blockCount = static_cast<uint16_t>(ubFactor_);163 mainMoveAlignV2Info_.blockCount = static_cast<uint16_t>(ubFactor_);
170- mainMoveAlignV2Info_.blockLen =164+ mainMoveAlignV2Info_.blockLen = static_cast<uint32_t>(lastTwoOutputDim_ * lastOneInputDim_ *
171- static_cast<uint32_t>(lastTwoOutputDim_ * lastOneInputDim_ * xDtypeSize_); // 每个blockLen之间会补pad165+ xDtypeSize_); // 每个blockLen之间会补pad
172- mainMoveAlignV2Info_.srcStride =166+ mainMoveAlignV2Info_.srcStride = static_cast<uint32_t>((lastTwoInputDim_ - lastTwoOutputDim_) * lastOneInputDim_ *
173- static_cast<uint32_t>((lastTwoInputDim_ - lastTwoOutputDim_) * lastOneInputDim_ * xDtypeSize_);167+ xDtypeSize_);
174 mainMoveAlignV2Info_.dstStride = static_cast<uint32_t>(0);168 mainMoveAlignV2Info_.dstStride = static_cast<uint32_t>(0);
175 169 
176 // out170 // out
@@ -187,16 +181,16 @@ loop1size = b.i
187void SliceTiling::SliceGatherUbSplitLastFourDim()181void SliceTiling::SliceGatherUbSplitLastFourDim()
188{182{
189 mainMoveAlignV2Info_.blockCount = static_cast<uint16_t>(lastThreeOutputDim_);183 mainMoveAlignV2Info_.blockCount = static_cast<uint16_t>(lastThreeOutputDim_);
190- mainMoveAlignV2Info_.blockLen =184+ mainMoveAlignV2Info_.blockLen = static_cast<uint32_t>(lastTwoOutputDim_ * lastOneInputDim_ *
191- static_cast<uint32_t>(lastTwoOutputDim_ * lastOneInputDim_ * xDtypeSize_); // 每个blockLen之间会补pad185+ xDtypeSize_); // 每个blockLen之间会补pad
192- mainMoveAlignV2Info_.srcStride =186+ mainMoveAlignV2Info_.srcStride = static_cast<uint32_t>((lastTwoInputDim_ - lastTwoOutputDim_) * lastOneInputDim_ *
193- static_cast<uint32_t>((lastTwoInputDim_ - lastTwoOutputDim_) * lastOneInputDim_ * xDtypeSize_);187+ xDtypeSize_);
194 mainMoveAlignV2Info_.dstStride = static_cast<uint32_t>(0);188 mainMoveAlignV2Info_.dstStride = static_cast<uint32_t>(0);
195 outBlockLen_ = static_cast<uint32_t>(lastTwoOutputDim_ * lastOneOutputDim_ * xDtypeSize_);189 outBlockLen_ = static_cast<uint32_t>(lastTwoOutputDim_ * lastOneOutputDim_ * xDtypeSize_);
196 190 
197 int64_t loop1SrcStride = lastOneInputDim_ * lastTwoInputDim_ * lastThreeInputDim_ * xDtypeSize_;191 int64_t loop1SrcStride = lastOneInputDim_ * lastTwoInputDim_ * lastThreeInputDim_ * xDtypeSize_;
198- int64_t loop1DstStride =192+ int64_t loop1DstStride = Ops::Base::CeilAlign(lastOneInputDim_ * lastTwoOutputDim_ * xDtypeSize_, BLOCK_SIZE) *
199- Ops::Base::CeilAlign(lastOneInputDim_ * lastTwoOutputDim_ * xDtypeSize_, BLOCK_SIZE) * lastThreeOutputDim_;193+ lastThreeOutputDim_;
200 mainMoveAlignV2Info_.loop1Size = static_cast<uint16_t>(ubFactor_);194 mainMoveAlignV2Info_.loop1Size = static_cast<uint16_t>(ubFactor_);
201 mainMoveAlignV2Info_.loop1SrcStride = static_cast<uint32_t>(loop1SrcStride); // repeat stride是头和头之间的间隔195 mainMoveAlignV2Info_.loop1SrcStride = static_cast<uint32_t>(loop1SrcStride); // repeat stride是头和头之间的间隔
202 mainMoveAlignV2Info_.loop1DstStride = static_cast<uint16_t>(loop1DstStride);196 mainMoveAlignV2Info_.loop1DstStride = static_cast<uint16_t>(loop1DstStride);
@@ -304,8 +298,8 @@ void SliceTiling::FillSliceTilingData150()
304 SetRowsStepsParamsFor150(sliceMoveAlignLast2DimTilingData_);298 SetRowsStepsParamsFor150(sliceMoveAlignLast2DimTilingData_);
305 299 
306 auto tilingData = tilingContext_->GetTilingData<SliceMoveAlignLast2DimTilingData>();300 auto tilingData = tilingContext_->GetTilingData<SliceMoveAlignLast2DimTilingData>();
307- errno_t ret = memcpy_s(301+ errno_t ret = memcpy_s(tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceMoveAlignLast2DimTilingData_),
308- tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceMoveAlignLast2DimTilingData_), tilingDataSize);302+ tilingDataSize);
309 if (ret != EOK) {303 if (ret != EOK) {
310 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);304 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);
311 }305 }
@@ -346,8 +340,8 @@ void SliceTiling::FillSliceTilingData100()
346 sliceMoveAlignTilingData_.ubOutLoopSteps = outLoopSteps_;340 sliceMoveAlignTilingData_.ubOutLoopSteps = outLoopSteps_;
347 SetMoveAlignParamsSlice(sliceMoveAlignTilingData_.moveAlignParams, mainMoveAlignV2Info_);341 SetMoveAlignParamsSlice(sliceMoveAlignTilingData_.moveAlignParams, mainMoveAlignV2Info_);
348 auto tilingData = tilingContext_->GetTilingData<SliceMoveAlignTilingData>();342 auto tilingData = tilingContext_->GetTilingData<SliceMoveAlignTilingData>();
349- errno_t ret =343+ errno_t ret = memcpy_s(tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceMoveAlignTilingData_),
350- memcpy_s(tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceMoveAlignTilingData_), tilingDataSize);344+ tilingDataSize);
351 if (ret != EOK) {345 if (ret != EOK) {
352 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);346 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);
353 }347 }
@@ -359,8 +353,8 @@ void SliceTiling::FillSliceTilingData101()
359 OP_LOGD(tilingContext_->GetNodeName(), "Entering FillTilingData101.");353 OP_LOGD(tilingContext_->GetNodeName(), "Entering FillTilingData101.");
360 FillSliceBaseTilingData(sliceMoveAlignLastDimTilingData_.sliceBaseTilingData);354 FillSliceBaseTilingData(sliceMoveAlignLastDimTilingData_.sliceBaseTilingData);
361 auto tilingData = tilingContext_->GetTilingData<SliceMoveAlignLastDimTilingData>();355 auto tilingData = tilingContext_->GetTilingData<SliceMoveAlignLastDimTilingData>();
362- errno_t ret = memcpy_s(356+ errno_t ret = memcpy_s(tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceMoveAlignLastDimTilingData_),
363- tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceMoveAlignLastDimTilingData_), tilingDataSize);357+ tilingDataSize);
364 if (ret != EOK) {358 if (ret != EOK) {
365 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);359 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);
366 }360 }
@@ -397,8 +391,8 @@ void SliceTiling::FillSliceTilingData103()
397 sliceNDDMALastDimTilingData_.nddmaLoopDstStride[i] = nddmaLoopDstStride_[i];391 sliceNDDMALastDimTilingData_.nddmaLoopDstStride[i] = nddmaLoopDstStride_[i];
398 }392 }
399 auto tilingData = tilingContext_->GetTilingData<SliceNDDMALastDimTilingData>();393 auto tilingData = tilingContext_->GetTilingData<SliceNDDMALastDimTilingData>();
400- errno_t ret =394+ errno_t ret = memcpy_s(tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceNDDMALastDimTilingData_),
401- memcpy_s(tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceNDDMALastDimTilingData_), tilingDataSize);395+ tilingDataSize);
402 if (ret != EOK) {396 if (ret != EOK) {
403 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);397 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);
404 }398 }
@@ -417,8 +411,8 @@ void SliceTiling::FillSliceTilingData300()
417 411 
418 SetMoveAlignParamsSlice(sliceMoveAlignGatherTilingData_.moveAlignParams, mainMoveAlignV2Info_);412 SetMoveAlignParamsSlice(sliceMoveAlignGatherTilingData_.moveAlignParams, mainMoveAlignV2Info_);
419 auto tilingData = tilingContext_->GetTilingData<SliceMoveAlignGatherTilingData>();413 auto tilingData = tilingContext_->GetTilingData<SliceMoveAlignGatherTilingData>();
420- errno_t ret =414+ errno_t ret = memcpy_s(tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceMoveAlignGatherTilingData_),
421- memcpy_s(tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceMoveAlignGatherTilingData_), tilingDataSize);415+ tilingDataSize);
422 if (ret != EOK) {416 if (ret != EOK) {
423 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);417 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);
424 }418 }
@@ -440,8 +434,8 @@ void SliceTiling::FillSliceTilingData400()
440 sliceTwoDimSmallSapeTilingData_.isBeginConst = isConstBegin;434 sliceTwoDimSmallSapeTilingData_.isBeginConst = isConstBegin;
441 435 
442 auto tilingData = tilingContext_->GetTilingData<SliceTwoDimSmallSapeTilingData>();436 auto tilingData = tilingContext_->GetTilingData<SliceTwoDimSmallSapeTilingData>();
443- errno_t ret =437+ errno_t ret = memcpy_s(tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceTwoDimSmallSapeTilingData_),
444- memcpy_s(tilingData, tilingDataSize, reinterpret_cast<void*>(&sliceTwoDimSmallSapeTilingData_), tilingDataSize);438+ tilingDataSize);
445 if (ret != EOK) {439 if (ret != EOK) {
446 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);440 OP_LOGE(tilingContext_->GetNodeName(), "memcpy_s failed, ret=%d", ret);
447 }441 }
@@ -533,35 +527,33 @@ void SliceTiling::FillTilingData()
533void SliceTiling::PrintSliceTilingDataOther()527void SliceTiling::PrintSliceTilingDataOther()
534{528{
535 StridedSliceTilingData2& tilingData = sliceTilingData_.stridedSliceTilingData;529 StridedSliceTilingData2& tilingData = sliceTilingData_.stridedSliceTilingData;
536- OP_LOGI(530+ OP_LOGI(tilingContext_->GetNodeName(), "tilingData is ubSize:%ld, coreNum:%ld, realCoreNum:%ld, \
537- tilingContext_->GetNodeName(),
538- "tilingData is ubSize:%ld, coreNum:%ld, realCoreNum:%ld, \
539 ubIndex:%ld, ubFactor:%ld, ubTailFactor:%ld, ubTailTailFactor:%ld, \531 ubIndex:%ld, ubFactor:%ld, ubTailFactor:%ld, ubTailTailFactor:%ld, \
540 blkIndex:%ld, blkFactor:%ld, blkTailFactor:%ld, xDtypeSize:%ld, tilingKey:%ld, \532 blkIndex:%ld, blkFactor:%ld, blkTailFactor:%ld, xDtypeSize:%ld, tilingKey:%ld, \
541 isBeginConst:%d, begin:%s, end:%s, stride:%s, inputShape:%s, outputShape:%s, \533 isBeginConst:%d, begin:%s, end:%s, stride:%s, inputShape:%s, outputShape:%s, \
542 rowsOffsetSteps:%s, inputSteps:%s, outputSteps:%s",534 rowsOffsetSteps:%s, inputSteps:%s, outputSteps:%s",
543- tilingData.ubSize, tilingData.coreNum, tilingData.realCoreNum, tilingData.ubIndex, tilingData.ubFactor,535+ tilingData.ubSize, tilingData.coreNum, tilingData.realCoreNum, tilingData.ubIndex, tilingData.ubFactor,
544- tilingData.ubTailFactor, tilingData.ubTailTailFactor, tilingData.blkIndex, tilingData.blkFactor,536+ tilingData.ubTailFactor, tilingData.ubTailTailFactor, tilingData.blkIndex, tilingData.blkFactor,
545- tilingData.blkTailFactor, tilingData.xDtypeSize, tilingData.tilingKey, tilingData.isBeginConst,537+ tilingData.blkTailFactor, tilingData.xDtypeSize, tilingData.tilingKey, tilingData.isBeginConst,
546- ArrayToStr(tilingData.begin, dimNum_).c_str(), ArrayToStr(end_, dimNum_).c_str(),538+ ArrayToStr(tilingData.begin, dimNum_).c_str(), ArrayToStr(end_, dimNum_).c_str(),
547- ArrayToStr(tilingData.strides, dimNum_).c_str(), ArrayToStr(inputShape_, dimNum_).c_str(),539+ ArrayToStr(tilingData.strides, dimNum_).c_str(), ArrayToStr(inputShape_, dimNum_).c_str(),
548- ArrayToStr(tilingData.outputShape, dimNum_).c_str(), ArrayToStr(tilingData.rowsOffsetSteps, dimNum_).c_str(),540+ ArrayToStr(tilingData.outputShape, dimNum_).c_str(),
549- ArrayToStr(tilingData.inputSteps, dimNum_).c_str(), ArrayToStr(outputSteps_, dimNum_).c_str());541+ ArrayToStr(tilingData.rowsOffsetSteps, dimNum_).c_str(), ArrayToStr(tilingData.inputSteps, dimNum_).c_str(),
542+ ArrayToStr(outputSteps_, dimNum_).c_str());
550 543 
551- OP_LOGI(544+ OP_LOGI(tilingContext_->GetNodeName(), "tilingData is nddmaTotalNum:%ld nddmaLoopSize:%s, nddmaLoopSrcStride: %s, \
552- tilingContext_->GetNodeName(),
553- "tilingData is nddmaTotalNum:%ld nddmaLoopSize:%s, nddmaLoopSrcStride: %s, \
554 nddmaLoopDstStride: %s, moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \545 nddmaLoopDstStride: %s, moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \
555 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u outputShapeProd: %s \546 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u outputShapeProd: %s \
556 inputShapeProd: %s Tiling4StrideSlice ends.",547 inputShapeProd: %s Tiling4StrideSlice ends.",
557- tilingData.nddmaTotalNum, ArrayToStr(tilingData.nddmaLoopSize, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),548+ tilingData.nddmaTotalNum, ArrayToStr(tilingData.nddmaLoopSize, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
558- ArrayToStr(tilingData.nddmaLoopSrcStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),549+ ArrayToStr(tilingData.nddmaLoopSrcStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
559- ArrayToStr(tilingData.nddmaLoopDstStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(), mainMoveAlignV2Info_.blockCount,550+ ArrayToStr(tilingData.nddmaLoopDstStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
560- mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride, mainMoveAlignV2Info_.dstStride,551+ mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride,
561- mainMoveAlignV2Info_.loop1Size, mainMoveAlignV2Info_.loop2Size, mainMoveAlignV2Info_.loop1SrcStride,552+ mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size, mainMoveAlignV2Info_.loop2Size,
562- mainMoveAlignV2Info_.loop1DstStride, mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride,553+ mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride,
563- ArrayToStr(tilingData.outputShapeProd, MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str(),554+ mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride,
564- ArrayToStr(tilingData.inputShapeProd, MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str());555+ ArrayToStr(tilingData.outputShapeProd, MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str(),
556+ ArrayToStr(tilingData.inputShapeProd, MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str());
565}557}
566 558 
567void SliceTiling::PrintTilingData()559void SliceTiling::PrintTilingData()
@@ -596,42 +588,38 @@ void SliceTiling::PrintTilingData()
596 588 
597void SliceTiling::PrintSliceBaseTilingData(SliceBaseTilingData& tilingData)589void SliceTiling::PrintSliceBaseTilingData(SliceBaseTilingData& tilingData)
598{590{
599- OP_LOGI(591+ OP_LOGI(tilingContext_->GetNodeName(), "SliceBaseTilingData is ubSize:%d, realCoreNum:%d, \
600- tilingContext_->GetNodeName(),
601- "SliceBaseTilingData is ubSize:%d, realCoreNum:%d, \
602 ubIndex:%d, ubFactor:%d, ubTailFactor:%d, ubTailTailFactor:%d, \592 ubIndex:%d, ubFactor:%d, ubTailFactor:%d, ubTailTailFactor:%d, \
603 blkIndex:%d, blkFactor:%ld, blkTailFactor:%ld, \593 blkIndex:%d, blkFactor:%ld, blkTailFactor:%ld, \
604 isBeginConst:%d, begin:%s, end:%s, inputShape:%s, outputShape:%s, \594 isBeginConst:%d, begin:%s, end:%s, inputShape:%s, outputShape:%s, \
605 rowsOffsetSteps:%s, inputSteps:%s, outputSteps:%s, ubInLoopSteps:%ld",595 rowsOffsetSteps:%s, inputSteps:%s, outputSteps:%s, ubInLoopSteps:%ld",
606- tilingData.ubSize, tilingData.realCoreNum, tilingData.ubIndex, tilingData.ubFactor, tilingData.ubTailFactor,596+ tilingData.ubSize, tilingData.realCoreNum, tilingData.ubIndex, tilingData.ubFactor, tilingData.ubTailFactor,
607- tilingData.ubTailTailFactor, tilingData.blkIndex, tilingData.blkFactor, tilingData.blkTailFactor,597+ tilingData.ubTailTailFactor, tilingData.blkIndex, tilingData.blkFactor, tilingData.blkTailFactor,
608- tilingData.isBeginConst, ArrayToStr(tilingData.begin, dimNum_).c_str(), ArrayToStr(end_, dimNum_).c_str(),598+ tilingData.isBeginConst, ArrayToStr(tilingData.begin, dimNum_).c_str(), ArrayToStr(end_, dimNum_).c_str(),
609- ArrayToStr(inputShape_, dimNum_).c_str(), ArrayToStr(tilingData.outputShape, dimNum_).c_str(),599+ ArrayToStr(inputShape_, dimNum_).c_str(), ArrayToStr(tilingData.outputShape, dimNum_).c_str(),
610- ArrayToStr(tilingData.rowsOffsetSteps, dimNum_).c_str(), ArrayToStr(tilingData.inputSteps, dimNum_).c_str(),600+ ArrayToStr(tilingData.rowsOffsetSteps, dimNum_).c_str(), ArrayToStr(tilingData.inputSteps, dimNum_).c_str(),
611- ArrayToStr(outputSteps_, dimNum_).c_str(), tilingData.ubInLoopSteps);601+ ArrayToStr(outputSteps_, dimNum_).c_str(), tilingData.ubInLoopSteps);
612}602}
613 603 
614void SliceTiling::PrintSliceTilingData150()604void SliceTiling::PrintSliceTilingData150()
615{605{
616- OP_LOGI(606+ OP_LOGI(tilingContext_->GetNodeName(), "SliceMoveAlignLast2DimTilingData is ubSize:%d, realCoreNum:%d, \
617- tilingContext_->GetNodeName(),
618- "SliceMoveAlignLast2DimTilingData is ubSize:%d, realCoreNum:%d, \
619 ubFactor:%d, ubTailFactor:%d, ubTailTailFactor:%d, \607 ubFactor:%d, ubTailFactor:%d, ubTailTailFactor:%d, \
620 blkFactor:%ld, blkTailFactor:%ld, \608 blkFactor:%ld, blkTailFactor:%ld, \
621 isBeginConst:%d, begin:%s, end:%s, inputShape:%s, outputShape:%s, \609 isBeginConst:%d, begin:%s, end:%s, inputShape:%s, outputShape:%s, \
622 inputSteps:%s, outputSteps:%s, ubInLoopSteps:%ld, ubOutLoopSteps:%ld, \610 inputSteps:%s, outputSteps:%s, ubInLoopSteps:%ld, ubOutLoopSteps:%ld, \
623 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u",611 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u",
624- sliceMoveAlignLast2DimTilingData_.ubSize, sliceMoveAlignLast2DimTilingData_.realCoreNum,612+ sliceMoveAlignLast2DimTilingData_.ubSize, sliceMoveAlignLast2DimTilingData_.realCoreNum,
625- sliceMoveAlignLast2DimTilingData_.ubFactor, sliceMoveAlignLast2DimTilingData_.ubTailFactor,613+ sliceMoveAlignLast2DimTilingData_.ubFactor, sliceMoveAlignLast2DimTilingData_.ubTailFactor,
626- sliceMoveAlignLast2DimTilingData_.ubTailTailFactor, sliceMoveAlignLast2DimTilingData_.blkFactor,614+ sliceMoveAlignLast2DimTilingData_.ubTailTailFactor, sliceMoveAlignLast2DimTilingData_.blkFactor,
627- sliceMoveAlignLast2DimTilingData_.blkTailFactor, sliceMoveAlignLast2DimTilingData_.isBeginConst,615+ sliceMoveAlignLast2DimTilingData_.blkTailFactor, sliceMoveAlignLast2DimTilingData_.isBeginConst,
628- ArrayToStr(sliceMoveAlignLast2DimTilingData_.begin, dimNum_).c_str(), ArrayToStr(end_, dimNum_).c_str(),616+ ArrayToStr(sliceMoveAlignLast2DimTilingData_.begin, dimNum_).c_str(), ArrayToStr(end_, dimNum_).c_str(),
629- ArrayToStr(inputShape_, dimNum_).c_str(),617+ ArrayToStr(inputShape_, dimNum_).c_str(),
630- ArrayToStr(sliceMoveAlignLast2DimTilingData_.outputShape, dimNum_).c_str(),618+ ArrayToStr(sliceMoveAlignLast2DimTilingData_.outputShape, dimNum_).c_str(),
631- ArrayToStr(sliceMoveAlignLast2DimTilingData_.inputSteps, dimNum_).c_str(),619+ ArrayToStr(sliceMoveAlignLast2DimTilingData_.inputSteps, dimNum_).c_str(),
632- ArrayToStr(outputSteps_, dimNum_).c_str(), sliceMoveAlignLast2DimTilingData_.ubInLoopSteps,620+ ArrayToStr(outputSteps_, dimNum_).c_str(), sliceMoveAlignLast2DimTilingData_.ubInLoopSteps,
633- sliceMoveAlignLast2DimTilingData_.ubOutLoopSteps, mainMoveAlignV2Info_.blockCount,621+ sliceMoveAlignLast2DimTilingData_.ubOutLoopSteps, mainMoveAlignV2Info_.blockCount,
634- mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride, mainMoveAlignV2Info_.dstStride);622+ mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride, mainMoveAlignV2Info_.dstStride);
635}623}
636 624 
637void SliceTiling::PrintSliceTilingData101()625void SliceTiling::PrintSliceTilingData101()
@@ -644,72 +632,64 @@ void SliceTiling::PrintSliceTilingData100()
644{632{
645 OP_LOGI(tilingContext_->GetNodeName(), "Printing SliceMoveAlignTilingData:");633 OP_LOGI(tilingContext_->GetNodeName(), "Printing SliceMoveAlignTilingData:");
646 PrintSliceBaseTilingData(sliceMoveAlignTilingData_.sliceBaseTilingData);634 PrintSliceBaseTilingData(sliceMoveAlignTilingData_.sliceBaseTilingData);
647- OP_LOGI(635+ OP_LOGI(tilingContext_->GetNodeName(), "SliceMoveAlignTilingData is ubOutLoopSteps:%ld, \
648- tilingContext_->GetNodeName(),
649- "SliceMoveAlignTilingData is ubOutLoopSteps:%ld, \
650 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \636 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \
651 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u",637 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u",
652- sliceMoveAlignTilingData_.ubOutLoopSteps, mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen,638+ sliceMoveAlignTilingData_.ubOutLoopSteps, mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen,
653- mainMoveAlignV2Info_.srcStride, mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size,639+ mainMoveAlignV2Info_.srcStride, mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size,
654- mainMoveAlignV2Info_.loop2Size, mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride,640+ mainMoveAlignV2Info_.loop2Size, mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride,
655- mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride);641+ mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride);
656}642}
657 643 
658void SliceTiling::PrintSliceTilingData102()644void SliceTiling::PrintSliceTilingData102()
659{645{
660 OP_LOGI(tilingContext_->GetNodeName(), "Printing SliceNDDMATilingData:");646 OP_LOGI(tilingContext_->GetNodeName(), "Printing SliceNDDMATilingData:");
661 PrintSliceBaseTilingData(sliceNDDMATilingData_.sliceBaseTilingData);647 PrintSliceBaseTilingData(sliceNDDMATilingData_.sliceBaseTilingData);
662- OP_LOGI(648+ OP_LOGI(tilingContext_->GetNodeName(), "SliceNDDMATilingData is ubOutLoopSteps:%ld, \
663- tilingContext_->GetNodeName(),
664- "SliceNDDMATilingData is ubOutLoopSteps:%ld, \
665 nddmaTotalNum:%ld, nddmaLoopSize:%s, nddmaLoopSrcStride: %s, nddmaLoopDstStride: %s",649 nddmaTotalNum:%ld, nddmaLoopSize:%s, nddmaLoopSrcStride: %s, nddmaLoopDstStride: %s",
666- sliceNDDMATilingData_.ubOutLoopSteps, sliceNDDMATilingData_.nddmaTotalNum,650+ sliceNDDMATilingData_.ubOutLoopSteps, sliceNDDMATilingData_.nddmaTotalNum,
667- ArrayToStr(sliceNDDMATilingData_.nddmaLoopSize, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),651+ ArrayToStr(sliceNDDMATilingData_.nddmaLoopSize, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
668- ArrayToStr(sliceNDDMATilingData_.nddmaLoopSrcStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),652+ ArrayToStr(sliceNDDMATilingData_.nddmaLoopSrcStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
669- ArrayToStr(sliceNDDMATilingData_.nddmaLoopDstStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str());653+ ArrayToStr(sliceNDDMATilingData_.nddmaLoopDstStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str());
670}654}
671 655 
672void SliceTiling::PrintSliceTilingData103()656void SliceTiling::PrintSliceTilingData103()
673{657{
674 OP_LOGI(tilingContext_->GetNodeName(), "Printing SliceNDDMALastDimTilingData:");658 OP_LOGI(tilingContext_->GetNodeName(), "Printing SliceNDDMALastDimTilingData:");
675 PrintSliceBaseTilingData(sliceNDDMALastDimTilingData_.sliceBaseTilingData);659 PrintSliceBaseTilingData(sliceNDDMALastDimTilingData_.sliceBaseTilingData);
676- OP_LOGI(660+ OP_LOGI(tilingContext_->GetNodeName(),
677- tilingContext_->GetNodeName(), "SliceNDDMALastDimTilingData is nddmaLoopSrcStride: %s, nddmaLoopDstStride: %s",661+ "SliceNDDMALastDimTilingData is nddmaLoopSrcStride: %s, nddmaLoopDstStride: %s",
678- ArrayToStr(sliceNDDMALastDimTilingData_.nddmaLoopSrcStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),662+ ArrayToStr(sliceNDDMALastDimTilingData_.nddmaLoopSrcStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
679- ArrayToStr(sliceNDDMALastDimTilingData_.nddmaLoopDstStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str());663+ ArrayToStr(sliceNDDMALastDimTilingData_.nddmaLoopDstStride, MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str());
680}664}
681 665 
682void SliceTiling::PrintSliceTilingData300()666void SliceTiling::PrintSliceTilingData300()
683{667{
684 OP_LOGI(tilingContext_->GetNodeName(), "Printing SliceMoveAlignGatherTilingData:");668 OP_LOGI(tilingContext_->GetNodeName(), "Printing SliceMoveAlignGatherTilingData:");
685 PrintSliceBaseTilingData(sliceMoveAlignGatherTilingData_.sliceBaseTilingData);669 PrintSliceBaseTilingData(sliceMoveAlignGatherTilingData_.sliceBaseTilingData);
686- OP_LOGI(670+ OP_LOGI(tilingContext_->GetNodeName(), "SliceMoveAlignGatherTilingData is ubOutLoopSteps:%ld, \
687- tilingContext_->GetNodeName(),
688- "SliceMoveAlignGatherTilingData is ubOutLoopSteps:%ld, \
689 ubSizeInput:%d, lastOneInputDim:%u, outBlockLen:%u, \671 ubSizeInput:%d, lastOneInputDim:%u, outBlockLen:%u, \
690 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \672 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \
691 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u",673 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u",
692- sliceMoveAlignGatherTilingData_.ubOutLoopSteps, sliceMoveAlignGatherTilingData_.ubSizeInput,674+ sliceMoveAlignGatherTilingData_.ubOutLoopSteps, sliceMoveAlignGatherTilingData_.ubSizeInput,
693- sliceMoveAlignGatherTilingData_.lastOneInputDim, sliceMoveAlignGatherTilingData_.outBlockLen,675+ sliceMoveAlignGatherTilingData_.lastOneInputDim, sliceMoveAlignGatherTilingData_.outBlockLen,
694- mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride,676+ mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride,
695- mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size, mainMoveAlignV2Info_.loop2Size,677+ mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size, mainMoveAlignV2Info_.loop2Size,
696- mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride, mainMoveAlignV2Info_.loop2SrcStride,678+ mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride,
697- mainMoveAlignV2Info_.loop2DstStride);679+ mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride);
698}680}
699 681 
700void SliceTiling::PrintSliceTilingData400()682void SliceTiling::PrintSliceTilingData400()
701{683{
702 OP_LOGI(tilingContext_->GetNodeName(), "Printing SliceTwoDimSmallSapeTilingData:");684 OP_LOGI(tilingContext_->GetNodeName(), "Printing SliceTwoDimSmallSapeTilingData:");
703- OP_LOGI(685+ OP_LOGI(tilingContext_->GetNodeName(), "SliceTwoDimSmallSapeTilingData is realCoreNum:%d, \
704- tilingContext_->GetNodeName(),
705- "SliceTwoDimSmallSapeTilingData is realCoreNum:%d, \
706 mainCoreNum:%d, outBlockLen:%d, blkFactor:%d, lastOneInputDim:%ld, lastOneOutputDim:%ld, ubSize:%d, \686 mainCoreNum:%d, outBlockLen:%d, blkFactor:%d, lastOneInputDim:%ld, lastOneOutputDim:%ld, ubSize:%d, \
707 lastOneDimOffset:%ld, isBeginConst:%d",687 lastOneDimOffset:%ld, isBeginConst:%d",
708- sliceTwoDimSmallSapeTilingData_.realCoreNum, sliceTwoDimSmallSapeTilingData_.mainCoreNum,688+ sliceTwoDimSmallSapeTilingData_.realCoreNum, sliceTwoDimSmallSapeTilingData_.mainCoreNum,
709- sliceTwoDimSmallSapeTilingData_.blockLen, sliceTwoDimSmallSapeTilingData_.blkFactor,689+ sliceTwoDimSmallSapeTilingData_.blockLen, sliceTwoDimSmallSapeTilingData_.blkFactor,
710- sliceTwoDimSmallSapeTilingData_.lastOneInputDim, sliceTwoDimSmallSapeTilingData_.lastOneOutputDim,690+ sliceTwoDimSmallSapeTilingData_.lastOneInputDim, sliceTwoDimSmallSapeTilingData_.lastOneOutputDim,
711- sliceTwoDimSmallSapeTilingData_.ubSize, sliceTwoDimSmallSapeTilingData_.lastOneDimOffset,691+ sliceTwoDimSmallSapeTilingData_.ubSize, sliceTwoDimSmallSapeTilingData_.lastOneDimOffset,
712- sliceTwoDimSmallSapeTilingData_.isBeginConst);692+ sliceTwoDimSmallSapeTilingData_.isBeginConst);
713}693}
714 694 
715void SliceTiling::SetBlockDimAndTilingKey()695void SliceTiling::SetBlockDimAndTilingKey()
@@ -718,9 +698,8 @@ void SliceTiling::SetBlockDimAndTilingKey()
718 tilingContext_->SetTilingKey(tilingKey_);698 tilingContext_->SetTilingKey(tilingKey_);
719}699}
720 700 
721-ge::graphStatus SliceTilingForAscendC(701+ge::graphStatus SliceTilingForAscendC(gert::TilingContext* context, int64_t coreNum, int64_t ubSize,
722- gert::TilingContext* context, int64_t coreNum, int64_t ubSize, int64_t cacheLineSize, SliceParasRuntime2& param,702+ int64_t cacheLineSize, SliceParasRuntime2& param, const ge::DataType dtype)
723- const ge::DataType dtype)
724{703{
725 SliceTiling tilingImpl(context);704 SliceTiling tilingImpl(context);
726 SliceParametersRuntime2 sliceParam;705 SliceParametersRuntime2 sliceParam;
@@ -742,9 +721,9 @@ ge::graphStatus SliceTilingForAscendC(
742}721}
743 722 
744template <typename T>723template <typename T>
745-static ge::graphStatus AssignInputValueOpt(724+static ge::graphStatus AssignInputValueOpt(gert::TilingContext* context, size_t size, const gert::Tensor* tensor,
746- gert::TilingContext* context, size_t size, const gert::Tensor* tensor, gert::Shape& list_vector, bool isAscendc,725+ gert::Shape& list_vector, bool isAscendc, bool& isConst,
747- bool& isConst, const ge::DataType dtype)726+ const ge::DataType dtype)
748{727{
749 list_vector.SetDimNum(size);728 list_vector.SetDimNum(size);
750 const T* value = tensor->GetData<T>();729 const T* value = tensor->GetData<T>();
@@ -757,9 +736,8 @@ static ge::graphStatus AssignInputValueOpt(
757 return ge::GRAPH_SUCCESS;736 return ge::GRAPH_SUCCESS;
758 }737 }
759 if (value == nullptr) {738 if (value == nullptr) {
760- OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(739+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(context->GetNodeName(), "value", "nullptr",
761- context->GetNodeName(), "value", "nullptr",740+ "When check input is const or not, const value cannot be nullptr");
762- "When check input is const or not, const value cannot be nullptr");
763 return ge::GRAPH_FAILED;741 return ge::GRAPH_FAILED;
764 }742 }
765 for (size_t i = 0; i < size; i++) {743 for (size_t i = 0; i < size; i++) {
@@ -767,9 +745,9 @@ static ge::graphStatus AssignInputValueOpt(
767 }745 }
768 if (dtype == ge::DT_FLOAT4_E2M1 || dtype == ge::DT_FLOAT4_E1M2) {746 if (dtype == ge::DT_FLOAT4_E2M1 || dtype == ge::DT_FLOAT4_E1M2) {
769 if (list_vector[size - 1] & 1) {747 if (list_vector[size - 1] & 1) {
770- OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(748+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(context->GetNodeName(), "offsets",
771- context->GetNodeName(), "offsets", Ops::Base::ToString(list_vector).c_str(),749+ Ops::Base::ToString(list_vector).c_str(),
772- "Expected last dimension of offsets to be even for fp4 input.");750+ "Expected last dimension of offsets to be even for fp4 input.");
773 return ge::GRAPH_FAILED;751 return ge::GRAPH_FAILED;
774 }752 }
775 list_vector[size - 1] /= SLICE_CONST2;753 list_vector[size - 1] /= SLICE_CONST2;
@@ -779,17 +757,15 @@ static ge::graphStatus AssignInputValueOpt(
779}757}
780 758 
781template <typename T>759template <typename T>
782-static ge::graphStatus AssignInputValue(760+static ge::graphStatus AssignInputValue(gert::TilingContext* context, size_t size, const gert::Tensor* tensor,
783- gert::TilingContext* context, size_t size, const gert::Tensor* tensor, gert::Shape& list_vector,761+ gert::Shape& list_vector, const ge::DataType dtype)
784- const ge::DataType dtype)
785{762{
786 int32_t dim_num = tensor->GetShapeSize();763 int32_t dim_num = tensor->GetShapeSize();
787 list_vector.SetDimNum(dim_num);764 list_vector.SetDimNum(dim_num);
788 const T* value = tensor->GetData<T>();765 const T* value = tensor->GetData<T>();
789 if (value == nullptr) {766 if (value == nullptr) {
790- OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(767+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(context->GetNodeName(), "value", "nullptr",
791- context->GetNodeName(), "value", "nullptr",768+ "When check input is const or not, const value cannot be nullptr");
792- "When check input is const or not, const value cannot be nullptr");
793 return ge::GRAPH_FAILED;769 return ge::GRAPH_FAILED;
794 }770 }
795 for (size_t i = 0; i < size; i++) {771 for (size_t i = 0; i < size; i++) {
@@ -797,9 +773,9 @@ static ge::graphStatus AssignInputValue(
797 }773 }
798 if (dtype == ge::DT_FLOAT4_E2M1 || dtype == ge::DT_FLOAT4_E1M2) {774 if (dtype == ge::DT_FLOAT4_E2M1 || dtype == ge::DT_FLOAT4_E1M2) {
799 if (list_vector[size - 1] & 1) {775 if (list_vector[size - 1] & 1) {
800- OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(776+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(context->GetNodeName(), "last dimension of size",
801- context->GetNodeName(), "last dimension of size", Ops::Base::ToString(list_vector).c_str(),777+ Ops::Base::ToString(list_vector).c_str(),
802- "Expected last dimension of size to be even for fp4 input");778+ "Expected last dimension of size to be even for fp4 input");
803 return ge::GRAPH_FAILED;779 return ge::GRAPH_FAILED;
804 }780 }
805 list_vector[size - 1] /= SLICE_CONST2;781 list_vector[size - 1] /= SLICE_CONST2;
@@ -807,17 +783,15 @@ static ge::graphStatus AssignInputValue(
807 return ge::GRAPH_SUCCESS;783 return ge::GRAPH_SUCCESS;
808}784}
809 785 
810-static bool CalcEndAndBeginList(786+static bool CalcEndAndBeginList(gert::Shape& list_end_vector, gert::Shape& list_begin_vector,
811- gert::Shape& list_end_vector, gert::Shape& list_begin_vector, const gert::Shape& shape_input, size_t size,787+ const gert::Shape& shape_input, size_t size, bool flag, bool is_begin_const)
812- bool flag, bool is_begin_const)
813{788{
814 if (flag) {789 if (flag) {
815 for (size_t index = 0; index < size; index++) {790 for (size_t index = 0; index < size; index++) {
816 if (list_end_vector[index] == -1) {791 if (list_end_vector[index] == -1) {
817 if (is_begin_const == false) {792 if (is_begin_const == false) {
818- OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(793+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON("Slice", "end", "-1",
819- "Slice", "end", "-1",794+ "End cannot be -1 while begin is not const.");
820- "End cannot be -1 while begin is not const.");
821 return false;795 return false;
822 }796 }
823 list_end_vector[index] = shape_input.GetDim(index) - list_begin_vector[index];797 list_end_vector[index] = shape_input.GetDim(index) - list_begin_vector[index];
@@ -828,11 +802,10 @@ static bool CalcEndAndBeginList(
828 if (list_begin_vector[i] < 0 || list_begin_vector[i] + list_end_vector[i] < list_begin_vector[i] ||802 if (list_begin_vector[i] < 0 || list_begin_vector[i] + list_end_vector[i] < list_begin_vector[i] ||
829 list_begin_vector[i] + list_end_vector[i] > shape_input.GetDim(i)) {803 list_begin_vector[i] + list_end_vector[i] > shape_input.GetDim(i)) {
830 OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(804 OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(
831- "Slice", "list_begin_vector, list_end_vector, shape_input", 805+ "Slice", "list_begin_vector, list_end_vector, shape_input",
832- "index: " + std::to_string(i) + ", begin: " + std::to_string(list_begin_vector[i]) +806+ "index: " + std::to_string(i) + ", begin: " + std::to_string(list_begin_vector[i]) + ", end: " +
833- ", end: " + std::to_string(list_end_vector[i]) +807+ std::to_string(list_end_vector[i]) + ", input shape: " + std::to_string(shape_input.GetDim(i)),
834- ", input shape: " + std::to_string(shape_input.GetDim(i)),808+ "Requirements: 0<=offsets[i]<= offsets[i]+size[i]<=input_shape[i].");
835- "Requirements: 0<=offsets[i]<= offsets[i]+size[i]<=input_shape[i].");
836 return false;809 return false;
837 }810 }
838 }811 }
@@ -880,8 +853,8 @@ static void MakePerformanceParams(SliceParasRuntime2& parameters)
880 perf_params.stride_list[perf_params.input.GetDimNum() - last_second] == 1) {853 perf_params.stride_list[perf_params.input.GetDimNum() - last_second] == 1) {
881 const auto last_second_index = perf_params.input.GetDimNum() - last_second;854 const auto last_second_index = perf_params.input.GetDimNum() - last_second;
882 perf_params.input[last_second_index] *= perf_params.input.GetDim(perf_params.input.GetDimNum() - 1);855 perf_params.input[last_second_index] *= perf_params.input.GetDim(perf_params.input.GetDimNum() - 1);
883- perf_params.output_shape[last_second_index] *=856+ perf_params.output_shape[last_second_index] *= perf_params.output_shape.GetDim(
884- perf_params.output_shape.GetDim(perf_params.output_shape.GetDimNum() - 1);857+ perf_params.output_shape.GetDimNum() - 1);
885 perf_params.begin_list[last_second_index] *= perf_params.input.GetDim(perf_params.input.GetDimNum() - 1);858 perf_params.begin_list[last_second_index] *= perf_params.input.GetDim(perf_params.input.GetDimNum() - 1);
886 perf_params.end_list[last_second_index] *= perf_params.input.GetDim(perf_params.input.GetDimNum() - 1);859 perf_params.end_list[last_second_index] *= perf_params.input.GetDim(perf_params.input.GetDimNum() - 1);
887 perf_params.stride_list[last_second_index] = 1;860 perf_params.stride_list[last_second_index] = 1;
@@ -902,9 +875,8 @@ static ge::graphStatus Tiling4Slice(gert::TilingContext* context)
902 OP_CHECK_NULL_WITH_CONTEXT(context, compile_info);875 OP_CHECK_NULL_WITH_CONTEXT(context, compile_info);
903 const gert::Shape& in_shape = Ops::Base::EnsureNotScalar(context->GetInputShape(0)->GetStorageShape());876 const gert::Shape& in_shape = Ops::Base::EnsureNotScalar(context->GetInputShape(0)->GetStorageShape());
904 if (compile_info->block_dim == 0) {877 if (compile_info->block_dim == 0) {
905- OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(878+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(context->GetNodeName(), "core number", "0",
906- context->GetNodeName(), "core number", "0",879+ "The value of core number cannot be 0.");
907- "The vale of core number cannot be 0.");
908 return ge::GRAPH_FAILED;880 return ge::GRAPH_FAILED;
909 }881 }
910 // instantiate param882 // instantiate param
@@ -939,9 +911,9 @@ static ge::graphStatus Tiling4Slice(gert::TilingContext* context)
939 ge::DataType inputDtype = shape_tensor_x->GetDataType();911 ge::DataType inputDtype = shape_tensor_x->GetDataType();
940 if (inputDtype == ge::DT_FLOAT4_E2M1 || inputDtype == ge::DT_FLOAT4_E1M2) {912 if (inputDtype == ge::DT_FLOAT4_E2M1 || inputDtype == ge::DT_FLOAT4_E1M2) {
941 if (sliceparam.input[shape_size_offsets - 1] & 1) {913 if (sliceparam.input[shape_size_offsets - 1] & 1) {
942- OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(914+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(context->GetNodeName(), "last dimension of input",
943- context->GetNodeName(), "last dimension of input", Ops::Base::ToString(sliceparam.input).c_str(),915+ Ops::Base::ToString(sliceparam.input).c_str(),
944- "Expected last dimension of input to be even for fp4 input.");916+ "Expected last dimension of input to be even for fp4 input.");
945 return ge::GRAPH_FAILED;917 return ge::GRAPH_FAILED;
946 }918 }
947 sliceparam.input[shape_size_offsets - 1] /= SLICE_CONST2;919 sliceparam.input[shape_size_offsets - 1] /= SLICE_CONST2;
@@ -949,45 +921,42 @@ static ge::graphStatus Tiling4Slice(gert::TilingContext* context)
949 ge::DataType offset_dtype = shape_tensor_offsets->GetDataType();921 ge::DataType offset_dtype = shape_tensor_offsets->GetDataType();
950 if (offset_dtype == ge::DT_INT32) {922 if (offset_dtype == ge::DT_INT32) {
951 // Get offset const val923 // Get offset const val
952- OP_CHECK_IF(924+ OP_CHECK_IF(AssignInputValueOpt<int32_t>(context, shape_size_offsets, shape_tensor_offsets,
953- AssignInputValueOpt<int32_t>(925+ sliceparam.begin_list, compile_info->isAscendc,
954- context, shape_size_offsets, shape_tensor_offsets, sliceparam.begin_list, compile_info->isAscendc,926+ sliceparam.is_begin_const, inputDtype) != ge::GRAPH_SUCCESS,
955- sliceparam.is_begin_const, inputDtype) != ge::GRAPH_SUCCESS,927+ OP_LOGE(context->GetNodeName(), "get offset fail, check input is const or not."),
956- OP_LOGE(context->GetNodeName(), "get offset fail, check input is const or not."), return ge::GRAPH_FAILED);928+ return ge::GRAPH_FAILED);
957 } else {929 } else {
958 // Get offset const val930 // Get offset const val
959- OP_CHECK_IF(931+ OP_CHECK_IF(AssignInputValueOpt<int64_t>(context, shape_size_offsets, shape_tensor_offsets,
960- AssignInputValueOpt<int64_t>(932+ sliceparam.begin_list, compile_info->isAscendc,
961- context, shape_size_offsets, shape_tensor_offsets, sliceparam.begin_list, compile_info->isAscendc,933+ sliceparam.is_begin_const, inputDtype) != ge::GRAPH_SUCCESS,
962- sliceparam.is_begin_const, inputDtype) != ge::GRAPH_SUCCESS,934+ OP_LOGE(context->GetNodeName(), "get offset fail, check input is const or not."),
963- OP_LOGE(context->GetNodeName(), "get offset fail, check input is const or not."), return ge::GRAPH_FAILED);935+ return ge::GRAPH_FAILED);
964 }936 }
965 ge::DataType sizeDtype = shape_tensor_size->GetDataType();937 ge::DataType sizeDtype = shape_tensor_size->GetDataType();
966 if (sizeDtype == ge::DT_INT32) {938 if (sizeDtype == ge::DT_INT32) {
967 // Get size const val939 // Get size const val
968- OP_CHECK_IF(940+ OP_CHECK_IF(AssignInputValue<int32_t>(context, shape_size_size, shape_tensor_size, sliceparam.end_list,
969- AssignInputValue<int32_t>(context, shape_size_size, shape_tensor_size, sliceparam.end_list, inputDtype) !=941+ inputDtype) != ge::GRAPH_SUCCESS,
970- ge::GRAPH_SUCCESS,942+ OP_LOGE(context->GetNodeName(), "get size fail, check input is const or not."),
971- OP_LOGE(context->GetNodeName(), "get size fail, check input is const or not."), return ge::GRAPH_FAILED);943+ return ge::GRAPH_FAILED);
972 } else {944 } else {
973 // Get size const val945 // Get size const val
974- OP_CHECK_IF(946+ OP_CHECK_IF(AssignInputValue<int64_t>(context, shape_size_size, shape_tensor_size, sliceparam.end_list,
975- AssignInputValue<int64_t>(context, shape_size_size, shape_tensor_size, sliceparam.end_list, inputDtype) !=947+ inputDtype) != ge::GRAPH_SUCCESS,
976- ge::GRAPH_SUCCESS,948+ OP_LOGE(context->GetNodeName(), "get size fail, check input is const or not."),
977- OP_LOGE(context->GetNodeName(), "get size fail, check input is const or not."), return ge::GRAPH_FAILED);949+ return ge::GRAPH_FAILED);
978 }950 }
979 // calc endlist951 // calc endlist
980 bool end_list_flag = true;952 bool end_list_flag = true;
981- bool isEndValid = CalcEndAndBeginList(953+ bool isEndValid = CalcEndAndBeginList(sliceparam.end_list, sliceparam.begin_list, sliceparam.input,
982- sliceparam.end_list, sliceparam.begin_list, sliceparam.input, shape_size_offsets, end_list_flag,954+ shape_size_offsets, end_list_flag, sliceparam.is_begin_const);
983- sliceparam.is_begin_const);
984 bool begin_list_flag = false;955 bool begin_list_flag = false;
985- bool isBeginValid = CalcEndAndBeginList(956+ bool isBeginValid = CalcEndAndBeginList(sliceparam.end_list, sliceparam.begin_list, sliceparam.input,
986- sliceparam.end_list, sliceparam.begin_list, sliceparam.input, shape_size_size, begin_list_flag,957+ shape_size_size, begin_list_flag, sliceparam.is_begin_const);
987- sliceparam.is_begin_const);958+ OP_CHECK_IF((compile_info->isAscendc && (!isEndValid || !isBeginValid)),
988- OP_CHECK_IF(959+ OP_LOGE("Slice", "CalcEndAndBeginList failed"), return ge::GRAPH_FAILED);
989- (compile_info->isAscendc && (!isEndValid || !isBeginValid)), OP_LOGE("Slice", "CalcEndAndBeginList failed"),
990- return ge::GRAPH_FAILED);
991 960 
992 // in slice end_list is size values961 // in slice end_list is size values
993 sliceparam.output_shape = sliceparam.end_list;962 sliceparam.output_shape = sliceparam.end_list;
@@ -1003,8 +972,8 @@ static ge::graphStatus Tiling4Slice(gert::TilingContext* context)
1003 if (inputDtype == ge::DT_FLOAT4_E2M1 || inputDtype == ge::DT_FLOAT4_E1M2) {972 if (inputDtype == ge::DT_FLOAT4_E2M1 || inputDtype == ge::DT_FLOAT4_E1M2) {
1004 inputDtype = ge::DT_INT8;973 inputDtype = ge::DT_INT8;
1005 }974 }
1006- return SliceTilingForAscendC(975+ return SliceTilingForAscendC(context, compile_info->block_dim, compile_info->ub_size, compile_info->cacheLineSize,
1007- context, compile_info->block_dim, compile_info->ub_size, compile_info->cacheLineSize, sliceparam, inputDtype);976+ sliceparam, inputDtype);
1008}977}
1009 978 
1010static ge::graphStatus TilingPrepare4Slice(gert::TilingParseContext* context)979static ge::graphStatus TilingPrepare4Slice(gert::TilingParseContext* context)
@@ -1016,21 +985,20 @@ static ge::graphStatus TilingPrepare4Slice(gert::TilingParseContext* context)
1016 OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo);985 OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo);
1017 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);986 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);
1018 compileInfo->block_dim = ascendcPlatform.GetCoreNumAiv();987 compileInfo->block_dim = ascendcPlatform.GetCoreNumAiv();
1019- OP_CHECK_IF(988+ OP_CHECK_IF((compileInfo->block_dim <= 0), OP_LOGE(context->GetNodeName(), "block_dim invalid."),
1020- (compileInfo->block_dim <= 0), OP_LOGE(context->GetNodeName(), "block_dim invalid."), return ge::GRAPH_FAILED);989+ return ge::GRAPH_FAILED);
1021 uint64_t ubSize = 0;990 uint64_t ubSize = 0;
1022 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);991 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);
1023 compileInfo->ub_size = static_cast<int64_t>(ubSize);992 compileInfo->ub_size = static_cast<int64_t>(ubSize);
1024- OP_CHECK_IF(993+ OP_CHECK_IF((compileInfo->ub_size <= 0), OP_LOGE(context->GetNodeName(), "ub size invalid."),
1025- (compileInfo->ub_size <= 0), OP_LOGE(context->GetNodeName(), "ub size invalid."), return ge::GRAPH_FAILED);994+ return ge::GRAPH_FAILED);
1026 995 
1027 compileInfo->isAscendc = true;996 compileInfo->isAscendc = true;
1028 compileInfo->cacheLineSize = Ops::Base::GetCacheLineSize(context);997 compileInfo->cacheLineSize = Ops::Base::GetCacheLineSize(context);
1029- OP_CHECK_IF(998+ OP_CHECK_IF((compileInfo->cacheLineSize == static_cast<uint32_t>(0)),
1030- (compileInfo->cacheLineSize == static_cast<uint32_t>(0)),999+ OP_LOGE(context->GetNodeName(), "Failed to get cacheLineSize."), return ge::GRAPH_FAILED);
1031- OP_LOGE(context->GetNodeName(), "Failed to get cacheLineSize."), return ge::GRAPH_FAILED);
1032 return ge::GRAPH_SUCCESS;1000 return ge::GRAPH_SUCCESS;
1033}1001}
1034 1002 
1035IMPL_OP_OPTILING(Slice).Tiling(Tiling4Slice).TilingParse<SliceCompileParam>(TilingPrepare4Slice);1003IMPL_OP_OPTILING(Slice).Tiling(Tiling4Slice).TilingParse<SliceCompileParam>(TilingPrepare4Slice);
1036-} // namespace optiling1004+} // namespace optiling
@@ -53,11 +53,11 @@ struct SliceConstParams {
53 }53 }
54};54};
55 55 
56-static int64_t SliceInferRankFn(56+static int64_t SliceInferRankFn(gert::InferShapeContext* context, const gert::Shape* x_shape,
57- gert::InferShapeContext* context, const gert::Shape* x_shape, const SliceConstParams& slice_infer_info)57+ const SliceConstParams& slice_infer_info)
58{58{
59- int64_t offset_num =59+ int64_t offset_num = slice_infer_info.is_offset_const ? slice_infer_info.offset.GetDimNum() :
60- slice_infer_info.is_offset_const ? slice_infer_info.offset.GetDimNum() : slice_infer_info.offset_num;60+ slice_infer_info.offset_num;
61 int64_t size_num = slice_infer_info.is_size_const ? slice_infer_info.size.GetDimNum() : slice_infer_info.size_num;61 int64_t size_num = slice_infer_info.is_size_const ? slice_infer_info.size.GetDimNum() : slice_infer_info.size_num;
62 int64_t x_shape_rank = Ops::Base::IsUnknownRank(*x_shape) ? -1 : x_shape->GetDimNum();62 int64_t x_shape_rank = Ops::Base::IsUnknownRank(*x_shape) ? -1 : x_shape->GetDimNum();
63 63 
@@ -72,42 +72,37 @@ static bool CheckSliceInfo(const gert::Shape* x_shape, const SliceConstParams& s
72{72{
73 const bool is_unknown_rank_x = Ops::Base::IsUnknownRank(*x_shape);73 const bool is_unknown_rank_x = Ops::Base::IsUnknownRank(*x_shape);
74 if (is_unknown_rank_x) {74 if (is_unknown_rank_x) {
75- OP_LOGD("CheckSliceInfo", "input is unknown rank, no nedd check.");75+ OP_LOGD("CheckSliceInfo", "input is unknown rank, no need check.");
76 return true;76 return true;
77 }77 }
78 78 
79 const size_t input_dim = x_shape->GetDimNum();79 const size_t input_dim = x_shape->GetDimNum();
80 if (slice_infer_info.is_offset_const) {80 if (slice_infer_info.is_offset_const) {
81 OP_LOGD("CheckSliceInfo", "will check offset const value.");81 OP_LOGD("CheckSliceInfo", "will check offset const value.");
82- OP_CHECK_IF(82+ OP_CHECK_IF(slice_infer_info.offset.GetDimNum() != input_dim,
83- slice_infer_info.offset.GetDimNum() != input_dim,83+ OP_LOGE("CheckSliceInfo", "%s",
84- OP_LOGE(84+ ops::ConcatString("offset num and input rank must be the same, but offset_value is ",
85- "CheckSliceInfo", "%s",85+ Ops::Base::ToString(slice_infer_info.offset).c_str(), ", input shape is ",
86- ops::ConcatString(86+ Ops::Base::ToString(*x_shape).c_str())
87- "offset num and input rank must be the same, but offset_value is ",87+ .c_str()),
88- Ops::Base::ToString(slice_infer_info.offset).c_str(), ", input shape is ",88+ return false);
89- Ops::Base::ToString(*x_shape).c_str()).c_str()),
90- return false);
91 }89 }
92 if (slice_infer_info.is_size_const) {90 if (slice_infer_info.is_size_const) {
93 OP_LOGD("CheckSliceInfo", "will check size const value.");91 OP_LOGD("CheckSliceInfo", "will check size const value.");
94- OP_CHECK_IF(92+ OP_CHECK_IF(slice_infer_info.size.GetDimNum() != input_dim,
95- slice_infer_info.size.GetDimNum() != input_dim,93+ OP_LOGE("CheckSliceInfo", "%s",
96- OP_LOGE(94+ ops::ConcatString("size num and input rank must be the same, but offset_value is ",
97- "CheckSliceInfo", "%s",95+ Ops::Base::ToString(slice_infer_info.size).c_str(), ", input shape is ",
98- ops::ConcatString(96+ Ops::Base::ToString(*x_shape).c_str())
99- "size num and input rank must be the same, but offset_value is ",97+ .c_str()),
100- Ops::Base::ToString(slice_infer_info.size).c_str(), ", input shape is ",98+ return false);
101- Ops::Base::ToString(*x_shape).c_str()).c_str()),
102- return false);
103 }99 }
104 100 
105 return true;101 return true;
106}102}
107 103 
108-static graphStatus SliceInferShapeFnWithConstSize(104+static graphStatus SliceInferShapeFnWithConstSize(gert::InferShapeContext* context, const gert::Shape* x_shape,
109- gert::InferShapeContext* context, const gert::Shape* x_shape, const SliceConstParams& slice_infer_info,105+ const SliceConstParams& slice_infer_info, gert::Shape* out_shape)
110- gert::Shape* out_shape)
111{106{
112 OP_LOGD(context->GetNodeName(), "start to do SliceInferShapeFnWithConstSize");107 OP_LOGD(context->GetNodeName(), "start to do SliceInferShapeFnWithConstSize");
113 OP_LOGD(context->GetNodeName(), "slice input shape is %s", Ops::Base::ToString(*x_shape).c_str());108 OP_LOGD(context->GetNodeName(), "slice input shape is %s", Ops::Base::ToString(*x_shape).c_str());
@@ -121,13 +116,12 @@ static graphStatus SliceInferShapeFnWithConstSize(
121 const size_t output_rank = out_shape->GetDimNum();116 const size_t output_rank = out_shape->GetDimNum();
122 for (size_t i = 0; i < output_rank; ++i) {117 for (size_t i = 0; i < output_rank; ++i) {
123 int64_t size_value = out_shape->GetDim(i);118 int64_t size_value = out_shape->GetDim(i);
124- OP_CHECK_IF(119+ OP_CHECK_IF(size_value < -1,
125- size_value < -1,120+ OP_LOGE(context->GetNodeName(), "%s",
126- OP_LOGE(121+ ops::ConcatString("the value of size can not < -1, but is ",
127- context->GetNodeName(), "%s",122+ Ops::Base::ToString(slice_infer_info.size).c_str())
128- ops::ConcatString(123+ .c_str()),
129- "the value of size can not < -1, but is ", Ops::Base::ToString(slice_infer_info.size).c_str()).c_str()),124+ return ge::GRAPH_FAILED);
130- return ge::GRAPH_FAILED);
131 if (!is_unknown_rank_x && slice_infer_info.is_offset_const) {125 if (!is_unknown_rank_x && slice_infer_info.is_offset_const) {
132 int64_t x_dim_value = x_shape->GetDim(i);126 int64_t x_dim_value = x_shape->GetDim(i);
133 if (size_value == -1 && x_dim_value != -1) {127 if (size_value == -1 && x_dim_value != -1) {
@@ -141,17 +135,15 @@ static graphStatus SliceInferShapeFnWithConstSize(
141 return ge::GRAPH_SUCCESS;135 return ge::GRAPH_SUCCESS;
142}136}
143 137 
144-static graphStatus SliceInferShapeFn(138+static graphStatus SliceInferShapeFn(gert::InferShapeContext* context, const gert::Shape* x_shape,
145- gert::InferShapeContext* context, const gert::Shape* x_shape, const SliceConstParams& slice_infer_info,139+ const SliceConstParams& slice_infer_info, gert::Shape* out_shape)
146- gert::Shape* out_shape)
147{140{
148 OP_LOGD(context->GetNodeName(), "start to do SliceInferShapeFn");141 OP_LOGD(context->GetNodeName(), "start to do SliceInferShapeFn");
149 OP_LOGD(context->GetNodeName(), "slice input shape is %s", Ops::Base::ToString(*x_shape).c_str());142 OP_LOGD(context->GetNodeName(), "slice input shape is %s", Ops::Base::ToString(*x_shape).c_str());
150 OP_LOGD(context->GetNodeName(), "slice const info is %s", slice_infer_info.to_string().c_str());143 OP_LOGD(context->GetNodeName(), "slice const info is %s", slice_infer_info.to_string().c_str());
151 // check the input info144 // check the input info
152- OP_CHECK_IF(145+ OP_CHECK_IF(!CheckSliceInfo(x_shape, slice_infer_info), OP_LOGE(context->GetNodeName(), "check input info failed."),
153- !CheckSliceInfo(x_shape, slice_infer_info), OP_LOGE(context->GetNodeName(), "check input info failed."),146+ return ge::GRAPH_FAILED);
154- return ge::GRAPH_FAILED);
155 if (slice_infer_info.is_size_const) {147 if (slice_infer_info.is_size_const) {
156 return SliceInferShapeFnWithConstSize(context, x_shape, slice_infer_info, out_shape);148 return SliceInferShapeFnWithConstSize(context, x_shape, slice_infer_info, out_shape);
157 }149 }
Rconversion/strided_slice_v3/tests/st/aclnnSlice/atk_aclnnSlice.jsonconversion/slice/tests/st/aclnnSlice/atk_aclnnSlice.json+0-0
文件重命名但无更改。
Rconversion/strided_slice_v3/tests/st/aclnnSlice/executor_aclnnSlice.pyconversion/slice/tests/st/aclnnSlice/executor_aclnnSlice.py+0-0
文件重命名但无更改。
@@ -34,8 +34,8 @@ static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST = {
34 op::DataType::DT_COMPLEX32, op::DataType::DT_COMPLEX64, op::DataType::DT_HIFLOAT8, op::DataType::DT_FLOAT8_E5M2,34 op::DataType::DT_COMPLEX32, op::DataType::DT_COMPLEX64, op::DataType::DT_HIFLOAT8, op::DataType::DT_FLOAT8_E5M2,
35 ge::DT_FLOAT8_E4M3FN};35 ge::DT_FLOAT8_E4M3FN};
36 36 
37-static inline bool CheckNotNull(37+static inline bool CheckNotNull(const aclTensor* self, const aclIntArray* begin, const aclIntArray* end,
38- const aclTensor* self, const aclIntArray* begin, const aclIntArray* end, const aclIntArray* strides, aclTensor* out)38+ const aclIntArray* strides, aclTensor* out)
39{39{
40 OP_CHECK_NULL(self, return false);40 OP_CHECK_NULL(self, return false);
41 OP_CHECK_NULL(begin, return false);41 OP_CHECK_NULL(begin, return false);
@@ -55,7 +55,7 @@ static bool CheckDtypeValid(const aclTensor* self, aclTensor* out)
55 // 检查out和输入的数据类型是否一致55 // 检查out和输入的数据类型是否一致
56 OP_CHECK_DTYPE_NOT_SAME(self, out, return false);56 OP_CHECK_DTYPE_NOT_SAME(self, out, return false);
57 } else {57 } else {
58- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "aclnnStridedSlice only support ASCEND950.");58+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "aclnnStridedSlice only supports ASCEND950.");
59 return false;59 return false;
60 }60 }
61 61 
@@ -73,24 +73,21 @@ static bool CheckInputDims(const aclTensor* self)
73static bool CheckArray(const aclIntArray* begin, const aclIntArray* end, const aclIntArray* strides)73static bool CheckArray(const aclIntArray* begin, const aclIntArray* end, const aclIntArray* strides)
74{74{
75 if (begin->Size() != end->Size()) {75 if (begin->Size() != end->Size()) {
76- OP_LOGE(76+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expected aclnnStridedSlice begin.size() %lu to be equal to end.size() %lu.",
77- ACLNN_ERR_PARAM_INVALID, "Expected aclnnStridedSlice begin.size() %lu to be equal to end.size() %lu.",77+ begin->Size(), end->Size());
78- begin->Size(), end->Size());
79 return false;78 return false;
80 }79 }
81 80 
82 if (end->Size() != strides->Size()) {81 if (end->Size() != strides->Size()) {
83- OP_LOGE(82+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expected aclnnStridedSlice end.size() %lu to be equal to strides.size() %lu.",
84- ACLNN_ERR_PARAM_INVALID, "Expected aclnnStridedSlice end.size() %lu to be equal to strides.size() %lu.",83+ end->Size(), strides->Size());
85- end->Size(), strides->Size());
86 return false;84 return false;
87 }85 }
88 86 
89 for (size_t i = 0; i < strides->Size(); i++) {87 for (size_t i = 0; i < strides->Size(); i++) {
90 if ((*strides)[i] == 0) {88 if ((*strides)[i] == 0) {
91- OP_LOGE(89+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
92- ACLNN_ERR_PARAM_INVALID, "Expected strides value must not be zero, but strides No.[%lu] value is zero.",90+ "Expected strides value must not be zero, but strides No.[%lu] value is zero.", i);
93- i);
94 return false;91 return false;
95 }92 }
96 }93 }
@@ -110,9 +107,8 @@ static bool CheckInputMask(const aclIntArray* strides, int64_t ellipsisMask, int
110 for (size_t i = 0; i < strides->Size(); i++) {107 for (size_t i = 0; i < strides->Size(); i++) {
111 if ((shrinkAxisMask >> i) & 1) {108 if ((shrinkAxisMask >> i) & 1) {
112 if ((*strides)[i] <= 0) {109 if ((*strides)[i] <= 0) {
113- OP_LOGE(110+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
114- ACLNN_ERR_PARAM_INVALID,111+ "Strides must be positive when shrinkAxisMask has bit set at dimension [%lu].", i);
115- "Strides must be positive when shrinkAxisMask has bit set at dimension [%lu].", i);
116 return false;112 return false;
117 }113 }
118 }114 }
@@ -121,9 +117,8 @@ static bool CheckInputMask(const aclIntArray* strides, int64_t ellipsisMask, int
121 return true;117 return true;
122}118}
123 119 
124-static aclnnStatus CheckParams(120+static aclnnStatus CheckParams(const aclTensor* self, const aclIntArray* begin, const aclIntArray* end,
125- const aclTensor* self, const aclIntArray* begin, const aclIntArray* end, const aclIntArray* strides,121+ const aclIntArray* strides, int64_t ellipsisMask, int64_t shrinkAxisMask, aclTensor* out)
126- int64_t ellipsisMask, int64_t shrinkAxisMask, aclTensor* out)
127{122{
128 // 1. 检查参数是否为空指针123 // 1. 检查参数是否为空指针
129 CHECK_RET(CheckNotNull(self, begin, end, strides, out), ACLNN_ERR_PARAM_NULLPTR);124 CHECK_RET(CheckNotNull(self, begin, end, strides, out), ACLNN_ERR_PARAM_NULLPTR);
@@ -144,14 +139,14 @@ static aclnnStatus CheckParams(
144}139}
145 140 
146// 第一段接口141// 第一段接口
147-aclnnStatus aclnnStridedSliceGetWorkspaceSize(142+aclnnStatus aclnnStridedSliceGetWorkspaceSize(const aclTensor* self, const aclIntArray* begin, const aclIntArray* end,
148- const aclTensor* self, const aclIntArray* begin, const aclIntArray* end, const aclIntArray* strides,143+ const aclIntArray* strides, int64_t beginMask, int64_t endMask,
149- int64_t beginMask, int64_t endMask, int64_t ellipsisMask, int64_t newAxisMask, int64_t shrinkAxisMask,144+ int64_t ellipsisMask, int64_t newAxisMask, int64_t shrinkAxisMask,
150- aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)145+ aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)
151{146{
152- L2_DFX_PHASE_1(147+ L2_DFX_PHASE_1(aclnnStridedSlice,
153- aclnnStridedSlice,148+ DFX_IN(self, begin, end, strides, beginMask, endMask, ellipsisMask, newAxisMask, shrinkAxisMask),
154- DFX_IN(self, begin, end, strides, beginMask, endMask, ellipsisMask, newAxisMask, shrinkAxisMask), DFX_OUT(out));149+ DFX_OUT(out));
155 150 
156 // 固定写法,创建OpExecutor151 // 固定写法,创建OpExecutor
157 auto uniqueExecutor = CREATE_EXECUTOR();152 auto uniqueExecutor = CREATE_EXECUTOR();
@@ -183,9 +178,9 @@ aclnnStatus aclnnStridedSliceGetWorkspaceSize(
183 auto endTensor = uniqueExecutor.get()->ConvertToTensor(end, op::ToOpDataType(ACL_INT64));178 auto endTensor = uniqueExecutor.get()->ConvertToTensor(end, op::ToOpDataType(ACL_INT64));
184 auto stridesTensor = uniqueExecutor.get()->ConvertToTensor(strides, op::ToOpDataType(ACL_INT64));179 auto stridesTensor = uniqueExecutor.get()->ConvertToTensor(strides, op::ToOpDataType(ACL_INT64));
185 180 
186- auto stridedsliceOut = l0op::StridedSlice(181+ auto stridedsliceOut = l0op::StridedSlice(selfReformat, beginTensor, endTensor, stridesTensor, beginMask,
187- selfReformat, beginTensor, endTensor, stridesTensor, beginMask, endMask, ellipsisMask, newAxisMask,182+ endMask, ellipsisMask, newAxisMask, shrinkAxisMask,
188- shrinkAxisMask, uniqueExecutor.get());183+ uniqueExecutor.get());
189 CHECK_RET(stridedsliceOut != nullptr, ACLNN_ERR_INNER_NULLPTR);184 CHECK_RET(stridedsliceOut != nullptr, ACLNN_ERR_INNER_NULLPTR);
190 185 
191 // 检查输出Tensor out186 // 检查输出Tensor out
@@ -34,13 +34,12 @@ static const size_t IDX_MASK_ELLIPSIS = 2;
34static const size_t IDX_MASK_NEW_AXIS = 3;34static const size_t IDX_MASK_NEW_AXIS = 3;
35static const size_t IDX_MASK_SHRINK_AXIS = 4;35static const size_t IDX_MASK_SHRINK_AXIS = 4;
36 36 
37-ge::graphStatus StrideSliceTiling::Init(37+ge::graphStatus StrideSliceTiling::Init(int64_t coreNum, int64_t ubSize, int64_t cacheLineSize,
38- int64_t coreNum, int64_t ubSize, int64_t cacheLineSize, SliceParametersRuntime2& sliceParam,38+ SliceParametersRuntime2& sliceParam, const ge::DataType& dtype)
39- const ge::DataType& dtype)
40{39{
41 OP_LOGD(tilingContext_->GetNodeName(), "Start init StrideSliceTiling.");40 OP_LOGD(tilingContext_->GetNodeName(), "Start init StrideSliceTiling.");
42 coreNum_ = coreNum;41 coreNum_ = coreNum;
43- ubSize_ = ubSize; 42+ ubSize_ = ubSize;
44 cacheLineSize_ = cacheLineSize;43 cacheLineSize_ = cacheLineSize;
45 if (CheckPlatformParam() != ge::GRAPH_SUCCESS) {44 if (CheckPlatformParam() != ge::GRAPH_SUCCESS) {
46 return ge::GRAPH_FAILED;45 return ge::GRAPH_FAILED;
@@ -51,11 +50,10 @@ ge::graphStatus StrideSliceTiling::Init(
51 ubElementNum_ = (ubSize_ - UB_RESERVE_SIZE) / xDtypeSize_ / DOUBLE_BUFFER; // 负Stride会在ub切分时重新赋值50 ubElementNum_ = (ubSize_ - UB_RESERVE_SIZE) / xDtypeSize_ / DOUBLE_BUFFER; // 负Stride会在ub切分时重新赋值
52 dimNum_ = sliceParam.inputShape.GetDimNum();51 dimNum_ = sliceParam.inputShape.GetDimNum();
53 if (dimNum_ > MAX_AXIS_NUM_FOR_STRIDESLICE) {52 if (dimNum_ > MAX_AXIS_NUM_FOR_STRIDESLICE) {
54- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(53+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(tilingContext_->GetNodeName(), "input", std::to_string(dimNum_),
55- tilingContext_->GetNodeName(), "input", std::to_string(dimNum_),54+ "The shape dim of input must be <= 8.");
56- "The shape dim of input must be <= 8.");
57 return ge::GRAPH_FAILED;55 return ge::GRAPH_FAILED;
58- } 56+ }
59 57 
60 const auto outputShape = sliceParam.outputShape;58 const auto outputShape = sliceParam.outputShape;
61 const auto inputShape = sliceParam.inputShape;59 const auto inputShape = sliceParam.inputShape;
@@ -90,21 +88,19 @@ ge::graphStatus StrideSliceTiling::Init(
90ge::graphStatus StrideSliceTiling::CheckPlatformParam()88ge::graphStatus StrideSliceTiling::CheckPlatformParam()
91{89{
92 if (coreNum_ <= 0) {90 if (coreNum_ <= 0) {
93- OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(91+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(tilingContext_->GetNodeName(), "core number", std::to_string(coreNum_),
94- tilingContext_->GetNodeName(), "core number", std::to_string(coreNum_),92+ "The value of core number cannot <= 0.");
95- "The value of core number cannot <= 0.");
96 return ge::GRAPH_FAILED;93 return ge::GRAPH_FAILED;
97 }94 }
98 if (ubSize_ <= 0) {95 if (ubSize_ <= 0) {
99- OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(96+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(tilingContext_->GetNodeName(), "ubSize", std::to_string(ubSize_),
100- tilingContext_->GetNodeName(), "ubSize", std::to_string(ubSize_),97+ "The value of ubSize cannot <= 0.");
101- "The value of ubSize cannot <= 0.");
102 return ge::GRAPH_FAILED;98 return ge::GRAPH_FAILED;
103- } 99+ }
104 if (cacheLineSize_ <= 0) {100 if (cacheLineSize_ <= 0) {
105- OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(101+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(tilingContext_->GetNodeName(), "cacheLineSize",
106- tilingContext_->GetNodeName(), "cacheLineSize", std::to_string(cacheLineSize_),102+ std::to_string(cacheLineSize_),
107- "The value of cacheLineSize cannot <= 0.");103+ "The value of cacheLineSize cannot <= 0.");
108 return ge::GRAPH_FAILED;104 return ge::GRAPH_FAILED;
109 }105 }
110 return ge::GRAPH_SUCCESS;106 return ge::GRAPH_SUCCESS;
@@ -148,8 +144,8 @@ void StrideSliceTiling::SetAllInUbSplitInfo()
148void StrideSliceTiling::SetTwoDimTilingInfo()144void StrideSliceTiling::SetTwoDimTilingInfo()
149{145{
150 // 计算分核 整尾块切分 moveAlignv2参数146 // 计算分核 整尾块切分 moveAlignv2参数
151- if (lastOneInputDim_ * xDtypeSize_ < VL_SIZE && sliceParam_.isBeginConst == 1 && 147+ if (lastOneInputDim_ * xDtypeSize_ < VL_SIZE && sliceParam_.isBeginConst == 1 &&
152- sliceParam_.beginList.GetDim(1) == 0) {148+ sliceParam_.beginList.GetDim(1) == 0) {
153 outBlockLen_ = static_cast<uint32_t>(lastOneInputDim_ * xDtypeSize_); // 全量搬入149 outBlockLen_ = static_cast<uint32_t>(lastOneInputDim_ * xDtypeSize_); // 全量搬入
154 } else {150 } else {
155 outBlockLen_ = static_cast<uint32_t>(lastOneOutputDim_ * xDtypeSize_);151 outBlockLen_ = static_cast<uint32_t>(lastOneOutputDim_ * xDtypeSize_);
@@ -204,8 +200,8 @@ void StrideSliceTiling::CalcBlockSplitInfo()
204 // 最后一维留够1KB200 // 最后一维留够1KB
205 if (maxSplitDim_ == MAX_MOV_ALIGN_V2_UB_SPLIT_AXIS_NUM && blkIndex_ == static_cast<int64_t>(dimNum_ - 1) &&201 if (maxSplitDim_ == MAX_MOV_ALIGN_V2_UB_SPLIT_AXIS_NUM && blkIndex_ == static_cast<int64_t>(dimNum_ - 1) &&
206 blkFactor_ * std::abs(lastOneStride_) < LAST_DIM_MIN_DATA_SIZE / xDtypeSize_) {202 blkFactor_ * std::abs(lastOneStride_) < LAST_DIM_MIN_DATA_SIZE / xDtypeSize_) {
207- blkFactor_ =203+ blkFactor_ = std::min(LAST_DIM_MIN_DATA_SIZE / xDtypeSize_ / std::abs(lastOneStride_),
208- std::min(LAST_DIM_MIN_DATA_SIZE / xDtypeSize_ / std::abs(lastOneStride_), outputShape.GetDim(blkIndex_));204+ outputShape.GetDim(blkIndex_));
209 }205 }
210 206 
211 // 说明整个shape都很小,blk不切最后一根轴207 // 说明整个shape都很小,blk不切最后一根轴
@@ -229,17 +225,17 @@ void StrideSliceTiling::CalcUbSplitInfo()
229 uint64_t halfUbSize = static_cast<uint64_t>((ubSize_ - INIT_INDEX_SIZE - cacheLineSize_) / DOUBLE_BUFFER);225 uint64_t halfUbSize = static_cast<uint64_t>((ubSize_ - INIT_INDEX_SIZE - cacheLineSize_) / DOUBLE_BUFFER);
230 if (calOutputSize + calInputSize < halfUbSize) {226 if (calOutputSize + calInputSize < halfUbSize) {
231 // ub切分轴至少在-3轴227 // ub切分轴至少在-3轴
232- ubSizeInput_ = static_cast<int64_t>(228+ ubSizeInput_ = static_cast<int64_t>(halfUbSize * calInputSize / (calOutputSize + calInputSize) /
233- halfUbSize * calInputSize / (calOutputSize + calInputSize) / BLOCK_SIZE * BLOCK_SIZE);229+ BLOCK_SIZE * BLOCK_SIZE);
234 ubSizeOutput_ = static_cast<int64_t>(230 ubSizeOutput_ = static_cast<int64_t>(
235 halfUbSize * calOutputSize / (calOutputSize + calInputSize) / BLOCK_SIZE * BLOCK_SIZE + cacheLineSize_);231 halfUbSize * calOutputSize / (calOutputSize + calInputSize) / BLOCK_SIZE * BLOCK_SIZE + cacheLineSize_);
236 } else {232 } else {
237 // ub切分轴在-2轴233 // ub切分轴在-2轴
238- ubSizeInput_ = static_cast<int64_t>(234+ ubSizeInput_ = static_cast<int64_t>(halfUbSize * lastOneInputDim_ / (lastOneInputDim_ + lastOneOutputDim_) /
239- halfUbSize * lastOneInputDim_ / (lastOneInputDim_ + lastOneOutputDim_) / BLOCK_SIZE * BLOCK_SIZE);235+ BLOCK_SIZE * BLOCK_SIZE);
240- ubSizeOutput_ = static_cast<int64_t>(236+ ubSizeOutput_ = static_cast<int64_t>(halfUbSize * lastOneOutputDim_ /
241- halfUbSize * lastOneOutputDim_ / (lastOneInputDim_ + lastOneOutputDim_) / BLOCK_SIZE * BLOCK_SIZE +237+ (lastOneInputDim_ + lastOneOutputDim_) / BLOCK_SIZE * BLOCK_SIZE +
242- cacheLineSize_);238+ cacheLineSize_);
243 }239 }
244 ubElementNum_ = ubSizeInput_ / xDtypeSize_;240 ubElementNum_ = ubSizeInput_ / xDtypeSize_;
245 }241 }
@@ -261,9 +257,9 @@ void StrideSliceTiling::CalcUbSplitInfo()
261 rightProduct = Ops::Base::CeilAlign(curDim * rightProduct * xDtypeSize_, BLOCK_SIZE) / xDtypeSize_;257 rightProduct = Ops::Base::CeilAlign(curDim * rightProduct * xDtypeSize_, BLOCK_SIZE) / xDtypeSize_;
262 } else if (isSliceGather_ && i == shapeSize - 1) {258 } else if (isSliceGather_ && i == shapeSize - 1) {
263 rightProduct = inputShape.GetDim(i);259 rightProduct = inputShape.GetDim(i);
264- } else if (260+ } else if (isSliceGather_ &&
265- isSliceGather_ &&261+ i == shapeSize -
266- i == shapeSize - NUMBER_TWO) { // 最后2维连续搬入,倒数2根轴可以合并,否则就是最后一维数据需要block对齐262+ NUMBER_TWO) { // 最后2维连续搬入,倒数2根轴可以合并,否则就是最后一维数据需要block对齐
267 rightProduct = Ops::Base::CeilAlign(curDim * rightProduct * xDtypeSize_, BLOCK_SIZE) / xDtypeSize_;263 rightProduct = Ops::Base::CeilAlign(curDim * rightProduct * xDtypeSize_, BLOCK_SIZE) / xDtypeSize_;
268 } else {264 } else {
269 rightProduct = curDim * rightProduct;265 rightProduct = curDim * rightProduct;
@@ -289,8 +285,8 @@ void StrideSliceTiling::CalcUbSplitInfoNeg()
289 int32_t ubInFactor = isNddma_ ? 1 : std::abs(lastOneStride_);285 int32_t ubInFactor = isNddma_ ? 1 : std::abs(lastOneStride_);
290 ubInFactor = std::max(ubInFactor, 1);286 ubInFactor = std::max(ubInFactor, 1);
291 // 开启db: 2*UbIn + 2*UbOut = 2*UbOut*ubInFactor + 2*UbOut = ubSize_287 // 开启db: 2*UbIn + 2*UbOut = 2*UbOut*ubInFactor + 2*UbOut = ubSize_
292- int32_t ubOutBase = static_cast<int32_t>(288+ int32_t ubOutBase = static_cast<int32_t>((ubSize_ - UB_RESERVE_SIZE) / DOUBLE_BUFFER / (ubInFactor + 1) /
293- (ubSize_ - UB_RESERVE_SIZE) / DOUBLE_BUFFER / (ubInFactor + 1) / cacheLineSize_ * cacheLineSize_);289+ cacheLineSize_ * cacheLineSize_);
294 ubOutBase = std::max(ubOutBase, static_cast<int32_t>(cacheLineSize_));290 ubOutBase = std::max(ubOutBase, static_cast<int32_t>(cacheLineSize_));
295 ubSizeInput_ = static_cast<int64_t>(ubOutBase * ubInFactor);291 ubSizeInput_ = static_cast<int64_t>(ubOutBase * ubInFactor);
296 // B8/B16使用uint16作为gather的索引,这里限制一下,保证不超过uint16的最大值。限制输入大小不超过64KB292 // B8/B16使用uint16作为gather的索引,这里限制一下,保证不超过uint16的最大值。限制输入大小不超过64KB
@@ -434,8 +430,8 @@ int64_t StrideSliceTiling::GetValidNumInCacheLine()
434 startOffsetNum += startV * inputShapeStride;430 startOffsetNum += startV * inputShapeStride;
435 inputShapeStride *= sliceParam_.inputShape[i];431 inputShapeStride *= sliceParam_.inputShape[i];
436 }432 }
437- OP_LOGD(433+ OP_LOGD(tilingContext_->GetNodeName(), "startOffsetNum:%ld inputShapeProd_[0]:%ld", startOffsetNum,
438- tilingContext_->GetNodeName(), "startOffsetNum:%ld inputShapeProd_[0]:%ld", startOffsetNum, inputShapeProd_[0]);434+ inputShapeProd_[0]);
439 435 
440 int64_t totalInputCnt = std::min(inputShapeProd_[0], startOffsetNum + cachelineNum);436 int64_t totalInputCnt = std::min(inputShapeProd_[0], startOffsetNum + cachelineNum);
441 for (int64_t idx = startOffsetNum + 1; idx < totalInputCnt; idx++) {437 for (int64_t idx = startOffsetNum + 1; idx < totalInputCnt; idx++) {
@@ -638,8 +634,8 @@ void StrideSliceTiling::SetNddmaTilingModeNeg()
638 nddmaLoopSrcStride_[MAX_NDDMA_UB_SPLIT_AXIS_NUM_NEG - j] *= sliceParam_.inputShape.GetDim(dimNum_ - k);634 nddmaLoopSrcStride_[MAX_NDDMA_UB_SPLIT_AXIS_NUM_NEG - j] *= sliceParam_.inputShape.GetDim(dimNum_ - k);
639 // 尾轴对齐到block635 // 尾轴对齐到block
640 if (k == 1) {636 if (k == 1) {
641- nddmaLoopDstStride_[MAX_NDDMA_UB_SPLIT_AXIS_NUM_NEG - j] *=637+ nddmaLoopDstStride_[MAX_NDDMA_UB_SPLIT_AXIS_NUM_NEG - j] *= Ops::Base::CeilAlign(
642- Ops::Base::CeilAlign(sliceParam_.outputShape.GetDim(dimNum_ - k), BLOCK_SIZE / xDtypeSize_);638+ sliceParam_.outputShape.GetDim(dimNum_ - k), BLOCK_SIZE / xDtypeSize_);
643 } else {639 } else {
644 nddmaLoopDstStride_[MAX_NDDMA_UB_SPLIT_AXIS_NUM_NEG - j] *= sliceParam_.outputShape.GetDim(dimNum_ - k);640 nddmaLoopDstStride_[MAX_NDDMA_UB_SPLIT_AXIS_NUM_NEG - j] *= sliceParam_.outputShape.GetDim(dimNum_ - k);
645 }641 }
@@ -784,8 +780,8 @@ void StrideSliceTiling::MovAlignV2UbSplitLastOneDim()
784 if (isStrideNeg_ || useGather_) {780 if (isStrideNeg_ || useGather_) {
785 mainMoveAlignV2Info_.blockCount = static_cast<uint16_t>(1);781 mainMoveAlignV2Info_.blockCount = static_cast<uint16_t>(1);
786 // 首尾都是有效的、能取到的数782 // 首尾都是有效的、能取到的数
787- mainMoveAlignV2Info_.blockLen =783+ mainMoveAlignV2Info_.blockLen = static_cast<uint32_t>(
788- static_cast<uint32_t>((ubFactor_ * std::abs(lastOneStride_) - std::abs(lastOneStride_) + 1) * xDtypeSize_);784+ (ubFactor_ * std::abs(lastOneStride_) - std::abs(lastOneStride_) + 1) * xDtypeSize_);
789 mainMoveAlignV2Info_.srcStride = 0U;785 mainMoveAlignV2Info_.srcStride = 0U;
790 mainMoveAlignV2Info_.dstStride = 0U;786 mainMoveAlignV2Info_.dstStride = 0U;
791 }787 }
@@ -878,8 +874,8 @@ void StrideSliceTiling::MovAlignV2UbSplitLastFourDim()
878{874{
879 int64_t srcStride = std::abs(lastTwoStride_ * lastOneInputDim_ * xDtypeSize_);875 int64_t srcStride = std::abs(lastTwoStride_ * lastOneInputDim_ * xDtypeSize_);
880 int64_t loop1SrcStride = std::abs(lastThreeStride_ * lastOneInputDim_ * lastTwoInputDim_ * xDtypeSize_);876 int64_t loop1SrcStride = std::abs(lastThreeStride_ * lastOneInputDim_ * lastTwoInputDim_ * xDtypeSize_);
881- int64_t loop2SrcStride =877+ int64_t loop2SrcStride = std::abs(lastFourStride_ * lastOneInputDim_ * lastTwoInputDim_ * lastThreeInputDim_ *
882- std::abs(lastFourStride_ * lastOneInputDim_ * lastTwoInputDim_ * lastThreeInputDim_ * xDtypeSize_);878+ xDtypeSize_);
883 int64_t loop1DstStride = Ops::Base::CeilAlign(lastOneOutputDim_ * lastTwoOutputDim_ * xDtypeSize_, BLOCK_SIZE);879 int64_t loop1DstStride = Ops::Base::CeilAlign(lastOneOutputDim_ * lastTwoOutputDim_ * xDtypeSize_, BLOCK_SIZE);
884 int64_t burstLenNeg = 0;880 int64_t burstLenNeg = 0;
885 if (isStrideNeg_ || useGather_) {881 if (isStrideNeg_ || useGather_) {
@@ -1088,8 +1084,8 @@ void StrideSliceTiling::SetMoveAlignParams(StridedSliceMoveAlignParams& params,
1088 params.set_loop2DstStride(actInfo.loop2DstStride);1084 params.set_loop2DstStride(actInfo.loop2DstStride);
1089}1085}
1090 1086 
1091-void StrideSliceTiling::SetShortMoveAlignParams(1087+void StrideSliceTiling::SetShortMoveAlignParams(StridedSliceShortMoveAlignParams& params,
1092- StridedSliceShortMoveAlignParams& params, const MoveAlignV2Info& actInfo)1088+ const MoveAlignV2Info& actInfo)
1093{1089{
1094 params.set_blockCount(actInfo.blockCount);1090 params.set_blockCount(actInfo.blockCount);
1095 params.set_blockLen(actInfo.blockLen);1091 params.set_blockLen(actInfo.blockLen);
@@ -1179,8 +1175,8 @@ void StrideSliceTiling::FillStridedSliceTilingData100()
1179 FillStridedSliceBaseTilingData(maTilingData_.stridedSliceBaseTilingData);1175 FillStridedSliceBaseTilingData(maTilingData_.stridedSliceBaseTilingData);
1180 1176 
1181 SetMoveAlignParams(maTilingData_.moveAlignParams, mainMoveAlignV2Info_);1177 SetMoveAlignParams(maTilingData_.moveAlignParams, mainMoveAlignV2Info_);
1182- maTilingData_.SaveToBuffer(1178+ maTilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(),
1183- tilingContext_->GetRawTilingData()->GetData(), tilingContext_->GetRawTilingData()->GetCapacity());1179+ tilingContext_->GetRawTilingData()->GetCapacity());
1184 tilingContext_->GetRawTilingData()->SetDataSize(maTilingData_.GetDataSize());1180 tilingContext_->GetRawTilingData()->SetDataSize(maTilingData_.GetDataSize());
1185}1181}
1186 1182 
@@ -1189,8 +1185,8 @@ void StrideSliceTiling::FillStridedSliceTilingData101()
1189 OP_LOGD(tilingContext_->GetNodeName(), "Entering FillTilingData101.");1185 OP_LOGD(tilingContext_->GetNodeName(), "Entering FillTilingData101.");
1190 FillStridedSliceBaseTilingData(maLastDimTilingData_.stridedSliceBaseTilingData);1186 FillStridedSliceBaseTilingData(maLastDimTilingData_.stridedSliceBaseTilingData);
1191 1187 
1192- maLastDimTilingData_.SaveToBuffer(1188+ maLastDimTilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(),
1193- tilingContext_->GetRawTilingData()->GetData(), tilingContext_->GetRawTilingData()->GetCapacity());1189+ tilingContext_->GetRawTilingData()->GetCapacity());
1194 tilingContext_->GetRawTilingData()->SetDataSize(maLastDimTilingData_.GetDataSize());1190 tilingContext_->GetRawTilingData()->SetDataSize(maLastDimTilingData_.GetDataSize());
1195}1191}
1196 1192 
@@ -1204,8 +1200,8 @@ void StrideSliceTiling::FillStridedSliceTilingDataNDDMA()
1204 nddmaTilingData_.set_nddmaLoopSrcStride(nddmaLoopSrcStride_);1200 nddmaTilingData_.set_nddmaLoopSrcStride(nddmaLoopSrcStride_);
1205 nddmaTilingData_.set_nddmaLoopDstStride(nddmaLoopDstStride_);1201 nddmaTilingData_.set_nddmaLoopDstStride(nddmaLoopDstStride_);
1206 1202 
1207- nddmaTilingData_.SaveToBuffer(1203+ nddmaTilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(),
1208- tilingContext_->GetRawTilingData()->GetData(), tilingContext_->GetRawTilingData()->GetCapacity());1204+ tilingContext_->GetRawTilingData()->GetCapacity());
1209 tilingContext_->GetRawTilingData()->SetDataSize(nddmaTilingData_.GetDataSize());1205 tilingContext_->GetRawTilingData()->SetDataSize(nddmaTilingData_.GetDataSize());
1210}1206}
1211 1207 
@@ -1245,8 +1241,8 @@ void StrideSliceTiling::FillStridedSliceTilingData150()
1245 maLast2DimTilingData_.set_strides(strides);1241 maLast2DimTilingData_.set_strides(strides);
1246 maLast2DimTilingData_.set_outputShape(outputShape);1242 maLast2DimTilingData_.set_outputShape(outputShape);
1247 SetRowsStepsParamsFor150(maLast2DimTilingData_);1243 SetRowsStepsParamsFor150(maLast2DimTilingData_);
1248- maLast2DimTilingData_.SaveToBuffer(1244+ maLast2DimTilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(),
1249- tilingContext_->GetRawTilingData()->GetData(), tilingContext_->GetRawTilingData()->GetCapacity());1245+ tilingContext_->GetRawTilingData()->GetCapacity());
1250 tilingContext_->GetRawTilingData()->SetDataSize(maLast2DimTilingData_.GetDataSize());1246 tilingContext_->GetRawTilingData()->SetDataSize(maLast2DimTilingData_.GetDataSize());
1251}1247}
1252 1248 
@@ -1259,8 +1255,8 @@ void StrideSliceTiling::FillStridedSliceTilingDataSIMT()
1259 simtTilingData_.set_strides(strides_);1255 simtTilingData_.set_strides(strides_);
1260 simtTilingData_.set_outputShapeProd(outputShapeProd_);1256 simtTilingData_.set_outputShapeProd(outputShapeProd_);
1261 simtTilingData_.set_inputShapeProd(inputShapeProd_);1257 simtTilingData_.set_inputShapeProd(inputShapeProd_);
1262- simtTilingData_.SaveToBuffer(1258+ simtTilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(),
1263- tilingContext_->GetRawTilingData()->GetData(), tilingContext_->GetRawTilingData()->GetCapacity());1259+ tilingContext_->GetRawTilingData()->GetCapacity());
1264 tilingContext_->GetRawTilingData()->SetDataSize(simtTilingData_.GetDataSize());1260 tilingContext_->GetRawTilingData()->SetDataSize(simtTilingData_.GetDataSize());
1265}1261}
1266 1262 
@@ -1270,8 +1266,8 @@ void StrideSliceTiling::FillStridedSliceTilingData300()
1270 FillStridedSliceBaseTilingData(maGatherTilingData_.stridedSliceBaseTilingData);1266 FillStridedSliceBaseTilingData(maGatherTilingData_.stridedSliceBaseTilingData);
1271 maGatherTilingData_.set_ubSizeInput(ubSizeInput_);1267 maGatherTilingData_.set_ubSizeInput(ubSizeInput_);
1272 SetMoveAlignParams(maGatherTilingData_.moveAlignParams, mainMoveAlignV2Info_);1268 SetMoveAlignParams(maGatherTilingData_.moveAlignParams, mainMoveAlignV2Info_);
1273- maGatherTilingData_.SaveToBuffer(1269+ maGatherTilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(),
1274- tilingContext_->GetRawTilingData()->GetData(), tilingContext_->GetRawTilingData()->GetCapacity());1270+ tilingContext_->GetRawTilingData()->GetCapacity());
1275 tilingContext_->GetRawTilingData()->SetDataSize(maGatherTilingData_.GetDataSize());1271 tilingContext_->GetRawTilingData()->SetDataSize(maGatherTilingData_.GetDataSize());
1276}1272}
1277 1273 
@@ -1281,8 +1277,8 @@ void StrideSliceTiling::FillStridedSliceTilingData301()
1281 FillStridedSliceBaseTilingData(maUB2UBTilingData_.stridedSliceBaseTilingData);1277 FillStridedSliceBaseTilingData(maUB2UBTilingData_.stridedSliceBaseTilingData);
1282 maUB2UBTilingData_.set_ubSizeInput(ubSizeInput_);1278 maUB2UBTilingData_.set_ubSizeInput(ubSizeInput_);
1283 SetMoveAlignParams(maUB2UBTilingData_.moveAlignParams, mainMoveAlignV2Info_);1279 SetMoveAlignParams(maUB2UBTilingData_.moveAlignParams, mainMoveAlignV2Info_);
1284- maUB2UBTilingData_.SaveToBuffer(1280+ maUB2UBTilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(),
1285- tilingContext_->GetRawTilingData()->GetData(), tilingContext_->GetRawTilingData()->GetCapacity());1281+ tilingContext_->GetRawTilingData()->GetCapacity());
1286 tilingContext_->GetRawTilingData()->SetDataSize(maUB2UBTilingData_.GetDataSize());1282 tilingContext_->GetRawTilingData()->SetDataSize(maUB2UBTilingData_.GetDataSize());
1287}1283}
1288 1284 
@@ -1323,8 +1319,8 @@ void StrideSliceTiling::FillStridedSliceTilingDataOther()
1323 tilingData_.set_outputShape(outputShape_);1319 tilingData_.set_outputShape(outputShape_);
1324 1320 
1325 SetRowsStepsParams(tilingData_);1321 SetRowsStepsParams(tilingData_);
1326- tilingData_.SaveToBuffer(1322+ tilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(),
1327- tilingContext_->GetRawTilingData()->GetData(), tilingContext_->GetRawTilingData()->GetCapacity());1323+ tilingContext_->GetRawTilingData()->GetCapacity());
1328 tilingContext_->GetRawTilingData()->SetDataSize(tilingData_.GetDataSize());1324 tilingContext_->GetRawTilingData()->SetDataSize(tilingData_.GetDataSize());
1329}1325}
1330 1326 
@@ -1406,37 +1402,33 @@ void StrideSliceTiling::PrintTilingData()
1406 1402 
1407void StrideSliceTiling::PrintStridedSliceBaseTilingData(StridedSliceBaseTilingData& tilingData)1403void StrideSliceTiling::PrintStridedSliceBaseTilingData(StridedSliceBaseTilingData& tilingData)
1408{1404{
1409- OP_LOGI(1405+ OP_LOGI(tilingContext_->GetNodeName(), "StridedSliceBaseTilingData is isStrideNeg_:%d, ubSize:%d, realCoreNum:%d, \
1410- tilingContext_->GetNodeName(),
1411- "StridedSliceBaseTilingData is isStrideNeg_:%d, ubSize:%d, realCoreNum:%d, \
1412 ubIndex:%d, ubFactor:%d, ubTailFactor:%d, ubTailTailFactor:%d, \1406 ubIndex:%d, ubFactor:%d, ubTailFactor:%d, ubTailTailFactor:%d, \
1413 blkIndex:%d, blkFactor:%ld, blkTailFactor:%ld, \1407 blkIndex:%d, blkFactor:%ld, blkTailFactor:%ld, \
1414 begin:%s, end:%s, stride:%s, inputShape:%s, outputShape:%s, \1408 begin:%s, end:%s, stride:%s, inputShape:%s, outputShape:%s, \
1415 rowsOffsetSteps:%s, inputSteps:%s, outputSteps:%s, ubInLoopSteps:%ld, ubOutLoopSteps:%ld",1409 rowsOffsetSteps:%s, inputSteps:%s, outputSteps:%s, ubInLoopSteps:%ld, ubOutLoopSteps:%ld",
1416- isStrideNeg_, tilingData.get_ubSize(), tilingData.get_realCoreNum(), tilingData.get_ubIndex(),1410+ isStrideNeg_, tilingData.get_ubSize(), tilingData.get_realCoreNum(), tilingData.get_ubIndex(),
1417- tilingData.get_ubFactor(), tilingData.get_ubTailFactor(), tilingData.get_ubTailTailFactor(),1411+ tilingData.get_ubFactor(), tilingData.get_ubTailFactor(), tilingData.get_ubTailTailFactor(),
1418- tilingData.get_blkIndex(), tilingData.get_blkFactor(), tilingData.get_blkTailFactor(),1412+ tilingData.get_blkIndex(), tilingData.get_blkFactor(), tilingData.get_blkTailFactor(),
1419- ArrayToStr(tilingData.get_begin(), dimNum_).c_str(), ArrayToStr(end_, dimNum_).c_str(),1413+ ArrayToStr(tilingData.get_begin(), dimNum_).c_str(), ArrayToStr(end_, dimNum_).c_str(),
1420- ArrayToStr(tilingData.get_strides(), dimNum_).c_str(), ArrayToStr(inputShape_, dimNum_).c_str(),1414+ ArrayToStr(tilingData.get_strides(), dimNum_).c_str(), ArrayToStr(inputShape_, dimNum_).c_str(),
1421- ArrayToStr(tilingData.get_outputShape(), dimNum_).c_str(),1415+ ArrayToStr(tilingData.get_outputShape(), dimNum_).c_str(),
1422- ArrayToStr(tilingData.get_rowsOffsetSteps(), dimNum_).c_str(),1416+ ArrayToStr(tilingData.get_rowsOffsetSteps(), dimNum_).c_str(),
1423- ArrayToStr(tilingData.get_inputSteps(), dimNum_).c_str(), ArrayToStr(outputSteps_, dimNum_).c_str(),1417+ ArrayToStr(tilingData.get_inputSteps(), dimNum_).c_str(), ArrayToStr(outputSteps_, dimNum_).c_str(),
1424- tilingData.get_ubInLoopSteps(), tilingData.get_ubOutLoopSteps());1418+ tilingData.get_ubInLoopSteps(), tilingData.get_ubOutLoopSteps());
1425}1419}
1426 1420 
1427void StrideSliceTiling::PrintStridedSliceTilingData100()1421void StrideSliceTiling::PrintStridedSliceTilingData100()
1428{1422{
1429 OP_LOGI(tilingContext_->GetNodeName(), "Printing StridedSliceMATilingData:");1423 OP_LOGI(tilingContext_->GetNodeName(), "Printing StridedSliceMATilingData:");
1430 PrintStridedSliceBaseTilingData(maTilingData_.stridedSliceBaseTilingData);1424 PrintStridedSliceBaseTilingData(maTilingData_.stridedSliceBaseTilingData);
1431- OP_LOGI(1425+ OP_LOGI(tilingContext_->GetNodeName(), "StridedSliceMATilingData is \
1432- tilingContext_->GetNodeName(),
1433- "StridedSliceMATilingData is \
1434 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \1426 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \
1435 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u",1427 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u",
1436- mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride,1428+ mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride,
1437- mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size, mainMoveAlignV2Info_.loop2Size,1429+ mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size, mainMoveAlignV2Info_.loop2Size,
1438- mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride, mainMoveAlignV2Info_.loop2SrcStride,1430+ mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride,
1439- mainMoveAlignV2Info_.loop2DstStride);1431+ mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride);
1440}1432}
1441 1433 
1442void StrideSliceTiling::PrintStridedSliceTilingData101()1434void StrideSliceTiling::PrintStridedSliceTilingData101()
@@ -1449,116 +1441,104 @@ void StrideSliceTiling::PrintStridedSliceTilingDataNDDMA()
1449{1441{
1450 OP_LOGI(tilingContext_->GetNodeName(), "Printing StridedSliceNDDMATilingData:");1442 OP_LOGI(tilingContext_->GetNodeName(), "Printing StridedSliceNDDMATilingData:");
1451 PrintStridedSliceBaseTilingData(nddmaTilingData_.stridedSliceBaseTilingData);1443 PrintStridedSliceBaseTilingData(nddmaTilingData_.stridedSliceBaseTilingData);
1452- OP_LOGI(1444+ OP_LOGI(tilingContext_->GetNodeName(), "StridedSliceNDDMATilingData is ubSizeInput:%d\
1453- tilingContext_->GetNodeName(),
1454- "StridedSliceNDDMATilingData is ubSizeInput:%d\
1455 nddmaTotalNum:%ld, nddmaLoopSize:%s, nddmaLoopSrcStride: %s, nddmaLoopDstStride: %s",1445 nddmaTotalNum:%ld, nddmaLoopSize:%s, nddmaLoopSrcStride: %s, nddmaLoopDstStride: %s",
1456- nddmaTilingData_.get_ubSizeInput(), nddmaTilingData_.get_nddmaTotalNum(),1446+ nddmaTilingData_.get_ubSizeInput(), nddmaTilingData_.get_nddmaTotalNum(),
1457- ArrayToStr(nddmaTilingData_.get_nddmaLoopSize(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),1447+ ArrayToStr(nddmaTilingData_.get_nddmaLoopSize(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
1458- ArrayToStr(nddmaTilingData_.get_nddmaLoopSrcStride(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),1448+ ArrayToStr(nddmaTilingData_.get_nddmaLoopSrcStride(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
1459- ArrayToStr(nddmaTilingData_.get_nddmaLoopDstStride(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str());1449+ ArrayToStr(nddmaTilingData_.get_nddmaLoopDstStride(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str());
1460}1450}
1461 1451 
1462void StrideSliceTiling::PrintStridedSliceTilingData150()1452void StrideSliceTiling::PrintStridedSliceTilingData150()
1463{1453{
1464- OP_LOGI(1454+ OP_LOGI(tilingContext_->GetNodeName(), "StridedSliceMALast2DimTilingData is ubSize:%d, realCoreNum:%d, \
1465- tilingContext_->GetNodeName(),
1466- "StridedSliceMALast2DimTilingData is ubSize:%d, realCoreNum:%d, \
1467 ubFactor:%d, ubTailFactor:%d, ubTailTailFactor:%d, \1455 ubFactor:%d, ubTailFactor:%d, ubTailTailFactor:%d, \
1468 blkFactor:%ld, blkTailFactor:%ld, \1456 blkFactor:%ld, blkTailFactor:%ld, \
1469 begin:%s, end:%s, inputShape:%s, outputShape:%s, \1457 begin:%s, end:%s, inputShape:%s, outputShape:%s, \
1470 inputSteps:%s, outputSteps:%s, ubInLoopSteps:%ld, ubOutLoopSteps:%ld, \1458 inputSteps:%s, outputSteps:%s, ubInLoopSteps:%ld, ubOutLoopSteps:%ld, \
1471 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u",1459 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u",
1472- maLast2DimTilingData_.get_ubSize(), maLast2DimTilingData_.get_realCoreNum(),1460+ maLast2DimTilingData_.get_ubSize(), maLast2DimTilingData_.get_realCoreNum(),
1473- maLast2DimTilingData_.get_ubFactor(), maLast2DimTilingData_.get_ubTailFactor(),1461+ maLast2DimTilingData_.get_ubFactor(), maLast2DimTilingData_.get_ubTailFactor(),
1474- maLast2DimTilingData_.get_ubTailTailFactor(), maLast2DimTilingData_.get_blkFactor(),1462+ maLast2DimTilingData_.get_ubTailTailFactor(), maLast2DimTilingData_.get_blkFactor(),
1475- maLast2DimTilingData_.get_blkTailFactor(), ArrayToStr(maLast2DimTilingData_.get_begin(), dimNum_).c_str(),1463+ maLast2DimTilingData_.get_blkTailFactor(), ArrayToStr(maLast2DimTilingData_.get_begin(), dimNum_).c_str(),
1476- ArrayToStr(end_, dimNum_).c_str(), ArrayToStr(inputShape_, dimNum_).c_str(),1464+ ArrayToStr(end_, dimNum_).c_str(), ArrayToStr(inputShape_, dimNum_).c_str(),
1477- ArrayToStr(maLast2DimTilingData_.get_outputShape(), dimNum_).c_str(),1465+ ArrayToStr(maLast2DimTilingData_.get_outputShape(), dimNum_).c_str(),
1478- ArrayToStr(maLast2DimTilingData_.get_inputSteps(), dimNum_).c_str(), ArrayToStr(outputSteps_, dimNum_).c_str(),1466+ ArrayToStr(maLast2DimTilingData_.get_inputSteps(), dimNum_).c_str(),
1479- maLast2DimTilingData_.get_ubInLoopSteps(), maLast2DimTilingData_.get_ubOutLoopSteps(),1467+ ArrayToStr(outputSteps_, dimNum_).c_str(), maLast2DimTilingData_.get_ubInLoopSteps(),
1480- mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride,1468+ maLast2DimTilingData_.get_ubOutLoopSteps(), mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen,
1481- mainMoveAlignV2Info_.dstStride);1469+ mainMoveAlignV2Info_.srcStride, mainMoveAlignV2Info_.dstStride);
1482}1470}
1483 1471 
1484void StrideSliceTiling::PrintStridedSliceTilingDataSIMT()1472void StrideSliceTiling::PrintStridedSliceTilingDataSIMT()
1485{1473{
1486- OP_LOGI(1474+ OP_LOGI(tilingContext_->GetNodeName(),
1487- tilingContext_->GetNodeName(),1475+ "StridedSliceSIMTTilingData is isStrideNeg_:%d, isEmptyTensor:%d, begin:%s, stride:%s \
1488- "StridedSliceSIMTTilingData is isStrideNeg_:%d, isEmptyTensor:%d, begin:%s, stride:%s \
1489 outputShapeProd:%s, inputShapeProd:%s",1476 outputShapeProd:%s, inputShapeProd:%s",
1490- isStrideNeg_, simtTilingData_.get_isEmptyTensor(), ArrayToStr(simtTilingData_.get_begin(), dimNum_).c_str(),1477+ isStrideNeg_, simtTilingData_.get_isEmptyTensor(), ArrayToStr(simtTilingData_.get_begin(), dimNum_).c_str(),
1491- ArrayToStr(simtTilingData_.get_strides(), dimNum_).c_str(),1478+ ArrayToStr(simtTilingData_.get_strides(), dimNum_).c_str(),
1492- ArrayToStr(simtTilingData_.get_outputShapeProd(), MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str(),1479+ ArrayToStr(simtTilingData_.get_outputShapeProd(), MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str(),
1493- ArrayToStr(simtTilingData_.get_inputShapeProd(), MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str());1480+ ArrayToStr(simtTilingData_.get_inputShapeProd(), MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str());
1494}1481}
1495 1482 
1496void StrideSliceTiling::PrintStridedSliceTilingData300()1483void StrideSliceTiling::PrintStridedSliceTilingData300()
1497{1484{
1498 OP_LOGI(tilingContext_->GetNodeName(), "Printing StridedSliceMAGatherTilingData:");1485 OP_LOGI(tilingContext_->GetNodeName(), "Printing StridedSliceMAGatherTilingData:");
1499 PrintStridedSliceBaseTilingData(maGatherTilingData_.stridedSliceBaseTilingData);1486 PrintStridedSliceBaseTilingData(maGatherTilingData_.stridedSliceBaseTilingData);
1500- OP_LOGI(1487+ OP_LOGI(tilingContext_->GetNodeName(), "StridedSliceMAGatherTilingData is ubSizeInput:%d \
1501- tilingContext_->GetNodeName(),
1502- "StridedSliceMAGatherTilingData is ubSizeInput:%d \
1503 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \1488 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \
1504 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u",1489 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u",
1505- maGatherTilingData_.get_ubSizeInput(), mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen,1490+ maGatherTilingData_.get_ubSizeInput(), mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen,
1506- mainMoveAlignV2Info_.srcStride, mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size,1491+ mainMoveAlignV2Info_.srcStride, mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size,
1507- mainMoveAlignV2Info_.loop2Size, mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride,1492+ mainMoveAlignV2Info_.loop2Size, mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride,
1508- mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride);1493+ mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride);
1509}1494}
1510 1495 
1511void StrideSliceTiling::PrintStridedSliceTilingData301()1496void StrideSliceTiling::PrintStridedSliceTilingData301()
1512{1497{
1513 OP_LOGI(tilingContext_->GetNodeName(), "Printing StridedSliceMAUB2UBTilingData:");1498 OP_LOGI(tilingContext_->GetNodeName(), "Printing StridedSliceMAUB2UBTilingData:");
1514 PrintStridedSliceBaseTilingData(maUB2UBTilingData_.stridedSliceBaseTilingData);1499 PrintStridedSliceBaseTilingData(maUB2UBTilingData_.stridedSliceBaseTilingData);
1515- OP_LOGI(1500+ OP_LOGI(tilingContext_->GetNodeName(), "StridedSliceMAUB2UBTilingData is ubSizeInput:%d \
1516- tilingContext_->GetNodeName(),
1517- "StridedSliceMAUB2UBTilingData is ubSizeInput:%d \
1518 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \1501 moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \
1519 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u",1502 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u",
1520- maUB2UBTilingData_.get_ubSizeInput(), mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen,1503+ maUB2UBTilingData_.get_ubSizeInput(), mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen,
1521- mainMoveAlignV2Info_.srcStride, mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size,1504+ mainMoveAlignV2Info_.srcStride, mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size,
1522- mainMoveAlignV2Info_.loop2Size, mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride,1505+ mainMoveAlignV2Info_.loop2Size, mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride,
1523- mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride);1506+ mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride);
1524}1507}
1525 1508 
1526void StrideSliceTiling::PrintStridedSliceTilingDataOther()1509void StrideSliceTiling::PrintStridedSliceTilingDataOther()
1527{1510{
1528- OP_LOGI(1511+ OP_LOGI(tilingContext_->GetNodeName(),
1529- tilingContext_->GetNodeName(),1512+ "tilingData is isStrideNeg_:%d ubSize:%ld ubSizeInput:%ld, coreNum:%ld, realCoreNum:%ld, \
1530- "tilingData is isStrideNeg_:%d ubSize:%ld ubSizeInput:%ld, coreNum:%ld, realCoreNum:%ld, \
1531 ubIndex:%ld, ubFactor:%ld, ubTailFactor:%ld, ubTailTailFactor:%ld, \1513 ubIndex:%ld, ubFactor:%ld, ubTailFactor:%ld, ubTailTailFactor:%ld, \
1532 blkIndex:%ld, blkFactor:%ld, blkTailFactor:%ld, xDtypeSize:%ld, tilingKey:%ld, isShapeExceedUint32:%d, \1514 blkIndex:%ld, blkFactor:%ld, blkTailFactor:%ld, xDtypeSize:%ld, tilingKey:%ld, isShapeExceedUint32:%d, \
1533 isEmptyTensor:%d, begin:%s, end:%s, stride:%s, inputShape:%s, outputShape:%s, \1515 isEmptyTensor:%d, begin:%s, end:%s, stride:%s, inputShape:%s, outputShape:%s, \
1534 rowsOffsetSteps:%s, inputSteps:%s, outputSteps:%s",1516 rowsOffsetSteps:%s, inputSteps:%s, outputSteps:%s",
1535- isStrideNeg_, tilingData_.get_ubSize(), ubSizeInput_, coreNum_, tilingData_.get_realCoreNum(),1517+ isStrideNeg_, tilingData_.get_ubSize(), ubSizeInput_, coreNum_, tilingData_.get_realCoreNum(),
1536- tilingData_.get_ubIndex(), tilingData_.get_ubFactor(), tilingData_.get_ubTailFactor(),1518+ tilingData_.get_ubIndex(), tilingData_.get_ubFactor(), tilingData_.get_ubTailFactor(),
1537- tilingData_.get_ubTailTailFactor(), tilingData_.get_blkIndex(), tilingData_.get_blkFactor(),1519+ tilingData_.get_ubTailTailFactor(), tilingData_.get_blkIndex(), tilingData_.get_blkFactor(),
1538- tilingData_.get_blkTailFactor(), tilingData_.get_xDtypeSize(), tilingData_.get_tilingKey(),1520+ tilingData_.get_blkTailFactor(), tilingData_.get_xDtypeSize(), tilingData_.get_tilingKey(),
1539- tilingData_.get_isShapeExceedUint32(), tilingData_.get_isEmptyTensor(),1521+ tilingData_.get_isShapeExceedUint32(), tilingData_.get_isEmptyTensor(),
1540- ArrayToStr(tilingData_.get_begin(), dimNum_).c_str(), ArrayToStr(end_, dimNum_).c_str(),1522+ ArrayToStr(tilingData_.get_begin(), dimNum_).c_str(), ArrayToStr(end_, dimNum_).c_str(),
1541- ArrayToStr(tilingData_.get_strides(), dimNum_).c_str(), ArrayToStr(inputShape_, dimNum_).c_str(),1523+ ArrayToStr(tilingData_.get_strides(), dimNum_).c_str(), ArrayToStr(inputShape_, dimNum_).c_str(),
1542- ArrayToStr(tilingData_.get_outputShape(), dimNum_).c_str(),1524+ ArrayToStr(tilingData_.get_outputShape(), dimNum_).c_str(),
1543- ArrayToStr(tilingData_.get_rowsOffsetSteps(), dimNum_).c_str(),1525+ ArrayToStr(tilingData_.get_rowsOffsetSteps(), dimNum_).c_str(),
1544- ArrayToStr(tilingData_.get_inputSteps(), dimNum_).c_str(), ArrayToStr(outputSteps_, dimNum_).c_str());1526+ ArrayToStr(tilingData_.get_inputSteps(), dimNum_).c_str(), ArrayToStr(outputSteps_, dimNum_).c_str());
1545 1527 
1546- OP_LOGI(1528+ OP_LOGI(tilingContext_->GetNodeName(), "tilingData is nddmaTotalNum:%ld nddmaLoopSize:%s, nddmaLoopSrcStride: %s, \
1547- tilingContext_->GetNodeName(),
1548- "tilingData is nddmaTotalNum:%ld nddmaLoopSize:%s, nddmaLoopSrcStride: %s, \
1549 nddmaLoopDstStride: %s, moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \1529 nddmaLoopDstStride: %s, moveAlignInfo: blockCount:%u blockLen:%u srcStride:%u dstStride:%u loop1Size:%u \
1550 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u outputShapeProd: %s \1530 loop2Size:%u loop1SrcStride:%u loop1DstStride:%u loop2SrcStride:%u loop2DstStride:%u outputShapeProd: %s \
1551 inputShapeProd: %s Tiling4StrideSlice ends.",1531 inputShapeProd: %s Tiling4StrideSlice ends.",
1552- tilingData_.get_nddmaTotalNum(),1532+ tilingData_.get_nddmaTotalNum(),
1553- ArrayToStr(tilingData_.get_nddmaLoopSize(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),1533+ ArrayToStr(tilingData_.get_nddmaLoopSize(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
1554- ArrayToStr(tilingData_.get_nddmaLoopSrcStride(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),1534+ ArrayToStr(tilingData_.get_nddmaLoopSrcStride(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
1555- ArrayToStr(tilingData_.get_nddmaLoopDstStride(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),1535+ ArrayToStr(tilingData_.get_nddmaLoopDstStride(), MAX_NDDMA_UB_SPLIT_AXIS_NUM).c_str(),
1556- mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride,1536+ mainMoveAlignV2Info_.blockCount, mainMoveAlignV2Info_.blockLen, mainMoveAlignV2Info_.srcStride,
1557- mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size, mainMoveAlignV2Info_.loop2Size,1537+ mainMoveAlignV2Info_.dstStride, mainMoveAlignV2Info_.loop1Size, mainMoveAlignV2Info_.loop2Size,
1558- mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride, mainMoveAlignV2Info_.loop2SrcStride,1538+ mainMoveAlignV2Info_.loop1SrcStride, mainMoveAlignV2Info_.loop1DstStride,
1559- mainMoveAlignV2Info_.loop2DstStride,1539+ mainMoveAlignV2Info_.loop2SrcStride, mainMoveAlignV2Info_.loop2DstStride,
1560- ArrayToStr(tilingData_.get_outputShapeProd(), MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str(),1540+ ArrayToStr(tilingData_.get_outputShapeProd(), MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str(),
1561- ArrayToStr(tilingData_.get_inputShapeProd(), MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str());1541+ ArrayToStr(tilingData_.get_inputShapeProd(), MAX_SIMT_UB_SPLIT_AXIS_NUM).c_str());
1562}1542}
1563 1543 
1564void StrideSliceTiling::SetBlockDimAndTilingKey()1544void StrideSliceTiling::SetBlockDimAndTilingKey()
@@ -1577,14 +1557,13 @@ std::string StrideSliceTiling::ArrayToStr(const int64_t* arr, size_t aSize) cons
1577}1557}
1578 1558 
1579template <typename T>1559template <typename T>
1580-static bool AssignInputValueConst(1560+static bool AssignInputValueConst(const gert::Tensor* tensor, ops::QuickVector& sliceList, bool isAscendc, bool depend,
1581- const gert::Tensor* tensor, ops::QuickVector& sliceList, bool isAscendc, bool depend, bool& isConst)1561+ bool& isConst)
1582{1562{
1583 int32_t dimNum = tensor->GetShapeSize();1563 int32_t dimNum = tensor->GetShapeSize();
1584 const T* data = tensor->GetData<T>();1564 const T* data = tensor->GetData<T>();
1585- OP_CHECK_IF(1565+ OP_CHECK_IF((!isAscendc || depend) && data == nullptr,
1586- (!isAscendc || depend) && data == nullptr,1566+ OP_LOGE(OP_NAME, "get const value fail, check input is const or not."), return false);
1587- OP_LOGE(OP_NAME, "get const value fail, check input is const or not."), return false);
1588 if (!data) {1567 if (!data) {
1589 isConst = false;1568 isConst = false;
1590 } else {1569 } else {
@@ -1597,8 +1576,8 @@ static bool AssignInputValueConst(
1597 return true;1576 return true;
1598}1577}
1599 1578 
1600-static bool ConstructSliceList(1579+static bool ConstructSliceList(const gert::Tensor* tensor, ops::QuickVector& sliceList, bool isAscendc, bool depend,
1601- const gert::Tensor* tensor, ops::QuickVector& sliceList, bool isAscendc, bool depend, bool& isConst)1580+ bool& isConst)
1602{1581{
1603 if (tensor->GetDataType() == ge::DT_INT32) {1582 if (tensor->GetDataType() == ge::DT_INT32) {
1604 return AssignInputValueConst<int32_t>(tensor, sliceList, isAscendc, depend, isConst);1583 return AssignInputValueConst<int32_t>(tensor, sliceList, isAscendc, depend, isConst);
@@ -1638,8 +1617,8 @@ static bool CheckStride(ops::QuickVector& stride, const gert::TilingContext* con
1638 return true;1617 return true;
1639}1618}
1640 1619 
1641-static ge::graphStatus ConstructSliceParam(1620+static ge::graphStatus ConstructSliceParam(const gert::TilingContext* context, SliceParametersRuntime2& sliceParam,
1642- const gert::TilingContext* context, SliceParametersRuntime2& sliceParam, bool isAscendc)1621+ bool isAscendc)
1643{1622{
1644 // construct slice_param.input, slice_param.output_shape1623 // construct slice_param.input, slice_param.output_shape
1645 const gert::StorageShape* xStorage = context->GetInputShape(INDEX_X);1624 const gert::StorageShape* xStorage = context->GetInputShape(INDEX_X);
@@ -1675,8 +1654,7 @@ static ge::graphStatus ConstructSliceParam(
1675 return ge::GRAPH_SUCCESS;1654 return ge::GRAPH_SUCCESS;
1676}1655}
1677 1656 
1678-static ge::graphStatus ProcBeginEndUnconst(1657+static ge::graphStatus ProcBeginEndUnconst(const gert::TilingContext* context, SliceParametersRuntime2& sliceParam)
1679- const gert::TilingContext* context, SliceParametersRuntime2& sliceParam)
1680{1658{
1681 if (sliceParam.isBeginConst && sliceParam.isEndConst) {1659 if (sliceParam.isBeginConst && sliceParam.isEndConst) {
1682 return ge::GRAPH_SUCCESS;1660 return ge::GRAPH_SUCCESS;
@@ -1692,9 +1670,7 @@ static ge::graphStatus ProcBeginEndUnconst(
1692 beginLen = std::max(tensorEnd->GetShapeSize(), beginLen);1670 beginLen = std::max(tensorEnd->GetShapeSize(), beginLen);
1693 beginLen = std::max(static_cast<int64_t>(sliceParam.strideList.GetDimNum()), beginLen);1671 beginLen = std::max(static_cast<int64_t>(sliceParam.strideList.GetDimNum()), beginLen);
1694 1672 
1695- OP_CHECK_IF(1673+ OP_CHECK_IF(beginLen == -1, OP_LOGE(OP_NAME, "beginLen invalid while nonconst"), return ge::GRAPH_FAILED);
1696- beginLen == -1, OP_LOGE(OP_NAME, "beginLen invalid while nonconst"),
1697- return ge::GRAPH_FAILED);
1698 1674 
1699 // begin or end被mask掉的话,infershape会依据strides的正负重新给begin/end赋值1675 // begin or end被mask掉的话,infershape会依据strides的正负重新给begin/end赋值
1700 // 此处只需要考虑strides为正1676 // 此处只需要考虑strides为正
@@ -1721,8 +1697,8 @@ static ge::graphStatus ProcBeginEndUnconst(
1721 return ge::GRAPH_SUCCESS;1697 return ge::GRAPH_SUCCESS;
1722}1698}
1723 1699 
1724-static void ReconstructSliceParamByInferShape(1700+static void ReconstructSliceParamByInferShape(ops::StridedSliceParams& inputParams, gert::Shape& shapeOutput,
1725- ops::StridedSliceParams& inputParams, gert::Shape& shapeOutput, SliceParametersRuntime2& sliceParam)1701+ SliceParametersRuntime2& sliceParam)
1726{1702{
1727 sliceParam.beginList = inputParams.begin;1703 sliceParam.beginList = inputParams.begin;
1728 sliceParam.endList = inputParams.end;1704 sliceParam.endList = inputParams.end;
@@ -1751,8 +1727,8 @@ static void MakePerformanceParamsNeg(SliceParametersRuntime2& param)
1751 const auto outputShapeI = param.outputShape[i];1727 const auto outputShapeI = param.outputShape[i];
1752 const auto beginI = param.beginList[i];1728 const auto beginI = param.beginList[i];
1753 const auto endI = param.endList[i];1729 const auto endI = param.endList[i];
1754- const auto stride_i =1730+ const auto stride_i = endI > beginI ? std::min(param.strideList[i], endI - beginI) :
1755- endI > beginI ? std::min(param.strideList[i], endI - beginI) : std::max(param.strideList[i], endI - beginI);1731+ std::max(param.strideList[i], endI - beginI);
1756 if (inputShapeI == 1 && outputShapeI == 1 && i != 0) {1732 if (inputShapeI == 1 && outputShapeI == 1 && i != 0) {
1757 continue;1733 continue;
1758 }1734 }
@@ -1836,8 +1812,9 @@ static void MakePerformanceParams(SliceParametersRuntime2& param, bool isAdjustL
1836 const auto stride_i = endI > beginI ? std::min(param.strideList[i], endI - beginI) : param.strideList[i];1812 const auto stride_i = endI > beginI ? std::min(param.strideList[i], endI - beginI) : param.strideList[i];
1837 if (i == 0 || inputShapeI != outputShapeI || stride_i != 1 || perfParams.strideList[perfSize - 1] != 1 ||1813 if (i == 0 || inputShapeI != outputShapeI || stride_i != 1 || perfParams.strideList[perfSize - 1] != 1 ||
1838 (!param.isBeginConst && (beginI < 0 || (i > 0 && param.beginList[i - 1] < 0)))) {1814 (!param.isBeginConst && (beginI < 0 || (i > 0 && param.beginList[i - 1] < 0)))) {
1839- int64_t realBeginValue =1815+ int64_t realBeginValue = (!param.isBeginConst && beginI < 0) ?
1840- (!param.isBeginConst && beginI < 0) ? (UNCONST_BEGIN_VALUE - static_cast<int64_t>(i)) : beginI;1816+ (UNCONST_BEGIN_VALUE - static_cast<int64_t>(i)) :
1817+ beginI;
1841 perfParams.inputShape.AppendDim(inputShapeI);1818 perfParams.inputShape.AppendDim(inputShapeI);
1842 perfParams.outputShape.AppendDim(outputShapeI);1819 perfParams.outputShape.AppendDim(outputShapeI);
1843 perfParams.beginList.AppendDim(realBeginValue);1820 perfParams.beginList.AppendDim(realBeginValue);
@@ -1884,9 +1861,9 @@ static void MakeSameDims(SliceParametersRuntime2* parametersPtr)
1884 }1861 }
1885}1862}
1886 1863 
1887-ge::graphStatus StrideSliceTilingForAscendC(1864+ge::graphStatus StrideSliceTilingForAscendC(gert::TilingContext* tilingContext, int64_t coreNum, int64_t ubSize,
1888- gert::TilingContext* tilingContext, int64_t coreNum, int64_t ubSize, int64_t cachelineSize,1865+ int64_t cachelineSize, SliceParametersRuntime2& sliceParam,
1889- SliceParametersRuntime2& sliceParam, const ge::DataType& dtype)1866+ const ge::DataType& dtype)
1890{1867{
1891 StrideSliceTiling tilingObject(tilingContext);1868 StrideSliceTiling tilingObject(tilingContext);
1892 if (tilingObject.Init(coreNum, ubSize, cachelineSize, sliceParam, dtype) != ge::GRAPH_SUCCESS) {1869 if (tilingObject.Init(coreNum, ubSize, cachelineSize, sliceParam, dtype) != ge::GRAPH_SUCCESS) {
@@ -1905,16 +1882,16 @@ ge::graphStatus TilingPrepare4StridedSlice(gert::TilingParseContext* context)
1905 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);1882 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);
1906 ci->coreNum = ascendcPlatform.GetCoreNumAiv();1883 ci->coreNum = ascendcPlatform.GetCoreNumAiv();
1907 ci->isAscendc = true;1884 ci->isAscendc = true;
1908- OP_CHECK_IF((ci->coreNum <= 0), OP_LOGE(context->GetNodeName(), "Failed to core num."), return ge::GRAPH_FAILED);1885+ OP_CHECK_IF((ci->coreNum <= 0), OP_LOGE(context->GetNodeName(), "Failed to get core number."),
1886+ return ge::GRAPH_FAILED);
1909 uint64_t ubSize;1887 uint64_t ubSize;
1910 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);1888 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);
1911 ci->ubSize = static_cast<int64_t>(ubSize);1889 ci->ubSize = static_cast<int64_t>(ubSize);
1912 OP_CHECK_IF((ci->ubSize <= 0), OP_LOGE(context->GetNodeName(), "Failed to get ub size."), return ge::GRAPH_FAILED);1890 OP_CHECK_IF((ci->ubSize <= 0), OP_LOGE(context->GetNodeName(), "Failed to get ub size."), return ge::GRAPH_FAILED);
1913 1891 
1914 ci->cacheLineSize = Ops::Base::GetCacheLineSize(context);1892 ci->cacheLineSize = Ops::Base::GetCacheLineSize(context);
1915- OP_CHECK_IF(1893+ OP_CHECK_IF((ci->cacheLineSize == 0), OP_LOGE(context->GetNodeName(), "Failed to get cacheLineSize."),
1916- (ci->cacheLineSize == 0), OP_LOGE(context->GetNodeName(), "Failed to get cacheLineSize."),1894+ return ge::GRAPH_FAILED);
1917- return ge::GRAPH_FAILED);
1918 return ge::GRAPH_SUCCESS;1895 return ge::GRAPH_SUCCESS;
1919}1896}
1920 1897 
@@ -1952,22 +1929,21 @@ ge::graphStatus Tiling4StridedSlice(gert::TilingContext* context)
1952 const gert::StorageShape* xStorage = context->GetInputShape(INDEX_X);1929 const gert::StorageShape* xStorage = context->GetInputShape(INDEX_X);
1953 OP_CHECK_NULL_WITH_CONTEXT(context, xStorage);1930 OP_CHECK_NULL_WITH_CONTEXT(context, xStorage);
1954 const gert::Shape& shapeInput = Ops::Base::EnsureNotScalar(xStorage->GetStorageShape());1931 const gert::Shape& shapeInput = Ops::Base::EnsureNotScalar(xStorage->GetStorageShape());
1955- ops::StridedSliceParams inputParams = {1932+ ops::StridedSliceParams inputParams = {shapeInput,
1956- shapeInput,1933+ sliceParam.beginList,
1957- sliceParam.beginList,1934+ sliceParam.endList,
1958- sliceParam.endList,1935+ sliceParam.strideList,
1959- sliceParam.strideList,1936+ static_cast<uint64_t>(*maskBegin),
1960- static_cast<uint64_t>(*maskBegin),1937+ static_cast<uint64_t>(*maskEnd),
1961- static_cast<uint64_t>(*maskEnd),1938+ static_cast<uint64_t>(*maskEllipsis),
1962- static_cast<uint64_t>(*maskEllipsis),1939+ static_cast<uint64_t>(*maskNewAxis),
1963- static_cast<uint64_t>(*maskNewAxis),1940+ static_cast<uint64_t>(*maskShrinkAxis),
1964- static_cast<uint64_t>(*maskShrinkAxis),1941+ true,
1965- true,1942+ true,
1966- true,1943+ true,
1967- true,1944+ sliceParam.isBeginConst,
1968- sliceParam.isBeginConst,1945+ sliceParam.isEndConst,
1969- sliceParam.isEndConst,1946+ shapeInput};
1970- shapeInput};
1971 gert::Shape shapeOutput;1947 gert::Shape shapeOutput;
1972 if (!ops::InferShape(inputParams, &shapeOutput)) {1948 if (!ops::InferShape(inputParams, &shapeOutput)) {
1973 return ge::GRAPH_FAILED;1949 return ge::GRAPH_FAILED;
@@ -1988,9 +1964,8 @@ ge::graphStatus Tiling4StridedSlice(gert::TilingContext* context)
1988 OP_CHECK_NULL_WITH_CONTEXT(context, xDesc);1964 OP_CHECK_NULL_WITH_CONTEXT(context, xDesc);
1989 1965 
1990 if (compileInfo->isAscendc) {1966 if (compileInfo->isAscendc) {
1991- return StrideSliceTilingForAscendC(1967+ return StrideSliceTilingForAscendC(context, compileInfo->coreNum, compileInfo->ubSize,
1992- context, compileInfo->coreNum, compileInfo->ubSize, compileInfo->cacheLineSize, sliceParam,1968+ compileInfo->cacheLineSize, sliceParam, xDesc->GetDataType());
1993- xDesc->GetDataType());
1994 }1969 }
1995 1970 
1996 return ge::GRAPH_SUCCESS;1971 return ge::GRAPH_SUCCESS;
@@ -2000,4 +1975,4 @@ IMPL_OP_OPTILING(StridedSlice)
2000 .Tiling(Tiling4StridedSlice)1975 .Tiling(Tiling4StridedSlice)
2001 .TilingParse<StridedSliceCompileInfo>(TilingPrepare4StridedSlice);1976 .TilingParse<StridedSliceCompileInfo>(TilingPrepare4StridedSlice);
2002 1977 
2003-} // namespace optiling1978+} // namespace optiling
@@ -263,7 +263,7 @@ uint32_t StridedSliceCpuKernel::ParseIndexInput(const CpuKernelContext& ctx, uin
263 break;263 break;
264 }264 }
265 default:265 default:
266- KERNEL_LOG_ERROR("[%s] input[%u] data_tpye must be in {int32 int64}.", kStridedSlice, index);266+ KERNEL_LOG_ERROR("[%s] input[%u] data_type must be in {int32 int64}.", kStridedSlice, index);
267 return KERNEL_STATUS_PARAM_INVALID;267 return KERNEL_STATUS_PARAM_INVALID;
268 }268 }
269 269 
@@ -285,7 +285,7 @@ uint32_t StridedSliceV2CpuKernel::DoStridedSliceV2(const CpuKernelContext& ctx,
285 STRIDED_SLICE_V2_CASE(DT_QUINT8, uint8_t)285 STRIDED_SLICE_V2_CASE(DT_QUINT8, uint8_t)
286 STRIDED_SLICE_V2_CASE(DT_QUINT16, uint16_t)286 STRIDED_SLICE_V2_CASE(DT_QUINT16, uint16_t)
287 default:287 default:
288- KERNEL_LOG_ERROR("%s kernel data type [%s] not support.", kStridedSliceV2, DTypeStr(data_type).c_str());288+ KERNEL_LOG_ERROR("%s kernel data type [%s] not supported.", kStridedSliceV2, DTypeStr(data_type).c_str());
289 return KERNEL_STATUS_PARAM_INVALID;289 return KERNEL_STATUS_PARAM_INVALID;
290 }290 }
291#undef STRIDED_SLICE_V2_CASE291#undef STRIDED_SLICE_V2_CASE
@@ -37,14 +37,10 @@ static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST = {
37 op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_INT64, op::DataType::DT_INT8,37 op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_INT64, op::DataType::DT_INT8,
38 op::DataType::DT_INT32, op::DataType::DT_UINT8, op::DataType::DT_BOOL, op::DataType::DT_BF16};38 op::DataType::DT_INT32, op::DataType::DT_UINT8, op::DataType::DT_BOOL, op::DataType::DT_BF16};
39 39 
40-static inline int64_t GetPosDim(int64_t dim, int64_t dimNum)40+static inline int64_t GetPosDim(int64_t dim, int64_t dimNum) { return dim >= 0 ? dim : dim + dimNum; }
41-{
42- return dim >= 0 ? dim : dim + dimNum;
43-}
44 41 
45-inline static bool CheckNotNull(42+inline static bool CheckNotNull(const aclTensor* self, const aclIntArray* starts, const aclIntArray* ends,
46- const aclTensor* self, const aclIntArray* starts, const aclIntArray* ends, const aclIntArray* axes,43+ const aclIntArray* axes, const aclIntArray* steps, aclTensor* out)
47- const aclIntArray* steps, aclTensor* out)
48{44{
49 OP_CHECK_NULL(self, return false);45 OP_CHECK_NULL(self, return false);
50 OP_CHECK_NULL(out, return false);46 OP_CHECK_NULL(out, return false);
@@ -67,7 +63,8 @@ static bool CheckDtypeValid(const aclTensor* self, const aclTensor* out)
67 OP_CHECK_DTYPE_NOT_MATCH(out, self->GetDataType(), return false);63 OP_CHECK_DTYPE_NOT_MATCH(out, self->GetDataType(), return false);
68 64 
69 if (!CheckSocVersionIsSupportBf16() && (self->GetDataType() == op::DataType::DT_BF16)) {65 if (!CheckSocVersionIsSupportBf16() && (self->GetDataType() == op::DataType::DT_BF16)) {
70- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Input dtype of aclnnSliceV2 is not support bfloat16 in current socversion.");66+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
67+ "Input dtype of aclnnSliceV2 is not supported bfloat16 in current socversion.");
71 return false;68 return false;
72 }69 }
73 70 
@@ -86,16 +83,16 @@ static bool CheckAxesValid(const aclTensor* self, const aclIntArray* axes)
86 83 
87 for (uint64_t i = 0; i < axes->Size(); i++) {84 for (uint64_t i = 0; i < axes->Size(); i++) {
88 if (axes->operator[](i) >= selfDimNum || axes->operator[](i) < (-selfDimNum)) {85 if (axes->operator[](i) >= selfDimNum || axes->operator[](i) < (-selfDimNum)) {
89- OP_LOGE(86+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
90- ACLNN_ERR_PARAM_INVALID, "Provided aclnnSliceV2 axes %ld not in the range of input tensor size %ld.",87+ "Provided aclnnSliceV2 axes %ld not in the range of input tensor size %ld.", axes->operator[](i),
91- axes->operator[](i), selfDimNum);88+ selfDimNum);
92 return false;89 return false;
93 }90 }
94 int64_t index = GetPosDim(axes->operator[](i), selfDimNum);91 int64_t index = GetPosDim(axes->operator[](i), selfDimNum);
95 // dim重复92 // dim重复
96 if (dimMask[index]) {93 if (dimMask[index]) {
97- OP_LOGE(94+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "aclnnSliceV2 axes %ld appears multiple times in the list of dims.",
98- ACLNN_ERR_PARAM_INVALID, "aclnnSliceV2 axes %ld appears multiple times in the list of dims.", index);95+ index);
99 return false;96 return false;
100 }97 }
101 98 
@@ -105,19 +102,17 @@ static bool CheckAxesValid(const aclTensor* self, const aclIntArray* axes)
105 return true;102 return true;
106}103}
107 104 
108-static bool CheckArray(105+static bool CheckArray(const aclIntArray* starts, const aclIntArray* ends, const aclIntArray* axes,
109- const aclIntArray* starts, const aclIntArray* ends, const aclIntArray* axes, const aclIntArray* steps)106+ const aclIntArray* steps)
110{107{
111 if (starts->Size() != axes->Size()) {108 if (starts->Size() != axes->Size()) {
112- OP_LOGE(109+ OP_LOGE(ACLNN_ERR_PARAM_NULLPTR, "Expected aclnnSliceV2 starts.size() %lu to be equal to axes.size() %lu.",
113- ACLNN_ERR_PARAM_NULLPTR, "Expected aclnnSliceV2 starts.size() %lu to be equal to axes.size() %lu.",110+ starts->Size(), axes->Size());
114- starts->Size(), axes->Size());
115 return false;111 return false;
116 }112 }
117 if (ends->Size() != axes->Size()) {113 if (ends->Size() != axes->Size()) {
118- OP_LOGE(114+ OP_LOGE(ACLNN_ERR_PARAM_NULLPTR, "Expected aclnnSliceV2 ends.size() %lu to be equal to axes.size() %lu.",
119- ACLNN_ERR_PARAM_NULLPTR, "Expected aclnnSliceV2 ends.size() %lu to be equal to axes.size() %lu.",115+ ends->Size(), axes->Size());
120- ends->Size(), axes->Size());
121 return false;116 return false;
122 }117 }
123 for (uint64_t i = 0; i < steps->Size(); i++) {118 for (uint64_t i = 0; i < steps->Size(); i++) {
@@ -149,9 +144,8 @@ static void CalculateValuesSliceLowerForSliceV2(const aclTensor* self, int64_t&
149 }144 }
150}145}
151 146 
152-static bool CheckShape(147+static bool CheckShape(const aclTensor* self, const aclIntArray* starts, const aclIntArray* ends,
153- const aclTensor* self, const aclIntArray* starts, const aclIntArray* ends, const aclIntArray* axes,148+ const aclIntArray* axes, const aclIntArray* steps, const aclTensor* out)
154- const aclIntArray* steps, const aclTensor* out)
155{149{
156 auto sliceShape = self->GetViewShape();150 auto sliceShape = self->GetViewShape();
157 int64_t start, end, dim, step, sliceNum;151 int64_t start, end, dim, step, sliceNum;
@@ -168,17 +162,15 @@ static bool CheckShape(
168 auto outShape = out->GetViewShape();162 auto outShape = out->GetViewShape();
169 // 校验输出shape163 // 校验输出shape
170 if (sliceShape != outShape) {164 if (sliceShape != outShape) {
171- OP_LOGE(165+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Shape of aclnnSliceV2 out should be %s, but current is %s.",
172- ACLNN_ERR_PARAM_INVALID, "Shape of aclnnSliceV2 out should be %s, but current is %s.",166+ op::ToString(sliceShape).GetString(), op::ToString(outShape).GetString());
173- op::ToString(sliceShape).GetString(), op::ToString(outShape).GetString());
174 return false;167 return false;
175 }168 }
176 return true;169 return true;
177}170}
178 171 
179-inline static aclnnStatus CheckParams(172+inline static aclnnStatus CheckParams(const aclTensor* self, const aclIntArray* starts, const aclIntArray* ends,
180- const aclTensor* self, const aclIntArray* starts, const aclIntArray* ends, const aclIntArray* axes,173+ const aclIntArray* axes, const aclIntArray* steps, aclTensor* out)
181- const aclIntArray* steps, aclTensor* out)
182{174{
183 // 1. 检查参数是否为空指针175 // 1. 检查参数是否为空指针
184 CHECK_RET(CheckNotNull(self, starts, ends, axes, steps, out), ACLNN_ERR_PARAM_NULLPTR);176 CHECK_RET(CheckNotNull(self, starts, ends, axes, steps, out), ACLNN_ERR_PARAM_NULLPTR);
@@ -201,9 +193,9 @@ inline static aclnnStatus CheckParams(
201 return ACLNN_SUCCESS;193 return ACLNN_SUCCESS;
202}194}
203 195 
204-aclnnStatus aclnnSliceV2GetWorkspaceSize(196+aclnnStatus aclnnSliceV2GetWorkspaceSize(const aclTensor* self, const aclIntArray* starts, const aclIntArray* ends,
205- const aclTensor* self, const aclIntArray* starts, const aclIntArray* ends, const aclIntArray* axes,197+ const aclIntArray* axes, const aclIntArray* steps, aclTensor* out,
206- const aclIntArray* steps, aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)198+ uint64_t* workspaceSize, aclOpExecutor** executor)
207{199{
208 OP_CHECK_COMM_INPUT(workspaceSize, executor);200 OP_CHECK_COMM_INPUT(workspaceSize, executor);
209 201 
@@ -104,7 +104,7 @@ static void CheckFormat(const aclTensor* self)
104{104{
105 op::Format format = self->GetStorageFormat();105 op::Format format = self->GetStorageFormat();
106 if (format == Format::FORMAT_FRACTAL_NZ) {106 if (format == Format::FORMAT_FRACTAL_NZ) {
107- OP_LOGW("Format of inputs gets [%s],this format mat lead to precision failure",107+ OP_LOGW("Format of inputs gets [%s],this format may lead to precision failure",
108 op::ToString(format).GetString());108 op::ToString(format).GetString());
109 }109 }
110}110}
@@ -32,160 +32,162 @@ extern "C" {
32constexpr size_t MAX_DIM_LEN = 8;32constexpr size_t MAX_DIM_LEN = 8;
33 33 
34static const std::initializer_list<op::DataType> DTYPE_SUPPORT_910_LIST = {34static const std::initializer_list<op::DataType> DTYPE_SUPPORT_910_LIST = {
35- op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16,35+ op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_INT64, op::DataType::DT_BOOL};
36- op::DataType::DT_INT64, op::DataType::DT_BOOL};
37 36 
38static const std::initializer_list<op::DataType> DTYPE_SUPPORT_GE910B_LIST = {37static const std::initializer_list<op::DataType> DTYPE_SUPPORT_GE910B_LIST = {
39- op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16,38+ op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_INT64, op::DataType::DT_BOOL,
40- op::DataType::DT_INT64, op::DataType::DT_BOOL,
41 op::DataType::DT_BF16};39 op::DataType::DT_BF16};
42namespace {40namespace {
43static const std::initializer_list<op::DataType> DTYPE_SUPPORT_REGBASE_LIST = {41static const std::initializer_list<op::DataType> DTYPE_SUPPORT_REGBASE_LIST = {
44- op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16,42+ op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_INT64,
45- op::DataType::DT_INT64, op::DataType::DT_BOOL,43+ op::DataType::DT_BOOL, op::DataType::DT_BF16, op::DataType::DT_INT32};
46- op::DataType::DT_BF16, op::DataType::DT_INT32};
47}44}
48 45 
49// 判断芯片类型是否大于等于910B46// 判断芯片类型是否大于等于910B
50-static inline bool CheckSocVersionGe910B(void) {47+static inline bool CheckSocVersionGe910B(void)
51- auto curArch = GetCurrentPlatformInfo().GetCurNpuArch();48+{
52- return curArch == NpuArch::DAV_2201 || IsRegBase(curArch);49+ auto curArch = GetCurrentPlatformInfo().GetCurNpuArch();
50+ return curArch == NpuArch::DAV_2201 || IsRegBase(curArch);
53}51}
54 52 
55// 判断芯片类型是否大于等于91053// 判断芯片类型是否大于等于910
56-static inline bool CheckSocVersionGe910(void) {54+static inline bool CheckSocVersionGe910(void)
57- auto curArch = GetCurrentPlatformInfo().GetCurNpuArch();
58- return curArch == NpuArch::DAV_1001 ||
59- curArch == NpuArch::DAV_2201 || IsRegBase(curArch);
60-}
61- 
62-static bool CheckDtypeValid(const aclTensor *self, const aclTensor *out) {
63- std::initializer_list<DataType> CURRENT_DTYPE_SUPPORT_LIST;
64- if (IsRegBase()) {
65- CURRENT_DTYPE_SUPPORT_LIST = DTYPE_SUPPORT_REGBASE_LIST;
66- } else {
67- bool isGe910BSocVersion = CheckSocVersionGe910B();
68- CURRENT_DTYPE_SUPPORT_LIST = isGe910BSocVersion ? DTYPE_SUPPORT_GE910B_LIST : DTYPE_SUPPORT_910_LIST;
69- }
70- 
71- OP_CHECK_DTYPE_NOT_SUPPORT(self, CURRENT_DTYPE_SUPPORT_LIST, return false);
72- OP_CHECK_DTYPE_NOT_SAME(self, out, return false);
73- return true;
74-}
75- 
76-static bool CheckNotNull(const aclTensor *self, const aclTensor *out, const aclTensor *indices) {
77- OP_CHECK_NULL(self, return false);
78- OP_CHECK_NULL(out, return false);
79- OP_CHECK_NULL(indices, return false);
80- return true;
81-}
82- 
83-static bool CheckShape(const aclTensor *self, const aclTensor *out, const aclTensor *indices) {
84- OP_CHECK_MAX_DIM(self, MAX_DIM_LEN, return false);
85- OP_CHECK_MAX_DIM(out, MAX_DIM_LEN, return false);
86- OP_CHECK_MAX_DIM(indices, MAX_DIM_LEN, return false);
87- return true;
88-}
89- 
90-static bool CheckDim(const aclTensor *self, const int64_t dim)
91{55{
92- int64_t shapeSize = self->GetViewShape().GetDimNum();56+ auto curArch = GetCurrentPlatformInfo().GetCurNpuArch();
93- int64_t dimMin = -1 * shapeSize;57+ return curArch == NpuArch::DAV_1001 || curArch == NpuArch::DAV_2201 || IsRegBase(curArch);
94- int64_t dimMax = shapeSize - 1;
95- if (shapeSize == 0) {
96- dimMin = -1;
97- dimMax = 0;
98- }
99- if ((dim > dimMax) || (dim < dimMin)) {
100- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "dim should within the range of [[%ld], [%ld]].", dimMin, dimMax);
101- return false;
102- }
103- return true;
104}58}
105 59 
106-static aclnnStatus CheckParams(const aclTensor *self, const int64_t dim,60+static bool CheckDtypeValid(const aclTensor* self, const aclTensor* out)
107- const aclTensor *out, const aclTensor *indices) {61+{
108- // 1. 检查参数是否为空指针62+ std::initializer_list<DataType> CURRENT_DTYPE_SUPPORT_LIST;
109- CHECK_RET(CheckNotNull(self, out, indices), ACLNN_ERR_PARAM_NULLPTR);63+ if (IsRegBase()) {
64+ CURRENT_DTYPE_SUPPORT_LIST = DTYPE_SUPPORT_REGBASE_LIST;
65+ } else {
66+ bool isGe910BSocVersion = CheckSocVersionGe910B();
67+ CURRENT_DTYPE_SUPPORT_LIST = isGe910BSocVersion ? DTYPE_SUPPORT_GE910B_LIST : DTYPE_SUPPORT_910_LIST;
68+ }
110 69 
111- // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验70+ OP_CHECK_DTYPE_NOT_SUPPORT(self, CURRENT_DTYPE_SUPPORT_LIST, return false);
112- CHECK_RET(CheckDtypeValid(self, out), ACLNN_ERR_PARAM_INVALID);71+ OP_CHECK_DTYPE_NOT_SAME(self, out, return false);
113- 72+ return true;
114- // 3. 检查shape是否支持
115- CHECK_RET(CheckShape(self, out, indices), ACLNN_ERR_PARAM_INVALID);
116- 
117- // 4. 检查dim是在支持范围内
118- CHECK_RET(CheckDim(self, dim), ACLNN_ERR_PARAM_INVALID);
119- 
120- return ACLNN_SUCCESS;
121}73}
122 74 
123-aclnnStatus aclnnMaxDimGetWorkspaceSize(const aclTensor *self, int64_t dim, bool keepdim,75+static bool CheckNotNull(const aclTensor* self, const aclTensor* out, const aclTensor* indices)
124- aclTensor *out, aclTensor *indices, uint64_t *workspaceSize, aclOpExecutor **executor) {76+{
125- L2_DFX_PHASE_1(aclnnMaxDim, DFX_IN(self, dim, keepdim), DFX_OUT(out, indices));77+ OP_CHECK_NULL(self, return false);
78+ OP_CHECK_NULL(out, return false);
79+ OP_CHECK_NULL(indices, return false);
80+ return true;
81+}
126 82 
127- auto ret = CheckParams(self, dim, out, indices);83+static bool CheckShape(const aclTensor* self, const aclTensor* out, const aclTensor* indices)
128- CHECK_RET(ret == ACLNN_SUCCESS, ret);84+{
85+ OP_CHECK_MAX_DIM(self, MAX_DIM_LEN, return false);
86+ OP_CHECK_MAX_DIM(out, MAX_DIM_LEN, return false);
87+ OP_CHECK_MAX_DIM(indices, MAX_DIM_LEN, return false);
88+ return true;
89+}
129 90 
130- auto uniqueExecutor = CREATE_EXECUTOR();91+static bool CheckDim(const aclTensor* self, const int64_t dim)
131- CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR);92+{
93+ int64_t shapeSize = self->GetViewShape().GetDimNum();
94+ int64_t dimMin = -1 * shapeSize;
95+ int64_t dimMax = shapeSize - 1;
96+ if (shapeSize == 0) {
97+ dimMin = -1;
98+ dimMax = 0;
99+ }
100+ if ((dim > dimMax) || (dim < dimMin)) {
101+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "dim should be within the range of [[%ld], [%ld]].", dimMin, dimMax);
102+ return false;
103+ }
104+ return true;
105+}
106+ 
107+static aclnnStatus CheckParams(const aclTensor* self, const int64_t dim, const aclTensor* out, const aclTensor* indices)
108+{
109+ // 1. 检查参数是否为空指针
110+ CHECK_RET(CheckNotNull(self, out, indices), ACLNN_ERR_PARAM_NULLPTR);
111+ 
112+ // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验
113+ CHECK_RET(CheckDtypeValid(self, out), ACLNN_ERR_PARAM_INVALID);
114+ 
115+ // 3. 检查shape是否支持
116+ CHECK_RET(CheckShape(self, out, indices), ACLNN_ERR_PARAM_INVALID);
117+ 
118+ // 4. 检查dim是在支持范围内
119+ CHECK_RET(CheckDim(self, dim), ACLNN_ERR_PARAM_INVALID);
132 120 
133- if (self->IsEmpty()) {
134- *workspaceSize = 0;
135- uniqueExecutor.ReleaseTo(executor);
136 return ACLNN_SUCCESS;121 return ACLNN_SUCCESS;
137- }
138- 
139- auto self_contiguous = l0op::Contiguous(self, uniqueExecutor.get());
140- CHECK_RET(self_contiguous != nullptr, ACLNN_ERR_PARAM_NULLPTR);
141- 
142- const aclTensor *self_cast;
143- bool isGe910SocVersion = CheckSocVersionGe910();
144- if (self->GetDataType() == op::DataType::DT_BOOL) {
145- self_cast = l0op::Cast(self_contiguous, op::DataType::DT_FLOAT, uniqueExecutor.get());
146- CHECK_RET(self_cast != nullptr, ACLNN_ERR_PARAM_NULLPTR);
147- } else if (self->GetDataType() == op::DataType::DT_INT64 && !isGe910SocVersion) {
148- self_cast = l0op::Cast(self_contiguous, op::DataType::DT_FLOAT, uniqueExecutor.get());
149- CHECK_RET(self_cast != nullptr, ACLNN_ERR_PARAM_NULLPTR);
150- } else {
151- self_cast = self_contiguous;
152- }
153- 
154- std::tuple<aclTensor*, aclTensor*> result;
155- if (IsRegBase()) {
156- result = l0op::ArgMaxWithValue(self_cast, dim, keepdim, indices->GetDataType(), uniqueExecutor.get());
157- } else {
158- result = l0op::ArgMaxWithValue(self_cast, dim, keepdim, op::DataType::DT_INT32, uniqueExecutor.get());
159- }
160- CHECK_RET(std::get<0>(result) != nullptr, ACLNN_ERR_PARAM_NULLPTR);
161- CHECK_RET(std::get<1>(result) != nullptr, ACLNN_ERR_PARAM_NULLPTR);
162- auto argmax_indices = std::get<0>(result);
163- auto argmax_out = std::get<1>(result);
164- CHECK_RET(CheckShapeAndScalarSame(argmax_indices, indices), ACLNN_ERR_PARAM_INVALID);
165- CHECK_RET(CheckShapeAndScalarSame(argmax_out, out), ACLNN_ERR_PARAM_INVALID);
166- 
167- auto indices_res = l0op::Cast(argmax_indices, indices->GetDataType(), uniqueExecutor.get());
168- CHECK_RET(indices_res != nullptr, ACLNN_ERR_PARAM_NULLPTR);
169- auto out_res = l0op::Cast(argmax_out, out->GetDataType(), uniqueExecutor.get());
170- CHECK_RET(out_res != nullptr, ACLNN_ERR_PARAM_NULLPTR);
171- 
172- auto indices_view_copy_result = l0op::ViewCopy(indices_res, indices, uniqueExecutor.get());
173- CHECK_RET(indices_view_copy_result != nullptr, ACLNN_ERR_PARAM_NULLPTR);
174- auto out_view_copy_result = l0op::ViewCopy(out_res, out, uniqueExecutor.get());
175- CHECK_RET(out_view_copy_result != nullptr, ACLNN_ERR_PARAM_NULLPTR);
176- 
177- *workspaceSize = uniqueExecutor->GetWorkspaceSize();
178- uniqueExecutor.ReleaseTo(executor);
179- 
180- return ACLNN_SUCCESS;
181}122}
182 123 
183-aclnnStatus aclnnMaxDim(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream) {124+aclnnStatus aclnnMaxDimGetWorkspaceSize(const aclTensor* self, int64_t dim, bool keepdim, aclTensor* out,
184- L2_DFX_PHASE_2(aclnnMaxDim);125+ aclTensor* indices, uint64_t* workspaceSize, aclOpExecutor** executor)
185- return CommonOpExecutorRun(workspace, workspaceSize, executor, stream);126+{
127+ L2_DFX_PHASE_1(aclnnMaxDim, DFX_IN(self, dim, keepdim), DFX_OUT(out, indices));
128+ 
129+ auto ret = CheckParams(self, dim, out, indices);
130+ CHECK_RET(ret == ACLNN_SUCCESS, ret);
131+ 
132+ auto uniqueExecutor = CREATE_EXECUTOR();
133+ CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR);
134+ 
135+ if (self->IsEmpty()) {
136+ *workspaceSize = 0;
137+ uniqueExecutor.ReleaseTo(executor);
138+ return ACLNN_SUCCESS;
139+ }
140+ 
141+ auto self_contiguous = l0op::Contiguous(self, uniqueExecutor.get());
142+ CHECK_RET(self_contiguous != nullptr, ACLNN_ERR_PARAM_NULLPTR);
143+ 
144+ const aclTensor* self_cast;
145+ bool isGe910SocVersion = CheckSocVersionGe910();
146+ if (self->GetDataType() == op::DataType::DT_BOOL) {
147+ self_cast = l0op::Cast(self_contiguous, op::DataType::DT_FLOAT, uniqueExecutor.get());
148+ CHECK_RET(self_cast != nullptr, ACLNN_ERR_PARAM_NULLPTR);
149+ } else if (self->GetDataType() == op::DataType::DT_INT64 && !isGe910SocVersion) {
150+ self_cast = l0op::Cast(self_contiguous, op::DataType::DT_FLOAT, uniqueExecutor.get());
151+ CHECK_RET(self_cast != nullptr, ACLNN_ERR_PARAM_NULLPTR);
152+ } else {
153+ self_cast = self_contiguous;
154+ }
155+ 
156+ std::tuple<aclTensor*, aclTensor*> result;
157+ if (IsRegBase()) {
158+ result = l0op::ArgMaxWithValue(self_cast, dim, keepdim, indices->GetDataType(), uniqueExecutor.get());
159+ } else {
160+ result = l0op::ArgMaxWithValue(self_cast, dim, keepdim, op::DataType::DT_INT32, uniqueExecutor.get());
161+ }
162+ CHECK_RET(std::get<0>(result) != nullptr, ACLNN_ERR_PARAM_NULLPTR);
163+ CHECK_RET(std::get<1>(result) != nullptr, ACLNN_ERR_PARAM_NULLPTR);
164+ auto argmax_indices = std::get<0>(result);
165+ auto argmax_out = std::get<1>(result);
166+ CHECK_RET(CheckShapeAndScalarSame(argmax_indices, indices), ACLNN_ERR_PARAM_INVALID);
167+ CHECK_RET(CheckShapeAndScalarSame(argmax_out, out), ACLNN_ERR_PARAM_INVALID);
168+ 
169+ auto indices_res = l0op::Cast(argmax_indices, indices->GetDataType(), uniqueExecutor.get());
170+ CHECK_RET(indices_res != nullptr, ACLNN_ERR_PARAM_NULLPTR);
171+ auto out_res = l0op::Cast(argmax_out, out->GetDataType(), uniqueExecutor.get());
172+ CHECK_RET(out_res != nullptr, ACLNN_ERR_PARAM_NULLPTR);
173+ 
174+ auto indices_view_copy_result = l0op::ViewCopy(indices_res, indices, uniqueExecutor.get());
175+ CHECK_RET(indices_view_copy_result != nullptr, ACLNN_ERR_PARAM_NULLPTR);
176+ auto out_view_copy_result = l0op::ViewCopy(out_res, out, uniqueExecutor.get());
177+ CHECK_RET(out_view_copy_result != nullptr, ACLNN_ERR_PARAM_NULLPTR);
178+ 
179+ *workspaceSize = uniqueExecutor->GetWorkspaceSize();
180+ uniqueExecutor.ReleaseTo(executor);
181+ 
182+ return ACLNN_SUCCESS;
183+}
184+ 
185+aclnnStatus aclnnMaxDim(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, aclrtStream stream)
186+{
187+ L2_DFX_PHASE_2(aclnnMaxDim);
188+ return CommonOpExecutorRun(workspace, workspaceSize, executor, stream);
186}189}
187 190 
188#ifdef __cplusplus191#ifdef __cplusplus
189}192}
190#endif193#endif
191- 
@@ -90,7 +90,7 @@ ge::graphStatus ArgOpsTiling(gert::TilingContext* context)
90 90 
91ge::graphStatus TilingPrepareForArgOpsAscendC(gert::TilingParseContext* context)91ge::graphStatus TilingPrepareForArgOpsAscendC(gert::TilingParseContext* context)
92{92{
93- OP_LOGD(context->GetNodeName(), "Entor TilingPrepare for ArgWithValue.");93+ OP_LOGD(context->GetNodeName(), "Enter TilingPrepare for ArgWithValue.");
94 auto ci = context->GetCompiledInfo<ArgOpsCompileInfo>();94 auto ci = context->GetCompiledInfo<ArgOpsCompileInfo>();
95 OP_CHECK_NULL_WITH_CONTEXT(context, ci);95 OP_CHECK_NULL_WITH_CONTEXT(context, ci);
96 auto platformInfo = context->GetPlatformInfo();96 auto platformInfo = context->GetPlatformInfo();
@@ -32,160 +32,162 @@ extern "C" {
32constexpr size_t MAX_DIM_LEN = 8;32constexpr size_t MAX_DIM_LEN = 8;
33 33 
34static const std::initializer_list<op::DataType> DTYPE_SUPPORT_910_LIST = {34static const std::initializer_list<op::DataType> DTYPE_SUPPORT_910_LIST = {
35- op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16,35+ op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_INT64, op::DataType::DT_BOOL};
36- op::DataType::DT_INT64, op::DataType::DT_BOOL};
37 36 
38static const std::initializer_list<op::DataType> DTYPE_SUPPORT_GE910B_LIST = {37static const std::initializer_list<op::DataType> DTYPE_SUPPORT_GE910B_LIST = {
39- op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16,38+ op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_INT64, op::DataType::DT_BOOL,
40- op::DataType::DT_INT64, op::DataType::DT_BOOL,
41 op::DataType::DT_BF16};39 op::DataType::DT_BF16};
42namespace {40namespace {
43static const std::initializer_list<op::DataType> DTYPE_SUPPORT_REGBASE_MIN_DIM_LIST = {41static const std::initializer_list<op::DataType> DTYPE_SUPPORT_REGBASE_MIN_DIM_LIST = {
44- op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16,42+ op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_INT64,
45- op::DataType::DT_INT64, op::DataType::DT_BOOL,43+ op::DataType::DT_BOOL, op::DataType::DT_BF16, op::DataType::DT_INT32};
46- op::DataType::DT_BF16, op::DataType::DT_INT32};
47}44}
48 45 
49// 判断芯片类型是否大于等于910B46// 判断芯片类型是否大于等于910B
50-static inline bool CheckSocVersionGe910B(void) {47+static inline bool CheckSocVersionGe910B(void)
51- auto curArch = GetCurrentPlatformInfo().GetCurNpuArch();48+{
52- return curArch == NpuArch::DAV_2201 || IsRegBase(curArch);49+ auto curArch = GetCurrentPlatformInfo().GetCurNpuArch();
50+ return curArch == NpuArch::DAV_2201 || IsRegBase(curArch);
53}51}
54 52 
55// 判断芯片类型是否大于等于91053// 判断芯片类型是否大于等于910
56-static inline bool CheckSocVersionGe910(void) {54+static inline bool CheckSocVersionGe910(void)
57- auto curArch = GetCurrentPlatformInfo().GetCurNpuArch();
58- return curArch == NpuArch::DAV_1001 || curArch == NpuArch::DAV_2201 ||
59- IsRegBase(curArch);
60-}
61- 
62-static bool CheckDtypeValid(const aclTensor *self, const aclTensor *out) {
63- std::initializer_list<DataType> CURRENT_DTYPE_SUPPORT_LIST;
64- if (IsRegBase()) {
65- CURRENT_DTYPE_SUPPORT_LIST = DTYPE_SUPPORT_REGBASE_MIN_DIM_LIST;
66- } else {
67- bool isGe910BSocVersion = CheckSocVersionGe910B();
68- CURRENT_DTYPE_SUPPORT_LIST = isGe910BSocVersion ? DTYPE_SUPPORT_GE910B_LIST : DTYPE_SUPPORT_910_LIST;
69- }
70- 
71- OP_CHECK_DTYPE_NOT_SUPPORT(self, CURRENT_DTYPE_SUPPORT_LIST, return false);
72- OP_CHECK_DTYPE_NOT_SAME(self, out, return false);
73- return true;
74-}
75- 
76-static bool CheckNotNull(const aclTensor *self, const aclTensor *out, const aclTensor *indices) {
77- OP_CHECK_NULL(self, return false);
78- OP_CHECK_NULL(out, return false);
79- OP_CHECK_NULL(indices, return false);
80- return true;
81-}
82- 
83-static bool CheckShape(const aclTensor *self, const aclTensor *out, const aclTensor *indices) {
84- OP_CHECK_MAX_DIM(self, MAX_DIM_LEN, return false);
85- OP_CHECK_MAX_DIM(out, MAX_DIM_LEN, return false);
86- OP_CHECK_MAX_DIM(indices, MAX_DIM_LEN, return false);
87- return true;
88-}
89- 
90-static bool CheckDim(const aclTensor *self, const int64_t dim)
91{55{
92- int64_t shapeSize = self->GetViewShape().GetDimNum();56+ auto curArch = GetCurrentPlatformInfo().GetCurNpuArch();
93- int64_t dimMin = -1 * shapeSize;57+ return curArch == NpuArch::DAV_1001 || curArch == NpuArch::DAV_2201 || IsRegBase(curArch);
94- int64_t dimMax = shapeSize - 1;
95- if (shapeSize == 0) {
96- dimMin = -1;
97- dimMax = 0;
98- }
99- if ((dim > dimMax) || (dim < dimMin)) {
100- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "dim should within the range of [[%ld], [%ld]].", dimMin, dimMax);
101- return false;
102- }
103- return true;
104}58}
105 59 
106-static aclnnStatus CheckParams(const aclTensor *self, const int64_t dim,60+static bool CheckDtypeValid(const aclTensor* self, const aclTensor* out)
107- const aclTensor *out, const aclTensor *indices) {61+{
108- // 1. 检查参数是否为空指针62+ std::initializer_list<DataType> CURRENT_DTYPE_SUPPORT_LIST;
109- CHECK_RET(CheckNotNull(self, out, indices), ACLNN_ERR_PARAM_NULLPTR);63+ if (IsRegBase()) {
64+ CURRENT_DTYPE_SUPPORT_LIST = DTYPE_SUPPORT_REGBASE_MIN_DIM_LIST;
65+ } else {
66+ bool isGe910BSocVersion = CheckSocVersionGe910B();
67+ CURRENT_DTYPE_SUPPORT_LIST = isGe910BSocVersion ? DTYPE_SUPPORT_GE910B_LIST : DTYPE_SUPPORT_910_LIST;
68+ }
110 69 
111- // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验70+ OP_CHECK_DTYPE_NOT_SUPPORT(self, CURRENT_DTYPE_SUPPORT_LIST, return false);
112- CHECK_RET(CheckDtypeValid(self, out), ACLNN_ERR_PARAM_INVALID);71+ OP_CHECK_DTYPE_NOT_SAME(self, out, return false);
113- 72+ return true;
114- // 3. 检查shape是否支持
115- CHECK_RET(CheckShape(self, out, indices), ACLNN_ERR_PARAM_INVALID);
116- 
117- // 4. 检查dim是在支持范围内
118- CHECK_RET(CheckDim(self, dim), ACLNN_ERR_PARAM_INVALID);
119- 
120- return ACLNN_SUCCESS;
121}73}
122 74 
123-aclnnStatus aclnnMinDimGetWorkspaceSize(const aclTensor *self, int64_t dim, bool keepdim,75+static bool CheckNotNull(const aclTensor* self, const aclTensor* out, const aclTensor* indices)
124- aclTensor *out, aclTensor *indices, uint64_t *workspaceSize, aclOpExecutor **executor) {76+{
125- L2_DFX_PHASE_1(aclnnMinDim, DFX_IN(self, dim, keepdim), DFX_OUT(out, indices));77+ OP_CHECK_NULL(self, return false);
78+ OP_CHECK_NULL(out, return false);
79+ OP_CHECK_NULL(indices, return false);
80+ return true;
81+}
126 82 
127- auto ret = CheckParams(self, dim, out, indices);83+static bool CheckShape(const aclTensor* self, const aclTensor* out, const aclTensor* indices)
128- CHECK_RET(ret == ACLNN_SUCCESS, ret);84+{
85+ OP_CHECK_MAX_DIM(self, MAX_DIM_LEN, return false);
86+ OP_CHECK_MAX_DIM(out, MAX_DIM_LEN, return false);
87+ OP_CHECK_MAX_DIM(indices, MAX_DIM_LEN, return false);
88+ return true;
89+}
129 90 
130- auto uniqueExecutor = CREATE_EXECUTOR();91+static bool CheckDim(const aclTensor* self, const int64_t dim)
131- CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR);92+{
93+ int64_t shapeSize = self->GetViewShape().GetDimNum();
94+ int64_t dimMin = -1 * shapeSize;
95+ int64_t dimMax = shapeSize - 1;
96+ if (shapeSize == 0) {
97+ dimMin = -1;
98+ dimMax = 0;
99+ }
100+ if ((dim > dimMax) || (dim < dimMin)) {
101+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "dim should be within the range of [[%ld], [%ld]].", dimMin, dimMax);
102+ return false;
103+ }
104+ return true;
105+}
106+ 
107+static aclnnStatus CheckParams(const aclTensor* self, const int64_t dim, const aclTensor* out, const aclTensor* indices)
108+{
109+ // 1. 检查参数是否为空指针
110+ CHECK_RET(CheckNotNull(self, out, indices), ACLNN_ERR_PARAM_NULLPTR);
111+ 
112+ // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验
113+ CHECK_RET(CheckDtypeValid(self, out), ACLNN_ERR_PARAM_INVALID);
114+ 
115+ // 3. 检查shape是否支持
116+ CHECK_RET(CheckShape(self, out, indices), ACLNN_ERR_PARAM_INVALID);
117+ 
118+ // 4. 检查dim是在支持范围内
119+ CHECK_RET(CheckDim(self, dim), ACLNN_ERR_PARAM_INVALID);
132 120 
133- if (self->IsEmpty()) {
134- *workspaceSize = 0;
135- uniqueExecutor.ReleaseTo(executor);
136 return ACLNN_SUCCESS;121 return ACLNN_SUCCESS;
137- }
138- 
139- auto self_contiguous = l0op::Contiguous(self, uniqueExecutor.get());
140- CHECK_RET(self_contiguous != nullptr, ACLNN_ERR_PARAM_NULLPTR);
141- 
142- const aclTensor *self_cast;
143- bool isGe910SocVersion = CheckSocVersionGe910();
144- if (self->GetDataType() == op::DataType::DT_BOOL) {
145- self_cast = l0op::Cast(self_contiguous, op::DataType::DT_FLOAT, uniqueExecutor.get());
146- CHECK_RET(self_cast != nullptr, ACLNN_ERR_PARAM_NULLPTR);
147- } else if (self->GetDataType() == op::DataType::DT_INT64 && !isGe910SocVersion) {
148- self_cast = l0op::Cast(self_contiguous, op::DataType::DT_FLOAT, uniqueExecutor.get());
149- CHECK_RET(self_cast != nullptr, ACLNN_ERR_PARAM_NULLPTR);
150- } else {
151- self_cast = self_contiguous;
152- }
153- 
154- std::tuple<aclTensor*, aclTensor*> result;
155- if (IsRegBase()) {
156- result = l0op::ArgMinWithValue(self_cast, dim, keepdim, indices->GetDataType(), uniqueExecutor.get());
157- } else {
158- result = l0op::ArgMinWithValue(self_cast, dim, keepdim, op::DataType::DT_INT32, uniqueExecutor.get());
159- }
160- CHECK_RET(std::get<0>(result) != nullptr, ACLNN_ERR_PARAM_NULLPTR);
161- CHECK_RET(std::get<1>(result) != nullptr, ACLNN_ERR_PARAM_NULLPTR);
162- auto argmin_indices = std::get<0>(result);
163- auto argmin_out = std::get<1>(result);
164- CHECK_RET(CheckShapeAndScalarSame(argmin_indices, indices), ACLNN_ERR_PARAM_INVALID);
165- CHECK_RET(CheckShapeAndScalarSame(argmin_out, out), ACLNN_ERR_PARAM_INVALID);
166- 
167- auto indices_res = l0op::Cast(argmin_indices, indices->GetDataType(), uniqueExecutor.get());
168- CHECK_RET(indices_res != nullptr, ACLNN_ERR_PARAM_NULLPTR);
169- auto out_res = l0op::Cast(argmin_out, out->GetDataType(), uniqueExecutor.get());
170- CHECK_RET(out_res != nullptr, ACLNN_ERR_PARAM_NULLPTR);
171- 
172- auto indices_view_copy_result = l0op::ViewCopy(indices_res, indices, uniqueExecutor.get());
173- CHECK_RET(indices_view_copy_result != nullptr, ACLNN_ERR_PARAM_NULLPTR);
174- auto out_view_copy_result = l0op::ViewCopy(out_res, out, uniqueExecutor.get());
175- CHECK_RET(out_view_copy_result != nullptr, ACLNN_ERR_PARAM_NULLPTR);
176- 
177- *workspaceSize = uniqueExecutor->GetWorkspaceSize();
178- uniqueExecutor.ReleaseTo(executor);
179- 
180- return ACLNN_SUCCESS;
181}122}
182 123 
183-aclnnStatus aclnnMinDim(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream) {124+aclnnStatus aclnnMinDimGetWorkspaceSize(const aclTensor* self, int64_t dim, bool keepdim, aclTensor* out,
184- L2_DFX_PHASE_2(aclnnMinDim);125+ aclTensor* indices, uint64_t* workspaceSize, aclOpExecutor** executor)
185- return CommonOpExecutorRun(workspace, workspaceSize, executor, stream);126+{
127+ L2_DFX_PHASE_1(aclnnMinDim, DFX_IN(self, dim, keepdim), DFX_OUT(out, indices));
128+ 
129+ auto ret = CheckParams(self, dim, out, indices);
130+ CHECK_RET(ret == ACLNN_SUCCESS, ret);
131+ 
132+ auto uniqueExecutor = CREATE_EXECUTOR();
133+ CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR);
134+ 
135+ if (self->IsEmpty()) {
136+ *workspaceSize = 0;
137+ uniqueExecutor.ReleaseTo(executor);
138+ return ACLNN_SUCCESS;
139+ }
140+ 
141+ auto self_contiguous = l0op::Contiguous(self, uniqueExecutor.get());
142+ CHECK_RET(self_contiguous != nullptr, ACLNN_ERR_PARAM_NULLPTR);
143+ 
144+ const aclTensor* self_cast;
145+ bool isGe910SocVersion = CheckSocVersionGe910();
146+ if (self->GetDataType() == op::DataType::DT_BOOL) {
147+ self_cast = l0op::Cast(self_contiguous, op::DataType::DT_FLOAT, uniqueExecutor.get());
148+ CHECK_RET(self_cast != nullptr, ACLNN_ERR_PARAM_NULLPTR);
149+ } else if (self->GetDataType() == op::DataType::DT_INT64 && !isGe910SocVersion) {
150+ self_cast = l0op::Cast(self_contiguous, op::DataType::DT_FLOAT, uniqueExecutor.get());
151+ CHECK_RET(self_cast != nullptr, ACLNN_ERR_PARAM_NULLPTR);
152+ } else {
153+ self_cast = self_contiguous;
154+ }
155+ 
156+ std::tuple<aclTensor*, aclTensor*> result;
157+ if (IsRegBase()) {
158+ result = l0op::ArgMinWithValue(self_cast, dim, keepdim, indices->GetDataType(), uniqueExecutor.get());
159+ } else {
160+ result = l0op::ArgMinWithValue(self_cast, dim, keepdim, op::DataType::DT_INT32, uniqueExecutor.get());
161+ }
162+ CHECK_RET(std::get<0>(result) != nullptr, ACLNN_ERR_PARAM_NULLPTR);
163+ CHECK_RET(std::get<1>(result) != nullptr, ACLNN_ERR_PARAM_NULLPTR);
164+ auto argmin_indices = std::get<0>(result);
165+ auto argmin_out = std::get<1>(result);
166+ CHECK_RET(CheckShapeAndScalarSame(argmin_indices, indices), ACLNN_ERR_PARAM_INVALID);
167+ CHECK_RET(CheckShapeAndScalarSame(argmin_out, out), ACLNN_ERR_PARAM_INVALID);
168+ 
169+ auto indices_res = l0op::Cast(argmin_indices, indices->GetDataType(), uniqueExecutor.get());
170+ CHECK_RET(indices_res != nullptr, ACLNN_ERR_PARAM_NULLPTR);
171+ auto out_res = l0op::Cast(argmin_out, out->GetDataType(), uniqueExecutor.get());
172+ CHECK_RET(out_res != nullptr, ACLNN_ERR_PARAM_NULLPTR);
173+ 
174+ auto indices_view_copy_result = l0op::ViewCopy(indices_res, indices, uniqueExecutor.get());
175+ CHECK_RET(indices_view_copy_result != nullptr, ACLNN_ERR_PARAM_NULLPTR);
176+ auto out_view_copy_result = l0op::ViewCopy(out_res, out, uniqueExecutor.get());
177+ CHECK_RET(out_view_copy_result != nullptr, ACLNN_ERR_PARAM_NULLPTR);
178+ 
179+ *workspaceSize = uniqueExecutor->GetWorkspaceSize();
180+ uniqueExecutor.ReleaseTo(executor);
181+ 
182+ return ACLNN_SUCCESS;
183+}
184+ 
185+aclnnStatus aclnnMinDim(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, aclrtStream stream)
186+{
187+ L2_DFX_PHASE_2(aclnnMinDim);
188+ return CommonOpExecutorRun(workspace, workspaceSize, executor, stream);
186}189}
187 190 
188#ifdef __cplusplus191#ifdef __cplusplus
189}192}
190#endif193#endif
191- 
@@ -41,13 +41,12 @@ static ge::graphStatus InferShape4BiasAddGrad(gert::InferShapeContext* context)
41 auto it = std::find_if(41 auto it = std::find_if(
42 kFormatMap.begin(), kFormatMap.end(),42 kFormatMap.begin(), kFormatMap.end(),
43 [&data_format](const std::pair<std::string, Format>& item) -> bool { return item.first == data_format; });43 [&data_format](const std::pair<std::string, Format>& item) -> bool { return item.first == data_format; });
44- OP_CHECK_IF(44+ OP_CHECK_IF(it == kFormatMap.end(),
45- it == kFormatMap.end(), OP_LOGE(context->GetNodeName(), "data_format %s must in (NCHW, NHWC).", data_format),45+ OP_LOGE(context->GetNodeName(), "data_format %s must be in (NCHW, NHWC).", data_format),
46- return GRAPH_FAILED);46+ return GRAPH_FAILED);
47 if (dim_num < DIM_SIZE2) {47 if (dim_num < DIM_SIZE2) {
48- OP_LOGE(48+ OP_LOGE(context->GetNodeName(),
49- context->GetNodeName(),49+ "The bias add grad op dimension(%lu) must be greater than or equal to 2 when format is NCHW!", dim_num);
50- "The bias add grad op dimension(%lu) must be greater than or equal to 2 when format is NCHW!", dim_num);
51 return GRAPH_FAILED;50 return GRAPH_FAILED;
52 }51 }
53 out_shape->SetDimNum(0);52 out_shape->SetDimNum(0);
@@ -21,7 +21,8 @@
21#include "cdist_tiling_arch35.h"21#include "cdist_tiling_arch35.h"
22 22 
23namespace optiling {23namespace optiling {
24-ge::graphStatus CdistTiling::CheckParams() {24+ge::graphStatus CdistTiling::CheckParams()
25+{
25 OP_LOGD(tilingContext_->GetNodeName(), "Start CheckParams.");26 OP_LOGD(tilingContext_->GetNodeName(), "Start CheckParams.");
26 auto x1 = tilingContext_->GetInputShape(0);27 auto x1 = tilingContext_->GetInputShape(0);
27 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, x1);28 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, x1);
@@ -40,38 +41,35 @@ ge::graphStatus CdistTiling::CheckParams() {
40 x2Shape_ = x2Shape;41 x2Shape_ = x2Shape;
41 yShape_ = yShape;42 yShape_ = yShape;
42 int64_t dimNum = x1Shape_.GetDimNum();43 int64_t dimNum = x1Shape_.GetDimNum();
43- OP_CHECK_IF(dimNum < MIN_DIM_LEN,44+ OP_CHECK_IF(
44- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(45+ dimNum < MIN_DIM_LEN,
45- tilingContext_->GetNodeName(), "x1", std::to_string(dimNum).c_str(),46+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(tilingContext_->GetNodeName(), "x1", std::to_string(dimNum).c_str(),
46- "Input only supports at least 2D tensors"),47+ "Input only supports at least 2D tensors"),
47- return ge::GRAPH_FAILED);48+ return ge::GRAPH_FAILED);
48 int64_t x2DimNum = x2Shape_.GetDimNum();49 int64_t x2DimNum = x2Shape_.GetDimNum();
49 if (x2DimNum != dimNum) {50 if (x2DimNum != dimNum) {
50- std::string reasonMsg = "The dim num of x1 and x2 must be the same, x1 got: " +51+ std::string reasonMsg = "The dim num of x1 and x2 must be the same, x1 got: " + std::to_string(dimNum) +
51- std::to_string(dimNum) + " ,x2 got: " + std::to_string(x2DimNum);52+ " ,x2 got: " + std::to_string(x2DimNum);
52- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(53+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(tilingContext_->GetNodeName(), "x2", std::to_string(x2DimNum).c_str(),
53- tilingContext_->GetNodeName(), "x2", std::to_string(x2DimNum).c_str(),54+ reasonMsg.c_str());
54- reasonMsg.c_str());
55 return ge::GRAPH_FAILED;55 return ge::GRAPH_FAILED;
56 }56 }
57 int64_t yDimNum = yShape_.GetDimNum();57 int64_t yDimNum = yShape_.GetDimNum();
58 if (yDimNum != dimNum) {58 if (yDimNum != dimNum) {
59- std::string reasonMsg = "The dim num of input and output must be the same, x1 got: " +59+ std::string reasonMsg = "The dim num of input and output must be the same, x1 got: " + std::to_string(dimNum) +
60- std::to_string(dimNum) + " ,y got: " + std::to_string(yDimNum);60+ " ,y got: " + std::to_string(yDimNum);
61- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(61+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(tilingContext_->GetNodeName(), "y", std::to_string(yDimNum).c_str(),
62- tilingContext_->GetNodeName(), "y", std::to_string(yDimNum).c_str(),62+ reasonMsg.c_str());
63- reasonMsg.c_str());
64 return ge::GRAPH_FAILED;63 return ge::GRAPH_FAILED;
65 }64 }
66 int64_t M1 = x1Shape_.GetDim(dimNum - 1);65 int64_t M1 = x1Shape_.GetDim(dimNum - 1);
67 int64_t M2 = x2Shape_.GetDim(dimNum - 1);66 int64_t M2 = x2Shape_.GetDim(dimNum - 1);
68 if (M1 != M2) {67 if (M1 != M2) {
69- std::string reasonMsg = "The last dim of x1 and x2 must be the same, x1 got: " +68+ std::string reasonMsg = "The last dim of x1 and x2 must be the same, x1 got: " + std::to_string(M1) +
70- std::to_string(M1) + " ,x2 got: " + std::to_string(M2);69+ " ,x2 got: " + std::to_string(M2);
71- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(70+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(tilingContext_->GetNodeName(), "x2", std::to_string(M2).c_str(),
72- tilingContext_->GetNodeName(), "x2", std::to_string(M2).c_str(),71+ reasonMsg.c_str());
73- reasonMsg.c_str());72+ return ge::GRAPH_FAILED;
74- return ge::GRAPH_FAILED;
75 }73 }
76 M_ = M1;74 M_ = M1;
77 P_ = x1Shape_.GetDim(dimNum - MIN_DIM_LEN);75 P_ = x1Shape_.GetDim(dimNum - MIN_DIM_LEN);
@@ -80,10 +78,10 @@ ge::graphStatus CdistTiling::CheckParams() {
80 std::string reasonMsg = "The last two dims of output are incorrect, output[-1] got: " +78 std::string reasonMsg = "The last two dims of output are incorrect, output[-1] got: " +
81 std::to_string(yShape_.GetDim(dimNum - 1)) +79 std::to_string(yShape_.GetDim(dimNum - 1)) +
82 " ,output[-2] got: " + std::to_string(yShape_.GetDim(dimNum - MIN_DIM_LEN));80 " ,output[-2] got: " + std::to_string(yShape_.GetDim(dimNum - MIN_DIM_LEN));
83- std:: string errDimMsg = "output[-1]: " + std::to_string(yShape_.GetDim(dimNum - 1)) +81+ std::string errDimMsg = "output[-1]: " + std::to_string(yShape_.GetDim(dimNum - 1)) +
84- " ,output[-2]: " + std::to_string(yShape_.GetDim(dimNum - MIN_DIM_LEN)); 82+ " ,output[-2]: " + std::to_string(yShape_.GetDim(dimNum - MIN_DIM_LEN));
85- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(83+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(tilingContext_->GetNodeName(), "y", errDimMsg.c_str(),
86- tilingContext_->GetNodeName(), "y", errDimMsg.c_str(), reasonMsg.c_str());84+ reasonMsg.c_str());
87 return ge::GRAPH_FAILED;85 return ge::GRAPH_FAILED;
88 }86 }
89 auto attrs = tilingContext_->GetAttrs();87 auto attrs = tilingContext_->GetAttrs();
@@ -93,15 +91,15 @@ ge::graphStatus CdistTiling::CheckParams() {
93 const float* pAttr = attrs->GetAttrPointer<float>(0);91 const float* pAttr = attrs->GetAttrPointer<float>(0);
94 tilingData_.p = pAttr == nullptr ? 2.0f : *pAttr;92 tilingData_.p = pAttr == nullptr ? 2.0f : *pAttr;
95 OP_CHECK_IF(tilingData_.p < 0,93 OP_CHECK_IF(tilingData_.p < 0,
96- OP_LOGE_WITH_INVALID_ATTR(tilingContext_->GetNodeName(), "p",94+ OP_LOGE_WITH_INVALID_ATTR(tilingContext_->GetNodeName(), "p", std::to_string(tilingData_.p).c_str(),
97- std::to_string(tilingData_.p).c_str(),95+ "greater than or equal to 0"),
98- "greater than or equal to 0"),96+ return ge::GRAPH_FAILED);
99- return ge::GRAPH_FAILED);
100 }97 }
101 return ge::GRAPH_SUCCESS;98 return ge::GRAPH_SUCCESS;
102}99}
103 100 
104-ge::graphStatus CdistTiling::MergeBatchAxis() {101+ge::graphStatus CdistTiling::MergeBatchAxis()
102+{
105 OP_LOGD(tilingContext_->GetNodeName(), "Start MergeBatchAxis.");103 OP_LOGD(tilingContext_->GetNodeName(), "Start MergeBatchAxis.");
106 int64_t dimNum = x1Shape_.GetDimNum();104 int64_t dimNum = x1Shape_.GetDimNum();
107 B_ = 1;105 B_ = 1;
@@ -113,11 +111,10 @@ ge::graphStatus CdistTiling::MergeBatchAxis() {
113 yB *= yShape_.GetDim(i);111 yB *= yShape_.GetDim(i);
114 }112 }
115 if (B_ != x2B || B_ != yB) {113 if (B_ != x2B || B_ != yB) {
116- std::string reasonMsg = "The batch of input and output must be the same, but x1 got: " +114+ std::string reasonMsg = "The batch of input and output must be the same, but x1 got: " + std::to_string(B_) +
117- std::to_string(B_) + ", x2 got: " + std::to_string(B_) + ", y got: " + std::to_string(yB);115+ ", x2 got: " + std::to_string(B_) + ", y got: " + std::to_string(yB);
118- OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(116+ OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(tilingContext_->GetNodeName(), "y", std::to_string(yB).c_str(),
119- tilingContext_->GetNodeName(), "y", std::to_string(yB).c_str(),117+ reasonMsg.c_str());
120- reasonMsg.c_str());
121 return ge::GRAPH_FAILED;118 return ge::GRAPH_FAILED;
122 }119 }
123 return ge::GRAPH_SUCCESS;120 return ge::GRAPH_SUCCESS;
@@ -133,8 +130,7 @@ void CdistTiling::DoSimtTiling()
133 tilingData_.blockFactor = totalElements;130 tilingData_.blockFactor = totalElements;
134 tilingData_.blockTailFactor = totalElements;131 tilingData_.blockTailFactor = totalElements;
135 return;132 return;
136- }133+ } else {
137- else {
138 int64_t minRequiredCores = Ops::Base::CeilDiv(totalElements, minPerCoreElement);134 int64_t minRequiredCores = Ops::Base::CeilDiv(totalElements, minPerCoreElement);
139 int64_t usedCoreNum = std::min(coreNum_, minRequiredCores);135 int64_t usedCoreNum = std::min(coreNum_, minRequiredCores);
140 if (usedCoreNum == 0) {136 if (usedCoreNum == 0) {
@@ -222,7 +218,7 @@ void CdistTiling::SetDefaultUbTiling()
222}218}
223 219 
224void CdistTiling::ProcessDimension(const DimConfig& config, int64_t availableUbElements, int64_t& findUbTilingIdx)220void CdistTiling::ProcessDimension(const DimConfig& config, int64_t availableUbElements, int64_t& findUbTilingIdx)
225-{ 221+{
226 findUbTilingIdx++;222 findUbTilingIdx++;
227 int64_t totalElements = config.calcTotalElements(config.baseValue);223 int64_t totalElements = config.calcTotalElements(config.baseValue);
228 if (totalElements > availableUbElements) {224 if (totalElements > availableUbElements) {
@@ -254,75 +250,50 @@ void CdistTiling::DoNormalUbTiling()
254 250 
255 std::vector<DimConfig> configs;251 std::vector<DimConfig> configs;
256 if (dtypeSize_ == B4) {252 if (dtypeSize_ == B4) {
257- configs = {253+ configs = {{&tilingData_.ubLoopNumM, &tilingData_.ubFactorM, &tilingData_.ubTailFactorM, M_,
258- {&tilingData_.ubLoopNumM, &tilingData_.ubFactorM, &tilingData_.ubTailFactorM, M_,254+ [this, blockElements](int64_t i) {
259- [this, blockElements](int64_t i)255+ int64_t iBlockAlign = Ops::Base::CeilAlign(i * dtypeSize_, BLOCK_BYTES) / dtypeSize_;
260- {256+ return BUFFER_NUM * (iBlockAlign + iBlockAlign + blockElements) + blockElements;
261- int64_t iBlockAlign = Ops::Base::CeilAlign(i * dtypeSize_, BLOCK_BYTES) / dtypeSize_;257+ }},
262- return BUFFER_NUM * (iBlockAlign + iBlockAlign + blockElements) +258+ {&tilingData_.ubLoopNumR, &tilingData_.ubFactorR, &tilingData_.ubTailFactorR, R0,
263- blockElements;259+ [this, MBlockAlign, blockElements](int64_t i) {
264- }260+ int64_t iBlockAlign = Ops::Base::CeilAlign(i * dtypeSize_, BLOCK_BYTES) / dtypeSize_;
265- },261+ return BUFFER_NUM * (MBlockAlign + i * MBlockAlign + iBlockAlign) + blockElements;
266- {&tilingData_.ubLoopNumR, &tilingData_.ubFactorR, &tilingData_.ubTailFactorR, R0,262+ }},
267- [this, MBlockAlign, blockElements](int64_t i)263+ {&tilingData_.ubLoopNumP, &tilingData_.ubFactorP, &tilingData_.ubTailFactorP, P0,
268- {264+ [this, MBlockAlign, R0BlockAlign, R0, blockElements](int64_t i) {
269- int64_t iBlockAlign = Ops::Base::CeilAlign(i * dtypeSize_, BLOCK_BYTES) / dtypeSize_;265+ return BUFFER_NUM * (i * MBlockAlign + R0 * MBlockAlign + i * R0BlockAlign) + blockElements;
270- return BUFFER_NUM * (MBlockAlign + i * MBlockAlign + iBlockAlign) +266+ }},
271- blockElements;267+ {&tilingData_.ubLoopNumB, &tilingData_.ubFactorB, &tilingData_.ubTailFactorB, B0,
272- }268+ [this, MBlockAlign, R0BlockAlign, R0, P0, blockElements](int64_t i) {
273- },269+ return BUFFER_NUM * (i * P0 * MBlockAlign + i * R0 * MBlockAlign + i * P0 * R0BlockAlign) +
274- {&tilingData_.ubLoopNumP, &tilingData_.ubFactorP, &tilingData_.ubTailFactorP, P0,270+ blockElements;
275- [this, MBlockAlign, R0BlockAlign, R0, blockElements](int64_t i)271+ }}};
276- {
277- return BUFFER_NUM * (i * MBlockAlign + R0 * MBlockAlign + i * R0BlockAlign) +
278- blockElements;
279- }
280- },
281- {&tilingData_.ubLoopNumB, &tilingData_.ubFactorB, &tilingData_.ubTailFactorB, B0,
282- [this, MBlockAlign, R0BlockAlign, R0, P0, blockElements](int64_t i)
283- {
284- return BUFFER_NUM * (i * P0 * MBlockAlign + i * R0 * MBlockAlign + i * P0 * R0BlockAlign) +
285- blockElements;
286- }
287- }
288- };
289 } else {272 } else {
290 configs = {273 configs = {
291 {&tilingData_.ubLoopNumM, &tilingData_.ubFactorM, &tilingData_.ubTailFactorM, M_,274 {&tilingData_.ubLoopNumM, &tilingData_.ubFactorM, &tilingData_.ubTailFactorM, M_,
292- [this, blockElements](int64_t i)275+ [this, blockElements](int64_t i) {
293- {276+ int64_t iBlockAlign = Ops::Base::CeilAlign(i * dtypeSize_, BLOCK_BYTES) / dtypeSize_;
294- int64_t iBlockAlign = Ops::Base::CeilAlign(i * dtypeSize_, BLOCK_BYTES) / dtypeSize_;277+ return BUFFER_NUM * (iBlockAlign + iBlockAlign + blockElements) +
295- return BUFFER_NUM * (iBlockAlign + iBlockAlign + blockElements) +278+ CAST_BUFFER_RATIO * (iBlockAlign + iBlockAlign + blockElements) + blockElements;
296- CAST_BUFFER_RATIO * (iBlockAlign + iBlockAlign + blockElements) +279+ }},
297- blockElements;
298- }
299- },
300 {&tilingData_.ubLoopNumR, &tilingData_.ubFactorR, &tilingData_.ubTailFactorR, R0,280 {&tilingData_.ubLoopNumR, &tilingData_.ubFactorR, &tilingData_.ubTailFactorR, R0,
301- [this, MBlockAlign, blockElements](int64_t i)281+ [this, MBlockAlign, blockElements](int64_t i) {
302- {282+ int64_t iBlockAlign = Ops::Base::CeilAlign(i * dtypeSize_, BLOCK_BYTES) / dtypeSize_;
303- int64_t iBlockAlign = Ops::Base::CeilAlign(i * dtypeSize_, BLOCK_BYTES) / dtypeSize_;283+ return BUFFER_NUM * (MBlockAlign + i * MBlockAlign + iBlockAlign) +
304- return BUFFER_NUM * (MBlockAlign + i * MBlockAlign + iBlockAlign) +284+ CAST_BUFFER_RATIO * (MBlockAlign + i * MBlockAlign + iBlockAlign) + blockElements;
305- CAST_BUFFER_RATIO * (MBlockAlign + i * MBlockAlign + iBlockAlign) +285+ }},
306- blockElements;
307- }
308- },
309 {&tilingData_.ubLoopNumP, &tilingData_.ubFactorP, &tilingData_.ubTailFactorP, P0,286 {&tilingData_.ubLoopNumP, &tilingData_.ubFactorP, &tilingData_.ubTailFactorP, P0,
310- [this, MBlockAlign, R0BlockAlign, R0, blockElements](int64_t i)287+ [this, MBlockAlign, R0BlockAlign, R0, blockElements](int64_t i) {
311- {288+ return BUFFER_NUM * (i * MBlockAlign + R0 * MBlockAlign + i * R0BlockAlign) +
312- return BUFFER_NUM * (i * MBlockAlign + R0 * MBlockAlign + i * R0BlockAlign) +289+ CAST_BUFFER_RATIO * (i * MBlockAlign + R0 * MBlockAlign + i * R0BlockAlign) + blockElements;
313- CAST_BUFFER_RATIO * (i * MBlockAlign + R0 * MBlockAlign + i * R0BlockAlign) +290+ }},
314- blockElements;
315- }
316- },
317 {&tilingData_.ubLoopNumB, &tilingData_.ubFactorB, &tilingData_.ubTailFactorB, B0,291 {&tilingData_.ubLoopNumB, &tilingData_.ubFactorB, &tilingData_.ubTailFactorB, B0,
318- [this, MBlockAlign, R0BlockAlign, R0, P0, blockElements](int64_t i)292+ [this, MBlockAlign, R0BlockAlign, R0, P0, blockElements](int64_t i) {
319- { 293+ return BUFFER_NUM * (i * P0 * MBlockAlign + i * R0 * MBlockAlign + i * P0 * R0BlockAlign) +
320- return BUFFER_NUM * (i * P0 * MBlockAlign + i * R0 * MBlockAlign + i * P0 * R0BlockAlign) +294+ CAST_BUFFER_RATIO * (i * P0 * MBlockAlign + i * R0 * MBlockAlign + i * P0 * R0BlockAlign) +
321- CAST_BUFFER_RATIO * (i * P0 * MBlockAlign + i * R0 * MBlockAlign + i * P0 * R0BlockAlign) +295+ blockElements;
322- blockElements;296+ }}};
323- }
324- }
325- };
326 }297 }
327 298 
328 SetDefaultUbTiling();299 SetDefaultUbTiling();
@@ -357,7 +328,7 @@ void CdistTiling::DoNormalUbTiling()
357}328}
358 329 
359void CdistTiling::DoNormalTiling()330void CdistTiling::DoNormalTiling()
360-{ 331+{
361 OP_LOGD(tilingContext_->GetNodeName(), "Start DoNormalTiling.");332 OP_LOGD(tilingContext_->GetNodeName(), "Start DoNormalTiling.");
362 DoNormalBlockTiling();333 DoNormalBlockTiling();
363 tilingData_.realCoreNum = (tilingData_.blockMainNumB + tilingData_.blockTailNumB) *334 tilingData_.realCoreNum = (tilingData_.blockMainNumB + tilingData_.blockTailNumB) *
@@ -382,17 +353,13 @@ ge::graphStatus CdistTiling::RunCdistTiling()
382{353{
383 OP_LOGD(tilingContext_->GetNodeName(), "Start RunCdistTiling.");354 OP_LOGD(tilingContext_->GetNodeName(), "Start RunCdistTiling.");
384 OP_CHECK_IF(CheckParams() != ge::GRAPH_SUCCESS,355 OP_CHECK_IF(CheckParams() != ge::GRAPH_SUCCESS,
385- OP_LOGE(tilingContext_->GetNodeName(),356+ OP_LOGE(tilingContext_->GetNodeName(), "RunCdistTiling check params failed!"), return ge::GRAPH_FAILED);
386- "RunCdistTiling check params failed!"),
387- return ge::GRAPH_FAILED);
388 OP_CHECK_IF(MergeBatchAxis() != ge::GRAPH_SUCCESS,357 OP_CHECK_IF(MergeBatchAxis() != ge::GRAPH_SUCCESS,
389- OP_LOGE(tilingContext_->GetNodeName(),358+ OP_LOGE(tilingContext_->GetNodeName(), "RunCdistTiling merge batch axis failed!"),
390- "RunCdistTiling merge batch axis failed!"),
391 return ge::GRAPH_FAILED);359 return ge::GRAPH_FAILED);
392 DoTiling();360 DoTiling();
393 OP_CHECK_IF(SetTilingData() != ge::GRAPH_SUCCESS,361 OP_CHECK_IF(SetTilingData() != ge::GRAPH_SUCCESS,
394- OP_LOGE(tilingContext_->GetNodeName(),362+ OP_LOGE(tilingContext_->GetNodeName(), "RunCdistTiling failed to set tiling data!"),
395- "RunCdistTiling failed to set tiling data!"),
396 return ge::GRAPH_FAILED);363 return ge::GRAPH_FAILED);
397 PrintTilingData();364 PrintTilingData();
398 return ge::GRAPH_SUCCESS;365 return ge::GRAPH_SUCCESS;
@@ -404,19 +371,17 @@ ge::graphStatus CdistTiling::Init()
404 auto compileInfo = reinterpret_cast<const CdistCompileInfo*>(tilingContext_->GetCompileInfo());371 auto compileInfo = reinterpret_cast<const CdistCompileInfo*>(tilingContext_->GetCompileInfo());
405 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, compileInfo);372 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, compileInfo);
406 coreNum_ = compileInfo->coreNum;373 coreNum_ = compileInfo->coreNum;
407- OP_CHECK_IF((coreNum_ <= 0),374+ OP_CHECK_IF((coreNum_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get core num."),
408- OP_LOGE(tilingContext_->GetNodeName(), "Failed to get core num."),
409 return ge::GRAPH_FAILED);375 return ge::GRAPH_FAILED);
410 ubSize_ = compileInfo->ubSize;376 ubSize_ = compileInfo->ubSize;
411- OP_CHECK_IF((ubSize_ <= 0),377+ OP_CHECK_IF((ubSize_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get ub size."),
412- OP_LOGE(tilingContext_->GetNodeName(), "Failed to get ub size."),
413 return ge::GRAPH_FAILED);378 return ge::GRAPH_FAILED);
414- OP_LOGD(tilingContext_->GetNodeName(), "Init CdistTiling sucess.");379+ OP_LOGD(tilingContext_->GetNodeName(), "Init CdistTiling success.");
415 return ge::GRAPH_SUCCESS;380 return ge::GRAPH_SUCCESS;
416}381}
417 382 
418ge::graphStatus CdistTiling::SetTilingData()383ge::graphStatus CdistTiling::SetTilingData()
419-{ 384+{
420 OP_LOGD(tilingContext_->GetNodeName(), "Start SetTilingData.");385 OP_LOGD(tilingContext_->GetNodeName(), "Start SetTilingData.");
421 tilingData_.B = B_;386 tilingData_.B = B_;
422 tilingData_.P = P_;387 tilingData_.P = P_;
@@ -429,9 +394,8 @@ ge::graphStatus CdistTiling::SetTilingData()
429 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, ptrData);394 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, ptrData);
430 void* ptrStruct = static_cast<void*>(&tilingData_);395 void* ptrStruct = static_cast<void*>(&tilingData_);
431 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, ptrStruct);396 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, ptrStruct);
432- OP_CHECK_IF(397+ OP_CHECK_IF(memcpy_s(ptrData, capSize, ptrStruct, sizeof(tilingData_)) != 0,
433- memcpy_s(ptrData, capSize, ptrStruct, sizeof(tilingData_)) != 0,398+ OP_LOGE(tilingContext_->GetNodeName(), "Set tiling data failed!"), return ge::GRAPH_FAILED);
434- OP_LOGE(tilingContext_->GetNodeName(), "Set tiling data failed!"), return ge::GRAPH_FAILED);
435 ptrTilingData->SetDataSize(sizeof(tilingData_));399 ptrTilingData->SetDataSize(sizeof(tilingData_));
436 400 
437 tilingContext_->SetBlockDim(tilingData_.realCoreNum);401 tilingContext_->SetBlockDim(tilingData_.realCoreNum);
@@ -447,29 +411,28 @@ void CdistTiling::PrintTilingData()
447{411{
448 std::stringstream ss;412 std::stringstream ss;
449 ss << " realCoreNum: " << tilingData_.realCoreNum << " blockFactor: " << tilingData_.blockFactor413 ss << " realCoreNum: " << tilingData_.realCoreNum << " blockFactor: " << tilingData_.blockFactor
450- << " blockTailFactor: " << tilingData_.blockTailFactor << " B: " << tilingData_.B414+ << " blockTailFactor: " << tilingData_.blockTailFactor << " B: " << tilingData_.B << " P: " << tilingData_.P
451- << " P: " << tilingData_.P << " R: " << tilingData_.R << " M: " << tilingData_.M415+ << " R: " << tilingData_.R << " M: " << tilingData_.M << " blockMainNumB: " << tilingData_.blockMainNumB
452- << " blockMainNumB: " << tilingData_.blockMainNumB << " blockTailNumB: " << tilingData_.blockTailNumB416+ << " blockTailNumB: " << tilingData_.blockTailNumB << " blockMainFactorB: " << tilingData_.blockMainFactorB
453- << " blockMainFactorB: " << tilingData_.blockMainFactorB << " blockTailFactorB: " << tilingData_.blockTailFactorB417+ << " blockTailFactorB: " << tilingData_.blockTailFactorB << " blockMainNumP: " << tilingData_.blockMainNumP
454- << " blockMainNumP: " << tilingData_.blockMainNumP << " blockTailNumP: " << tilingData_.blockTailNumP418+ << " blockTailNumP: " << tilingData_.blockTailNumP << " blockMainFactorP: " << tilingData_.blockMainFactorP
455- << " blockMainFactorP: " << tilingData_.blockMainFactorP << " blockTailFactorP: " << tilingData_.blockTailFactorP419+ << " blockTailFactorP: " << tilingData_.blockTailFactorP << " blockMainNumR: " << tilingData_.blockMainNumR
456- << " blockMainNumR: " << tilingData_.blockMainNumR << " blockTailNumR: " << tilingData_.blockTailNumR420+ << " blockTailNumR: " << tilingData_.blockTailNumR << " blockMainFactorR: " << tilingData_.blockMainFactorR
457- << " blockMainFactorR: " << tilingData_.blockMainFactorR << " blockTailFactorR: " << tilingData_.blockTailFactorR421+ << " blockTailFactorR: " << tilingData_.blockTailFactorR << " ubLoopNumB: " << tilingData_.ubLoopNumB
458- << " ubLoopNumB: " << tilingData_.ubLoopNumB << " ubFactorB: " << tilingData_.ubFactorB422+ << " ubFactorB: " << tilingData_.ubFactorB << " ubTailFactorB: " << tilingData_.ubTailFactorB
459- << " ubTailFactorB: " << tilingData_.ubTailFactorB << " ubLoopNumP: " << tilingData_.ubLoopNumP423+ << " ubLoopNumP: " << tilingData_.ubLoopNumP << " ubFactorP: " << tilingData_.ubFactorP
460- << " ubFactorP: " << tilingData_.ubFactorP << " ubTailFactorP: " << tilingData_.ubTailFactorP424+ << " ubTailFactorP: " << tilingData_.ubTailFactorP << " ubLoopNumR: " << tilingData_.ubLoopNumR
461- << " ubLoopNumR: " << tilingData_.ubLoopNumR << " ubFactorR: " << tilingData_.ubFactorR425+ << " ubFactorR: " << tilingData_.ubFactorR << " ubTailFactorR: " << tilingData_.ubTailFactorR
462- << " ubTailFactorR: " << tilingData_.ubTailFactorR << " ubLoopNumM: " << tilingData_.ubLoopNumM426+ << " ubLoopNumM: " << tilingData_.ubLoopNumM << " ubFactorM: " << tilingData_.ubFactorM
463- << " ubFactorM: " << tilingData_.ubFactorM << " ubTailFactorM: " << tilingData_.ubTailFactorM427+ << " ubTailFactorM: " << tilingData_.ubTailFactorM << " p: " << tilingData_.p;
464- << " p: " << tilingData_.p;
465 OP_LOGI(tilingContext_->GetNodeName(), "CdistTilingData: %s", ss.str().c_str());428 OP_LOGI(tilingContext_->GetNodeName(), "CdistTilingData: %s", ss.str().c_str());
466}429}
467 430 
468static ge::graphStatus TilingParseForCdist([[maybe_unused]] gert::TilingParseContext* context)431static ge::graphStatus TilingParseForCdist([[maybe_unused]] gert::TilingParseContext* context)
469{432{
470 OP_LOGD(context->GetNodeName(), "Start TilingParseForCdist");433 OP_LOGD(context->GetNodeName(), "Start TilingParseForCdist");
471- OP_CHECK_IF(434+ OP_CHECK_IF(context == nullptr, OP_LOGE("TilingParseForCdist", "TilingParseContext is nullptr!"),
472- context == nullptr, OP_LOGE("TilingParseForCdist", "TilingParseContext is nullptr!"), return ge::GRAPH_FAILED);435+ return ge::GRAPH_FAILED);
473 auto compileInfo = context->GetCompiledInfo<CdistCompileInfo>();436 auto compileInfo = context->GetCompiledInfo<CdistCompileInfo>();
474 OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo);437 OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo);
475 auto platformInfo = context->GetPlatformInfo();438 auto platformInfo = context->GetPlatformInfo();
@@ -477,15 +440,13 @@ static ge::graphStatus TilingParseForCdist([[maybe_unused]] gert::TilingParseCon
477 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);440 auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);
478 compileInfo->coreNum = ascendcPlatform.GetCoreNumAiv();441 compileInfo->coreNum = ascendcPlatform.GetCoreNumAiv();
479 OP_CHECK_IF((compileInfo->coreNum <= 0),442 OP_CHECK_IF((compileInfo->coreNum <= 0),
480- OP_LOGE(context->GetNodeName(),443+ OP_LOGE(context->GetNodeName(), "Get hardwareInfo failed, coreNum:%ld.", compileInfo->coreNum),
481- "Get hardwareInfo failed, coreNum:%ld.", compileInfo->coreNum),
482 return ge::GRAPH_FAILED);444 return ge::GRAPH_FAILED);
483 uint64_t ubSize;445 uint64_t ubSize;
484 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);446 ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);
485 compileInfo->ubSize = static_cast<int64_t>(ubSize);447 compileInfo->ubSize = static_cast<int64_t>(ubSize);
486 OP_CHECK_IF((compileInfo->ubSize <= 0),448 OP_CHECK_IF((compileInfo->ubSize <= 0),
487- OP_LOGE(context->GetNodeName(),449+ OP_LOGE(context->GetNodeName(), "Get hardwareInfo failed, ubSize:%ld.", compileInfo->ubSize),
488- "Get hardwareInfo failed, ubSize:%ld.", compileInfo->ubSize),
489 return ge::GRAPH_FAILED);450 return ge::GRAPH_FAILED);
490 451 
491 OP_LOGD(context->GetNodeName(), "Get coreNum:%ld, ubSize:%ld.", compileInfo->coreNum, compileInfo->ubSize);452 OP_LOGD(context->GetNodeName(), "Get coreNum:%ld, ubSize:%ld.", compileInfo->coreNum, compileInfo->ubSize);
@@ -503,4 +464,4 @@ static ge::graphStatus CdistTilingFunc(gert::TilingContext* context)
503}464}
504 465 
505IMPL_OP_OPTILING(Cdist).Tiling(CdistTilingFunc).TilingParse<CdistCompileInfo>(TilingParseForCdist);466IMPL_OP_OPTILING(Cdist).Tiling(CdistTilingFunc).TilingParse<CdistCompileInfo>(TilingParseForCdist);
506-} // namespace optiling467+} // namespace optiling
@@ -1,5 +1,5 @@
1/**1/**
2-* Copyright (c) 2025 Huawei Technologies Co., Ltd.2+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of3 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 * CANN Open Software License Agreement Version 2.0 (the "License").4 * CANN Open Software License Agreement Version 2.0 (the "License").
5 * Please refer to the License for details. You may not use this file except in compliance with the License.5 * Please refer to the License for details. You may not use this file except in compliance with the License.
@@ -23,23 +23,19 @@ ge::graphStatus DiagPartTiling::Init()
23 auto compileInfo = reinterpret_cast<const DiagCompileInfo*>(tilingContext_->GetCompileInfo());23 auto compileInfo = reinterpret_cast<const DiagCompileInfo*>(tilingContext_->GetCompileInfo());
24 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, compileInfo);24 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, compileInfo);
25 coreNum_ = compileInfo->core_num;25 coreNum_ = compileInfo->core_num;
26- OP_CHECK_IF(26+ OP_CHECK_IF((coreNum_ <= 0),
27- (coreNum_ <= 0),27+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(tilingContext_->GetNodeName(), "core num",
28- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(28+ std::to_string(coreNum_).c_str(), "must be greater than 0"),
29- tilingContext_->GetNodeName(), "core num", std::to_string(coreNum_).c_str(), "must be greater than 0"),29+ return ge::GRAPH_FAILED);
30- return ge::GRAPH_FAILED);
31 ubSize_ = compileInfo->ub_size;30 ubSize_ = compileInfo->ub_size;
32- OP_CHECK_IF(31+ OP_CHECK_IF((ubSize_ <= 0),
33- (ubSize_ <= 0),32+ OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(tilingContext_->GetNodeName(), "ub size",
34- OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(33+ std::to_string(ubSize_).c_str(), "must be greater than 0"),
35- tilingContext_->GetNodeName(), "ub size", std::to_string(ubSize_).c_str(), "must be greater than 0"),34+ return ge::GRAPH_FAILED);
36- return ge::GRAPH_FAILED);
37 auto res = tilingContext_->SetLocalMemorySize(static_cast<uint32_t>(ubSize_ - DCACHE_SIZE));35 auto res = tilingContext_->SetLocalMemorySize(static_cast<uint32_t>(ubSize_ - DCACHE_SIZE));
38- OP_CHECK_IF(36+ OP_CHECK_IF((res != ge::GRAPH_SUCCESS), OP_LOGE(tilingContext_->GetNodeName(), "SetLocalMemorySize ubSize failed."),
39- (res != ge::GRAPH_SUCCESS),37+ return ge::GRAPH_FAILED);
40- OP_LOGE(tilingContext_->GetNodeName(), "SetLocalMemorySize ubSize failed."),38+ OP_LOGD(tilingContext_->GetNodeName(), "Init DiagPartTiling success.");
41- return ge::GRAPH_FAILED);
42- OP_LOGD(tilingContext_->GetNodeName(), "Init DiagPartTiling sucess.");
43 return ge::GRAPH_SUCCESS;39 return ge::GRAPH_SUCCESS;
44}40}
45 41 
@@ -47,9 +43,9 @@ ge::graphStatus DiagPartTiling::RunDiagPartTiling()
47{43{
48 OP_LOGD(tilingContext_->GetNodeName(), "Start RunDiagPartTiling.");44 OP_LOGD(tilingContext_->GetNodeName(), "Start RunDiagPartTiling.");
49 45 
50- OP_CHECK_IF(46+ OP_CHECK_IF(DiagPartVerifying() != ge::GRAPH_SUCCESS,
51- DiagPartVerifying() != ge::GRAPH_SUCCESS,47+ OP_LOGE(tilingContext_->GetNodeName(), "DiagPartTiling failed to verify params!"),
52- OP_LOGE(tilingContext_->GetNodeName(), "DiagPartTiling failed to verify params!"), return ge::GRAPH_FAILED);48+ return ge::GRAPH_FAILED);
53 49 
54 return RunDiagPartGatherTiling();50 return RunDiagPartGatherTiling();
55}51}
@@ -63,21 +59,18 @@ ge::graphStatus DiagPartTiling::DiagPartVerifying()
63 auto xDimNum = xShape.GetDimNum();59 auto xDimNum = xShape.GetDimNum();
64 60 
65 // limit input dim > 0 and dim % 2 == 061 // limit input dim > 0 and dim % 2 == 0
66- OP_CHECK_IF(62+ OP_CHECK_IF((xDimNum <= 0 || (xDimNum % TWO) != 0),
67- (xDimNum <= 0 || (xDimNum % TWO) != 0),63+ OP_LOGE_FOR_INVALID_SHAPEDIM(tilingContext_->GetNodeName(), "x", std::to_string(xDimNum).c_str(),
68- OP_LOGE_FOR_INVALID_SHAPEDIM(64+ "an even number and greater than 0"),
69- tilingContext_->GetNodeName(), "x", std::to_string(xDimNum).c_str(),65+ return ge::GRAPH_FAILED);
70- "an even number and greater than 0"),
71- return ge::GRAPH_FAILED);
72 66 
73 // limit the dimensions corresponding to the half and half of the input shape are the same67 // limit the dimensions corresponding to the half and half of the input shape are the same
74 for (uint64_t i = 0; i < xDimNum / TWO; i++) {68 for (uint64_t i = 0; i < xDimNum / TWO; i++) {
75- OP_CHECK_IF(69+ OP_CHECK_IF((xShape.GetDim(i) != xShape.GetDim(i + xDimNum / TWO)),
76- (xShape.GetDim(i) != xShape.GetDim(i + xDimNum / TWO)),70+ OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(tilingContext_->GetNodeName(), "x",
77- OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(71+ Ops::Base::ToString(xShape).c_str(),
78- tilingContext_->GetNodeName(), "x", Ops::Base::ToString(xShape).c_str(),72+ "the front half and back half dims of x must be equal"),
79- "the front half and back half dims of x must be equal"),73+ return ge::GRAPH_FAILED);
80- return ge::GRAPH_FAILED);
81 sideLength_ *= xShape.GetDim(i);74 sideLength_ *= xShape.GetDim(i);
82 }75 }
83 76 
@@ -86,22 +79,19 @@ ge::graphStatus DiagPartTiling::DiagPartVerifying()
86 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, yStorageShape);79 OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, yStorageShape);
87 auto yShape = yStorageShape->GetStorageShape();80 auto yShape = yStorageShape->GetStorageShape();
88 auto yDimNum = yShape.GetDimNum();81 auto yDimNum = yShape.GetDimNum();
89- OP_CHECK_IF(82+ OP_CHECK_IF((yDimNum != xDimNum / TWO),
90- (yDimNum != xDimNum / TWO),83+ OP_LOGE_FOR_INVALID_SHAPEDIM(tilingContext_->GetNodeName(), "y", std::to_string(yDimNum).c_str(),
91- OP_LOGE_FOR_INVALID_SHAPEDIM(84+ "equal to half of the dim num of x"),
92- tilingContext_->GetNodeName(), "y", std::to_string(yDimNum).c_str(),85+ return ge::GRAPH_FAILED);
93- "equal to half of the dim num of x"),
94- return ge::GRAPH_FAILED);
95 for (uint64_t i = 0; i < yDimNum; i++) {86 for (uint64_t i = 0; i < yDimNum; i++) {
96- OP_CHECK_IF(87+ OP_CHECK_IF((xShape.GetDim(i) != yShape.GetDim(i)),
97- (xShape.GetDim(i) != yShape.GetDim(i)),88+ OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(
98- OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(89+ tilingContext_->GetNodeName(), "x and y",
99- tilingContext_->GetNodeName(), "x and y",90+ (Ops::Base::ToString(xShape) + " and " + Ops::Base::ToString(yShape)).c_str(),
100- (Ops::Base::ToString(xShape) + " and " + Ops::Base::ToString(yShape)).c_str(),91+ "the front dims of x and y must be equal"),
101- "the front dims of x and y must be equal"),92+ return ge::GRAPH_FAILED);
102- return ge::GRAPH_FAILED);
103 }93 }
104- OP_LOGD(tilingContext_->GetNodeName(), "DiagPartVerifying sucess.");94+ OP_LOGD(tilingContext_->GetNodeName(), "DiagPartVerifying success.");
105 return ge::GRAPH_SUCCESS;95 return ge::GRAPH_SUCCESS;
106}96}
107 97 
@@ -153,8 +143,8 @@ ge::graphStatus DiagPartTiling::RunDiagPartGatherTiling()
153 143 
154ge::graphStatus DiagPartTiling::SetTilingData()144ge::graphStatus DiagPartTiling::SetTilingData()
155{145{
156- tilingData_.SaveToBuffer(146+ tilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(),
157- tilingContext_->GetRawTilingData()->GetData(), tilingContext_->GetRawTilingData()->GetCapacity());147+ tilingContext_->GetRawTilingData()->GetCapacity());
158 tilingContext_->GetRawTilingData()->SetDataSize(tilingData_.GetDataSize());148 tilingContext_->GetRawTilingData()->SetDataSize(tilingData_.GetDataSize());
159 149 
160 tilingContext_->SetBlockDim(tilingData_.get_realCoreNum());150 tilingContext_->SetBlockDim(tilingData_.get_realCoreNum());
@@ -172,12 +162,10 @@ ge::graphStatus DiagPartTiling::SetTilingData()
172 162 
173void DiagPartTiling::PrintTilingData()163void DiagPartTiling::PrintTilingData()
174{164{
175- OP_LOGI(165+ OP_LOGI(tilingContext_->GetNodeName(), "tilingData is sideLength:%ld, \
176- tilingContext_->GetNodeName(),
177- "tilingData is sideLength:%ld, \
178 realCoreNum:%ld, numPerCore:%ld, tailNum:%ld",166 realCoreNum:%ld, numPerCore:%ld, tailNum:%ld",
179- tilingData_.get_sideLength(), tilingData_.get_realCoreNum(), tilingData_.get_numPerCore(),167+ tilingData_.get_sideLength(), tilingData_.get_realCoreNum(), tilingData_.get_numPerCore(),
180- tilingData_.get_tailNum());168+ tilingData_.get_tailNum());
181}169}
182 170 
183ge::graphStatus DiagPartTilingForAscendC(gert::TilingContext* context)171ge::graphStatus DiagPartTilingForAscendC(gert::TilingContext* context)
@@ -189,4 +177,4 @@ ge::graphStatus DiagPartTilingForAscendC(gert::TilingContext* context)
189 }177 }
190 return tilingObject.RunDiagPartTiling();178 return tilingObject.RunDiagPartTiling();
191}179}
192-} // namespace optiling180+} // namespace optiling
@@ -40,7 +40,7 @@ static graphStatus GroupedBiasAddGradHostExecFunc(OpExecuteContext* host_api_ctx
40 auto api_ret = CANN_OPS_OPB_SYN_EXEC_ACLNN(host_api_ctx, aclnnGroupedBiasAddGradV2, grad_y, group_idx,40 auto api_ret = CANN_OPS_OPB_SYN_EXEC_ACLNN(host_api_ctx, aclnnGroupedBiasAddGradV2, grad_y, group_idx,
41 *groupIdxType, output);41 *groupIdxType, output);
42 42 
43- OP_CHECK_IF(api_ret != GRAPH_SUCCESS, OP_LOGE("aclnnfallback", "api_ret faild:%u", api_ret), return GRAPH_FAILED);43+ OP_CHECK_IF(api_ret != GRAPH_SUCCESS, OP_LOGE("aclnnfallback", "api_ret failed:%u", api_ret), return GRAPH_FAILED);
44 44 
45 OP_LOGD("aclnnFallback", "GroupedBiasAddGrad fallback end");45 OP_LOGD("aclnnFallback", "GroupedBiasAddGrad fallback end");
46 return GRAPH_SUCCESS;46 return GRAPH_SUCCESS;
@@ -133,7 +133,7 @@ ge::graphStatus GroupedBiasAddGradTiling::CheckOutput()
133 auto gradBiasdim0 = gradBiasOutputShape.GetDim(0);133 auto gradBiasdim0 = gradBiasOutputShape.GetDim(0);
134 auto gradBiasdim1 = gradBiasOutputShape.GetDim(1);134 auto gradBiasdim1 = gradBiasOutputShape.GetDim(1);
135 OP_CHECK_IF(((gradBiasdim0 != baseInfoOp_.dimG) || (gradBiasdim1 != baseInfoOp_.dimH)),135 OP_CHECK_IF(((gradBiasdim0 != baseInfoOp_.dimG) || (gradBiasdim1 != baseInfoOp_.dimH)),
136- OP_LOGE(nodeName_, "the shape of grad_bias should be [%ld, %ld], bug got [%ld, %ld].", baseInfoOp_.dimG,136+ OP_LOGE(nodeName_, "the shape of grad_bias should be [%ld, %ld], but got [%ld, %ld].", baseInfoOp_.dimG,
137 baseInfoOp_.dimH, gradBiasdim0, gradBiasdim1),137 baseInfoOp_.dimH, gradBiasdim0, gradBiasdim1),
138 return ge::GRAPH_FAILED);138 return ge::GRAPH_FAILED);
139 return ge::GRAPH_SUCCESS;139 return ge::GRAPH_SUCCESS;
@@ -161,9 +161,8 @@ static bool CheckDtypeValid(const aclTensor* self, const aclTensor* out)
161static bool CheckFormat(const aclTensor* self)161static bool CheckFormat(const aclTensor* self)
162{162{
163 if (op::IsPrivateFormat(self->GetStorageFormat())) {163 if (op::IsPrivateFormat(self->GetStorageFormat())) {
164- OP_LOGE(164+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support ND,NCHW,NHWC,HWCN,NDHWC,NCDHW, self [%s]",
165- ACLNN_ERR_PARAM_INVALID, "Format only support ND、NCHW、NHWC、HWCN、NDHWC、NCDHW, self [%s]",165+ ToString(self->GetStorageFormat()).GetString());
166- ToString(self->GetStorageFormat()).GetString());
167 return false;166 return false;
168 }167 }
169 168 
@@ -183,9 +182,8 @@ static bool CheckShape(const aclTensor* self, const aclTensor* out, const aclInt
183 if (outShape == out->GetViewShape()) {182 if (outShape == out->GetViewShape()) {
184 return true;183 return true;
185 }184 }
186- OP_LOGE(185+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expect out shape [%s], but got: [%s].", op::ToString(outShape).GetString(),
187- ACLNN_ERR_PARAM_INVALID, "Expect out shape [%s], but got: [%s].", op::ToString(outShape).GetString(),186+ op::ToString(out->GetViewShape()).GetString());
188- op::ToString(out->GetViewShape()).GetString());
189 return false;187 return false;
190}188}
191 189 
@@ -206,9 +204,9 @@ static bool CheckDim(const aclTensor* self, const aclIntArray* dim)
206 bitset<DIM_BITS_LEN> dimMask = bitset<DIM_BITS_LEN>();204 bitset<DIM_BITS_LEN> dimMask = bitset<DIM_BITS_LEN>();
207 for (size_t idx = 0; idx < dim->Size(); idx++) {205 for (size_t idx = 0; idx < dim->Size(); idx++) {
208 if ((*dim)[idx] < -(input_dim_num) || (*dim)[idx] >= input_dim_num) {206 if ((*dim)[idx] < -(input_dim_num) || (*dim)[idx] >= input_dim_num) {
209- OP_LOGE(207+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
210- ACLNN_ERR_PARAM_INVALID, "Dimension out of range (expected to be in range of [-%ld, %ld], but got %ld)",208+ "Dimension out of range (expected to be in range of [-%ld, %ld], but got %ld)", input_dim_num,
211- input_dim_num, input_dim_num - 1, (*dim)[idx]);209+ input_dim_num - 1, (*dim)[idx]);
212 return false;210 return false;
213 }211 }
214 uint64_t index = GetPosDim((*dim)[idx], input_dim_num);212 uint64_t index = GetPosDim((*dim)[idx], input_dim_num);
@@ -260,9 +258,8 @@ static const aclTensor* GetTensorWithValueTrue(aclTensor* out, aclOpExecutor* ex
260 return viewCopyResult;258 return viewCopyResult;
261}259}
262 260 
263-aclnnStatus aclnnAllGetWorkspaceSize(261+aclnnStatus aclnnAllGetWorkspaceSize(const aclTensor* self, const aclIntArray* dim, bool keepdim, aclTensor* out,
264- const aclTensor* self, const aclIntArray* dim, bool keepdim, aclTensor* out, uint64_t* workspaceSize,262+ uint64_t* workspaceSize, aclOpExecutor** executor)
265- aclOpExecutor** executor)
266{263{
267 L2_DFX_PHASE_1(aclnnAll, DFX_IN(self, dim, keepdim), DFX_OUT(out));264 L2_DFX_PHASE_1(aclnnAll, DFX_IN(self, dim, keepdim), DFX_OUT(out));
268 265 
@@ -293,8 +290,12 @@ aclnnStatus aclnnAllGetWorkspaceSize(
293 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);290 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
294 291 
295 auto selfCasted = selfContiguous;292 auto selfCasted = selfContiguous;
296- if (!((selfContiguous->GetDataType() == op::DataType::DT_FLOAT16 || selfContiguous->GetDataType() == op::DataType::DT_BF16 || selfContiguous->GetDataType() == op::DataType::DT_FLOAT) &&293+ if (!((selfContiguous->GetDataType() == op::DataType::DT_FLOAT16 ||
297- (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93 || GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_3510))) {294+ selfContiguous->GetDataType() == op::DataType::DT_BF16 ||
295+ selfContiguous->GetDataType() == op::DataType::DT_FLOAT) &&
296+ (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B ||
297+ GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93 ||
298+ GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_3510))) {
298 // 将输入self的数据类型转换成隐式数据类型,根据具体算子语义按需调用299 // 将输入self的数据类型转换成隐式数据类型,根据具体算子语义按需调用
299 selfCasted = l0op::Cast(selfContiguous, DataType::DT_BOOL, uniqueExecutor.get());300 selfCasted = l0op::Cast(selfContiguous, DataType::DT_BOOL, uniqueExecutor.get());
300 CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);301 CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -20,14 +20,14 @@
20namespace {20namespace {
21constexpr uint32_t kReduceAllInputNum = 1;21constexpr uint32_t kReduceAllInputNum = 1;
22constexpr uint32_t kReduceAllOutputNum = 1;22constexpr uint32_t kReduceAllOutputNum = 1;
23-const char *const kReduceAll = "ReduceAll";23+const char* const kReduceAll = "ReduceAll";
24-}24+} // namespace
25 25 
26namespace aicpu {26namespace aicpu {
27-uint32_t ReduceAllCpuKernel::GenDataNoAxis(const CpuKernelContext &ctx) const27+uint32_t ReduceAllCpuKernel::GenDataNoAxis(const CpuKernelContext& ctx) const
28{28{
29- auto x_data = reinterpret_cast<bool *>(ctx.Input(kFirstInputIndex)->GetData());29+ auto x_data = reinterpret_cast<bool*>(ctx.Input(kFirstInputIndex)->GetData());
30- auto y_data = reinterpret_cast<bool *>(ctx.Output(kFirstOutputIndex)->GetData());30+ auto y_data = reinterpret_cast<bool*>(ctx.Output(kFirstOutputIndex)->GetData());
31 int64_t input_data_size = ctx.Input(kFirstInputIndex)->NumElements();31 int64_t input_data_size = ctx.Input(kFirstInputIndex)->NumElements();
32 bool output_y = true;32 bool output_y = true;
33 for (int64_t i = 0; i < input_data_size; ++i) {33 for (int64_t i = 0; i < input_data_size; ++i) {
@@ -38,8 +38,8 @@ uint32_t ReduceAllCpuKernel::GenDataNoAxis(const CpuKernelContext &ctx) const
38}38}
39 39 
40template <typename T>40template <typename T>
41-uint32_t ReduceAllCpuKernel::AxisCal(41+uint32_t ReduceAllCpuKernel::AxisCal(T axis, const std::vector<int64_t>& data_dims, int64_t& head_dim,
42- T axis, const std::vector<int64_t> &data_dims, int64_t &head_dim, int64_t &end_dim) const42+ int64_t& end_dim) const
43{43{
44 bool axis_appear = false;44 bool axis_appear = false;
45 size_t data_dims_size = data_dims.size();45 size_t data_dims_size = data_dims.size();
@@ -56,8 +56,7 @@ uint32_t ReduceAllCpuKernel::AxisCal(
56 end_dim *= data_dims[i];56 end_dim *= data_dims[i];
57 } else {57 } else {
58 if (data_dims[i] != 0 && head_dim > (INT64_MAX / data_dims[i])) {58 if (data_dims[i] != 0 && head_dim > (INT64_MAX / data_dims[i])) {
59- KERNEL_LOG_ERROR(59+ KERNEL_LOG_ERROR("Product is overflow. multiplier 1: %ld. multiplier 2: %ld.", head_dim, data_dims[i]);
60- "Product is overflow. multiplier 1: %ld. multiplier 2: %ld.", head_dim, data_dims[i]);
61 return KERNEL_STATUS_PARAM_INVALID;60 return KERNEL_STATUS_PARAM_INVALID;
62 }61 }
63 head_dim *= data_dims[i];62 head_dim *= data_dims[i];
@@ -67,7 +66,7 @@ uint32_t ReduceAllCpuKernel::AxisCal(
67}66}
68 67 
69template <typename T>68template <typename T>
70-std::vector<int64_t> ReduceAllCpuKernel::GetOutputShape(const std::vector<int64_t> &input_shape, const T &axis)69+std::vector<int64_t> ReduceAllCpuKernel::GetOutputShape(const std::vector<int64_t>& input_shape, const T& axis)
71{70{
72 std::vector<int64_t> output_shape;71 std::vector<int64_t> output_shape;
73 for (size_t i = 0; i < input_shape.size(); ++i) {72 for (size_t i = 0; i < input_shape.size(); ++i) {
@@ -83,17 +82,16 @@ std::vector<int64_t> ReduceAllCpuKernel::GetOutputShape(const std::vector<int64_
83}82}
84 83 
85template <typename T>84template <typename T>
86-uint32_t ReduceAllCpuKernel::AxesRankCheckAndReverse(85+uint32_t ReduceAllCpuKernel::AxesRankCheckAndReverse(const CpuKernelContext& ctx, const T* axis_data,
87- const CpuKernelContext &ctx, const T *axis_data, const int64_t &axes_num, std::map<T, int64_t> &axis_map,86+ const int64_t& axes_num, std::map<T, int64_t>& axis_map,
88- int32_t &rank)87+ int32_t& rank)
89{88{
90 T axis_temp = 0;89 T axis_temp = 0;
91 rank = static_cast<T>(rank);90 rank = static_cast<T>(rank);
92 for (int64_t i = 0; i < axes_num; i++) {91 for (int64_t i = 0; i < axes_num; i++) {
93 if (axis_data[i] < -rank || axis_data[i] > (rank - 1)) {92 if (axis_data[i] < -rank || axis_data[i] > (rank - 1)) {
94- KERNEL_LOG_ERROR(93+ KERNEL_LOG_ERROR("[%s] the value of axes should be in [-%d, %d], axes is %ld", ctx.GetOpType().c_str(),
95- "[%s] the value of axes should be in [-%d, %d], axes is %ld", ctx.GetOpType().c_str(), rank, rank,94+ rank, rank, static_cast<int64_t>(axis_data[i]));
96- static_cast<int64_t>(axis_data[i]));
97 return KERNEL_STATUS_PARAM_INVALID;95 return KERNEL_STATUS_PARAM_INVALID;
98 }96 }
99 if (axis_data[i] < 0) {97 if (axis_data[i] < 0) {
@@ -102,9 +100,8 @@ uint32_t ReduceAllCpuKernel::AxesRankCheckAndReverse(
102 axis_temp = axis_data[i];100 axis_temp = axis_data[i];
103 }101 }
104 if (axis_map.find(axis_temp) != axis_map.end()) {102 if (axis_map.find(axis_temp) != axis_map.end()) {
105- KERNEL_LOG_ERROR(103+ KERNEL_LOG_ERROR("[%s] invalid reduction arguments: axes contains duplicate dimension: %ld",
106- "[%s] invalid reduction arguments: axes contains duplicate dimension: %ld", ctx.GetOpType().c_str(),104+ ctx.GetOpType().c_str(), static_cast<int64_t>(axis_temp));
107- static_cast<int64_t>(axis_temp));
108 return KERNEL_STATUS_PARAM_INVALID;105 return KERNEL_STATUS_PARAM_INVALID;
109 }106 }
110 axis_map.emplace(std::pair<T, int64_t>(axis_temp, i));107 axis_map.emplace(std::pair<T, int64_t>(axis_temp, i));
@@ -113,9 +110,8 @@ uint32_t ReduceAllCpuKernel::AxesRankCheckAndReverse(
113}110}
114 111 
115template <typename T, typename T2>112template <typename T, typename T2>
116-uint32_t ReduceAllCpuKernel::ReduceAllOneAxes(113+uint32_t ReduceAllCpuKernel::ReduceAllOneAxes(const T* input_data, std::vector<int64_t>& input_dims, T* output_data,
117- const T *input_data, std::vector<int64_t> &input_dims, T *output_data, const int64_t &output_num,114+ const int64_t& output_num, std::vector<T2>& axes)
118- std::vector<T2> &axes)
119{115{
120 if (axes_idx_ >= axes.size()) {116 if (axes_idx_ >= axes.size()) {
121 for (int64_t i = 0; i < output_num; i++) {117 for (int64_t i = 0; i < output_num; i++) {
@@ -129,7 +125,7 @@ uint32_t ReduceAllCpuKernel::ReduceAllOneAxes(
129 if (ret != KERNEL_STATUS_OK) {125 if (ret != KERNEL_STATUS_OK) {
130 return KERNEL_STATUS_PARAM_INVALID;126 return KERNEL_STATUS_PARAM_INVALID;
131 }127 }
132- auto *output_data_temp = new (std::nothrow) T[head_dim * end_dim];128+ auto* output_data_temp = new (std::nothrow) T[head_dim * end_dim];
133 KERNEL_CHECK_NULLPTR(output_data_temp, KERNEL_STATUS_INNER_ERROR, "apply memory failed.");129 KERNEL_CHECK_NULLPTR(output_data_temp, KERNEL_STATUS_INNER_ERROR, "apply memory failed.");
134 bool tmp_x = true;130 bool tmp_x = true;
135 bool tmp_y = true;131 bool tmp_y = true;
@@ -152,15 +148,15 @@ uint32_t ReduceAllCpuKernel::ReduceAllOneAxes(
152}148}
153 149 
154template <typename T, typename T2>150template <typename T, typename T2>
155-uint32_t ReduceAllCpuKernel::ReduceAllCompute(const CpuKernelContext &ctx)151+uint32_t ReduceAllCpuKernel::ReduceAllCompute(const CpuKernelContext& ctx)
156{152{
157 axes_idx_ = 0;153 axes_idx_ = 0;
158- Tensor *x = ctx.Input(kFirstInputIndex);154+ Tensor* x = ctx.Input(kFirstInputIndex);
159- Tensor *axes = ctx.Input(kSecondInputIndex);155+ Tensor* axes = ctx.Input(kSecondInputIndex);
160- Tensor *y = ctx.Output(kFirstInputIndex);156+ Tensor* y = ctx.Output(kFirstInputIndex);
161 157 
162- auto *output_data = reinterpret_cast<T *>(y->GetData());158+ auto* output_data = reinterpret_cast<T*>(y->GetData());
163- auto *keep_dims = ctx.GetAttr("keep_dims");159+ auto* keep_dims = ctx.GetAttr("keep_dims");
164 KERNEL_CHECK_NULLPTR(keep_dims, KERNEL_STATUS_PARAM_INVALID, "Get attr [keep_dims] failed.");160 KERNEL_CHECK_NULLPTR(keep_dims, KERNEL_STATUS_PARAM_INVALID, "Get attr [keep_dims] failed.");
165 keep_dims_ = keep_dims->GetBool();161 keep_dims_ = keep_dims->GetBool();
166 int64_t output_num = y->NumElements();162 int64_t output_num = y->NumElements();
@@ -179,8 +175,8 @@ uint32_t ReduceAllCpuKernel::ReduceAllCompute(const CpuKernelContext &ctx)
179 return GenDataNoAxis(ctx);175 return GenDataNoAxis(ctx);
180 }176 }
181 177 
182- auto *input_data = reinterpret_cast<T *>(x->GetData());178+ auto* input_data = reinterpret_cast<T*>(x->GetData());
183- auto *axis_data = reinterpret_cast<T2 *>(axes->GetData());179+ auto* axis_data = reinterpret_cast<T2*>(axes->GetData());
184 int64_t axes_num = axes->GetTensorShape()->NumElements();180 int64_t axes_num = axes->GetTensorShape()->NumElements();
185 std::vector<int64_t> input_dims = x->GetTensorShape()->GetDimSizes();181 std::vector<int64_t> input_dims = x->GetTensorShape()->GetDimSizes();
186 int32_t rank = x->GetTensorShape()->GetDims();182 int32_t rank = x->GetTensorShape()->GetDims();
@@ -201,31 +197,30 @@ uint32_t ReduceAllCpuKernel::ReduceAllCompute(const CpuKernelContext &ctx)
201 return KERNEL_STATUS_OK;197 return KERNEL_STATUS_OK;
202}198}
203 199 
204-uint32_t ReduceAllCpuKernel::ReduceAllCheck(const CpuKernelContext &ctx) const200+uint32_t ReduceAllCpuKernel::ReduceAllCheck(const CpuKernelContext& ctx) const
205{201{
206- auto *x = ctx.Input(kFirstInputIndex);202+ auto* x = ctx.Input(kFirstInputIndex);
207- auto *axes = ctx.Input(kSecondInputIndex);203+ auto* axes = ctx.Input(kSecondInputIndex);
208 if (x != nullptr && x->GetData() != nullptr) {204 if (x != nullptr && x->GetData() != nullptr) {
209- KERNEL_CHECK_FALSE(205+ KERNEL_CHECK_FALSE((x->GetDataType() == DT_BOOL), KERNEL_STATUS_PARAM_INVALID,
210- (x->GetDataType() == DT_BOOL), KERNEL_STATUS_PARAM_INVALID,206+ "Data type of x is not supported, x data type is [%u].",
211- "Data type of x is not support, x data type is [%u].", static_cast<uint32_t>(x->GetDataType()));207+ static_cast<uint32_t>(x->GetDataType()));
212 }208 }
213 if (axes != nullptr && axes->GetData() != nullptr) {209 if (axes != nullptr && axes->GetData() != nullptr) {
214- KERNEL_CHECK_FALSE(210+ KERNEL_CHECK_FALSE((axes->GetDataType() == DT_INT32 || axes->GetDataType() == DT_INT64),
215- (axes->GetDataType() == DT_INT32 || axes->GetDataType() == DT_INT64), KERNEL_STATUS_PARAM_INVALID,211+ KERNEL_STATUS_PARAM_INVALID, "Data type of axis is not supported, axis data type is [%u].",
216- "Data type of axis is not support, axis data type is [%u].",212+ static_cast<uint32_t>(axes->GetDataType()));
217- static_cast<uint32_t>(axes->GetDataType()));
218 }213 }
219 return KERNEL_STATUS_OK;214 return KERNEL_STATUS_OK;
220}215}
221 216 
222-uint32_t ReduceAllCpuKernel::Compute(CpuKernelContext &ctx)217+uint32_t ReduceAllCpuKernel::Compute(CpuKernelContext& ctx)
223{218{
224 KERNEL_HANDLE_ERROR(NormalCheck(ctx, kReduceAllInputNum, kReduceAllOutputNum),219 KERNEL_HANDLE_ERROR(NormalCheck(ctx, kReduceAllInputNum, kReduceAllOutputNum),
225- "[%s] check input and output failed.", kReduceAll);220+ "[%s] check input and output failed.", kReduceAll);
226 KERNEL_HANDLE_ERROR(ReduceAllCheck(ctx), "[%s] check params failed.", kReduceAll);221 KERNEL_HANDLE_ERROR(ReduceAllCheck(ctx), "[%s] check params failed.", kReduceAll);
227 222 
228- Tensor *axes = ctx.Input(kSecondInputIndex);223+ Tensor* axes = ctx.Input(kSecondInputIndex);
229 if (axes == nullptr || axes->GetDataSize() == 0) {224 if (axes == nullptr || axes->GetDataSize() == 0) {
230 return ReduceAllCompute<bool, int32_t>(ctx);225 return ReduceAllCompute<bool, int32_t>(ctx);
231 }226 }
@@ -240,7 +235,7 @@ uint32_t ReduceAllCpuKernel::Compute(CpuKernelContext &ctx)
240 ret = ReduceAllCompute<bool, int64_t>(ctx);235 ret = ReduceAllCompute<bool, int64_t>(ctx);
241 break;236 break;
242 default:237 default:
243- KERNEL_LOG_ERROR("Data type not support[%s].", DTypeStr(axes_data_type).c_str());238+ KERNEL_LOG_ERROR("Data type is not supported[%s].", DTypeStr(axes_data_type).c_str());
244 return KERNEL_STATUS_PARAM_INVALID;239 return KERNEL_STATUS_PARAM_INVALID;
245 }240 }
246 241 
@@ -251,4 +246,4 @@ uint32_t ReduceAllCpuKernel::Compute(CpuKernelContext &ctx)
251}246}
252 247 
253REGISTER_CPU_KERNEL(kReduceAll, ReduceAllCpuKernel);248REGISTER_CPU_KERNEL(kReduceAll, ReduceAllCpuKernel);
254-} // namespace aicpu249+} // namespace aicpu
@@ -210,7 +210,7 @@ static Status ParseOpToGraphReduceLogSumExp13(const Operator& op, Graph& graph)
210 output_indexs.emplace_back(reduce_log_sum_exp, vector<std::size_t>{0});210 output_indexs.emplace_back(reduce_log_sum_exp, vector<std::size_t>{0});
211 graph.SetInputs(inputs).SetOutputs(output_indexs);211 graph.SetInputs(inputs).SetOutputs(output_indexs);
212 } else {212 } else {
213- OP_LOGE(GetOpName(op).c_str(), "Input num or set attr is error");213+ OP_LOGE(GetOpName(op).c_str(), "Input num or set attr is invalid");
214 return FAILED;214 return FAILED;
215 }215 }
216 return SUCCESS;216 return SUCCESS;
@@ -223,7 +223,7 @@ aclnnStatus aclnnLogSumExpGetWorkspaceSize(const aclTensor* self, const aclIntAr
223 // 检查Format223 // 检查Format
224 if (op::IsPrivateFormat(self->GetStorageFormat())) {224 if (op::IsPrivateFormat(self->GetStorageFormat())) {
225 if (IsRegBase()) {225 if (IsRegBase()) {
226- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support NDNCHWNHWCHWCNNDHWCNCDHW, self [%s]",226+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support ND,NCHW,NHWC,HWCN,NDHWC,NCDHW, self [%s]",
227 ToString(self->GetStorageFormat()).GetString());227 ToString(self->GetStorageFormat()).GetString());
228 return ACLNN_ERR_PARAM_INVALID;228 return ACLNN_ERR_PARAM_INVALID;
229 } else {229 } else {
@@ -217,7 +217,7 @@ static Status ParseOpToGraphReduceMax13(const Operator& op, Graph& graph)
217 output_indexs.emplace_back(reducemax13, vector<std::size_t>{0});217 output_indexs.emplace_back(reducemax13, vector<std::size_t>{0});
218 graph.SetInputs(inputs).SetOutputs(output_indexs);218 graph.SetInputs(inputs).SetOutputs(output_indexs);
219 } else {219 } else {
220- OP_LOGE(GetOpName(op).c_str(), "Input num or set attr is error");220+ OP_LOGE(GetOpName(op).c_str(), "Input num or set attr is invalid");
221 return FAILED;221 return FAILED;
222 }222 }
223 return SUCCESS;223 return SUCCESS;
@@ -120,8 +120,9 @@ static bool CheckDtypeValid(const aclTensor* self, const aclTensor* out)
120static void CheckFormat(const aclTensor* self)120static void CheckFormat(const aclTensor* self)
121{121{
122 op::Format format = self->GetStorageFormat();122 op::Format format = self->GetStorageFormat();
123- if (format == Format::FORMAT_FRACTAL_NZ){123+ if (format == Format::FORMAT_FRACTAL_NZ) {
124- OP_LOGW("Format of inputs gets [%s],this format mat lead to precision failure",op::ToString(format).GetString());124+ OP_LOGW("Format of inputs gets [%s], this format may lead to precision failure",
125+ op::ToString(format).GetString());
125 }126 }
126}127}
127 128 
@@ -140,15 +141,14 @@ static bool CheckDimValid(const aclTensor* self, const aclIntArray* dim)
140 141 
141 for (size_t i = 0; i < dim->Size(); i++) {142 for (size_t i = 0; i < dim->Size(); i++) {
142 if (dim->operator[](i) >= selfDimNum || dim->operator[](i) < (-selfDimNum)) {143 if (dim->operator[](i) >= selfDimNum || dim->operator[](i) < (-selfDimNum)) {
143- OP_LOGE(144+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Provided dim %ld must be in the range of [%ld, %ld].", dim->operator[](i),
144- ACLNN_ERR_PARAM_INVALID, "Provided dim %ld must be in the range of [%ld, %ld].", dim->operator[](i),145+ -selfDimNum, selfDimNum - 1);
145- -selfDimNum, selfDimNum - 1);
146 return false;146 return false;
147 }147 }
148 uint64_t index = GetPosDim(dim->operator[](i), selfDimNum);148 uint64_t index = GetPosDim(dim->operator[](i), selfDimNum);
149 // 非标量reduce的dim不能为0149 // 非标量reduce的dim不能为0
150 if (!isScalar && selfViewShape.GetDim(index) == 0) {150 if (!isScalar && selfViewShape.GetDim(index) == 0) {
151- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expected reducution dim %lu to have non-zero size.", index);151+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expected reduction dim %lu to have non-zero size.", index);
152 return false;152 return false;
153 }153 }
154 // dim重复154 // dim重复
@@ -193,9 +193,8 @@ static aclnnStatus CheckParams(const aclTensor* self, const aclIntArray* dim, co
193 return ACLNN_SUCCESS;193 return ACLNN_SUCCESS;
194}194}
195 195 
196-aclnnStatus aclnnAmaxGetWorkspaceSize(196+aclnnStatus aclnnAmaxGetWorkspaceSize(const aclTensor* self, const aclIntArray* dim, bool keepDim, aclTensor* out,
197- const aclTensor* self, const aclIntArray* dim, bool keepDim, aclTensor* out, uint64_t* workspaceSize,197+ uint64_t* workspaceSize, aclOpExecutor** executor)
198- aclOpExecutor** executor)
199{198{
200 L2_DFX_PHASE_1(aclnnAmax, DFX_IN(self, dim, keepDim), DFX_OUT(out));199 L2_DFX_PHASE_1(aclnnAmax, DFX_IN(self, dim, keepDim), DFX_OUT(out));
201 // 创建OpExecutor200 // 创建OpExecutor
@@ -233,8 +232,8 @@ aclnnStatus aclnnAmaxGetWorkspaceSize(
233 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);232 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
234 233 
235 // 将输入self的数据类型转换成目标数据类型, bool 转为float, 其余保持原类型234 // 将输入self的数据类型转换成目标数据类型, bool 转为float, 其余保持原类型
236- op::DataType selfCastType =235+ op::DataType selfCastType = (self->GetDataType() == op::DataType::DT_BOOL) ? op::DataType::DT_FLOAT :
237- (self->GetDataType() == op::DataType::DT_BOOL) ? op::DataType::DT_FLOAT : self->GetDataType();236+ self->GetDataType();
238 237 
239 auto selfCasted = l0op::Cast(selfContiguous, selfCastType, uniqueExecutor.get());238 auto selfCasted = l0op::Cast(selfContiguous, selfCastType, uniqueExecutor.get());
240 CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);239 CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -268,4 +267,4 @@ aclnnStatus aclnnAmax(void* workspace, uint64_t workspaceSize, aclOpExecutor* ex
268 267 
269#ifdef __cplusplus268#ifdef __cplusplus
270}269}
271-#endif270+#endif
@@ -84,8 +84,8 @@ static inline uint64_t GetPosDim(int64_t dim, int64_t dimNum)
84 return dim >= 0 ? dim : dim + dimNum;84 return dim >= 0 ? dim : dim + dimNum;
85}85}
86 86 
87-static inline const aclIntArray* GetAllDims(87+static inline const aclIntArray* GetAllDims(const aclTensor* self, const bool noopWithEmptyDims,
88- const aclTensor* self, const bool noopWithEmptyDims, aclOpExecutor* executor)88+ aclOpExecutor* executor)
89{89{
90 auto inputShape = self->GetViewShape();90 auto inputShape = self->GetViewShape();
91 size_t inputDimNum = inputShape.GetDimNum();91 size_t inputDimNum = inputShape.GetDimNum();
@@ -98,9 +98,8 @@ static inline const aclIntArray* GetAllDims(
98 return executor->AllocIntArray(dims.data(), dims.size());98 return executor->AllocIntArray(dims.data(), dims.size());
99}99}
100 100 
101-static void reduce_maxInferShape(101+static void reduce_maxInferShape(const op::Shape& selfShape, const aclIntArray* dims, bool keepDims,
102- const op::Shape& selfShape, const aclIntArray* dims, bool keepDims, const bool noopWithEmptyDims,102+ const bool noopWithEmptyDims, op::Shape& reduceShape)
103- op::Shape& reduceShape)
104{103{
105 bitset<MAX_MASK_LEN> dimMask = bitset<MAX_MASK_LEN>();104 bitset<MAX_MASK_LEN> dimMask = bitset<MAX_MASK_LEN>();
106 105 
@@ -150,15 +149,14 @@ static bool CheckDimValid(const aclTensor* self, const aclIntArray* dims)
150 149 
151 for (size_t i = 0; i < dims->Size(); i++) {150 for (size_t i = 0; i < dims->Size(); i++) {
152 if (dims->operator[](i) >= selfDimNum || dims->operator[](i) < (-selfDimNum)) {151 if (dims->operator[](i) >= selfDimNum || dims->operator[](i) < (-selfDimNum)) {
153- OP_LOGE(152+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Provided dims %ld must be in the range of [%ld, %ld].",
154- ACLNN_ERR_PARAM_INVALID, "Provided dims %ld must be in the range of [%ld, %ld].", dims->operator[](i),153+ dims->operator[](i), -selfDimNum, selfDimNum - 1);
155- -selfDimNum, selfDimNum - 1);
156 return false;154 return false;
157 }155 }
158 uint64_t index = GetPosDim(dims->operator[](i), selfDimNum);156 uint64_t index = GetPosDim(dims->operator[](i), selfDimNum);
159 // 非标量reduce的dims不能为0157 // 非标量reduce的dims不能为0
160 if (!isScalar && selfViewShape.GetDim(index) == 0) {158 if (!isScalar && selfViewShape.GetDim(index) == 0) {
161- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expected reducution dims %lu to have non-zero size.", index);159+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expected reduction dims %lu to have non-zero size.", index);
162 return false;160 return false;
163 }161 }
164 // dims重复162 // dims重复
@@ -173,9 +171,8 @@ static bool CheckDimValid(const aclTensor* self, const aclIntArray* dims)
173 return true;171 return true;
174}172}
175 173 
176-static bool CheckShape(174+static bool CheckShape(const aclTensor* self, const aclIntArray* dims, const bool keepDims,
177- const aclTensor* self, const aclIntArray* dims, const bool keepDims, const bool noopWithEmptyDims,175+ const bool noopWithEmptyDims, const aclTensor* out)
178- const aclTensor* out)
179{176{
180 OP_CHECK_MAX_DIM(self, MAX_SUPPORT_DIMS_NUMS, return false);177 OP_CHECK_MAX_DIM(self, MAX_SUPPORT_DIMS_NUMS, return false);
181 OP_CHECK_MAX_DIM(out, MAX_SUPPORT_DIMS_NUMS, return false);178 OP_CHECK_MAX_DIM(out, MAX_SUPPORT_DIMS_NUMS, return false);
@@ -187,9 +184,8 @@ static bool CheckShape(
187 return true;184 return true;
188}185}
189 186 
190-static aclnnStatus CheckParams(187+static aclnnStatus CheckParams(const aclTensor* self, const aclIntArray* dims, const bool keepDims,
191- const aclTensor* self, const aclIntArray* dims, const bool keepDims, const bool noopWithEmptyDims,188+ const bool noopWithEmptyDims, const aclTensor* out)
192- const aclTensor* out)
193{189{
194 // 1. 检查参数是否为空指针190 // 1. 检查参数是否为空指针
195 CHECK_RET(CheckNotNull(self, dims, out), ACLNN_ERR_PARAM_NULLPTR);191 CHECK_RET(CheckNotNull(self, dims, out), ACLNN_ERR_PARAM_NULLPTR);
@@ -205,9 +201,9 @@ static aclnnStatus CheckParams(
205 return ACLNN_SUCCESS;201 return ACLNN_SUCCESS;
206}202}
207 203 
208-aclnnStatus aclnnMaxV2GetWorkspaceSize(204+aclnnStatus aclnnMaxV2GetWorkspaceSize(const aclTensor* self, const aclIntArray* dims, const bool keepDims,
209- const aclTensor* self, const aclIntArray* dims, const bool keepDims, bool noopWithEmptyDims, aclTensor* out,205+ bool noopWithEmptyDims, aclTensor* out, uint64_t* workspaceSize,
210- uint64_t* workspaceSize, aclOpExecutor** executor)206+ aclOpExecutor** executor)
211{207{
212 L2_DFX_PHASE_1(aclnnMaxV2, DFX_IN(self, dims, keepDims, noopWithEmptyDims), DFX_OUT(out));208 L2_DFX_PHASE_1(aclnnMaxV2, DFX_IN(self, dims, keepDims, noopWithEmptyDims), DFX_OUT(out));
213 // 创建OpExecutor209 // 创建OpExecutor
@@ -245,8 +241,8 @@ aclnnStatus aclnnMaxV2GetWorkspaceSize(
245 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);241 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
246 242 
247 // 将输入self的数据类型转换成目标数据类型, bool 转为float, 其余保持原类型243 // 将输入self的数据类型转换成目标数据类型, bool 转为float, 其余保持原类型
248- op::DataType selfCastType =244+ op::DataType selfCastType = (self->GetDataType() == op::DataType::DT_BOOL) ? op::DataType::DT_FLOAT :
249- (self->GetDataType() == op::DataType::DT_BOOL) ? op::DataType::DT_FLOAT : self->GetDataType();245+ self->GetDataType();
250 246 
251 auto selfCasted = l0op::Cast(selfContiguous, selfCastType, uniqueExecutor.get());247 auto selfCasted = l0op::Cast(selfContiguous, selfCastType, uniqueExecutor.get());
252 CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);248 CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -50,43 +50,41 @@ static bool IsAiCoreSupport(const aclTensor* self)
50}50}
51 51 
52// AICORE算子kernel52// AICORE算子kernel
53-static const aclTensor* ReduceMaxAiCore(53+static const aclTensor* ReduceMaxAiCore(const aclTensor* self, const aclTensor* dimList, bool keepDim,
54- const aclTensor* self, const aclTensor* dimList, bool keepDim, bool noopWithEmptyDims, const aclTensor* maxOut,54+ bool noopWithEmptyDims, const aclTensor* maxOut, aclOpExecutor* executor)
55- aclOpExecutor* executor)
56{55{
57 L0_DFX(ReduceMaxAiCore, self, dimList, keepDim, noopWithEmptyDims, maxOut);56 L0_DFX(ReduceMaxAiCore, self, dimList, keepDim, noopWithEmptyDims, maxOut);
58 57 
59- auto retAicore = ADD_TO_LAUNCHER_LIST_AICORE(58+ auto retAicore = ADD_TO_LAUNCHER_LIST_AICORE(ReduceMax, OP_INPUT(self, dimList), OP_OUTPUT(maxOut),
60- ReduceMax, OP_INPUT(self, dimList), OP_OUTPUT(maxOut), OP_ATTR(keepDim, noopWithEmptyDims));59+ OP_ATTR(keepDim, noopWithEmptyDims));
61- OP_CHECK_ADD_TO_LAUNCHER_LIST_AICORE(60+ OP_CHECK_ADD_TO_LAUNCHER_LIST_AICORE(retAicore != ACLNN_SUCCESS, return nullptr,
62- retAicore != ACLNN_SUCCESS, return nullptr, "ReduceMax ADD_TO_LAUNCHER_LIST_AICORE failed.");61+ "ReduceMax ADD_TO_LAUNCHER_LIST_AICORE failed.");
63 62 
64 return maxOut;63 return maxOut;
65}64}
66 65 
67// AICPU算子kernel66// AICPU算子kernel
68-static const aclTensor* ReduceMaxAiCpu(67+static const aclTensor* ReduceMaxAiCpu(const aclTensor* self, const aclTensor* dimList, bool keepDim,
69- const aclTensor* self, const aclTensor* dimList, bool keepDim, const aclTensor* maxOut, aclOpExecutor* executor)68+ const aclTensor* maxOut, aclOpExecutor* executor)
70{69{
71 L0_DFX(ReduceMaxAiCpu, self, dimList, keepDim, maxOut);70 L0_DFX(ReduceMaxAiCpu, self, dimList, keepDim, maxOut);
72 71 
73 static internal::AicpuTaskSpace space("Max", ge::DEPEND_IN_SHAPE, true);72 static internal::AicpuTaskSpace space("Max", ge::DEPEND_IN_SHAPE, true);
74- auto ret = ADD_TO_LAUNCHER_LIST_AICPU(73+ auto ret = ADD_TO_LAUNCHER_LIST_AICPU(ReduceMax, OP_ATTR_NAMES({"keep_dims", "Tidx"}), OP_INPUT(self, dimList),
75- ReduceMax, OP_ATTR_NAMES({"keep_dims", "Tidx"}), OP_INPUT(self, dimList), OP_OUTPUT(maxOut),74+ OP_OUTPUT(maxOut), OP_ATTR(keepDim, dimList->GetDataType()));
76- OP_ATTR(keepDim, dimList->GetDataType()));
77 CHECK_RET(ret == ACLNN_SUCCESS, nullptr);75 CHECK_RET(ret == ACLNN_SUCCESS, nullptr);
78 return maxOut;76 return maxOut;
79}77}
80 78 
81-const aclTensor* ReduceMax(79+const aclTensor* ReduceMax(const aclTensor* self, const aclIntArray* dim, bool keepDim, bool noopWithEmptyDims,
82- const aclTensor* self, const aclIntArray* dim, bool keepDim, bool noopWithEmptyDims, aclOpExecutor* executor)80+ aclOpExecutor* executor)
83{81{
84 auto dimList = executor->ConvertToTensor(dim, op::DataType::DT_INT64);82 auto dimList = executor->ConvertToTensor(dim, op::DataType::DT_INT64);
85 auto maxOut = executor->AllocTensor(self->GetViewShape(), self->GetDataType());83 auto maxOut = executor->AllocTensor(self->GetViewShape(), self->GetDataType());
86 84 
87 auto ret = INFER_SHAPE(ReduceMax, OP_INPUT(self, dimList), OP_OUTPUT(maxOut), OP_ATTR(keepDim, noopWithEmptyDims));85 auto ret = INFER_SHAPE(ReduceMax, OP_INPUT(self, dimList), OP_OUTPUT(maxOut), OP_ATTR(keepDim, noopWithEmptyDims));
88 if (ret != ACLNN_SUCCESS) {86 if (ret != ACLNN_SUCCESS) {
89- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "ReduceMax infer shape faild.");87+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "ReduceMax infer shape failed.");
90 return nullptr;88 return nullptr;
91 }89 }
92 90 
@@ -214,7 +214,7 @@ static Status ParseOpToGraphReduceMean13(const Operator& op, Graph& graph)
214 output_indexs.emplace_back(reducemean13, vector<std::size_t>{0});214 output_indexs.emplace_back(reducemean13, vector<std::size_t>{0});
215 graph.SetInputs(inputs).SetOutputs(output_indexs);215 graph.SetInputs(inputs).SetOutputs(output_indexs);
216 } else {216 } else {
217- OP_LOGE(GetOpName(op).c_str(), "Input num or set attr is error");217+ OP_LOGE(GetOpName(op).c_str(), "Input num or set attr is invalid");
218 return FAILED;218 return FAILED;
219 }219 }
220 return SUCCESS;220 return SUCCESS;
@@ -52,8 +52,8 @@ static const std::initializer_list<DataType>& GetDtypeSupportList()
52 }52 }
53}53}
54 54 
55-static const std::initializer_list<op::Format> FORMAT_SUPPORT_LIST = {55+static const std::initializer_list<op::Format> FORMAT_SUPPORT_LIST = {op::Format::FORMAT_ND, op::Format::FORMAT_NCHW,
56- op::Format::FORMAT_ND, op::Format::FORMAT_NCHW, op::Format::FORMAT_NCDHW};56+ op::Format::FORMAT_NCDHW};
57 57 
58static bool CheckNotNull(const aclTensor* self, const aclTensor* out)58static bool CheckNotNull(const aclTensor* self, const aclTensor* out)
59{59{
@@ -90,7 +90,7 @@ static bool CheckFormatValid(const aclTensor* self, const aclTensor* out)
90 if (findSelfFormat != FORMAT_SUPPORT_LIST.end() && findOutFormat != FORMAT_SUPPORT_LIST.end()) {90 if (findSelfFormat != FORMAT_SUPPORT_LIST.end() && findOutFormat != FORMAT_SUPPORT_LIST.end()) {
91 return true;91 return true;
92 } else {92 } else {
93- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support NDNCHW and NCDHW.");93+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support ND, NCHW and NCDHW.");
94 return false;94 return false;
95 }95 }
96}96}
@@ -136,8 +136,8 @@ static bool IsNonContiguousSupport(const aclTensor* self, const aclIntArray* dim
136 return true;136 return true;
137}137}
138 138 
139-aclnnStatus aclnnGlobalAveragePoolGetWorkspaceSize(139+aclnnStatus aclnnGlobalAveragePoolGetWorkspaceSize(const aclTensor* self, aclTensor* out, uint64_t* workspaceSize,
140- const aclTensor* self, aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)140+ aclOpExecutor** executor)
141{141{
142 L2_DFX_PHASE_1(aclnnGlobalAveragePool, DFX_IN(self), DFX_OUT(out));142 L2_DFX_PHASE_1(aclnnGlobalAveragePool, DFX_IN(self), DFX_OUT(out));
143 143 
@@ -158,9 +158,9 @@ aclnnStatus aclnnGlobalAveragePoolGetWorkspaceSize(
158 const aclIntArray* dims = aclCreateIntArray(dimVector.data(), dimNum - 2);158 const aclIntArray* dims = aclCreateIntArray(dimVector.data(), dimNum - 2);
159 159 
160 if (IsNonContiguousSupport(self, dims)) {160 if (IsNonContiguousSupport(self, dims)) {
161- OP_LOGD("Enter NonContigous");161+ OP_LOGD("Enter NonContiguous");
162- auto selfContiguous = uniqueExecutor.get()->CreateView(162+ auto selfContiguous = uniqueExecutor.get()->CreateView(self, self->GetViewShape(), self->GetStorageShape(),
163- self, self->GetViewShape(), self->GetStorageShape(), self->GetViewStrides(), self->GetViewOffset());163+ self->GetViewStrides(), self->GetViewOffset());
164 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);164 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
165 auto meanOpOut = l0op::ReduceMean(selfContiguous, dims, true, uniqueExecutor.get());165 auto meanOpOut = l0op::ReduceMean(selfContiguous, dims, true, uniqueExecutor.get());
166 CHECK_RET(meanOpOut != nullptr, ACLNN_ERR_INNER_NULLPTR);166 CHECK_RET(meanOpOut != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -169,7 +169,7 @@ aclnnStatus aclnnGlobalAveragePoolGetWorkspaceSize(
169 auto viewCopyResult = l0op::ViewCopy(meanOpOut, out, uniqueExecutor.get());169 auto viewCopyResult = l0op::ViewCopy(meanOpOut, out, uniqueExecutor.get());
170 CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);170 CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);
171 } else {171 } else {
172- OP_LOGD("Enter Contigous");172+ OP_LOGD("Enter Contiguous");
173 // 固定写法,将输入self转换成连续的tensor173 // 固定写法,将输入self转换成连续的tensor
174 auto selfContiguous = l0op::Contiguous(self, uniqueExecutor.get());174 auto selfContiguous = l0op::Contiguous(self, uniqueExecutor.get());
175 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);175 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -189,8 +189,8 @@ aclnnStatus aclnnGlobalAveragePoolGetWorkspaceSize(
189 return ACLNN_SUCCESS;189 return ACLNN_SUCCESS;
190}190}
191 191 
192-aclnnStatus aclnnGlobalAveragePool(192+aclnnStatus aclnnGlobalAveragePool(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor,
193- void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, const aclrtStream stream)193+ const aclrtStream stream)
194{194{
195 L2_DFX_PHASE_2(aclnnGlobalAveragePool);195 L2_DFX_PHASE_2(aclnnGlobalAveragePool);
196 // 固定写法,调用框架能力,完成计算196 // 固定写法,调用框架能力,完成计算
@@ -84,9 +84,8 @@ static bool CheckDtypeValid(const aclTensor* self, aclDataType dtype, aclTensor*
84 84 
85 // 检查dtype指定的数据类型是否支持85 // 检查dtype指定的数据类型是否支持
86 if (!CheckType(op::ToOpDataType(dtype), supportList)) {86 if (!CheckType(op::ToOpDataType(dtype), supportList)) {
87- OP_LOGE(87+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "type %s should be in dtype support list [%s].",
88- ACLNN_ERR_PARAM_INVALID, "type %s should be in dtype support list [%s].",88+ op::ToString(op::ToOpDataType(dtype)).GetString(), op::ToString(supportList).GetString());
89- op::ToString(op::ToOpDataType(dtype)).GetString(), op::ToString(supportList).GetString());
90 return false;89 return false;
91 }90 }
92 OP_CHECK_DTYPE_NOT_SUPPORT(out, supportList, return false);91 OP_CHECK_DTYPE_NOT_SUPPORT(out, supportList, return false);
@@ -125,9 +124,8 @@ static bool CheckDimValid(const aclTensor* self, const aclIntArray* dim)
125 // 获取dim元素124 // 获取dim元素
126 for (size_t i = 0; i < dim->Size(); i++) {125 for (size_t i = 0; i < dim->Size(); i++) {
127 if (dim->operator[](i) >= selfDimNum || dim->operator[](i) < (-selfDimNum)) {126 if (dim->operator[](i) >= selfDimNum || dim->operator[](i) < (-selfDimNum)) {
128- OP_LOGE(127+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "provided dim %ld must be in the range of [%ld, %ld].", dim->operator[](i),
129- ACLNN_ERR_PARAM_INVALID, "provided dim %ld must be in the range of [%ld, %ld].", dim->operator[](i),128+ -selfDimNum, selfDimNum - 1);
130- -selfDimNum, selfDimNum - 1);
131 return false;129 return false;
132 }130 }
133 }131 }
@@ -231,16 +229,16 @@ static bool IsNonContiguousSupport(const aclTensor* self, DataType dtype, const
231 return true;229 return true;
232}230}
233 231 
234-static void CheckFormat(const aclTensor* self) {232+static void CheckFormat(const aclTensor* self)
233+{
235 ge::Format selfStorageFormat = self->GetStorageFormat();234 ge::Format selfStorageFormat = self->GetStorageFormat();
236 if (selfStorageFormat == ge::Format::FORMAT_FRACTAL_NZ) {235 if (selfStorageFormat == ge::Format::FORMAT_FRACTAL_NZ) {
237 OP_LOGW("aclnnMean doesn't support format NZ.");236 OP_LOGW("aclnnMean doesn't support format NZ.");
238 }237 }
239}238}
240 239 
241-aclnnStatus aclnnMeanGetWorkspaceSize(240+aclnnStatus aclnnMeanGetWorkspaceSize(const aclTensor* self, const aclIntArray* dim, bool keepDim, aclDataType dtype,
242- const aclTensor* self, const aclIntArray* dim, bool keepDim, aclDataType dtype, aclTensor* out,241+ aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)
243- uint64_t* workspaceSize, aclOpExecutor** executor)
244{242{
245 L2_DFX_PHASE_1(aclnnMean, DFX_IN(self, dim, keepDim, dtype), DFX_OUT(out));243 L2_DFX_PHASE_1(aclnnMean, DFX_IN(self, dim, keepDim, dtype), DFX_OUT(out));
246 // 创建OpExecutor244 // 创建OpExecutor
@@ -253,7 +251,7 @@ aclnnStatus aclnnMeanGetWorkspaceSize(
253 251 
254 // 检查self的format是否支持252 // 检查self的format是否支持
255 CheckFormat(self);253 CheckFormat(self);
256- 254+ 
257 // 算子的空tensor处理255 // 算子的空tensor处理
258 if (self->IsEmpty()) {256 if (self->IsEmpty()) {
259 // 空tensor填充NAN257 // 空tensor填充NAN
@@ -264,9 +262,9 @@ aclnnStatus aclnnMeanGetWorkspaceSize(
264 }262 }
265 263 
266 if (IsNonContiguousSupport(self, op::ToOpDataType(dtype), dim)) {264 if (IsNonContiguousSupport(self, op::ToOpDataType(dtype), dim)) {
267- OP_LOGD("Enter NonContigous");265+ OP_LOGD("Enter NonContiguous");
268- auto selfContiguous = uniqueExecutor.get()->CreateView(266+ auto selfContiguous = uniqueExecutor.get()->CreateView(self, self->GetViewShape(), self->GetStorageShape(),
269- self, self->GetViewShape(), self->GetStorageShape(), self->GetViewStrides(), self->GetViewOffset());267+ self->GetViewStrides(), self->GetViewOffset());
270 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);268 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
271 auto meanOpOut = l0op::ReduceMean(selfContiguous, dim, keepDim, uniqueExecutor.get());269 auto meanOpOut = l0op::ReduceMean(selfContiguous, dim, keepDim, uniqueExecutor.get());
272 CHECK_RET(meanOpOut != nullptr, ACLNN_ERR_INNER_NULLPTR);270 CHECK_RET(meanOpOut != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -311,9 +309,9 @@ aclnnStatus aclnnMean(void* workspace, uint64_t workspaceSize, aclOpExecutor* ex
311 return CommonOpExecutorRun(workspace, workspaceSize, executor, stream);309 return CommonOpExecutorRun(workspace, workspaceSize, executor, stream);
312}310}
313 311 
314-aclnnStatus aclnnMeanV2GetWorkspaceSize(312+aclnnStatus aclnnMeanV2GetWorkspaceSize(const aclTensor* self, const aclIntArray* dim, bool keepDim,
315- const aclTensor* self, const aclIntArray* dim, bool keepDim, bool noopWithEmptyAxes, aclTensor* out,313+ bool noopWithEmptyAxes, aclTensor* out, uint64_t* workspaceSize,
316- uint64_t* workspaceSize, aclOpExecutor** executor)314+ aclOpExecutor** executor)
317{315{
318 L2_DFX_PHASE_1(aclnnMeanV2, DFX_IN(self, dim, keepDim, noopWithEmptyAxes), DFX_OUT(out));316 L2_DFX_PHASE_1(aclnnMeanV2, DFX_IN(self, dim, keepDim, noopWithEmptyAxes), DFX_OUT(out));
319 // 创建OpExecutor317 // 创建OpExecutor
@@ -323,10 +321,10 @@ aclnnStatus aclnnMeanV2GetWorkspaceSize(
323 // 参数检查321 // 参数检查
324 auto ret = CheckParamsONNX(self, dim, out);322 auto ret = CheckParamsONNX(self, dim, out);
325 CHECK_RET(ret == ACLNN_SUCCESS, ret);323 CHECK_RET(ret == ACLNN_SUCCESS, ret);
326- 324+ 
327 // 检查self的format是否支持325 // 检查self的format是否支持
328 CheckFormat(self);326 CheckFormat(self);
329- 327+ 
330 // 算子的空tensor处理328 // 算子的空tensor处理
331 if (self->IsEmpty()) {329 if (self->IsEmpty()) {
332 // 空tensor填充NAN330 // 空tensor填充NAN
@@ -347,9 +345,9 @@ aclnnStatus aclnnMeanV2GetWorkspaceSize(
347 }345 }
348 346 
349 if (IsNonContiguousSupport(self, out->GetDataType(), dim)) {347 if (IsNonContiguousSupport(self, out->GetDataType(), dim)) {
350- OP_LOGD("Enter NonContigous");348+ OP_LOGD("Enter NonContiguous");
351- auto selfContiguous = uniqueExecutor.get()->CreateView(349+ auto selfContiguous = uniqueExecutor.get()->CreateView(self, self->GetViewShape(), self->GetStorageShape(),
352- self, self->GetViewShape(), self->GetStorageShape(), self->GetViewStrides(), self->GetViewOffset());350+ self->GetViewStrides(), self->GetViewOffset());
353 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);351 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
354 auto meanOpOut = l0op::ReduceMean(selfContiguous, dim, keepDim, noopWithEmptyAxes, uniqueExecutor.get());352 auto meanOpOut = l0op::ReduceMean(selfContiguous, dim, keepDim, noopWithEmptyAxes, uniqueExecutor.get());
355 CHECK_RET(meanOpOut != nullptr, ACLNN_ERR_INNER_NULLPTR);353 CHECK_RET(meanOpOut != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -359,7 +357,7 @@ aclnnStatus aclnnMeanV2GetWorkspaceSize(
359 auto viewCopyResult = l0op::ViewCopy(castMeanOut, out, uniqueExecutor.get());357 auto viewCopyResult = l0op::ViewCopy(castMeanOut, out, uniqueExecutor.get());
360 CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);358 CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);
361 } else {359 } else {
362- OP_LOGD("Enter Contigous");360+ OP_LOGD("Enter Contiguous");
363 // 将输入self转换成连续的tensor361 // 将输入self转换成连续的tensor
364 auto selfContiguous = l0op::Contiguous(self, uniqueExecutor.get());362 auto selfContiguous = l0op::Contiguous(self, uniqueExecutor.get());
365 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);363 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -393,4 +391,4 @@ aclnnStatus aclnnMeanV2(void* workspace, uint64_t workspaceSize, aclOpExecutor*
393 391 
394#ifdef __cplusplus392#ifdef __cplusplus
395}393}
396-#endif394+#endif
@@ -191,7 +191,7 @@ bool GlobalavgpoolPass::MeetRequirements(const std::unique_ptr<MatchResult>& mat
191 auto status = match_result->GetCapturedTensor(CAPTURE_TENSOR_IDX_INPUT, matchedNode);191 auto status = match_result->GetCapturedTensor(CAPTURE_TENSOR_IDX_INPUT, matchedNode);
192 OP_LOGD(FUSION_PASS_NAME.c_str(), "GetCapturedTensor returned: %d", status);192 OP_LOGD(FUSION_PASS_NAME.c_str(), "GetCapturedTensor returned: %d", status);
193 if (status != SUCCESS) {193 if (status != SUCCESS) {
194- OP_LOGE_WITHOUT_REPORT(FUSION_PASS_NAME.c_str(), "Failed to GetCaptrue tensor");194+ OP_LOGE_WITHOUT_REPORT(FUSION_PASS_NAME.c_str(), "Failed to GetCapture tensor");
195 return false;195 return false;
196 }196 }
197 197 
@@ -62,7 +62,7 @@ uint32_t ReduceMeanCpuKernel::Compute(CpuKernelContext& ctx)
62 auto axes_data = static_cast<int64_t*>(axes_tensor->GetData());62 auto axes_data = static_cast<int64_t*>(axes_tensor->GetData());
63 GetValueFromData<int64_t>(axes_data, axes_tensor->NumElements(), axes);63 GetValueFromData<int64_t>(axes_data, axes_tensor->NumElements(), axes);
64 } else {64 } else {
65- KERNEL_LOG_ERROR("axes type[%d] not support, only support DT_INT32 or DT_INT64.", axes_type);65+ KERNEL_LOG_ERROR("axes type[%d] not supported, only supports DT_INT32 or DT_INT64.", axes_type);
66 return KERNEL_STATUS_PARAM_INVALID;66 return KERNEL_STATUS_PARAM_INVALID;
67 }67 }
68 auto input_dtype = ctx.Input(kXIdx)->GetDataType();68 auto input_dtype = ctx.Input(kXIdx)->GetDataType();
@@ -70,7 +70,7 @@ uint32_t ReduceMeanCpuKernel::Compute(CpuKernelContext& ctx)
70 if (func != kreduce_mean_calls.end()) {70 if (func != kreduce_mean_calls.end()) {
71 return (func->second)(&ctx, axes);71 return (func->second)(&ctx, axes);
72 } else {72 } else {
73- KERNEL_LOG_ERROR("input[0] type[%d] not support", input_dtype);73+ KERNEL_LOG_ERROR("input[0] type[%d] not supported", input_dtype);
74 return KERNEL_STATUS_PARAM_INVALID;74 return KERNEL_STATUS_PARAM_INVALID;
75 }75 }
76}76}
@@ -55,8 +55,8 @@ struct ComplexFloatMeanReducer : Eigen::internal::MeanReducer<std::complex<float
55 {55 {
56 Eigen::internal::scalar_sum_op<std::complex<float>> sum_op;56 Eigen::internal::scalar_sum_op<std::complex<float>> sum_op;
57 return sum_op(saccum, predux(vaccum)) /57 return sum_op(saccum, predux(vaccum)) /
58- static_cast<std::complex<float>>(58+ static_cast<std::complex<float>>(scalarCount_ +
59- scalarCount_ + packetCount_ * Eigen::internal::unpacket_traits<Packet>::size);59+ packetCount_ * Eigen::internal::unpacket_traits<Packet>::size);
60 }60 }
61};61};
62 62 
@@ -71,8 +71,8 @@ struct ComplexDoubleMeanReducer : Eigen::internal::MeanReducer<std::complex<doub
71 {71 {
72 Eigen::internal::scalar_sum_op<std::complex<double>> sum_op;72 Eigen::internal::scalar_sum_op<std::complex<double>> sum_op;
73 return sum_op(saccum, predux(vaccum)) /73 return sum_op(saccum, predux(vaccum)) /
74- static_cast<std::complex<double>>(74+ static_cast<std::complex<double>>(scalarCount_ +
75- scalarCount_ + packetCount_ * Eigen::internal::unpacket_traits<Packet>::size);75+ packetCount_ * Eigen::internal::unpacket_traits<Packet>::size);
76 }76 }
77};77};
78 78 
@@ -82,9 +82,8 @@ uint32_t CheckAxes(const CpuKernelContext* context, const QuickVector& axes, boo
82 for (size_t i = 0U; i < axes.GetDimNum(); i++) {82 for (size_t i = 0U; i < axes.GetDimNum(); i++) {
83 auto index = axes[i];83 auto index = axes[i];
84 if (index < -input_dim_num || index >= input_dim_num) {84 if (index < -input_dim_num || index >= input_dim_num) {
85- KERNEL_LOG_ERROR(85+ KERNEL_LOG_ERROR("%s kernel reduction dimension axes[%zu]=%ld is invalid, input dimNum is %ld",
86- "%s kernel reduction dimension axes[%zu]=%ld is invalid, input dimNum is %ld",86+ context->GetOpType().c_str(), i, index, input_dim_num);
87- context->GetOpType().c_str(), i, index, input_dim_num);
88 return KERNEL_STATUS_PARAM_INVALID;87 return KERNEL_STATUS_PARAM_INVALID;
89 }88 }
90 index = (index + input_dim_num) % input_dim_num;89 index = (index + input_dim_num) % input_dim_num;
@@ -93,9 +92,8 @@ uint32_t CheckAxes(const CpuKernelContext* context, const QuickVector& axes, boo
93 return KERNEL_STATUS_OK;92 return KERNEL_STATUS_OK;
94}93}
95 94 
96-uint32_t ReductionHelper(95+uint32_t ReductionHelper(CpuKernelContext* context, bool& reduce_first_axis, const QuickVector& axes,
97- CpuKernelContext* context, bool& reduce_first_axis, const QuickVector& axes, QuickVector& input_reshape,96+ QuickVector& input_reshape, QuickVector& out_reshape)
98- QuickVector& out_reshape)
99{97{
100 bool bitmap[kMaxDimNum] = {false};98 bool bitmap[kMaxDimNum] = {false};
101 auto ret = CheckAxes(context, axes, bitmap);99 auto ret = CheckAxes(context, axes, bitmap);
@@ -147,9 +145,8 @@ void ReduceScalar(T* input_data, const QuickVector& input_reshape, T* out_data)
147}145}
148 146 
149template <typename T, typename Reducer, typename ReductionAxes, int32_t DIMS, int32_t UNREDUCE_DIMS>147template <typename T, typename Reducer, typename ReductionAxes, int32_t DIMS, int32_t UNREDUCE_DIMS>
150-void Reduce(148+void Reduce(const QuickVector& input_reshape, const QuickVector& out_reshape, const ReductionAxes& axis_eigen,
151- const QuickVector& input_reshape, const QuickVector& out_reshape, const ReductionAxes& axis_eigen, T* input_data,149+ T* input_data, T* out_data)
152- T* out_data)
153{150{
154 Eigen::TensorMap<Eigen::Tensor<T, 1, Eigen::RowMajor>> input_eigen(input_data, input_reshape.GetShapeSize());151 Eigen::TensorMap<Eigen::Tensor<T, 1, Eigen::RowMajor>> input_eigen(input_data, input_reshape.GetShapeSize());
155 Eigen::DSizes<Eigen::DenseIndex, DIMS> input_eigen_reshape;152 Eigen::DSizes<Eigen::DenseIndex, DIMS> input_eigen_reshape;
@@ -167,51 +164,56 @@ void Reduce(
167}164}
168 165 
169template <typename T, typename Reducer>166template <typename T, typename Reducer>
170-void ReduceBigger(167+void ReduceBigger(const QuickVector& input_reshape, const QuickVector& out_reshape, const bool reduce_first_axis,
171- const QuickVector& input_reshape, const QuickVector& out_reshape, const bool reduce_first_axis, T* input_data,168+ T* input_data, T* out_data)
172- T* out_data)
173{169{
174 if (input_reshape.GetDimNum() == DIM5 && reduce_first_axis) { // input_reshape dims = 5170 if (input_reshape.GetDimNum() == DIM5 && reduce_first_axis) { // input_reshape dims = 5
175- Reduce<T, Reducer, Eigen::array<int32_t, DIM3>, DIM5, DIM2>( // input_reshape dims = 5, reduce dims = 2, unreduce dims = 3171+ Reduce<T, Reducer, Eigen::array<int32_t, DIM3>, DIM5,
172+ DIM2>( // input_reshape dims = 5, reduce dims = 2, unreduce dims = 3
176 input_reshape, out_reshape, kReductionDimsZeroTwoForth, input_data, out_data);173 input_reshape, out_reshape, kReductionDimsZeroTwoForth, input_data, out_data);
177 } else if (input_reshape.GetDimNum() == DIM5 && !reduce_first_axis) { // input_reshape dims = 5174 } else if (input_reshape.GetDimNum() == DIM5 && !reduce_first_axis) { // input_reshape dims = 5
178- Reduce<T, Reducer, Eigen::array<int32_t, DIM2>, DIM5, DIM3>( // input_reshape dims = 5, reduce dims = 2, unreduce dims = 3175+ Reduce<T, Reducer, Eigen::array<int32_t, DIM2>, DIM5,
176+ DIM3>( // input_reshape dims = 5, reduce dims = 2, unreduce dims = 3
179 input_reshape, out_reshape, kReductionDimsOneThree, input_data, out_data);177 input_reshape, out_reshape, kReductionDimsOneThree, input_data, out_data);
180 } else if (input_reshape.GetDimNum() == DIM6 && reduce_first_axis) { // input_reshape dims = 6178 } else if (input_reshape.GetDimNum() == DIM6 && reduce_first_axis) { // input_reshape dims = 6
181- Reduce<T, Reducer, Eigen::array<int32_t, DIM3>, DIM6, DIM3>( // input_reshape dims = 6, reduce dims = 3, unreduce dims = 3179+ Reduce<T, Reducer, Eigen::array<int32_t, DIM3>, DIM6,
180+ DIM3>( // input_reshape dims = 6, reduce dims = 3, unreduce dims = 3
182 input_reshape, out_reshape, kReductionDimsZeroTwoForth, input_data, out_data);181 input_reshape, out_reshape, kReductionDimsZeroTwoForth, input_data, out_data);
183 } else if (input_reshape.GetDimNum() == DIM6 && !reduce_first_axis) { // input_reshape dims = 6182 } else if (input_reshape.GetDimNum() == DIM6 && !reduce_first_axis) { // input_reshape dims = 6
184- Reduce<T, Reducer, Eigen::array<int32_t, DIM3>, DIM6, DIM3>( // input_reshape dims = 6, reduce dims = 3, unreduce dims = 3183+ Reduce<T, Reducer, Eigen::array<int32_t, DIM3>, DIM6,
184+ DIM3>( // input_reshape dims = 6, reduce dims = 3, unreduce dims = 3
185 input_reshape, out_reshape, kReductionDimsOneThreeFive, input_data, out_data);185 input_reshape, out_reshape, kReductionDimsOneThreeFive, input_data, out_data);
186 } else if (input_reshape.GetDimNum() == DIM7 && reduce_first_axis) { // input_reshape dims = 7186 } else if (input_reshape.GetDimNum() == DIM7 && reduce_first_axis) { // input_reshape dims = 7
187- Reduce<T, Reducer, Eigen::array<int32_t, DIM4>, DIM7, DIM3>( // input_reshape dims = 7, reduce dims = 4, unreduce dims = 3187+ Reduce<T, Reducer, Eigen::array<int32_t, DIM4>, DIM7,
188+ DIM3>( // input_reshape dims = 7, reduce dims = 4, unreduce dims = 3
188 input_reshape, out_reshape, kReductionDimsZeroTwoForthSix, input_data, out_data);189 input_reshape, out_reshape, kReductionDimsZeroTwoForthSix, input_data, out_data);
189 } else if (input_reshape.GetDimNum() == DIM7 && !reduce_first_axis) { // input_reshape dims = DIM7190 } else if (input_reshape.GetDimNum() == DIM7 && !reduce_first_axis) { // input_reshape dims = DIM7
190- Reduce<T, Reducer, Eigen::array<int32_t, DIM3>, DIM7, DIM4>( // input_reshape dims = 7, reduce dims = 3, unreduce dims = 4191+ Reduce<T, Reducer, Eigen::array<int32_t, DIM3>, DIM7,
192+ DIM4>( // input_reshape dims = 7, reduce dims = 3, unreduce dims = 4
191 input_reshape, out_reshape, kReductionDimsOneThreeFive, input_data, out_data);193 input_reshape, out_reshape, kReductionDimsOneThreeFive, input_data, out_data);
192 } else if (input_reshape.GetDimNum() == DIM8 && reduce_first_axis) { // input_reshape dims = 8194 } else if (input_reshape.GetDimNum() == DIM8 && reduce_first_axis) { // input_reshape dims = 8
193- Reduce<T, Reducer, Eigen::array<int32_t, DIM4>, DIM8, DIM4>( // input_reshape dims = 8, reduce dims = 4, unreduce dims = 4195+ Reduce<T, Reducer, Eigen::array<int32_t, DIM4>, DIM8,
196+ DIM4>( // input_reshape dims = 8, reduce dims = 4, unreduce dims = 4
194 input_reshape, out_reshape, kReductionDimsZeroTwoForthSix, input_data, out_data);197 input_reshape, out_reshape, kReductionDimsZeroTwoForthSix, input_data, out_data);
195 } else if (input_reshape.GetDimNum() == DIM8 && !reduce_first_axis) { // input_reshape dims = 8198 } else if (input_reshape.GetDimNum() == DIM8 && !reduce_first_axis) { // input_reshape dims = 8
196- Reduce<T, Reducer, Eigen::array<int32_t, DIM4>, DIM8, DIM4>( // input_reshape dims = 8, reduce dims = 4, unreduce dims = 4199+ Reduce<T, Reducer, Eigen::array<int32_t, DIM4>, DIM8,
200+ DIM4>( // input_reshape dims = 8, reduce dims = 4, unreduce dims = 4
197 input_reshape, out_reshape, kReductionDimsOneThreeFiveSeven, input_data, out_data);201 input_reshape, out_reshape, kReductionDimsOneThreeFiveSeven, input_data, out_data);
198 } else {202 } else {
199- KERNEL_LOG_ERROR(203+ KERNEL_LOG_ERROR("reductionOp kernel input_reshape dims should be less or equal than 8, but now is [%zu]",
200- "reductionOp kernel input_reshape dims should be less or equal than 8, but now is [%zu]",204+ input_reshape.GetDimNum());
201- input_reshape.GetDimNum());
202 }205 }
203}206}
204 207 
205template <typename T, typename Reducer>208template <typename T, typename Reducer>
206-void ReduceDim3AndDim4(209+void ReduceDim3AndDim4(const QuickVector& input_reshape, const QuickVector& out_reshape, const bool reduce_first_axis,
207- const QuickVector& input_reshape, const QuickVector& out_reshape, const bool reduce_first_axis, T* input_data,210+ T* input_data, T* out_data)
208- T* out_data)
209{211{
210 if (input_reshape.GetDimNum() == DIM3 && reduce_first_axis) { // input_reshape dims = 3212 if (input_reshape.GetDimNum() == DIM3 && reduce_first_axis) { // input_reshape dims = 3
211- Reduce<T, Reducer, Eigen::array<int32_t, DIM2>, DIM3, 1>( // input_reshape dims = 3, reduce dims = 2213+ Reduce<T, Reducer, Eigen::array<int32_t, DIM2>, DIM3, 1>( // input_reshape dims = 3, reduce dims = 2
212 input_reshape, out_reshape, kReductionDimsZeroTwo, input_data, out_data);214 input_reshape, out_reshape, kReductionDimsZeroTwo, input_data, out_data);
213 } else if (input_reshape.GetDimNum() == DIM3 && !reduce_first_axis) { // input_reshape dims = 3215 } else if (input_reshape.GetDimNum() == DIM3 && !reduce_first_axis) { // input_reshape dims = 3
214- Reduce<T, Reducer, Eigen::array<int32_t, 1>, DIM3, DIM2>( // input_reshape dims = 3, unreduce dims = 2216+ Reduce<T, Reducer, Eigen::array<int32_t, 1>, DIM3, DIM2>( // input_reshape dims = 3, unreduce dims = 2
215 input_reshape, out_reshape, kReductionDimsOne, input_data, out_data);217 input_reshape, out_reshape, kReductionDimsOne, input_data, out_data);
216 } else if (input_reshape.GetDimNum() == DIM4 && reduce_first_axis) { // input_reshape dims = 4218 } else if (input_reshape.GetDimNum() == DIM4 && reduce_first_axis) { // input_reshape dims = 4
217 Reduce<T, Reducer, Eigen::array<int32_t, DIM2>, DIM4, DIM2>( // input_reshape dims = 4, reduce/unreduce dims = 2219 Reduce<T, Reducer, Eigen::array<int32_t, DIM2>, DIM4, DIM2>( // input_reshape dims = 4, reduce/unreduce dims = 2
@@ -220,13 +222,11 @@ void ReduceDim3AndDim4(
220 Reduce<T, Reducer, Eigen::array<int32_t, DIM2>, DIM4, DIM2>( // input_reshape dims = 4, reduce/unreduce dims = 2222 Reduce<T, Reducer, Eigen::array<int32_t, DIM2>, DIM4, DIM2>( // input_reshape dims = 4, reduce/unreduce dims = 2
221 input_reshape, out_reshape, kReductionDimsOneThree, input_data, out_data);223 input_reshape, out_reshape, kReductionDimsOneThree, input_data, out_data);
222 } else {224 } else {
223- KERNEL_LOG_ERROR(225+ KERNEL_LOG_ERROR("reductionOp kernel input_reshape dims should be less or equal than 8, but now is [%zu]",
224- "reductionOp kernel input_reshape dims should be less or equal than 8, but now is [%zu]",226+ input_reshape.GetDimNum());
225- input_reshape.GetDimNum());
226 }227 }
227}228}
228 229 
229- 
230template <typename T>230template <typename T>
231uint32_t ProcessingEmptyTensor(CpuKernelContext* context)231uint32_t ProcessingEmptyTensor(CpuKernelContext* context)
232{232{
@@ -237,12 +237,12 @@ uint32_t ProcessingEmptyTensor(CpuKernelContext* context)
237 KERNEL_LOG_INFO("Output num less than 1, output num is [%ld]", output_num);237 KERNEL_LOG_INFO("Output num less than 1, output num is [%ld]", output_num);
238 return KERNEL_STATUS_OK;238 return KERNEL_STATUS_OK;
239 }239 }
240- KERNEL_CHECK_NULLPTR(240+ KERNEL_CHECK_NULLPTR(out_tensor, KERNEL_STATUS_PARAM_INVALID, "%s get out_tensor failed.",
241- out_tensor, KERNEL_STATUS_PARAM_INVALID, "%s get out_tensor failed.", context->GetOpType().c_str());241+ context->GetOpType().c_str());
242 auto out_data = static_cast<T*>(out_tensor);242 auto out_data = static_cast<T*>(out_tensor);
243- KERNEL_CHECK_NULLPTR(243+ KERNEL_CHECK_NULLPTR(out_data, KERNEL_STATUS_PARAM_INVALID, "%s get out_data failed.",
244- out_data, KERNEL_STATUS_PARAM_INVALID, "%s get out_data failed.", context->GetOpType().c_str());244+ context->GetOpType().c_str());
245- static const std::vector<DataType> OutputZeroValue = {DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8,245+ static const std::vector<DataType> OutputZeroValue = {DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8,
246 DT_UINT16, DT_UINT32, DT_UINT64, DT_COMPLEX64, DT_COMPLEX128};246 DT_UINT16, DT_UINT32, DT_UINT64, DT_COMPLEX64, DT_COMPLEX128};
247 static const std::vector<DataType> OutputNanValue = {DT_FLOAT16, DT_FLOAT, DT_DOUBLE};247 static const std::vector<DataType> OutputNanValue = {DT_FLOAT16, DT_FLOAT, DT_DOUBLE};
248 T output_data{};248 T output_data{};
@@ -251,10 +251,9 @@ uint32_t ProcessingEmptyTensor(CpuKernelContext* context)
251 } else if (find(OutputNanValue.begin(), OutputNanValue.end(), input_type) != OutputNanValue.end()) {251 } else if (find(OutputNanValue.begin(), OutputNanValue.end(), input_type) != OutputNanValue.end()) {
252 output_data = static_cast<T>(std::numeric_limits<T>::quiet_NaN());252 output_data = static_cast<T>(std::numeric_limits<T>::quiet_NaN());
253 } else {253 } else {
254- KERNEL_LOG_WARN(254+ KERNEL_LOG_WARN("Empty tensor type not supported for input tensor, output num is [%ld], "
255- "Empty tensor type not support for input tensor, output num is [%ld], "255+ "data type is [%s]",
256- "data type is [%s]",256+ output_num, DTypeStr(input_type).c_str());
257- output_num, DTypeStr(input_type).c_str());
258 return KERNEL_STATUS_OK;257 return KERNEL_STATUS_OK;
259 }258 }
260 for (int64_t output_index = 0; output_index < output_num; output_index++) {259 for (int64_t output_index = 0; output_index < output_num; output_index++) {
@@ -266,10 +265,10 @@ uint32_t ProcessingEmptyTensor(CpuKernelContext* context)
266// 超大函数 重构265// 超大函数 重构
267template <typename T, typename Reducer>266template <typename T, typename Reducer>
268uint32_t ReduceDispatch(const QuickVector& input_reshape, const QuickVector& out_reshape, bool reduce_first_axis,267uint32_t ReduceDispatch(const QuickVector& input_reshape, const QuickVector& out_reshape, bool reduce_first_axis,
269- T* input_data, T* out_data)268+ T* input_data, T* out_data)
270{269{
271 // 因为tensor的维度最高为8,因此input_reshape的size最高为4270 // 因为tensor的维度最高为8,因此input_reshape的size最高为4
272- if (input_reshape.GetDimNum() == 1 && reduce_first_axis) { // reduce成一个标量271+ if (input_reshape.GetDimNum() == 1 && reduce_first_axis) { // reduce成一个标量
273 ReduceScalar<T, Reducer>(input_data, input_reshape, out_data);272 ReduceScalar<T, Reducer>(input_data, input_reshape, out_data);
274 } else if (input_reshape.GetDimNum() == DIM2 && reduce_first_axis) { // input_reshape dims = 2273 } else if (input_reshape.GetDimNum() == DIM2 && reduce_first_axis) { // input_reshape dims = 2
275 Reduce<T, Reducer, Eigen::array<int32_t, 1>, DIM2, 1>( // input_reshape dims = 2274 Reduce<T, Reducer, Eigen::array<int32_t, 1>, DIM2, 1>( // input_reshape dims = 2
@@ -279,7 +278,8 @@ uint32_t ReduceDispatch(const QuickVector& input_reshape, const QuickVector& out
279 input_reshape, out_reshape, kReductionDimsOne, input_data, out_data);278 input_reshape, out_reshape, kReductionDimsOne, input_data, out_data);
280 } else if (input_reshape.GetDimNum() == DIM3 || input_reshape.GetDimNum() == DIM4) { // input_reshape dims = 4 or =3279 } else if (input_reshape.GetDimNum() == DIM3 || input_reshape.GetDimNum() == DIM4) { // input_reshape dims = 4 or =3
281 ReduceDim3AndDim4<T, Reducer>(input_reshape, out_reshape, reduce_first_axis, input_data, out_data);280 ReduceDim3AndDim4<T, Reducer>(input_reshape, out_reshape, reduce_first_axis, input_data, out_data);
282- } else if (input_reshape.GetDimNum() > DIM4 && input_reshape.GetDimNum() <= DIM8) { // input_reshape dims > 4 and <= 8281+ } else if (input_reshape.GetDimNum() > DIM4 &&
282+ input_reshape.GetDimNum() <= DIM8) { // input_reshape dims > 4 and <= 8
283 ReduceBigger<T, Reducer>(input_reshape, out_reshape, reduce_first_axis, input_data, out_data);283 ReduceBigger<T, Reducer>(input_reshape, out_reshape, reduce_first_axis, input_data, out_data);
284 } else {284 } else {
285 return KERNEL_STATUS_PARAM_INVALID;285 return KERNEL_STATUS_PARAM_INVALID;
@@ -288,41 +288,42 @@ uint32_t ReduceDispatch(const QuickVector& input_reshape, const QuickVector& out
288}288}
289 289 
290template <typename T>290template <typename T>
291-uint32_t CheckInputs(CpuKernelContext* context) {291+uint32_t CheckInputs(CpuKernelContext* context)
292+{
292 auto input = context->Input(kXIdx);293 auto input = context->Input(kXIdx);
293 if (input == nullptr) {294 if (input == nullptr) {
294 KERNEL_LOG_ERROR("%s get input failed.", context->GetOpType().c_str());295 KERNEL_LOG_ERROR("%s get input failed.", context->GetOpType().c_str());
295- return KERNEL_STATUS_PARAM_INVALID; 296+ return KERNEL_STATUS_PARAM_INVALID;
296 }297 }
297 auto input_shape = input->GetTensorShape();298 auto input_shape = input->GetTensorShape();
298 if (input_shape == nullptr) {299 if (input_shape == nullptr) {
299- KERNEL_LOG_ERROR("%s get input_shape failed.", context->GetOpType().c_str()); 300+ KERNEL_LOG_ERROR("%s get input_shape failed.", context->GetOpType().c_str());
300- return KERNEL_STATUS_PARAM_INVALID; 301+ return KERNEL_STATUS_PARAM_INVALID;
301 }302 }
302 auto output = context->Output(kYIdx);303 auto output = context->Output(kYIdx);
303 if (output == nullptr) {304 if (output == nullptr) {
304 KERNEL_LOG_ERROR("%s get output failed.", context->GetOpType().c_str());305 KERNEL_LOG_ERROR("%s get output failed.", context->GetOpType().c_str());
305- return KERNEL_STATUS_PARAM_INVALID; 306+ return KERNEL_STATUS_PARAM_INVALID;
306 }307 }
307 auto input_tensor = input->GetData();308 auto input_tensor = input->GetData();
308 if (input_tensor == nullptr) {309 if (input_tensor == nullptr) {
309 KERNEL_LOG_ERROR("%s get input_tensor failed.", context->GetOpType().c_str());310 KERNEL_LOG_ERROR("%s get input_tensor failed.", context->GetOpType().c_str());
310- return KERNEL_STATUS_PARAM_INVALID; 311+ return KERNEL_STATUS_PARAM_INVALID;
311 }312 }
312 auto out_tensor = output->GetData();313 auto out_tensor = output->GetData();
313 if (out_tensor == nullptr) {314 if (out_tensor == nullptr) {
314 KERNEL_LOG_ERROR("%s get out_tensor failed.", context->GetOpType().c_str());315 KERNEL_LOG_ERROR("%s get out_tensor failed.", context->GetOpType().c_str());
315- return KERNEL_STATUS_PARAM_INVALID; 316+ return KERNEL_STATUS_PARAM_INVALID;
316- } 317+ }
317 auto out_data = static_cast<T*>(out_tensor);318 auto out_data = static_cast<T*>(out_tensor);
318 if (out_data == nullptr) {319 if (out_data == nullptr) {
319 KERNEL_LOG_ERROR("%s get out_data failed.", context->GetOpType().c_str());320 KERNEL_LOG_ERROR("%s get out_data failed.", context->GetOpType().c_str());
320- return KERNEL_STATUS_PARAM_INVALID; 321+ return KERNEL_STATUS_PARAM_INVALID;
321 }322 }
322- auto out_shape = output->GetTensorShape(); 323+ auto out_shape = output->GetTensorShape();
323 if (out_shape == nullptr) {324 if (out_shape == nullptr) {
324 KERNEL_LOG_ERROR("%s get out_shape failed.", context->GetOpType().c_str());325 KERNEL_LOG_ERROR("%s get out_shape failed.", context->GetOpType().c_str());
325- return KERNEL_STATUS_PARAM_INVALID; 326+ return KERNEL_STATUS_PARAM_INVALID;
326 }327 }
327 return KERNEL_STATUS_OK;328 return KERNEL_STATUS_OK;
328}329}
@@ -331,9 +332,9 @@ template <typename T, typename Reducer>
331uint32_t ReductionOp(CpuKernelContext* context, const QuickVector& axes)332uint32_t ReductionOp(CpuKernelContext* context, const QuickVector& axes)
332{333{
333 if (CheckInputs<T>(context) != KERNEL_STATUS_OK) {334 if (CheckInputs<T>(context) != KERNEL_STATUS_OK) {
334- return KERNEL_STATUS_PARAM_INVALID; 335+ return KERNEL_STATUS_PARAM_INVALID;
335- } 336+ }
336- 337+ 
337 // empty tensor338 // empty tensor
338 auto input = context->Input(kXIdx);339 auto input = context->Input(kXIdx);
339 auto data_num = input->NumElements();340 auto data_num = input->NumElements();
@@ -351,8 +352,8 @@ uint32_t ReductionOp(CpuKernelContext* context, const QuickVector& axes)
351 auto ret = ReductionHelper(context, reduce_first_axis, axes, input_reshape, out_reshape);352 auto ret = ReductionHelper(context, reduce_first_axis, axes, input_reshape, out_reshape);
352 if (ret != KERNEL_STATUS_OK) {353 if (ret != KERNEL_STATUS_OK) {
353 return ret;354 return ret;
354- } 355+ }
355- 356+ 
356 auto input_tensor = input->GetData();357 auto input_tensor = input->GetData();
357 auto input_data = static_cast<T*>(input_tensor);358 auto input_data = static_cast<T*>(input_tensor);
358 auto output = context->Output(kYIdx);359 auto output = context->Output(kYIdx);
@@ -371,7 +372,7 @@ uint32_t ReductionOp(CpuKernelContext* context, const QuickVector& axes)
371 if (ReduceDispatch<T, Reducer>(input_reshape, out_reshape, reduce_first_axis, input_data, out_data) ==372 if (ReduceDispatch<T, Reducer>(input_reshape, out_reshape, reduce_first_axis, input_data, out_data) ==
372 KERNEL_STATUS_PARAM_INVALID) {373 KERNEL_STATUS_PARAM_INVALID) {
373 KERNEL_LOG_ERROR("%s kernel input_reshape dims should be less or equal than 8, but now is [%zu]",374 KERNEL_LOG_ERROR("%s kernel input_reshape dims should be less or equal than 8, but now is [%zu]",
374- context->GetOpType().c_str(), input_reshape.GetDimNum());375+ context->GetOpType().c_str(), input_reshape.GetDimNum());
375 376 
376 return KERNEL_STATUS_PARAM_INVALID;377 return KERNEL_STATUS_PARAM_INVALID;
377 } else {378 } else {
@@ -217,7 +217,7 @@ static Status ParseOpToGraphReduceMin13(const Operator& op, Graph& graph)
217 output_indexs.emplace_back(reducemin13, vector<std::size_t>{0});217 output_indexs.emplace_back(reducemin13, vector<std::size_t>{0});
218 graph.SetInputs(inputs).SetOutputs(output_indexs);218 graph.SetInputs(inputs).SetOutputs(output_indexs);
219 } else {219 } else {
220- OP_LOGE(GetOpName(op).c_str(), "Input num or set attr is error");220+ OP_LOGE(GetOpName(op).c_str(), "Input num or set attr is invalid");
221 return FAILED;221 return FAILED;
222 }222 }
223 return SUCCESS;223 return SUCCESS;