已合并
gather_elements算子tik转ascendc实现 #8774
xiu_ling_wang创建于 8月17日
gather_elements算子tik转ascendc实现 #8774
已合并
xiu_ling_wang创建于 8月17日
17 个文件变更+6388-8
@@ -9,7 +9,10 @@
9# ----------------------------------------------------------------------------9# ----------------------------------------------------------------------------
10 10 
11# 设置算子定义时支持的芯片类型11# 设置算子定义时支持的芯片类型
12-set(SUPPORT_COMPUTE_UNIT "ascend950" "mc62")12+set(SUPPORT_COMPUTE_UNIT "ascend950" "mc62" "ascend910b" "ascend910_93")
13# 设置每种芯片类型对应的tiling文件目录,即采用op_host目录下哪个文件夹下的tiling文件编译13# 设置每种芯片类型对应的tiling文件目录,即采用op_host目录下哪个文件夹下的tiling文件编译
14-set(SUPPORT_TILING_DIR "arch35" "arch35")14+set(SUPPORT_TILING_DIR "arch35" "arch35" "arch22" "arch22")
15-add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE gather_elements ACLNNTYPE aclnn_exclude COMPUTE_UNIT ${SUPPORT_COMPUTE_UNIT} TILING_DIR ${SUPPORT_TILING_DIR} DISABLE_IN_OPP TRUE DEPENDENCIES gather_elements_v2)15+add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE gather_elements ACLNNTYPE aclnn_exclude COMPUTE_UNIT ${SUPPORT_COMPUTE_UNIT} TILING_DIR ${SUPPORT_TILING_DIR} DISABLE_IN_OPP TRUE DEPENDENCIES gather_elements_v2)
16+if (TARGET ${OPHOST_NAME}_tiling_obj)
17+ target_sources(${OPHOST_NAME}_tiling_obj PRIVATE op_host/gather_elements_def.cpp)
18+endif()
@@ -107,6 +107,8 @@ static int64_t GetTensorSize(const aclTensor* input)
107 return size;107 return size;
108}108}
109 109 
110+static int64_t CeilDiv(const int64_t a, const int64_t b) { return (a + b - 1) / b; }
111+ 
110static bool IsSameDimValueExceptAxis(const op::Shape x_shape, const op::Shape index_shape, const int64_t axis,112static bool IsSameDimValueExceptAxis(const op::Shape x_shape, const op::Shape index_shape, const int64_t axis,
111 const size_t dims)113 const size_t dims)
112{114{
@@ -168,9 +170,25 @@ static bool IsLastAxisSupport(const aclTensor* self, const aclTensor* index, con
168 } else if (!is_last_axis) {170 } else if (!is_last_axis) {
169 return false;171 return false;
170 }172 }
171- all_data_size = repeat_per_core * x_axis * x_dsize + repeat_per_core * index_axis * (x_dsize + index_dsize);173+ if (isSupportSoc) {
172- if (all_data_size >= available_ub_size) {174+ const int64_t blockSizeX = BLOCK_SIZE / x_dsize;
173- return false;175+ const int64_t blockSizeIdx = BLOCK_SIZE / index_dsize;
176+ const int64_t blockSizeIdx32 = BLOCK_SIZE / FOUR_BYTE;
177+ const int64_t xAligned = CeilDiv(x_axis, blockSizeX) * blockSizeX;
178+ const int64_t idxAligned = CeilDiv(index_axis, blockSizeIdx) * blockSizeIdx;
179+ const int64_t resAligned = CeilDiv(index_axis, blockSizeX) * blockSizeX;
180+ const int64_t idx32Aligned = CeilDiv(index_axis, blockSizeIdx32) * blockSizeIdx32;
181+ const int64_t lastAxisUbSize = repeat_per_core *
182+ (xAligned * x_dsize + idxAligned * index_dsize + resAligned * x_dsize +
183+ idx32Aligned * 2 * FOUR_BYTE + index_axis * FOUR_BYTE);
184+ if (lastAxisUbSize >= available_ub_size) {
185+ return false;
186+ }
187+ } else {
188+ all_data_size = repeat_per_core * x_axis * x_dsize + repeat_per_core * index_axis * (x_dsize + index_dsize);
189+ if (all_data_size >= available_ub_size) {
190+ return false;
191+ }
174 }192 }
175 return true;193 return true;
176}194}
@@ -233,4 +251,4 @@ const aclTensor* GatherElements(const aclTensor* self, const int64_t dim, const
233 }251 }
234 return out;252 return out;
235}253}
236-} // namespace l0op254+} // namespace l0op
@@ -0,0 +1,11 @@
1+# ----------------------------------------------------------------------------
2+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License")
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------
10+ 
11+add_graph_plugin_sources()
@@ -0,0 +1,57 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include <vector>
12+#include "op_fallback.h"
13+ 
14+#ifdef __cplusplus
15+extern "C" {
16+#endif
17+namespace fallback {
18+ 
19+using namespace ge;
20+using namespace gert;
21+static const size_t X_INDEX = 0;
22+static const size_t INDEX_INDEX = 1;
23+ 
24+static graphStatus GatherElementsHostExecuteFunc(OpExecuteContext* host_api_ctx)
25+{
26+ OP_CHECK_IF(host_api_ctx == nullptr, OP_LOGE(host_api_ctx->GetNodeName(), "host_api_ctx is null"),
27+ return GRAPH_FAILED);
28+ OP_LOGD(host_api_ctx->GetNodeName(), "GatherElementsHostExecuteFunc in ");
29+ 
30+ auto x = host_api_ctx->GetInputTensor(X_INDEX);
31+ OP_CHECK_IF(x == nullptr, OP_LOGE(host_api_ctx->GetNodeName(), "x is null"), return GRAPH_FAILED);
32+ 
33+ auto index = host_api_ctx->GetInputTensor(INDEX_INDEX);
34+ OP_CHECK_IF(index == nullptr, OP_LOGE(host_api_ctx->GetNodeName(), "index is null"), return GRAPH_FAILED);
35+ 
36+ auto y = host_api_ctx->GetOutputTensor(0);
37+ OP_CHECK_IF(y == nullptr, OP_LOGE(host_api_ctx->GetNodeName(), "y is null"), return GRAPH_FAILED);
38+ 
39+ auto attrs = host_api_ctx->GetAttrs();
40+ const int64_t* dim = attrs->GetAttrPointer<int64_t>(0);
41+ 
42+ OP_LOGD(host_api_ctx->GetNodeName(), "GatherElements fallback to aclnnGather begin, dim = %ld", *dim);
43+ 
44+ // execute opapi
45+ auto apiRet = CANN_OPS_OPB_SYN_EXEC_ACLNN(host_api_ctx, aclnnGather, x, *dim, index, y);
46+ OP_CHECK_IF(apiRet != GRAPH_SUCCESS, OP_LOGE(host_api_ctx->GetNodeName(), "apiRet failed:%d", apiRet),
47+ return GRAPH_FAILED);
48+ 
49+ return GRAPH_SUCCESS;
50+}
51+ 
52+IMPL_OP(GatherElements).OpExecuteFunc(GatherElementsHostExecuteFunc);
53+} // namespace fallback
54+ 
55+#ifdef __cplusplus
56+}
57+#endif
@@ -0,0 +1,1358 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+/*!
12+ * \file gather_elements_tiling.cpp
13+ * \brief
14+ */
15+#include "gather_elements_tiling.h"
16+#include "error_util.h"
17+#include "log/log.h"
18+#include "op_common/op_host/util/platform_util.h"
19+#include "op_host/tiling_util.h"
20+#include "graph/utils/type_utils.h"
21+#include "register/op_impl_registry.h"
22+#include <algorithm>
23+#include <set>
24+#include <vector>
25+ 
26+namespace {
27+const int32_t BLOCK_SIZE = 32;
28+const int32_t PARAMS_CUT_INTO_SLICE_UB = 149984;
29+const int32_t PARAMS_CARRY_BLOCK_UB = 730 * 1024;
30+const int32_t CONVERT_TO_AICPU_UB = 3000 * 1024;
31+const int32_t INDICES_NUM_THRESHOULD = 2048;
32+const int32_t RESERVED_UB_SIZE = 2 * 1024;
33+const int32_t INT_MAX_NUM = 2147483647;
34+const int32_t HALF = 2;
35+ 
36+// A: params larger than cache_ub
37+// B: indices larger than the number contained in one block for each core
38+// C: remaining indices larger than one block
39+ 
40+const int64_t TILING_MODE_X_LARGE_INDICES_LARGE = 1;
41+const int64_t TILING_MODE_X_SMALL_INDICES_LARGE = 2;
42+const int64_t TILING_MODE_X_SLICE_INDICES_LARGE = 3;
43+const int64_t TILING_MODE_DIF = 3;
44+// tiling mode when params and indices are so large that both are cut into slices
45+const int64_t TILING_MODE_FOR_LAST_AXIS = 7;
46+const int64_t TILING_MODE_FOR_LAST_AXIS_GATHER = 8;
47+const int64_t TILING_MODE_FOR_LAST_AXIS_DIFF_SHAPE = 9;
48+const int64_t TILING_MODE_FOR_LAST_AXIS_CUT_GATHER = 10;
49+ 
50+const size_t DIM_0 = 0;
51+const size_t DIM_1 = 1;
52+const size_t DIM_2 = 2;
53+const size_t DIM_3 = 3;
54+const size_t DIM_4 = 4;
55+const size_t DIM_5 = 5;
56+const size_t DIM_6 = 6;
57+const size_t DIM_7 = 7;
58+ 
59+const size_t MAX_DIMS = 8;
60+const int64_t PARAMS_AXIS_PRE_NONE = 1;
61+const int64_t LEAST_REPEAT_TIME = 1;
62+ 
63+const size_t INDEX_ATTR_AXIS = 0;
64+const size_t SIZE_INT32 = 4;
65+const std::string OP_NAME = "GatherElements";
66+ 
67+const std::set<ge::DataType> GATHER_DTYPES = {ge::DT_INT16, ge::DT_UINT16, ge::DT_FLOAT16, ge::DT_BF16,
68+ ge::DT_INT32, ge::DT_UINT32, ge::DT_FLOAT};
69+constexpr int64_t V2_RESERVED_UB_SIZE = 2048;
70+constexpr int64_t V2_CACHELINE = 512;
71+constexpr int64_t V2_BLOCK_SIZE = 32;
72+constexpr int64_t V2_TRANSPOSE_WS_LEN = 128;
73+constexpr int64_t V2_NUM_TWO = 2;
74+constexpr int64_t V2_UB_LIMIT = 120000;
75+constexpr int64_t V2_ASCEND_910B_CORE_NUM = 48;
76+constexpr int64_t V2_ASCEND_910B_UB = 196608;
77+constexpr int64_t V2_POST_DIM_LIMIT = 32;
78+constexpr int64_t V2_TRANS_LEN = 16;
79+constexpr int64_t V2_MODE_SCALAR = 0;
80+constexpr int64_t V2_MODE_TRANSPOSE = 1;
81+constexpr int64_t V2_MODE_LASTDIM = 2;
82+const std::set<ge::DataType> GATHER_ELEMENTS_V2_DTYPES = {ge::DT_INT32, ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_BF16};
83+constexpr int64_t V2LD_RESERVED_UB = 10 * 1024;
84+constexpr int64_t V2LD_NUM_ONE = 1;
85+constexpr int64_t V2LD_INT8_DSIZE = 1;
86+constexpr int64_t V2LD_INT6_DSIZE = 2;
87+constexpr int64_t V2LD_INT32_DSIZE = 4;
88+constexpr int64_t V2LD_INT64_DSIZE = 8;
89+constexpr int64_t V2LD_BLOCK_SIZE = 32;
90+constexpr int64_t V2LD_MAX_SLICE_NUM = 5;
91+constexpr int64_t V2LD_MAX_SIZE_RATIO = 256;
92+constexpr int64_t V2LD_DOUBLE_TIME = 2;
93+constexpr float V2LD_MASK_SIZE_RATE = 1.0f / 4;
94+ 
95+template <typename T, typename U>
96+inline T ceilAlign(T value, U factor)
97+{
98+ return (factor == 0) ? value :
99+ ((value + static_cast<T>(factor) - 1) / static_cast<T>(factor)) * static_cast<T>(factor);
100+}
101+ 
102+template <typename T, typename U>
103+inline T ceilDiv(T value, U factor)
104+{
105+ return (factor == 0) ? value : (value + static_cast<T>(factor) - 1) / static_cast<T>(factor);
106+}
107+ 
108+template <typename T, typename U>
109+inline T floorDiv(T value, U factor)
110+{
111+ return (factor == 0) ? value : value / static_cast<T>(factor);
112+}
113+ 
114+} // namespace
115+ 
116+namespace optiling {
117+ 
118+class GatherElementsTiling {
119+public:
120+ explicit GatherElementsTiling(gert::TilingContext* context) : tilingContext_(context) {}
121+ ge::graphStatus Init();
122+ ge::graphStatus SetKernelTiling();
123+ void TilingDataPrint();
124+ 
125+private:
126+ ge::graphStatus GetPlatformInfo();
127+ bool CheckTensorShape() const;
128+ bool IfParamsIndicesSameShapeExceptAxis() const;
129+ void FalseAxis(int32_t axis, int32_t paramsDims);
130+ void RecordTilingCommonInformation(int32_t axis, int32_t paramsDims);
131+ void RecordShapeInformation();
132+ void ConfirmCutIntoSliceInformation();
133+ void ConfirmIndicesLoopInformation(int64_t availableUbSize);
134+ void ChooseTilingModeSameShapeExceptAxis();
135+ bool LastAxisCutIntoSlices(bool sameShapeExceptAxisFlag, int64_t lastDimSize, int64_t availableUbSize);
136+ int64_t CalcuRepeatUnaligned(int32_t indicesAxis, int32_t largeNumPerBlock) const;
137+ bool ChooseTilingModeForLastAxis(bool ifSameDimValueExceptAxis);
138+ bool ChooseTilingMode(bool ifSameDimValueExceptAxis);
139+ 
140+ gert::TilingContext* tilingContext_ = nullptr;
141+ const GatherElementsCompileInfo* compileInfo_ = nullptr;
142+ int64_t coreNumAll_ = 0;
143+ int64_t ubSize_ = 0;
144+ GatherElementsTilingData tilingData_;
145+ CommonInformation commonInformation_;
146+ gert::Shape paramsShape_;
147+ gert::Shape indicesShape_;
148+ gert::Shape yShape_;
149+ int32_t axis_ = 0;
150+ int32_t dims_ = 0;
151+ int32_t paramsDsize_ = 0;
152+ int32_t indicesDsize_ = 0;
153+ int32_t supportGather_ = 0;
154+ 
155+ bool useV2_ = false;
156+ int64_t v2UsedCoreNum_ = 0;
157+ int64_t v2Workspace_ = 0;
158+ 
159+ ge::graphStatus TryRouteToV2();
160+ ge::graphStatus ComputeV2LastDimTiling();
161+ bool IfUseV2() const;
162+ bool V2MemCheck() const;
163+};
164+ 
165+// 获取平台信息比如CoreNum、UB资源大小;platformInfo 为空时回退到 compileInfo 中 TilingPrepare 阶段保存的值
166+ge::graphStatus GatherElementsTiling::GetPlatformInfo()
167+{
168+ auto platformInfo = tilingContext_->GetPlatformInfo();
169+ if (platformInfo == nullptr) {
170+ OP_CHECK_IF(compileInfo_ == nullptr, OP_LOGE(tilingContext_->GetNodeName(), "compile info is null"),
171+ return ge::GRAPH_FAILED);
172+ coreNumAll_ = compileInfo_->core_num;
173+ ubSize_ = compileInfo_->ub_size;
174+ } else {
175+ auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);
176+ coreNumAll_ = ascendcPlatform.GetCoreNumAiv();
177+ uint64_t ubSizePlatForm;
178+ ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSizePlatForm);
179+ ubSize_ = static_cast<int64_t>(ubSizePlatForm);
180+ }
181+ return ge::GRAPH_SUCCESS;
182+}
183+ 
184+bool GatherElementsTiling::CheckTensorShape() const
185+{
186+ int32_t paramsDims = paramsShape_.GetDimNum();
187+ int32_t indicesDims = indicesShape_.GetDimNum();
188+ int32_t yDims = yShape_.GetDimNum();
189+ if (paramsDims != yDims) {
190+ OP_LOGE(tilingContext_->GetNodeName(),
191+ "op [GatherElementsTiling] : CheckTensorShape, x shape range and index shape range is not the same.");
192+ return false;
193+ }
194+ if (yDims != indicesDims) {
195+ OP_LOGE(tilingContext_->GetNodeName(), "op [GatherElementsTiling] : CheckTensorShape, y Shape is invalid.");
196+ return false;
197+ }
198+ for (int32_t i = 0; i < yDims; i++) {
199+ if (yShape_.GetDim(i) != indicesShape_.GetDim(i)) {
200+ OP_LOGE(tilingContext_->GetNodeName(),
201+ "op [GatherElementsTiling] : CheckTensorShape, y Shape dim is invalid.");
202+ return false;
203+ }
204+ }
205+ return true;
206+}
207+ 
208+// confirm information of param_slice.
209+void GatherElementsTiling::ConfirmCutIntoSliceInformation()
210+{
211+ tilingData_.set_slice_num(
212+ ceilDiv(tilingData_.get_params_total() * commonInformation_.params_dsize, PARAMS_CUT_INTO_SLICE_UB));
213+ tilingData_.set_slice_thickness_once(ceilDiv(tilingData_.get_params_total(), tilingData_.get_slice_num()));
214+ tilingData_.set_slice_thickness_once(
215+ ceilDiv(tilingData_.get_slice_thickness_once(), commonInformation_.params_block_num) *
216+ commonInformation_.params_block_num);
217+ tilingData_.set_slice_thickness_last(tilingData_.get_params_total() -
218+ tilingData_.get_slice_thickness_once() * (tilingData_.get_slice_num() - 1));
219+}
220+ 
221+void GatherElementsTiling::ConfirmIndicesLoopInformation(int64_t availableUbSize)
222+{
223+ OP_TILING_CHECK(commonInformation_.indices_block_num == 0 || commonInformation_.params_block_num == 0 ||
224+ commonInformation_.indices_block_num_large == 0,
225+ VECTOR_INNER_ERR_REPORT_TILIING("GatherElements",
226+ "In the ConfirmIndicesLoopInformation function, the divisor is 0."),
227+ return);
228+ int64_t indicesNumEachLoop = availableUbSize / (static_cast<int64_t>(commonInformation_.indices_dsize) +
229+ static_cast<int64_t>(commonInformation_.params_dsize));
230+ indicesNumEachLoop = std::min(
231+ indicesNumEachLoop / commonInformation_.indices_block_num * commonInformation_.indices_block_num,
232+ indicesNumEachLoop / commonInformation_.params_block_num * commonInformation_.params_block_num);
233+ 
234+ tilingData_.set_indices_num_each_core(tilingData_.get_indices_num() / tilingData_.get_need_core_num() /
235+ commonInformation_.indices_block_num_large *
236+ commonInformation_.indices_block_num_large);
237+ tilingData_.set_indices_num_remaining(tilingData_.get_indices_num() -
238+ tilingData_.get_need_core_num() * tilingData_.get_indices_num_each_core());
239+ OP_TILING_CHECK(indicesNumEachLoop == static_cast<int64_t>(0),
240+ VECTOR_INNER_ERR_REPORT_TILIING("GatherElements",
241+ "In the ConfirmIndicesLoopInformation function, the divisor is 0."),
242+ return);
243+ tilingData_.set_indices_loop_num(tilingData_.get_indices_num_each_core() / indicesNumEachLoop);
244+ tilingData_.set_indices_row_num_once(indicesNumEachLoop);
245+ tilingData_.set_indices_row_num_last(tilingData_.get_indices_num_each_core() %
246+ tilingData_.get_indices_row_num_once());
247+ tilingData_.set_remaining_block_remain(tilingData_.get_indices_num_remaining() %
248+ commonInformation_.indices_block_num_large);
249+ tilingData_.set_remaining_block_num(tilingData_.get_indices_num_remaining() /
250+ commonInformation_.indices_block_num_large);
251+}
252+ 
253+bool GatherElementsTiling::IfParamsIndicesSameShapeExceptAxis() const
254+{
255+ for (int32_t i = 0; i < dims_; i++) {
256+ if ((i != axis_) && (paramsShape_.GetDim(i) != indicesShape_.GetDim(i))) {
257+ return false;
258+ }
259+ }
260+ return true;
261+}
262+ 
263+// record shape information
264+void GatherElementsTiling::RecordShapeInformation()
265+{
266+ std::vector<int64_t> paramsShapePerDim(MAX_DIMS, 0);
267+ std::vector<int64_t> indicesShapePerDim(MAX_DIMS, 0);
268+ for (int32_t i = 0; i < dims_; i++) {
269+ paramsShapePerDim[i] = paramsShape_.GetDim(i);
270+ indicesShapePerDim[i] = indicesShape_.GetDim(i);
271+ }
272+ tilingData_.set_indices_shape_0(indicesShapePerDim[DIM_0]);
273+ tilingData_.set_indices_shape_1(indicesShapePerDim[DIM_1]);
274+ tilingData_.set_indices_shape_2(indicesShapePerDim[DIM_2]);
275+ tilingData_.set_indices_shape_3(indicesShapePerDim[DIM_3]);
276+ tilingData_.set_indices_shape_4(indicesShapePerDim[DIM_4]);
277+ tilingData_.set_indices_shape_5(indicesShapePerDim[DIM_5]);
278+ tilingData_.set_indices_shape_6(indicesShapePerDim[DIM_6]);
279+ tilingData_.set_indices_shape_7(indicesShapePerDim[DIM_7]);
280+ 
281+ tilingData_.set_params_shape_0(paramsShapePerDim[DIM_0]);
282+ tilingData_.set_params_shape_1(paramsShapePerDim[DIM_1]);
283+ tilingData_.set_params_shape_2(paramsShapePerDim[DIM_2]);
284+ tilingData_.set_params_shape_3(paramsShapePerDim[DIM_3]);
285+ tilingData_.set_params_shape_4(paramsShapePerDim[DIM_4]);
286+ tilingData_.set_params_shape_5(paramsShapePerDim[DIM_5]);
287+ tilingData_.set_params_shape_6(paramsShapePerDim[DIM_6]);
288+ tilingData_.set_params_shape_7(paramsShapePerDim[DIM_7]);
289+}
290+ 
291+// params shape convert to 3D:[params_pre, params_axis, params_row]
292+// indices shape convert to 1D:[indices_num]
293+// output tensor, y shape convert to:[params_pre, indices_num, params_row]
294+void GatherElementsTiling::FalseAxis(int32_t axis, int32_t paramsDims)
295+{
296+ tilingData_.set_params_pre(PARAMS_AXIS_PRE_NONE);
297+ tilingData_.set_params_row(PARAMS_AXIS_PRE_NONE);
298+ for (int32_t i = 0; i < axis; i++) {
299+ tilingData_.set_params_pre(tilingData_.get_params_pre() * paramsShape_.GetDim(i));
300+ }
301+ tilingData_.set_params_axis(paramsShape_.GetDim(axis));
302+ tilingData_.set_indices_axis(indicesShape_.GetDim(axis));
303+ if (axis + 1 < paramsDims) {
304+ for (int32_t i = axis + 1; i < paramsDims; i++) {
305+ tilingData_.set_params_row(tilingData_.get_params_row() * paramsShape_.GetDim(i));
306+ }
307+ }
308+}
309+ 
310+void GatherElementsTiling::RecordTilingCommonInformation(int32_t axis, int32_t paramsDims)
311+{
312+ FalseAxis(axis, paramsDims);
313+ commonInformation_.indices_pre = PARAMS_AXIS_PRE_NONE;
314+ for (int32_t i = 0; i < axis; i++) {
315+ commonInformation_.indices_pre *= indicesShape_.GetDim(i);
316+ }
317+ int64_t paramsExceptPre = 1;
318+ for (int32_t i = axis; i < dims_; i++) {
319+ paramsExceptPre *= paramsShape_.GetDim(i);
320+ }
321+ commonInformation_.params_except_pre_size = ceilDiv(paramsExceptPre * commonInformation_.params_dsize, BLOCK_SIZE) *
322+ BLOCK_SIZE;
323+ commonInformation_.params_dsize = paramsDsize_;
324+ commonInformation_.indices_dsize = indicesDsize_;
325+ commonInformation_.params_block_num = BLOCK_SIZE / commonInformation_.params_dsize;
326+ commonInformation_.indices_block_num = BLOCK_SIZE / commonInformation_.indices_dsize;
327+ commonInformation_.large_num_per_block = std::max(commonInformation_.params_block_num,
328+ commonInformation_.indices_block_num);
329+ int32_t paramSmallerThanIndices = std::max(commonInformation_.indices_dsize / commonInformation_.params_dsize,
330+ static_cast<int32_t>(1));
331+ commonInformation_.indices_block_num_large = paramSmallerThanIndices * commonInformation_.indices_block_num;
332+ tilingData_.set_params_total(paramsShape_.GetShapeSize());
333+ tilingData_.set_indices_num(indicesShape_.GetShapeSize());
334+ tilingData_.set_slice_num(LEAST_REPEAT_TIME);
335+ commonInformation_.params_total_ceil = ceilDiv(tilingData_.get_params_total(),
336+ commonInformation_.params_block_num) *
337+ commonInformation_.params_block_num;
338+ commonInformation_.params_total_ceil_size = commonInformation_.params_total_ceil * commonInformation_.params_dsize;
339+}
340+ 
341+void GatherElementsTiling::ChooseTilingModeSameShapeExceptAxis()
342+{
343+ int64_t xUbSize = 0;
344+ tilingData_.set_need_core_num(coreNumAll_);
345+ if (commonInformation_.params_total_ceil_size > PARAMS_CARRY_BLOCK_UB) {
346+ tilingData_.set_tilingMode(TILING_MODE_X_LARGE_INDICES_LARGE);
347+ } else if (commonInformation_.params_total_ceil_size > PARAMS_CUT_INTO_SLICE_UB &&
348+ commonInformation_.params_total_ceil_size <= PARAMS_CARRY_BLOCK_UB) {
349+ ConfirmCutIntoSliceInformation();
350+ tilingData_.set_tilingMode(TILING_MODE_X_SLICE_INDICES_LARGE);
351+ xUbSize = tilingData_.get_slice_thickness_once() * commonInformation_.params_dsize;
352+ } else {
353+ tilingData_.set_tilingMode(TILING_MODE_X_SMALL_INDICES_LARGE);
354+ xUbSize = commonInformation_.params_total_ceil_size;
355+ }
356+ int64_t availableUbSize = ubSize_ - xUbSize - RESERVED_UB_SIZE;
357+ ConfirmIndicesLoopInformation(availableUbSize);
358+}
359+ 
360+bool GatherElementsTiling::LastAxisCutIntoSlices(bool sameShapeExceptAxisFlag, int64_t lastDimSize,
361+ int64_t availableUbSize)
362+{
363+ if (sameShapeExceptAxisFlag && lastDimSize >= availableUbSize &&
364+ tilingData_.get_params_axis() * commonInformation_.params_dsize <= availableUbSize / HALF &&
365+ tilingData_.get_indices_axis() % commonInformation_.large_num_per_block == 0) {
366+ const int64_t repeatPerCore = tilingData_.get_repeat_per_core();
367+ const int64_t paramsAxis = tilingData_.get_params_axis();
368+ const int64_t paramsDsize = commonInformation_.params_dsize;
369+ const int64_t indicesDsize = commonInformation_.indices_dsize;
370+ const int64_t blockSizeX = BLOCK_SIZE / paramsDsize;
371+ const int64_t xAligned = ceilDiv(paramsAxis, blockSizeX) * blockSizeX;
372+ const int64_t fixedPerRow = xAligned * paramsDsize;
373+ const int64_t perElem = indicesDsize + paramsDsize + SIZE_INT32 * 2;
374+ int64_t cutSlice = (availableUbSize - repeatPerCore * fixedPerRow) / (repeatPerCore * perElem) /
375+ commonInformation_.large_num_per_block * commonInformation_.large_num_per_block;
376+ if (cutSlice <= 0) {
377+ return false;
378+ }
379+ int64_t sliceNum = ceilDiv(tilingData_.get_indices_axis(), cutSlice);
380+ int64_t lastSlice = tilingData_.get_indices_axis() - (sliceNum - 1) * cutSlice;
381+ tilingData_.set_slice_num(sliceNum);
382+ tilingData_.set_slice_thickness_once(cutSlice);
383+ tilingData_.set_slice_thickness_last(lastSlice);
384+ tilingData_.set_tilingMode(TILING_MODE_FOR_LAST_AXIS_CUT_GATHER);
385+ return true;
386+ }
387+ return false;
388+}
389+ 
390+int64_t GatherElementsTiling::CalcuRepeatUnaligned(int32_t indicesAxis, int32_t largeNumPerBlock) const
391+{
392+ int64_t repeatPerCore = LEAST_REPEAT_TIME;
393+ if (largeNumPerBlock == static_cast<int32_t>(0)) {
394+ return repeatPerCore;
395+ }
396+ while (repeatPerCore * indicesAxis % largeNumPerBlock != 0) {
397+ repeatPerCore++;
398+ }
399+ return repeatPerCore;
400+}
401+ 
402+static int64_t Gcd(int64_t a, int64_t b)
403+{
404+ while (b != 0) {
405+ int64_t t = a % b;
406+ a = b;
407+ b = t;
408+ }
409+ return a;
410+}
411+ 
412+bool GatherElementsTiling::ChooseTilingModeForLastAxis(bool ifSameDimValueExceptAxis)
413+{
414+ int64_t repeatPerCore = LEAST_REPEAT_TIME;
415+ if (!ifSameDimValueExceptAxis && tilingData_.get_indices_axis() < commonInformation_.large_num_per_block) {
416+ return false;
417+ }
418+ // Normal branches
419+ tilingData_.set_tilingMode(ifSameDimValueExceptAxis ? TILING_MODE_FOR_LAST_AXIS :
420+ TILING_MODE_FOR_LAST_AXIS_DIFF_SHAPE);
421+ if (ifSameDimValueExceptAxis && tilingData_.get_indices_axis() % commonInformation_.large_num_per_block != 0) {
422+ // unaligned cases
423+ repeatPerCore = CalcuRepeatUnaligned(tilingData_.get_indices_axis(), commonInformation_.large_num_per_block);
424+ }
425+ 
426+ OP_TILING_CHECK(repeatPerCore == 0, OP_LOGW("GatherElements", "op GatherElementsTiling: while repeatPerCore is 0."),
427+ return false);
428+ int64_t availableUbSize = ubSize_ - static_cast<int64_t>(RESERVED_UB_SIZE);
429+ 
430+ const int64_t TASKS_PER_CORE_TARGET = 8;
431+ if (ifSameDimValueExceptAxis && supportGather_ == 0 && availableUbSize > 0) {
432+ const int64_t indicesAxis = tilingData_.get_indices_axis();
433+ const int64_t paramsAxis = tilingData_.get_params_axis();
434+ const int64_t blockSizeX = BLOCK_SIZE / commonInformation_.params_dsize;
435+ const int64_t blockSizeIdx = BLOCK_SIZE / commonInformation_.indices_dsize;
436+ const int64_t blockSizeIdx32 = BLOCK_SIZE / static_cast<int64_t>(SIZE_INT32);
437+ const int64_t xAligned = ceilDiv(paramsAxis, blockSizeX) * blockSizeX;
438+ const int64_t idxAligned = ceilDiv(indicesAxis, blockSizeIdx) * blockSizeIdx;
439+ const int64_t resAligned = ceilDiv(indicesAxis, blockSizeX) * blockSizeX;
440+ const int64_t idx32Aligned = ceilDiv(indicesAxis, blockSizeIdx32) * blockSizeIdx32;
441+ const int64_t perRowBytes = xAligned * commonInformation_.params_dsize +
442+ idxAligned * commonInformation_.indices_dsize +
443+ resAligned * commonInformation_.params_dsize +
444+ idx32Aligned * 2 * static_cast<int64_t>(SIZE_INT32) +
445+ indicesAxis * static_cast<int64_t>(SIZE_INT32);
446+ const int64_t maxByUb = perRowBytes > 0 ? (availableUbSize - 1) / perRowBytes : repeatPerCore;
447+ const int64_t coreNum = coreNumAll_;
448+ const int64_t maxByRounds = (coreNum > 0) ?
449+ (commonInformation_.indices_pre / (TASKS_PER_CORE_TARGET * coreNum)) :
450+ repeatPerCore;
451+ const int64_t cap = std::min(maxByUb, maxByRounds > 0 ? maxByRounds : repeatPerCore);
452+ const int64_t large = commonInformation_.large_num_per_block;
453+ const int64_t step = (large > 0) ? (large / Gcd(large, indicesAxis)) : 1;
454+ const int64_t inflated = (cap / step) * step;
455+ if (inflated > repeatPerCore) {
456+ repeatPerCore = inflated;
457+ }
458+ }
459+ 
460+ tilingData_.set_repeat_per_core(repeatPerCore);
461+ tilingData_.set_rounds(ceilDiv(commonInformation_.indices_pre, repeatPerCore));
462+ tilingData_.set_rounds_tail(commonInformation_.indices_pre % repeatPerCore);
463+ 
464+ int64_t lastDimSize = repeatPerCore * tilingData_.get_params_axis() * commonInformation_.params_dsize +
465+ repeatPerCore * tilingData_.get_indices_axis() *
466+ (static_cast<int64_t>(commonInformation_.params_dsize) +
467+ static_cast<int64_t>(commonInformation_.indices_dsize));
468+ tilingData_.set_indices_loop_num(tilingData_.get_rounds() / coreNumAll_);
469+ tilingData_.set_need_core_num(tilingData_.get_rounds() > coreNumAll_ ? coreNumAll_ : tilingData_.get_rounds());
470+ tilingData_.set_indices_row_num_last(tilingData_.get_rounds() % coreNumAll_);
471+ 
472+ // Branch judgment for cutting indices into slices
473+ if (LastAxisCutIntoSlices(ifSameDimValueExceptAxis, lastDimSize, availableUbSize)) {
474+ return true;
475+ }
476+ 
477+ const int64_t blockSizeX = BLOCK_SIZE / commonInformation_.params_dsize;
478+ const int64_t blockSizeIdx = BLOCK_SIZE / commonInformation_.indices_dsize;
479+ const int64_t blockSizeIdx32 = BLOCK_SIZE / static_cast<int64_t>(SIZE_INT32);
480+ const int64_t paramsAxis = tilingData_.get_params_axis();
481+ const int64_t indicesAxis = tilingData_.get_indices_axis();
482+ const int64_t xAligned = ceilDiv(paramsAxis, blockSizeX) * blockSizeX;
483+ const int64_t idxAligned = ceilDiv(indicesAxis, blockSizeIdx) * blockSizeIdx;
484+ const int64_t resAligned = ceilDiv(indicesAxis, blockSizeX) * blockSizeX;
485+ const int64_t idx32Aligned = ceilDiv(indicesAxis, blockSizeIdx32) * blockSizeIdx32;
486+ const int64_t lastAxisUbSize = repeatPerCore * (xAligned * commonInformation_.params_dsize +
487+ idxAligned * commonInformation_.indices_dsize +
488+ resAligned * commonInformation_.params_dsize +
489+ idx32Aligned * 2 * static_cast<int64_t>(SIZE_INT32) +
490+ indicesAxis * static_cast<int64_t>(SIZE_INT32));
491+ 
492+ if ((supportGather_ == 1) && (lastAxisUbSize < availableUbSize) && ifSameDimValueExceptAxis) {
493+ tilingData_.set_tilingMode(TILING_MODE_FOR_LAST_AXIS_GATHER);
494+ tilingData_.set_dbFlag(lastAxisUbSize < availableUbSize / HALF ? 1 : 0);
495+ }
496+ OP_TILING_CHECK(
497+ lastAxisUbSize >= availableUbSize,
498+ OP_LOGW("GatherElements", "op GatherElementsTiling: while axis is the last dim, the shape is too large."),
499+ return false);
500+ return true;
501+}
502+ 
503+bool GatherElementsTiling::ChooseTilingMode(bool ifSameDimValueExceptAxis)
504+{
505+ // 1.tiling mode for last axis.
506+ // 2.tiling mode for not too large shape.
507+ // 3.when choose tiling failed, aicpu recommended.
508+ OP_TILING_CHECK(
509+ commonInformation_.params_total_ceil_size > INT_MAX_NUM,
510+ OP_LOGW("GatherElements", "op GatherElementsTiling: x is too large, it's not proper to use aicore."),
511+ return false);
512+ 
513+ OP_TILING_CHECK(tilingData_.get_params_axis() > INT_MAX_NUM / HALF,
514+ OP_LOGW(OP_NAME.c_str(), "op [GatherElementsTiling] : shape range of x axis is larger than the "
515+ "threshold, it's not proper to use aicore."),
516+ return false);
517+ 
518+ bool indicesPreNotEqualOne = commonInformation_.indices_pre != 1;
519+ bool lastAxisFlag = axis_ == (dims_ - 1);
520+ 
521+ if (indicesPreNotEqualOne && lastAxisFlag && ChooseTilingModeForLastAxis(ifSameDimValueExceptAxis)) {
522+ return true;
523+ }
524+ 
525+ // determine to use aicore or aicpu gatherElements
526+ OP_TILING_CHECK((commonInformation_.params_total_ceil_size > CONVERT_TO_AICPU_UB &&
527+ tilingData_.get_indices_num() > INDICES_NUM_THRESHOULD),
528+ OP_LOGW("GatherElements", "op GatherElementsTiling: it's not proper to use aicore."), return false);
529+ 
530+ ChooseTilingModeSameShapeExceptAxis();
531+ if (!ifSameDimValueExceptAxis) {
532+ tilingData_.set_tilingMode(tilingData_.get_tilingMode() + TILING_MODE_DIF);
533+ }
534+ return true;
535+}
536+ 
537+bool GatherElementsTiling::V2MemCheck() const
538+{
539+ int64_t idxGatherDim = indicesShape_.GetDim(axis_);
540+ int64_t selfGatherDim = paramsShape_.GetDim(axis_);
541+ int64_t selfDtypeSize = paramsDsize_;
542+ int64_t idxDtypeSize = indicesDsize_;
543+ int64_t indexShapeProduct = 1;
544+ int64_t selfShapeProduct = 1;
545+ int64_t idxPreDim = 1;
546+ int64_t idxPostDim = 1;
547+ for (int32_t i = 0; i < dims_; i++) {
548+ indexShapeProduct *= indicesShape_.GetDim(i);
549+ selfShapeProduct *= paramsShape_.GetDim(i);
550+ if (i > axis_) {
551+ idxPostDim *= indicesShape_.GetDim(i);
552+ } else if (i < axis_) {
553+ idxPreDim *= indicesShape_.GetDim(i);
554+ }
555+ }
556+ bool isTransCase = true;
557+ bool memCheck = true;
558+ if (selfGatherDim * selfDtypeSize < V2_UB_LIMIT) {
559+ isTransCase = true;
560+ memCheck = idxGatherDim >= V2_TRANS_LEN && selfGatherDim >= V2_TRANS_LEN;
561+ } else if (selfGatherDim * selfDtypeSize > V2_ASCEND_910B_UB) {
562+ isTransCase = false;
563+ } else {
564+ memCheck = false;
565+ }
566+ if (memCheck && isTransCase) {
567+ int64_t tailGroupCoreNum = std::max(static_cast<int64_t>(1), V2_ASCEND_910B_CORE_NUM / idxPreDim);
568+ int64_t workspaceLen = std::min(V2_CACHELINE / selfDtypeSize,
569+ (idxPostDim + tailGroupCoreNum - 1) / tailGroupCoreNum);
570+ if (idxPreDim * idxPostDim <= V2_ASCEND_910B_CORE_NUM) {
571+ memCheck = selfShapeProduct > idxPreDim * idxPostDim * (idxGatherDim + selfGatherDim);
572+ } else {
573+ memCheck = selfShapeProduct * selfDtypeSize + indexShapeProduct * idxDtypeSize >
574+ indexShapeProduct * selfDtypeSize +
575+ V2_ASCEND_910B_CORE_NUM * workspaceLen *
576+ (idxGatherDim * idxDtypeSize + selfGatherDim * selfDtypeSize);
577+ }
578+ }
579+ return memCheck;
580+}
581+ 
582+bool GatherElementsTiling::IfUseV2() const
583+{
584+ auto inputDesc = tilingContext_->GetInputDesc(0);
585+ if (inputDesc == nullptr) {
586+ return false;
587+ }
588+ if (GATHER_ELEMENTS_V2_DTYPES.count(inputDesc->GetDataType()) == 0) {
589+ return false;
590+ }
591+ if (axis_ == dims_ - 1) {
592+ for (int32_t i = 0; i < dims_; i++) {
593+ if (i != axis_ && paramsShape_.GetDim(i) != indicesShape_.GetDim(i)) {
594+ return false;
595+ }
596+ }
597+ return true;
598+ }
599+ int64_t indexShapeProduct = 1;
600+ int64_t selfShapeProduct = 1;
601+ bool dimCheck = true;
602+ int64_t selfPostDim = 1;
603+ for (int32_t i = 0; i < dims_; i++) {
604+ int64_t indexDim = indicesShape_.GetDim(i);
605+ int64_t selfDim = paramsShape_.GetDim(i);
606+ indexShapeProduct *= indexDim;
607+ selfShapeProduct *= selfDim;
608+ if ((i != 0 && i != axis_ && i != axis_ + 1) && indexDim != selfDim) {
609+ dimCheck = false;
610+ break;
611+ }
612+ if (i > axis_) {
613+ selfPostDim *= selfDim;
614+ }
615+ }
616+ bool selfShapeCheck = selfShapeProduct < INT_MAX_NUM;
617+ dimCheck = dimCheck && selfPostDim > V2_POST_DIM_LIMIT;
618+ bool memCheck = V2MemCheck();
619+ return dimCheck && selfShapeCheck && memCheck;
620+}
621+ 
622+ge::graphStatus GatherElementsTiling::ComputeV2LastDimTiling()
623+{
624+ const int64_t totalCoreNum = coreNumAll_;
625+ const int64_t ubSize = ubSize_ - V2LD_RESERVED_UB;
626+ 
627+ gert::Shape xShape;
628+ gert::Shape indexShape;
629+ int i = 0;
630+ while (i < dims_) {
631+ int64_t xd = static_cast<int64_t>(paramsShape_.GetDim(i));
632+ int64_t id = static_cast<int64_t>(indicesShape_.GetDim(i));
633+ if (xd != id || i == dims_ - 1) {
634+ xShape.AppendDim(xd);
635+ indexShape.AppendDim(id);
636+ i++;
637+ } else {
638+ int j = i;
639+ while (j < dims_ && paramsShape_.GetDim(j) == indicesShape_.GetDim(j) && j != dims_ - 1) {
640+ j++;
641+ }
642+ if (j - i > 1) {
643+ int64_t val = 1;
644+ for (int k = i; k < j; k++) {
645+ val *= static_cast<int64_t>(paramsShape_.GetDim(k));
646+ }
647+ xShape.AppendDim(val);
648+ indexShape.AppendDim(val);
649+ } else {
650+ xShape.AppendDim(xd);
651+ indexShape.AppendDim(id);
652+ }
653+ i = j - 1;
654+ i++;
655+ }
656+ }
657+ int64_t dimNum = static_cast<int64_t>(xShape.GetDimNum());
658+ 
659+ int64_t nonCollectingAxisSize = 1;
660+ int64_t xAxisSize = 0;
661+ int64_t indexAxisSize = 0;
662+ int64_t specialDataMove = 0;
663+ int64_t xShapeArray[GATHER_ELEMENTS_V2_TILING_ARRAY_LEN_EIGHT] = {0};
664+ int64_t indexShapeArray[GATHER_ELEMENTS_V2_TILING_ARRAY_LEN_EIGHT] = {0};
665+ int64_t xStrideArray[GATHER_ELEMENTS_V2_TILING_ARRAY_LEN_EIGHT] = {1, 1, 1, 1, 1, 1, 1, 1};
666+ int64_t indexStrideArray[GATHER_ELEMENTS_V2_TILING_ARRAY_LEN_EIGHT] = {1, 1, 1, 1, 1, 1, 1, 1};
667+ for (int k = 0; k < dimNum; k++) {
668+ int64_t xd = xShape.GetDim(k);
669+ int64_t id = indexShape.GetDim(k);
670+ xShapeArray[k] = xd;
671+ indexShapeArray[k] = id;
672+ if (k < dimNum - 1) {
673+ nonCollectingAxisSize *= xd;
674+ if (k != 0 && xd != id) {
675+ specialDataMove = 1;
676+ }
677+ } else {
678+ xAxisSize = xd;
679+ indexAxisSize = id;
680+ }
681+ }
682+ for (int k = dimNum - 1; k > 0; k--) {
683+ xStrideArray[k - 1] = xStrideArray[k] * xShapeArray[k];
684+ indexStrideArray[k - 1] = indexStrideArray[k] * indexShapeArray[k];
685+ }
686+ 
687+ // GetDSize
688+ int64_t xDSize = static_cast<int64_t>(paramsDsize_);
689+ int64_t xRealDsize = xDSize;
690+ int64_t indexDSize = static_cast<int64_t>(indicesDsize_);
691+ int64_t indexRealDsize = indexDSize;
692+ int64_t xDsizeRatio = 1;
693+ if (xDSize == V2LD_INT8_DSIZE) {
694+ xDSize = V2LD_INT6_DSIZE;
695+ xDsizeRatio = V2LD_DOUBLE_TIME;
696+ }
697+ if (indexDSize == V2LD_INT32_DSIZE) {
698+ indexDSize = V2LD_INT64_DSIZE;
699+ }
700+ 
701+ // IfEnableBatch
702+ int64_t xAlignSize = ceilAlign(xAxisSize * xDSize, V2LD_BLOCK_SIZE * xDsizeRatio);
703+ int64_t yAlignSize = ceilAlign(indexAxisSize * xDSize, V2LD_BLOCK_SIZE * xDsizeRatio);
704+ int64_t indexAlignSize = ceilAlign(indexAxisSize * indexDSize, V2LD_BLOCK_SIZE * V2LD_DOUBLE_TIME);
705+ bool batchProcess = (xAlignSize + yAlignSize + indexAlignSize) <= ubSize / V2LD_DOUBLE_TIME;
706+ 
707+ // DoUBSlice
708+ int64_t eachCalculationLines = 0;
709+ int64_t xSliceNum = 0;
710+ int64_t indexSliceNum = 0;
711+ int64_t xBufferSize = 0;
712+ int64_t indexBufferSize = 0;
713+ int64_t yBufferSize = 0;
714+ int64_t maskBufferSize = 0;
715+ int64_t reservedXSize = 0;
716+ int64_t reservedIndexSize = 0;
717+ int64_t indexAxisSizeEqualOne = 0;
718+ int64_t dataMoveUBStride = 0;
719+ if (indexShape.GetDim(dimNum - 1) == 1 && batchProcess && specialDataMove == 0) {
720+ indexAxisSizeEqualOne = V2LD_NUM_ONE;
721+ int64_t perGroupSize = xAxisSize * xDSize + indexAxisSize * indexDSize + indexAxisSize * indexDSize;
722+ eachCalculationLines = floorDiv(ubSize, perGroupSize);
723+ xBufferSize = ceilAlign(xAxisSize * xDSize * eachCalculationLines, V2LD_BLOCK_SIZE * xDsizeRatio);
724+ indexBufferSize = ceilAlign(indexAxisSize * indexDSize * eachCalculationLines,
725+ V2LD_BLOCK_SIZE * V2LD_DOUBLE_TIME);
726+ yBufferSize = ceilAlign(indexAxisSize * indexDSize * eachCalculationLines, V2LD_BLOCK_SIZE * xDsizeRatio);
727+ } else if (batchProcess) {
728+ int64_t perGroupSize = xAlignSize + indexAlignSize + yAlignSize;
729+ eachCalculationLines = floorDiv(ubSize, perGroupSize);
730+ xBufferSize = xAlignSize * eachCalculationLines;
731+ yBufferSize = yAlignSize * eachCalculationLines;
732+ indexBufferSize = indexAlignSize * eachCalculationLines;
733+ if (ceilDiv(indexAxisSize * indexDSize, V2LD_BLOCK_SIZE) % V2LD_DOUBLE_TIME == 1 &&
734+ indexRealDsize == V2LD_INT64_DSIZE) {
735+ dataMoveUBStride = V2LD_NUM_ONE;
736+ }
737+ } else if (xAlignSize <= ubSize / V2LD_DOUBLE_TIME) {
738+ xSliceNum = V2LD_NUM_ONE;
739+ eachCalculationLines = V2LD_NUM_ONE;
740+ xBufferSize = xAlignSize;
741+ indexBufferSize = (ubSize - xBufferSize) / (indexDSize + xDSize) * indexDSize;
742+ indexBufferSize = ceilAlign(indexBufferSize, V2LD_BLOCK_SIZE * V2LD_DOUBLE_TIME);
743+ yBufferSize = indexBufferSize / indexDSize * xDSize;
744+ yBufferSize = ceilAlign(yBufferSize, V2LD_BLOCK_SIZE);
745+ indexSliceNum = ceilDiv(indexAlignSize, indexBufferSize);
746+ reservedIndexSize = indexAxisSize - (indexSliceNum - 1) * indexBufferSize / indexDSize;
747+ } else {
748+ eachCalculationLines = V2LD_NUM_ONE;
749+ xBufferSize = ubSize / V2LD_DOUBLE_TIME;
750+ xSliceNum = ceilDiv(xAlignSize, xBufferSize);
751+ reservedXSize = xAxisSize - (xSliceNum - 1) * xBufferSize / xDSize;
752+ indexBufferSize = static_cast<int64_t>(static_cast<float>(xBufferSize) /
753+ (indexDSize + xDSize * V2LD_DOUBLE_TIME + V2LD_MASK_SIZE_RATE) *
754+ indexDSize);
755+ indexBufferSize = ceilAlign(indexBufferSize, V2LD_BLOCK_SIZE * V2LD_INT64_DSIZE);
756+ indexSliceNum = ceilDiv(indexAlignSize, indexBufferSize);
757+ yBufferSize = indexBufferSize / indexDSize * xDSize;
758+ yBufferSize = ceilAlign(yBufferSize, V2LD_BLOCK_SIZE);
759+ reservedIndexSize = indexAxisSize - (indexSliceNum - 1) * indexBufferSize / indexDSize;
760+ maskBufferSize = indexBufferSize / indexDSize / V2LD_INT64_DSIZE;
761+ maskBufferSize = ceilAlign(maskBufferSize, V2LD_BLOCK_SIZE);
762+ }
763+ 
764+ // DoScalarMode
765+ int64_t scalarMode = 0;
766+ int64_t scalarModeLength = 0;
767+ if (xSliceNum > V2LD_MAX_SLICE_NUM || xAxisSize / indexAxisSize > V2LD_MAX_SIZE_RATIO) {
768+ scalarMode = V2LD_NUM_ONE;
769+ int64_t idxBlockSize = ceilDiv(indexAlignSize, V2LD_BLOCK_SIZE * V2LD_DOUBLE_TIME) * V2LD_DOUBLE_TIME;
770+ int64_t yBlockSize = ceilDiv(indexAxisSize * xRealDsize, V2LD_BLOCK_SIZE);
771+ eachCalculationLines = ubSize / V2LD_BLOCK_SIZE / (idxBlockSize + yBlockSize);
772+ bool multRowProcess = eachCalculationLines > 1 && (nonCollectingAxisSize > totalCoreNum ||
773+ (nonCollectingAxisSize <= totalCoreNum &&
774+ indexAxisSize < totalCoreNum * V2LD_BLOCK_SIZE));
775+ if (multRowProcess) {
776+ indexBufferSize = eachCalculationLines * idxBlockSize * V2LD_BLOCK_SIZE;
777+ yBufferSize = eachCalculationLines * yBlockSize * V2LD_BLOCK_SIZE;
778+ } else {
779+ indexSliceNum = ceilDiv(indexAlignSize, indexBufferSize);
780+ scalarModeLength = indexSliceNum * nonCollectingAxisSize;
781+ if (scalarModeLength < totalCoreNum) {
782+ indexSliceNum = totalCoreNum / nonCollectingAxisSize;
783+ scalarModeLength = indexSliceNum * nonCollectingAxisSize;
784+ }
785+ indexBufferSize = ceilAlign(indexAlignSize / indexSliceNum + V2LD_INT64_DSIZE,
786+ V2LD_BLOCK_SIZE * V2LD_DOUBLE_TIME);
787+ yBufferSize = indexBufferSize / indexDSize * xRealDsize;
788+ yBufferSize = ceilAlign(yBufferSize, V2LD_BLOCK_SIZE);
789+ reservedIndexSize = indexAxisSize - (indexSliceNum - 1) * indexBufferSize / indexDSize;
790+ }
791+ }
792+ 
793+ // DoNeedUseCore
794+ int64_t needUsedCore = 0;
795+ int64_t formerCoreRowNum = 0;
796+ int64_t formerCoreNum = 0;
797+ if (scalarModeLength == 0) {
798+ needUsedCore = nonCollectingAxisSize > totalCoreNum ? totalCoreNum : nonCollectingAxisSize;
799+ formerCoreRowNum = nonCollectingAxisSize / needUsedCore;
800+ formerCoreNum = nonCollectingAxisSize % needUsedCore;
801+ } else {
802+ needUsedCore = scalarModeLength > totalCoreNum ? totalCoreNum : scalarModeLength;
803+ }
804+ if (needUsedCore <= 0) {
805+ needUsedCore = 1;
806+ }
807+ 
808+ auto& ld = tilingData_.v2Data.lastDimTiling;
809+ ld.set_xShape(xShapeArray);
810+ ld.set_indexShape(indexShapeArray);
811+ ld.set_xStrideArray(xStrideArray);
812+ ld.set_indexStrideArray(indexStrideArray);
813+ ld.set_dimNum(dimNum);
814+ ld.set_specialDataMove(specialDataMove);
815+ ld.set_xSliceNum(xSliceNum);
816+ ld.set_indexSliceNum(indexSliceNum);
817+ ld.set_reservedXSize(reservedXSize);
818+ ld.set_reservedIndexSize(reservedIndexSize);
819+ ld.set_indexAxisSizeEqualOne(indexAxisSizeEqualOne);
820+ ld.set_scalarMode(scalarMode);
821+ ld.set_formerCoreRowNum(formerCoreRowNum);
822+ ld.set_formerCoreNum(formerCoreNum);
823+ ld.set_eachCalculationLines(eachCalculationLines);
824+ ld.set_xBufferSize(xBufferSize);
825+ ld.set_indexBufferSize(indexBufferSize);
826+ ld.set_yBufferSize(yBufferSize);
827+ ld.set_maskBufferSize(maskBufferSize);
828+ ld.set_scalarModeLength(scalarModeLength);
829+ ld.set_dataMoveUBStride(dataMoveUBStride);
830+ 
831+ tilingData_.set_v2Mode(V2_MODE_LASTDIM);
832+ tilingData_.set_useV2(1);
833+ useV2_ = true;
834+ v2UsedCoreNum_ = needUsedCore;
835+ v2Workspace_ = 0;
836+ return ge::GRAPH_SUCCESS;
837+}
838+ 
839+ge::graphStatus GatherElementsTiling::TryRouteToV2()
840+{
841+ useV2_ = false;
842+ if (!IfUseV2()) {
843+ return ge::GRAPH_SUCCESS;
844+ }
845+ if (axis_ == dims_ - 1) {
846+ return ComputeV2LastDimTiling();
847+ }
848+ const uint64_t xDtypeSize = static_cast<uint64_t>(paramsDsize_);
849+ const uint64_t idxDtypeSize = static_cast<uint64_t>(indicesDsize_);
850+ const uint64_t coreNum = static_cast<uint64_t>(coreNumAll_);
851+ const uint64_t ubSize = static_cast<uint64_t>(ubSize_);
852+ 
853+ uint64_t xPreDim = 1;
854+ uint64_t xGatherDim = 1;
855+ uint64_t xPostDim = 1;
856+ uint64_t idxPreDim = 1;
857+ uint64_t idxGatherDim = 1;
858+ uint64_t idxPostDim = 1;
859+ const uint64_t dim = static_cast<uint64_t>(axis_);
860+ const uint64_t dimNum = static_cast<uint64_t>(dims_);
861+ idxGatherDim = static_cast<uint64_t>(indicesShape_.GetDim(axis_));
862+ xGatherDim = static_cast<uint64_t>(paramsShape_.GetDim(axis_));
863+ for (uint64_t i = 0; i < dim; i++) {
864+ idxPreDim *= static_cast<uint64_t>(indicesShape_.GetDim(i));
865+ xPreDim *= static_cast<uint64_t>(paramsShape_.GetDim(i));
866+ }
867+ for (uint64_t i = dim + 1; i < dimNum; i++) {
868+ idxPostDim *= static_cast<uint64_t>(indicesShape_.GetDim(i));
869+ xPostDim *= static_cast<uint64_t>(paramsShape_.GetDim(i));
870+ }
871+ (void)xPreDim;
872+ (void)xPostDim;
873+ 
874+ // Tiling4GatherElementsV2 (row/column core grouping)
875+ uint64_t usedCoreNum = std::min(idxPreDim * idxPostDim, coreNum);
876+ uint64_t coreGroupNum = 0;
877+ uint64_t formerGroupNum = 0;
878+ uint64_t tailGroupNum = 0;
879+ uint64_t formerGroupPreDim = 0;
880+ uint64_t tailGroupPreDim = 0;
881+ uint64_t formerGroupCoreNum = 0;
882+ uint64_t tailGroupCoreNum = 0;
883+ uint64_t formerGroupFormerNum = 0;
884+ uint64_t formerGroupTailNum = 0;
885+ uint64_t formerGroupFormerPostDim = 0;
886+ uint64_t formerGroupTailPostDim = 0;
887+ uint64_t tailGroupFormerNum = 0;
888+ uint64_t tailGroupTailNum = 0;
889+ uint64_t tailGroupFormerPostDim = 0;
890+ uint64_t tailGroupTailPostDim = 0;
891+ if (idxPreDim > usedCoreNum) {
892+ coreGroupNum = usedCoreNum;
893+ tailGroupNum = (coreGroupNum - idxPreDim % coreGroupNum) % coreGroupNum;
894+ formerGroupNum = coreGroupNum - tailGroupNum;
895+ if (usedCoreNum == 0UL) {
896+ usedCoreNum = 1UL;
897+ }
898+ formerGroupPreDim = (idxPreDim + usedCoreNum - 1) / usedCoreNum;
899+ tailGroupPreDim = idxPreDim / usedCoreNum;
900+ formerGroupCoreNum = 1;
901+ tailGroupCoreNum = 1;
902+ formerGroupTailNum = 0;
903+ formerGroupFormerNum = 1;
904+ tailGroupTailNum = 0;
905+ tailGroupFormerNum = 1;
906+ formerGroupFormerPostDim = idxPostDim;
907+ formerGroupTailPostDim = idxPostDim;
908+ tailGroupFormerPostDim = idxPostDim;
909+ tailGroupTailPostDim = idxPostDim;
910+ } else {
911+ coreGroupNum = idxPreDim;
912+ tailGroupNum = (coreGroupNum - usedCoreNum % coreGroupNum) % coreGroupNum;
913+ formerGroupNum = coreGroupNum - tailGroupNum;
914+ formerGroupPreDim = 1;
915+ tailGroupPreDim = 1;
916+ formerGroupCoreNum = (usedCoreNum + coreGroupNum - 1) / coreGroupNum;
917+ tailGroupCoreNum = usedCoreNum / coreGroupNum;
918+ formerGroupTailNum = (formerGroupCoreNum - idxPostDim % formerGroupCoreNum) % formerGroupCoreNum;
919+ formerGroupFormerNum = formerGroupCoreNum - formerGroupTailNum;
920+ formerGroupFormerPostDim = (idxPostDim + formerGroupCoreNum - 1) / formerGroupCoreNum;
921+ formerGroupTailPostDim = idxPostDim / formerGroupCoreNum;
922+ tailGroupTailNum = (tailGroupCoreNum - idxPostDim % tailGroupCoreNum) % tailGroupCoreNum;
923+ tailGroupFormerNum = tailGroupCoreNum - tailGroupTailNum;
924+ tailGroupFormerPostDim = (idxPostDim + tailGroupCoreNum - 1) / tailGroupCoreNum;
925+ tailGroupTailPostDim = idxPostDim / tailGroupCoreNum;
926+ }
927+ 
928+ auto& params = tilingData_.v2Data.params;
929+ params.set_xPreDim(xPreDim);
930+ params.set_xGatherDim(xGatherDim);
931+ params.set_xPostDim(xPostDim);
932+ params.set_idxPreDim(idxPreDim);
933+ params.set_idxGatherDim(idxGatherDim);
934+ params.set_idxPostDim(idxPostDim);
935+ params.set_coreGroupNum(coreGroupNum);
936+ params.set_formerGroupNum(formerGroupNum);
937+ params.set_tailGroupNum(tailGroupNum);
938+ params.set_formerGroupPreDim(formerGroupPreDim);
939+ params.set_tailGroupPreDim(tailGroupPreDim);
940+ params.set_formerGroupCoreNum(formerGroupCoreNum);
941+ params.set_tailGroupCoreNum(tailGroupCoreNum);
942+ params.set_formerGroupFormerNum(formerGroupFormerNum);
943+ params.set_formerGroupTailNum(formerGroupTailNum);
944+ params.set_formerGroupFormerPostDim(formerGroupFormerPostDim);
945+ params.set_formerGroupTailPostDim(formerGroupTailPostDim);
946+ params.set_tailGroupFormerNum(tailGroupFormerNum);
947+ params.set_tailGroupTailNum(tailGroupTailNum);
948+ params.set_tailGroupFormerPostDim(tailGroupFormerPostDim);
949+ params.set_tailGroupTailPostDim(tailGroupTailPostDim);
950+ 
951+ // CalcMaxBufferSize to decide transpose vs scalar
952+ uint64_t carryNumAlign = V2_CACHELINE / xDtypeSize;
953+ uint64_t xAlign = V2_BLOCK_SIZE / xDtypeSize;
954+ uint64_t idxAlign = V2_BLOCK_SIZE / idxDtypeSize;
955+ uint64_t availableUb = ubSize - V2_RESERVED_UB_SIZE;
956+ uint64_t minIdxGatherDimSlice = V2_CACHELINE;
957+ uint64_t gatherInBufferSize = ceilAlign(xGatherDim, xAlign) * xDtypeSize +
958+ ceilAlign(minIdxGatherDimSlice, idxAlign) * idxDtypeSize * V2_NUM_TWO;
959+ uint64_t gatherOutBufferSize = ceilAlign(minIdxGatherDimSlice, xAlign) * xDtypeSize;
960+ uint64_t transInBufferSize = V2_TRANSPOSE_WS_LEN * V2_CACHELINE;
961+ uint64_t transOutBufferSize = V2_TRANSPOSE_WS_LEN * V2_CACHELINE;
962+ uint64_t inBufferSize = std::max(gatherInBufferSize, transInBufferSize);
963+ uint64_t outBufferSize = std::max(gatherOutBufferSize, transOutBufferSize);
964+ bool canTrans = (availableUb >= (inBufferSize + outBufferSize));
965+ uint64_t idxGatherDimSlice = 0;
966+ if (canTrans) {
967+ uint64_t ubLeft = availableUb - (std::max(transInBufferSize, ceilAlign(xGatherDim, xAlign) * xDtypeSize) +
968+ transOutBufferSize);
969+ uint64_t maxIdxGatherDimSlice = ubLeft / (V2_BLOCK_SIZE * V2_NUM_TWO) * idxAlign;
970+ uint64_t idxGatherDimAlign = ceilAlign(idxGatherDim, idxAlign);
971+ idxGatherDimSlice = std::min(maxIdxGatherDimSlice, idxGatherDimAlign);
972+ gatherInBufferSize = ceilAlign(xGatherDim, xAlign) * xDtypeSize +
973+ ceilAlign(idxGatherDimSlice, idxAlign) * idxDtypeSize;
974+ if (idxDtypeSize > static_cast<uint64_t>(sizeof(int32_t))) {
975+ uint64_t idx32Align = V2_BLOCK_SIZE / sizeof(int32_t);
976+ gatherInBufferSize = ceilAlign(xGatherDim, xAlign) * xDtypeSize +
977+ (ceilAlign(idxGatherDimSlice, idx32Align) + idxGatherDimSlice) * sizeof(int32_t);
978+ }
979+ gatherOutBufferSize = ceilAlign(idxGatherDimSlice, xAlign) * xDtypeSize;
980+ inBufferSize = std::max(gatherInBufferSize, transInBufferSize);
981+ outBufferSize = std::max(gatherOutBufferSize, transOutBufferSize);
982+ }
983+ 
984+ if (canTrans) {
985+ v2UsedCoreNum_ = static_cast<int64_t>(usedCoreNum);
986+ uint64_t xGatherDimAlign = ceilAlign(xGatherDim * xDtypeSize, idxDtypeSize) / xDtypeSize;
987+ uint64_t usedWorkspaceLen = std::min(carryNumAlign, std::max(formerGroupFormerPostDim, tailGroupFormerPostDim));
988+ uint64_t workspacePerBlock = usedWorkspaceLen * (xGatherDimAlign * xDtypeSize + idxGatherDim * idxDtypeSize);
989+ v2Workspace_ = static_cast<int64_t>(usedCoreNum * workspacePerBlock);
990+ 
991+ auto& trans = tilingData_.v2Data.transTiling;
992+ trans.set_carryNumAlign(carryNumAlign);
993+ trans.set_xCarryNumAlign(carryNumAlign);
994+ trans.set_idxCarryNumAlign(V2_CACHELINE / idxDtypeSize);
995+ trans.set_inBufferSize(inBufferSize);
996+ trans.set_outBufferSize(outBufferSize);
997+ trans.set_transGatherDimSlice(V2_TRANSPOSE_WS_LEN);
998+ trans.set_idxGatherDimSlice(idxGatherDimSlice);
999+ trans.set_workspacePerBlock(workspacePerBlock);
1000+ tilingData_.set_v2Mode(V2_MODE_TRANSPOSE);
1001+ } else {
1002+ // scalar mode (Tiling4Scalar)
1003+ uint64_t idxDataPerPre = idxGatherDim * idxPostDim;
1004+ uint64_t idxAllData = idxPreDim * idxDataPerPre;
1005+ usedCoreNum = std::min(idxAllData, coreNum);
1006+ uint64_t formerGroupFormerData = 0;
1007+ uint64_t formerGroupTailData = 0;
1008+ uint64_t tailGroupFormerData = 0;
1009+ uint64_t tailGroupTailData = 0;
1010+ if (idxPreDim >= usedCoreNum) {
1011+ formerGroupFormerData = idxDataPerPre;
1012+ formerGroupTailData = idxDataPerPre;
1013+ tailGroupFormerData = idxDataPerPre;
1014+ tailGroupTailData = idxDataPerPre;
1015+ } else {
1016+ coreGroupNum = idxPreDim;
1017+ tailGroupNum = (coreGroupNum - usedCoreNum % coreGroupNum) % coreGroupNum;
1018+ formerGroupNum = coreGroupNum - tailGroupNum;
1019+ formerGroupCoreNum = (usedCoreNum + coreGroupNum - 1) / coreGroupNum;
1020+ tailGroupCoreNum = usedCoreNum / coreGroupNum;
1021+ formerGroupTailNum = (formerGroupCoreNum - idxDataPerPre % formerGroupCoreNum) % formerGroupCoreNum;
1022+ formerGroupFormerNum = formerGroupCoreNum - formerGroupTailNum;
1023+ formerGroupFormerData = (idxDataPerPre + formerGroupCoreNum - 1) / formerGroupCoreNum;
1024+ formerGroupTailData = idxDataPerPre / formerGroupCoreNum;
1025+ tailGroupTailNum = (tailGroupCoreNum - idxDataPerPre % tailGroupCoreNum) % tailGroupCoreNum;
1026+ tailGroupFormerNum = tailGroupCoreNum - tailGroupTailNum;
1027+ tailGroupFormerData = (idxDataPerPre + tailGroupCoreNum - 1) / tailGroupCoreNum;
1028+ tailGroupTailData = idxDataPerPre / tailGroupCoreNum;
1029+ }
1030+ uint64_t maxIdxDataAlign = (ubSize - V2_RESERVED_UB_SIZE) / V2_BLOCK_SIZE * V2_BLOCK_SIZE /
1031+ (idxDtypeSize + xDtypeSize);
1032+ 
1033+ v2UsedCoreNum_ = static_cast<int64_t>(usedCoreNum);
1034+ auto& scalar = tilingData_.v2Data.scalarTiling;
1035+ scalar.set_formerGroupFormerData(formerGroupFormerData);
1036+ scalar.set_formerGroupTailData(formerGroupTailData);
1037+ scalar.set_tailGroupFormerData(tailGroupFormerData);
1038+ scalar.set_tailGroupTailData(tailGroupTailData);
1039+ scalar.set_maxIdxDataAlign(maxIdxDataAlign);
1040+ tilingData_.set_v2Mode(V2_MODE_SCALAR);
1041+ }
1042+ 
1043+ tilingData_.set_useV2(1);
1044+ useV2_ = true;
1045+ return ge::GRAPH_SUCCESS;
1046+}
1047+ 
1048+ge::graphStatus GatherElementsTiling::Init()
1049+{
1050+ OP_LOGD(tilingContext_->GetNodeName(), "GatherElementsTiling initing");
1051+ compileInfo_ = static_cast<const GatherElementsCompileInfo*>(tilingContext_->GetCompileInfo());
1052+ OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, compileInfo_);
1053+ OP_TILING_CHECK(GetPlatformInfo() != ge::GRAPH_SUCCESS,
1054+ VECTOR_INNER_ERR_REPORT_TILIING(tilingContext_->GetNodeName(),
1055+ "op GatherElementsTiling: GetPlatformInfo failed."),
1056+ return ge::GRAPH_FAILED);
1057+ auto inputDesc = tilingContext_->GetInputDesc(0);
1058+ OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, inputDesc);
1059+ auto indicesDesc = tilingContext_->GetInputDesc(1);
1060+ OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, indicesDesc);
1061+ auto attrs = tilingContext_->GetAttrs();
1062+ OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, attrs);
1063+ 
1064+ uint32_t paramsTypeLen = 0;
1065+ uint32_t indicesTypeLen = 0;
1066+ ge::TypeUtils::GetDataTypeLength(inputDesc->GetDataType(), paramsTypeLen);
1067+ ge::TypeUtils::GetDataTypeLength(indicesDesc->GetDataType(), indicesTypeLen);
1068+ paramsDsize_ = static_cast<int32_t>(paramsTypeLen);
1069+ indicesDsize_ = static_cast<int32_t>(indicesTypeLen);
1070+ OP_CHECK_IF((paramsDsize_ <= 0 || indicesDsize_ <= 0),
1071+ OP_LOGE(tilingContext_->GetNodeName(), "Failed to get data type length"), return ge::GRAPH_FAILED);
1072+ supportGather_ = GATHER_DTYPES.count(inputDesc->GetDataType()) > 0 ? 1 : 0;
1073+ 
1074+ paramsShape_ = tilingContext_->GetInputShape(0)->GetStorageShape();
1075+ indicesShape_ = tilingContext_->GetInputShape(1)->GetStorageShape();
1076+ yShape_ = tilingContext_->GetOutputShape(0)->GetStorageShape();
1077+ dims_ = static_cast<int32_t>(paramsShape_.GetDimNum());
1078+ 
1079+ const int64_t* axisPtr = attrs->GetAttrPointer<int64_t>(INDEX_ATTR_AXIS);
1080+ OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, axisPtr);
1081+ int32_t axis = static_cast<int32_t>(*axisPtr);
1082+ 
1083+ // check inputs shape
1084+ int32_t indicesDims = static_cast<int32_t>(indicesShape_.GetDimNum());
1085+ OP_TILING_CHECK(dims_ <= 0 || indicesDims <= 0,
1086+ VECTOR_INNER_ERR_REPORT_TILIING(tilingContext_->GetNodeName(),
1087+ "GatherElementsTiling: params_dims or indices_dims is 0."),
1088+ return ge::GRAPH_FAILED);
1089+ 
1090+ OP_TILING_CHECK(
1091+ axis < -dims_ || axis >= dims_,
1092+ VECTOR_INNER_ERR_REPORT_TILIING(tilingContext_->GetNodeName(), "op GatherElementsTiling: axis is invalid."),
1093+ return ge::GRAPH_FAILED);
1094+ axis_ = axis < 0 ? axis + dims_ : axis;
1095+ OP_TILING_CHECK(!CheckTensorShape(),
1096+ VECTOR_INNER_ERR_REPORT_TILIING(tilingContext_->GetNodeName(),
1097+ "op GatherElementsTiling: [checkTensorShape] failed."),
1098+ return ge::GRAPH_FAILED);
1099+ 
1100+ tilingData_.set_axis(axis_);
1101+ tilingData_.set_dims(dims_);
1102+ RecordTilingCommonInformation(axis_, dims_);
1103+ RecordShapeInformation();
1104+ 
1105+ // 优先尝试路由到 gather_elements_v2 能力(910B/910_93 兼容场景)
1106+ ge::graphStatus v2Ret = TryRouteToV2();
1107+ if (v2Ret != ge::GRAPH_SUCCESS) {
1108+ return v2Ret;
1109+ }
1110+ if (useV2_) {
1111+ OP_LOGD(tilingContext_->GetNodeName(), "GatherElementsTiling routed to gather_elements_v2");
1112+ return ge::GRAPH_SUCCESS;
1113+ }
1114+ 
1115+ OP_TILING_CHECK(!ChooseTilingMode(IfParamsIndicesSameShapeExceptAxis()),
1116+ OP_LOGW(tilingContext_->GetNodeName(), "choose tiling mode failed, aicpu recommended."),
1117+ return ge::GRAPH_FAILED);
1118+ OP_LOGD(tilingContext_->GetNodeName(), "GatherElementsTiling inited");
1119+ return ge::GRAPH_SUCCESS;
1120+}
1121+ 
1122+ge::graphStatus GatherElementsTiling::SetKernelTiling()
1123+{
1124+ size_t* currentWorkSpace = tilingContext_->GetWorkspaceSizes(1);
1125+ if (useV2_) {
1126+ // v2 路由:block dim 使用 v2 计算的核心数,workspace 合并 v2 的 workspace
1127+ tilingContext_->SetBlockDim(v2UsedCoreNum_);
1128+ currentWorkSpace[0] = compileInfo_->sysWorkspaceSize + static_cast<size_t>(v2Workspace_);
1129+ } else {
1130+ tilingContext_->SetBlockDim(tilingData_.get_need_core_num());
1131+ currentWorkSpace[0] = compileInfo_->sysWorkspaceSize;
1132+ }
1133+ tilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(),
1134+ tilingContext_->GetRawTilingData()->GetCapacity());
1135+ tilingContext_->GetRawTilingData()->SetDataSize(tilingData_.GetDataSize());
1136+ TilingDataPrint();
1137+ return ge::GRAPH_SUCCESS;
1138+}
1139+ 
1140+void GatherElementsTiling::TilingDataPrint()
1141+{
1142+ if (tilingData_.get_useV2() != 1) {
1143+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] tilingMode=%ld.", tilingData_.get_tilingMode());
1144+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] axis=%ld.", tilingData_.get_axis());
1145+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_pre=%ld.", tilingData_.get_params_pre());
1146+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_axis=%ld.", tilingData_.get_params_axis());
1147+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_row=%ld.", tilingData_.get_params_row());
1148+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_total=%ld.", tilingData_.get_params_total());
1149+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] need_core_num=%ld.", tilingData_.get_need_core_num());
1150+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_num=%ld.", tilingData_.get_indices_num());
1151+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_axis=%ld.", tilingData_.get_indices_axis());
1152+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_num_each_core=%ld.",
1153+ tilingData_.get_indices_num_each_core());
1154+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_num_remaining=%ld.",
1155+ tilingData_.get_indices_num_remaining());
1156+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_loop_num=%ld.",
1157+ tilingData_.get_indices_loop_num());
1158+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_row_num_once=%ld.",
1159+ tilingData_.get_indices_row_num_once());
1160+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_row_num_last=%ld.",
1161+ tilingData_.get_indices_row_num_last());
1162+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] remaining_block_remain=%ld.",
1163+ tilingData_.get_remaining_block_remain());
1164+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] remaining_block_num=%ld.",
1165+ tilingData_.get_remaining_block_num());
1166+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] slice_thickness_once=%ld.",
1167+ tilingData_.get_slice_thickness_once());
1168+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] slice_thickness_last=%ld.",
1169+ tilingData_.get_slice_thickness_last());
1170+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] slice_num=%ld.", tilingData_.get_slice_num());
1171+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_slice_thickness_dim1=%ld.",
1172+ tilingData_.get_indices_slice_thickness_dim1());
1173+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_slice_thickness_dim1_last=%ld.",
1174+ tilingData_.get_indices_slice_thickness_dim1_last());
1175+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_slice_num_dim1=%ld.",
1176+ tilingData_.get_indices_slice_num_dim1());
1177+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_shape_0=%ld.", tilingData_.get_params_shape_0());
1178+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_shape_1=%ld.", tilingData_.get_params_shape_1());
1179+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_shape_2=%ld.", tilingData_.get_params_shape_2());
1180+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_shape_3=%ld.", tilingData_.get_params_shape_3());
1181+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_shape_4=%ld.", tilingData_.get_params_shape_4());
1182+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_shape_5=%ld.", tilingData_.get_params_shape_5());
1183+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_shape_6=%ld.", tilingData_.get_params_shape_6());
1184+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] params_shape_7=%ld.", tilingData_.get_params_shape_7());
1185+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_shape_0=%ld.", tilingData_.get_indices_shape_0());
1186+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_shape_1=%ld.", tilingData_.get_indices_shape_1());
1187+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_shape_2=%ld.", tilingData_.get_indices_shape_2());
1188+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_shape_3=%ld.", tilingData_.get_indices_shape_3());
1189+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_shape_4=%ld.", tilingData_.get_indices_shape_4());
1190+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_shape_5=%ld.", tilingData_.get_indices_shape_5());
1191+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_shape_6=%ld.", tilingData_.get_indices_shape_6());
1192+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] indices_shape_7=%ld.", tilingData_.get_indices_shape_7());
1193+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] dims=%ld.", tilingData_.get_dims());
1194+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] repeat_per_core=%ld.", tilingData_.get_repeat_per_core());
1195+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] rounds=%ld.", tilingData_.get_rounds());
1196+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] rounds_tail=%ld.", tilingData_.get_rounds_tail());
1197+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData] dbFlag=%ld.", tilingData_.get_dbFlag());
1198+ }
1199+ if (tilingData_.get_useV2() == 1) {
1200+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] useV2=%ld, v2Mode=%ld.", tilingData_.get_useV2(),
1201+ tilingData_.get_v2Mode());
1202+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] usedCoreNum=%lu.", v2UsedCoreNum_);
1203+ auto& v2Params = tilingData_.v2Data.params;
1204+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] xPreDim=%lu.", v2Params.get_xPreDim());
1205+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] xGatherDim=%lu.", v2Params.get_xGatherDim());
1206+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] xPostDim=%lu.", v2Params.get_xPostDim());
1207+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] idxPreDim=%lu.", v2Params.get_idxPreDim());
1208+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] idxGatherDim=%lu.", v2Params.get_idxGatherDim());
1209+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] idxPostDim=%lu.", v2Params.get_idxPostDim());
1210+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] coreGroupNum=%lu.", v2Params.get_coreGroupNum());
1211+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] formerGroupNum=%lu.", v2Params.get_formerGroupNum());
1212+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] tailGroupNum=%lu.", v2Params.get_tailGroupNum());
1213+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] formerGroupPreDim=%lu.",
1214+ v2Params.get_formerGroupPreDim());
1215+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] tailGroupPreDim=%lu.", v2Params.get_tailGroupPreDim());
1216+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] formerGroupCoreNum=%lu.",
1217+ v2Params.get_formerGroupCoreNum());
1218+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] tailGroupCoreNum=%lu.",
1219+ v2Params.get_tailGroupCoreNum());
1220+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] formerGroupFormerNum=%lu.",
1221+ v2Params.get_formerGroupFormerNum());
1222+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] formerGroupTailNum=%lu.",
1223+ v2Params.get_formerGroupTailNum());
1224+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] formerGroupFormerPostDim=%lu.",
1225+ v2Params.get_formerGroupFormerPostDim());
1226+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] formerGroupTailPostDim=%lu.",
1227+ v2Params.get_formerGroupTailPostDim());
1228+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] tailGroupFormerNum=%lu.",
1229+ v2Params.get_tailGroupFormerNum());
1230+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] tailGroupTailNum=%lu.",
1231+ v2Params.get_tailGroupTailNum());
1232+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] tailGroupFormerPostDim=%lu.",
1233+ v2Params.get_tailGroupFormerPostDim());
1234+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2] tailGroupTailPostDim=%lu.",
1235+ v2Params.get_tailGroupTailPostDim());
1236+ if (tilingData_.get_v2Mode() == 0) {
1237+ auto& v2Scalar = tilingData_.v2Data.scalarTiling;
1238+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-scalar] formerGroupFormerData=%lu.",
1239+ v2Scalar.get_formerGroupFormerData());
1240+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-scalar] formerGroupTailData=%lu.",
1241+ v2Scalar.get_formerGroupTailData());
1242+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-scalar] tailGroupFormerData=%lu.",
1243+ v2Scalar.get_tailGroupFormerData());
1244+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-scalar] tailGroupTailData=%lu.",
1245+ v2Scalar.get_tailGroupTailData());
1246+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-scalar] maxIdxDataAlign=%lu.",
1247+ v2Scalar.get_maxIdxDataAlign());
1248+ } else if (tilingData_.get_v2Mode() == 1) {
1249+ auto& v2Trans = tilingData_.v2Data.transTiling;
1250+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-trans] carryNumAlign=%lu.",
1251+ v2Trans.get_carryNumAlign());
1252+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-trans] xCarryNumAlign=%lu.",
1253+ v2Trans.get_xCarryNumAlign());
1254+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-trans] idxCarryNumAlign=%lu.",
1255+ v2Trans.get_idxCarryNumAlign());
1256+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-trans] inBufferSize=%lu.",
1257+ v2Trans.get_inBufferSize());
1258+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-trans] outBufferSize=%lu.",
1259+ v2Trans.get_outBufferSize());
1260+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-trans] transGatherDimSlice=%lu.",
1261+ v2Trans.get_transGatherDimSlice());
1262+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-trans] idxGatherDimSlice=%lu.",
1263+ v2Trans.get_idxGatherDimSlice());
1264+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-trans] workspacePerBlock=%lu.",
1265+ v2Trans.get_workspacePerBlock());
1266+ } else if (tilingData_.get_v2Mode() == 2) {
1267+ auto& v2Last = tilingData_.v2Data.lastDimTiling;
1268+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] dimNum=%ld.", v2Last.get_dimNum());
1269+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] xShape=%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld.",
1270+ v2Last.get_xShape()[0], v2Last.get_xShape()[1], v2Last.get_xShape()[2], v2Last.get_xShape()[3],
1271+ v2Last.get_xShape()[4], v2Last.get_xShape()[5], v2Last.get_xShape()[6], v2Last.get_xShape()[7]);
1272+ OP_LOGD(tilingContext_->GetNodeName(),
1273+ "[tilingData-v2-lastdim] indexShape=%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld.", v2Last.get_indexShape()[0],
1274+ v2Last.get_indexShape()[1], v2Last.get_indexShape()[2], v2Last.get_indexShape()[3],
1275+ v2Last.get_indexShape()[4], v2Last.get_indexShape()[5], v2Last.get_indexShape()[6],
1276+ v2Last.get_indexShape()[7]);
1277+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] xStride=%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld.",
1278+ v2Last.get_xStrideArray()[0], v2Last.get_xStrideArray()[1], v2Last.get_xStrideArray()[2],
1279+ v2Last.get_xStrideArray()[3], v2Last.get_xStrideArray()[4], v2Last.get_xStrideArray()[5],
1280+ v2Last.get_xStrideArray()[6], v2Last.get_xStrideArray()[7]);
1281+ OP_LOGD(
1282+ tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] indexStride=%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld.",
1283+ v2Last.get_indexStrideArray()[0], v2Last.get_indexStrideArray()[1], v2Last.get_indexStrideArray()[2],
1284+ v2Last.get_indexStrideArray()[3], v2Last.get_indexStrideArray()[4], v2Last.get_indexStrideArray()[5],
1285+ v2Last.get_indexStrideArray()[6], v2Last.get_indexStrideArray()[7]);
1286+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] specialDataMove=%ld.",
1287+ v2Last.get_specialDataMove());
1288+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] xSliceNum=%ld.", v2Last.get_xSliceNum());
1289+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] indexSliceNum=%ld.",
1290+ v2Last.get_indexSliceNum());
1291+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] reservedXSize=%ld.",
1292+ v2Last.get_reservedXSize());
1293+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] reservedIndexSize=%ld.",
1294+ v2Last.get_reservedIndexSize());
1295+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] indexAxisSizeEqualOne=%ld.",
1296+ v2Last.get_indexAxisSizeEqualOne());
1297+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] scalarMode=%ld.", v2Last.get_scalarMode());
1298+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] formerCoreRowNum=%ld.",
1299+ v2Last.get_formerCoreRowNum());
1300+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] formerCoreNum=%ld.",
1301+ v2Last.get_formerCoreNum());
1302+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] eachCalculationLines=%ld.",
1303+ v2Last.get_eachCalculationLines());
1304+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] xBufferSize=%ld.",
1305+ v2Last.get_xBufferSize());
1306+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] indexBufferSize=%ld.",
1307+ v2Last.get_indexBufferSize());
1308+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] yBufferSize=%ld.",
1309+ v2Last.get_yBufferSize());
1310+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] maskBufferSize=%ld.",
1311+ v2Last.get_maskBufferSize());
1312+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] scalarModeLength=%ld.",
1313+ v2Last.get_scalarModeLength());
1314+ OP_LOGD(tilingContext_->GetNodeName(), "[tilingData-v2-lastdim] dataMoveUBStride=%ld.",
1315+ v2Last.get_dataMoveUBStride());
1316+ }
1317+ }
1318+}
1319+ 
1320+ge::graphStatus Tiling4GatherElements(gert::TilingContext* context)
1321+{
1322+ OP_LOGD(context->GetNodeName(), "Tiling4GatherElements running begin");
1323+ if (context == nullptr) {
1324+ OP_LOGE("GatherElements", "The context is nullptr.");
1325+ return ge::GRAPH_FAILED;
1326+ }
1327+ GatherElementsTiling tilingObject(context);
1328+ OP_CHECK_IF(tilingObject.Init() != ge::GRAPH_SUCCESS,
1329+ OP_LOGE(context->GetNodeName(), "gather elements tiling init fail"), return ge::GRAPH_FAILED);
1330+ return tilingObject.SetKernelTiling();
1331+}
1332+ 
1333+ge::graphStatus TilingPrepare4GatherElements(gert::TilingParseContext* context)
1334+{
1335+ OP_LOGD(context->GetNodeName(), "Tiling Prepare For GatherElements start.");
1336+ auto compileInfo = context->GetCompiledInfo<GatherElementsCompileInfo>();
1337+ OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo);
1338+ auto platformInfo = context->GetPlatformInfo();
1339+ OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo);
1340+ auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);
1341+ compileInfo->core_num = ascendcPlatform.GetCoreNumAiv();
1342+ uint64_t ub_size;
1343+ ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ub_size);
1344+ compileInfo->ub_size = static_cast<int64_t>(ub_size);
1345+ OP_CHECK_IF((compileInfo->ub_size <= 0), OP_LOGE(context->GetNodeName(), "Failed to get ub size"),
1346+ return ge::GRAPH_FAILED);
1347+ OP_LOGD(context->GetNodeName(), "ub_size_platform is %lu", compileInfo->ub_size);
1348+ compileInfo->sysWorkspaceSize = ascendcPlatform.GetLibApiWorkSpaceSize();
1349+ OP_LOGD(context->GetNodeName(), "sysWorkspaceSize is %lu", compileInfo->sysWorkspaceSize);
1350+ OP_LOGD(context->GetNodeName(), "Tiling Prepare For GatherElements end.");
1351+ return ge::GRAPH_SUCCESS;
1352+}
1353+ 
1354+// register tiling interface of the GatherElements op.
1355+IMPL_OP_OPTILING(GatherElements)
1356+ .Tiling(Tiling4GatherElements)
1357+ .TilingParse<GatherElementsCompileInfo>(TilingPrepare4GatherElements);
1358+} // namespace optiling
@@ -0,0 +1,110 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+/*!
11+ * \file gather_elements_tiling.h
12+ * \brief
13+ */
14+#ifndef GATHER_ELEMENTS_TILING_H
15+#define GATHER_ELEMENTS_TILING_H
16+#include <cstdint>
17+#include "register/tilingdata_base.h"
18+#include "gather_elements_v2_tiling_defs.h"
19+ 
20+namespace optiling {
21+struct GatherElementsCompileInfo {
22+ int32_t core_num;
23+ int32_t ub_size;
24+ uint64_t sysWorkspaceSize;
25+};
26+ 
27+BEGIN_TILING_DATA_DEF(GatherElementsTilingData)
28+TILING_DATA_FIELD_DEF(int64_t, tilingMode)
29+// parameters of params
30+TILING_DATA_FIELD_DEF(int64_t, axis)
31+TILING_DATA_FIELD_DEF(int64_t, params_pre)
32+TILING_DATA_FIELD_DEF(int64_t, params_axis)
33+TILING_DATA_FIELD_DEF(int64_t, params_row)
34+TILING_DATA_FIELD_DEF(int64_t, params_total)
35+ 
36+// parameters of indices
37+TILING_DATA_FIELD_DEF(int64_t, need_core_num)
38+TILING_DATA_FIELD_DEF(int64_t, indices_num)
39+TILING_DATA_FIELD_DEF(int64_t, indices_axis)
40+TILING_DATA_FIELD_DEF(int64_t, indices_num_each_core)
41+TILING_DATA_FIELD_DEF(int64_t, indices_num_remaining)
42+TILING_DATA_FIELD_DEF(int64_t, indices_loop_num)
43+TILING_DATA_FIELD_DEF(int64_t, indices_row_num_once)
44+TILING_DATA_FIELD_DEF(int64_t, indices_row_num_last)
45+TILING_DATA_FIELD_DEF(int64_t, remaining_block_remain)
46+TILING_DATA_FIELD_DEF(int64_t, remaining_block_num)
47+ 
48+// parameters of x slices and indices slices
49+TILING_DATA_FIELD_DEF(int64_t, slice_thickness_once)
50+TILING_DATA_FIELD_DEF(int64_t, slice_num)
51+TILING_DATA_FIELD_DEF(int64_t, slice_thickness_last)
52+ 
53+// parameters of indices slices
54+TILING_DATA_FIELD_DEF(int64_t, indices_slice_thickness_dim1)
55+TILING_DATA_FIELD_DEF(int64_t, indices_slice_thickness_dim1_last)
56+TILING_DATA_FIELD_DEF(int64_t, indices_slice_num_dim1)
57+ 
58+// shape of params
59+TILING_DATA_FIELD_DEF(int64_t, params_shape_0)
60+TILING_DATA_FIELD_DEF(int64_t, params_shape_1)
61+TILING_DATA_FIELD_DEF(int64_t, params_shape_2)
62+TILING_DATA_FIELD_DEF(int64_t, params_shape_3)
63+TILING_DATA_FIELD_DEF(int64_t, params_shape_4)
64+TILING_DATA_FIELD_DEF(int64_t, params_shape_5)
65+TILING_DATA_FIELD_DEF(int64_t, params_shape_6)
66+TILING_DATA_FIELD_DEF(int64_t, params_shape_7)
67+ 
68+// shape of indices
69+TILING_DATA_FIELD_DEF(int64_t, indices_shape_0)
70+TILING_DATA_FIELD_DEF(int64_t, indices_shape_1)
71+TILING_DATA_FIELD_DEF(int64_t, indices_shape_2)
72+TILING_DATA_FIELD_DEF(int64_t, indices_shape_3)
73+TILING_DATA_FIELD_DEF(int64_t, indices_shape_4)
74+TILING_DATA_FIELD_DEF(int64_t, indices_shape_5)
75+TILING_DATA_FIELD_DEF(int64_t, indices_shape_6)
76+TILING_DATA_FIELD_DEF(int64_t, indices_shape_7)
77+ 
78+// binary
79+TILING_DATA_FIELD_DEF(int64_t, dims)
80+ 
81+TILING_DATA_FIELD_DEF(int64_t, repeat_per_core)
82+TILING_DATA_FIELD_DEF(int64_t, rounds)
83+TILING_DATA_FIELD_DEF(int64_t, rounds_tail)
84+ 
85+TILING_DATA_FIELD_DEF(int64_t, dbFlag)
86+ 
87+// v2 dispatch fields
88+TILING_DATA_FIELD_DEF(int64_t, useV2)
89+TILING_DATA_FIELD_DEF(int64_t, v2Mode)
90+TILING_DATA_FIELD_DEF_STRUCT(GatherElementsV2TilingData, v2Data)
91+END_TILING_DATA_DEF
92+ 
93+REGISTER_TILING_DATA_CLASS(GatherElements, GatherElementsTilingData)
94+ 
95+// common information
96+struct CommonInformation {
97+ int64_t indices_pre;
98+ int64_t params_except_pre_size;
99+ int32_t params_block_num;
100+ int32_t indices_block_num;
101+ int32_t large_num_per_block;
102+ int32_t indices_block_num_large;
103+ int64_t params_total_ceil;
104+ int64_t params_total_ceil_size;
105+ int32_t params_dsize;
106+ int32_t indices_dsize;
107+ int64_t task_num;
108+};
109+} // namespace optiling
110+#endif // GATHER_ELEMENTS_TILING_H
@@ -0,0 +1,119 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+/*!
11+ * \file gather_elements_v2_tiling_defs.h
12+ * \brief
13+ */
14+#ifndef GATHER_ELEMENTS_V2_TILING_DEFS_H
15+#define GATHER_ELEMENTS_V2_TILING_DEFS_H
16+#include "register/tilingdata_base.h"
17+ 
18+namespace optiling {
19+ 
20+constexpr int64_t GATHER_ELEMENTS_V2_TILING_ARRAY_LEN_EIGHT = 8;
21+ 
22+BEGIN_TILING_DATA_DEF(GatherElementsV2TilingParam)
23+TILING_DATA_FIELD_DEF(uint64_t, xPreDim)
24+TILING_DATA_FIELD_DEF(uint64_t, xGatherDim)
25+TILING_DATA_FIELD_DEF(uint64_t, xPostDim)
26+TILING_DATA_FIELD_DEF(uint64_t, idxPreDim)
27+TILING_DATA_FIELD_DEF(uint64_t, idxGatherDim)
28+TILING_DATA_FIELD_DEF(uint64_t, idxPostDim)
29+ 
30+TILING_DATA_FIELD_DEF(uint64_t, coreGroupNum)
31+TILING_DATA_FIELD_DEF(uint64_t, formerGroupNum) // 大组数
32+TILING_DATA_FIELD_DEF(uint64_t, tailGroupNum) // 小组
33+ 
34+TILING_DATA_FIELD_DEF(uint64_t, formerGroupPreDim)
35+TILING_DATA_FIELD_DEF(uint64_t, tailGroupPreDim)
36+TILING_DATA_FIELD_DEF(uint64_t, formerGroupCoreNum) // 大组中大核数
37+TILING_DATA_FIELD_DEF(uint64_t, tailGroupCoreNum) // 大组中小核数
38+ 
39+TILING_DATA_FIELD_DEF(uint64_t, formerGroupFormerNum)
40+TILING_DATA_FIELD_DEF(uint64_t, formerGroupTailNum)
41+TILING_DATA_FIELD_DEF(uint64_t, formerGroupFormerPostDim)
42+TILING_DATA_FIELD_DEF(uint64_t, formerGroupTailPostDim)
43+ 
44+TILING_DATA_FIELD_DEF(uint64_t, tailGroupFormerNum)
45+TILING_DATA_FIELD_DEF(uint64_t, tailGroupTailNum)
46+TILING_DATA_FIELD_DEF(uint64_t, tailGroupFormerPostDim)
47+TILING_DATA_FIELD_DEF(uint64_t, tailGroupTailPostDim)
48+END_TILING_DATA_DEF
49+ 
50+REGISTER_TILING_DATA_CLASS(GeV2TilingParamOp, GatherElementsV2TilingParam)
51+ 
52+// transpose
53+BEGIN_TILING_DATA_DEF(GatherElementsV2TransTiling)
54+TILING_DATA_FIELD_DEF(uint64_t, carryNumAlign)
55+TILING_DATA_FIELD_DEF(uint64_t, xCarryNumAlign)
56+TILING_DATA_FIELD_DEF(uint64_t, idxCarryNumAlign)
57+ 
58+TILING_DATA_FIELD_DEF(uint64_t, inBufferSize)
59+TILING_DATA_FIELD_DEF(uint64_t, outBufferSize)
60+TILING_DATA_FIELD_DEF(uint64_t, transGatherDimSlice)
61+TILING_DATA_FIELD_DEF(uint64_t, idxGatherDimSlice)
62+ 
63+TILING_DATA_FIELD_DEF(uint64_t, workspacePerBlock)
64+END_TILING_DATA_DEF
65+ 
66+REGISTER_TILING_DATA_CLASS(GeV2TransTilingOp, GatherElementsV2TransTiling)
67+ 
68+// scalar
69+BEGIN_TILING_DATA_DEF(GatherElementsV2ScalarTiling)
70+TILING_DATA_FIELD_DEF(uint64_t, formerGroupFormerData)
71+TILING_DATA_FIELD_DEF(uint64_t, formerGroupTailData)
72+TILING_DATA_FIELD_DEF(uint64_t, tailGroupFormerData)
73+TILING_DATA_FIELD_DEF(uint64_t, tailGroupTailData)
74+TILING_DATA_FIELD_DEF(uint64_t, maxIdxDataAlign)
75+END_TILING_DATA_DEF
76+ 
77+REGISTER_TILING_DATA_CLASS(GeV2ScalarTilingOp, GatherElementsV2ScalarTiling)
78+ 
79+BEGIN_TILING_DATA_DEF(GatherElementsV2LastDimTilingParam)
80+TILING_DATA_FIELD_DEF_ARR(int64_t, GATHER_ELEMENTS_V2_TILING_ARRAY_LEN_EIGHT, xShape)
81+TILING_DATA_FIELD_DEF_ARR(int64_t, GATHER_ELEMENTS_V2_TILING_ARRAY_LEN_EIGHT, indexShape)
82+TILING_DATA_FIELD_DEF_ARR(int64_t, GATHER_ELEMENTS_V2_TILING_ARRAY_LEN_EIGHT, xStrideArray)
83+TILING_DATA_FIELD_DEF_ARR(int64_t, GATHER_ELEMENTS_V2_TILING_ARRAY_LEN_EIGHT, indexStrideArray)
84+ 
85+TILING_DATA_FIELD_DEF(int64_t, dimNum)
86+TILING_DATA_FIELD_DEF(int64_t, specialDataMove)
87+TILING_DATA_FIELD_DEF(int64_t, xSliceNum)
88+TILING_DATA_FIELD_DEF(int64_t, indexSliceNum)
89+TILING_DATA_FIELD_DEF(int64_t, reservedXSize)
90+TILING_DATA_FIELD_DEF(int64_t, reservedIndexSize)
91+ 
92+TILING_DATA_FIELD_DEF(int64_t, indexAxisSizeEqualOne)
93+TILING_DATA_FIELD_DEF(int64_t, scalarMode)
94+TILING_DATA_FIELD_DEF(int64_t, formerCoreRowNum)
95+TILING_DATA_FIELD_DEF(int64_t, formerCoreNum)
96+TILING_DATA_FIELD_DEF(int64_t, eachCalculationLines)
97+ 
98+TILING_DATA_FIELD_DEF(int64_t, xBufferSize)
99+TILING_DATA_FIELD_DEF(int64_t, indexBufferSize)
100+TILING_DATA_FIELD_DEF(int64_t, yBufferSize)
101+TILING_DATA_FIELD_DEF(int64_t, maskBufferSize)
102+TILING_DATA_FIELD_DEF(int64_t, scalarModeLength)
103+ 
104+TILING_DATA_FIELD_DEF(int64_t, dataMoveUBStride)
105+END_TILING_DATA_DEF
106+ 
107+REGISTER_TILING_DATA_CLASS(GeV2LastDimTilingParamOp, GatherElementsV2LastDimTilingParam)
108+ 
109+BEGIN_TILING_DATA_DEF(GatherElementsV2TilingData)
110+TILING_DATA_FIELD_DEF_STRUCT(GatherElementsV2TilingParam, params)
111+TILING_DATA_FIELD_DEF_STRUCT(GatherElementsV2TransTiling, transTiling)
112+TILING_DATA_FIELD_DEF_STRUCT(GatherElementsV2ScalarTiling, scalarTiling)
113+TILING_DATA_FIELD_DEF_STRUCT(GatherElementsV2LastDimTilingParam, lastDimTiling)
114+END_TILING_DATA_DEF
115+ 
116+REGISTER_TILING_DATA_CLASS(GeV2TilingDataForGatherElements, GatherElementsV2TilingData)
117+ 
118+} // namespace optiling
119+#endif // GATHER_ELEMENTS_V2_TILING_DEFS_H
@@ -0,0 +1,973 @@
1+{
2+ "op_type": "GatherElements",
3+ "op_list": [
4+ {
5+ "bin_filename": "GatherElements_093a9c399321376b38a75cfb730e3bd5",
6+ "inputs": [
7+ {
8+ "name": "x",
9+ "index": 0,
10+ "dtype": "bfloat16",
11+ "format": "ND",
12+ "paramType": "required",
13+ "shape": [
14+ -2
15+ ]
16+ },
17+ {
18+ "name": "index",
19+ "index": 1,
20+ "dtype": "int32",
21+ "format": "ND",
22+ "paramType": "required",
23+ "shape": [
24+ -2
25+ ]
26+ }
27+ ],
28+ "outputs": [
29+ {
30+ "name": "y",
31+ "index": 0,
32+ "dtype": "bfloat16",
33+ "format": "ND",
34+ "paramType": "required",
35+ "shape": [
36+ -2
37+ ]
38+ }
39+ ],
40+ "attrs": [
41+ {
42+ "name": "dim",
43+ "dtype": "int",
44+ "value": null
45+ }
46+ ]
47+ },
48+ {
49+ "bin_filename": "GatherElements_c956995141babe6b46a07ca335faa2f6",
50+ "inputs": [
51+ {
52+ "name": "x",
53+ "index": 0,
54+ "dtype": "bfloat16",
55+ "format": "ND",
56+ "paramType": "required",
57+ "shape": [
58+ -2
59+ ]
60+ },
61+ {
62+ "name": "index",
63+ "index": 1,
64+ "dtype": "int64",
65+ "format": "ND",
66+ "paramType": "required",
67+ "shape": [
68+ -2
69+ ]
70+ }
71+ ],
72+ "outputs": [
73+ {
74+ "name": "y",
75+ "index": 0,
76+ "dtype": "bfloat16",
77+ "format": "ND",
78+ "paramType": "required",
79+ "shape": [
80+ -2
81+ ]
82+ }
83+ ],
84+ "attrs": [
85+ {
86+ "name": "dim",
87+ "dtype": "int",
88+ "value": null
89+ }
90+ ]
91+ },
92+ {
93+ "bin_filename": "GatherElements_6e7f02d790c19489aa959f7a0decd9ba",
94+ "inputs": [
95+ {
96+ "name": "x",
97+ "index": 0,
98+ "dtype": "float16",
99+ "format": "ND",
100+ "paramType": "required",
101+ "shape": [
102+ -2
103+ ]
104+ },
105+ {
106+ "name": "index",
107+ "index": 1,
108+ "dtype": "int32",
109+ "format": "ND",
110+ "paramType": "required",
111+ "shape": [
112+ -2
113+ ]
114+ }
115+ ],
116+ "outputs": [
117+ {
118+ "name": "y",
119+ "index": 0,
120+ "dtype": "float16",
121+ "format": "ND",
122+ "paramType": "required",
123+ "shape": [
124+ -2
125+ ]
126+ }
127+ ],
128+ "attrs": [
129+ {
130+ "name": "dim",
131+ "dtype": "int",
132+ "value": null
133+ }
134+ ]
135+ },
136+ {
137+ "bin_filename": "GatherElements_03c0542f2023bc999d5085c3cf4d9b0b",
138+ "inputs": [
139+ {
140+ "name": "x",
141+ "index": 0,
142+ "dtype": "float16",
143+ "format": "ND",
144+ "paramType": "required",
145+ "shape": [
146+ -2
147+ ]
148+ },
149+ {
150+ "name": "index",
151+ "index": 1,
152+ "dtype": "int64",
153+ "format": "ND",
154+ "paramType": "required",
155+ "shape": [
156+ -2
157+ ]
158+ }
159+ ],
160+ "outputs": [
161+ {
162+ "name": "y",
163+ "index": 0,
164+ "dtype": "float16",
165+ "format": "ND",
166+ "paramType": "required",
167+ "shape": [
168+ -2
169+ ]
170+ }
171+ ],
172+ "attrs": [
173+ {
174+ "name": "dim",
175+ "dtype": "int",
176+ "value": null
177+ }
178+ ]
179+ },
180+ {
181+ "bin_filename": "GatherElements_59875a0ff8228b3015d96baf3c81bb9e",
182+ "inputs": [
183+ {
184+ "name": "x",
185+ "index": 0,
186+ "dtype": "float32",
187+ "format": "ND",
188+ "paramType": "required",
189+ "shape": [
190+ -2
191+ ]
192+ },
193+ {
194+ "name": "index",
195+ "index": 1,
196+ "dtype": "int32",
197+ "format": "ND",
198+ "paramType": "required",
199+ "shape": [
200+ -2
201+ ]
202+ }
203+ ],
204+ "outputs": [
205+ {
206+ "name": "y",
207+ "index": 0,
208+ "dtype": "float32",
209+ "format": "ND",
210+ "paramType": "required",
211+ "shape": [
212+ -2
213+ ]
214+ }
215+ ],
216+ "attrs": [
217+ {
218+ "name": "dim",
219+ "dtype": "int",
220+ "value": null
221+ }
222+ ]
223+ },
224+ {
225+ "bin_filename": "GatherElements_7a09f5b7af4126487a7f726a9aac7548",
226+ "inputs": [
227+ {
228+ "name": "x",
229+ "index": 0,
230+ "dtype": "float32",
231+ "format": "ND",
232+ "paramType": "required",
233+ "shape": [
234+ -2
235+ ]
236+ },
237+ {
238+ "name": "index",
239+ "index": 1,
240+ "dtype": "int64",
241+ "format": "ND",
242+ "paramType": "required",
243+ "shape": [
244+ -2
245+ ]
246+ }
247+ ],
248+ "outputs": [
249+ {
250+ "name": "y",
251+ "index": 0,
252+ "dtype": "float32",
253+ "format": "ND",
254+ "paramType": "required",
255+ "shape": [
256+ -2
257+ ]
258+ }
259+ ],
260+ "attrs": [
261+ {
262+ "name": "dim",
263+ "dtype": "int",
264+ "value": null
265+ }
266+ ]
267+ },
268+ {
269+ "bin_filename": "GatherElements_98bddd8e0187d69757cf7450fb6c5fd9",
270+ "inputs": [
271+ {
272+ "name": "x",
273+ "index": 0,
274+ "dtype": "int16",
275+ "format": "ND",
276+ "paramType": "required",
277+ "shape": [
278+ -2
279+ ]
280+ },
281+ {
282+ "name": "index",
283+ "index": 1,
284+ "dtype": "int32",
285+ "format": "ND",
286+ "paramType": "required",
287+ "shape": [
288+ -2
289+ ]
290+ }
291+ ],
292+ "outputs": [
293+ {
294+ "name": "y",
295+ "index": 0,
296+ "dtype": "int16",
297+ "format": "ND",
298+ "paramType": "required",
299+ "shape": [
300+ -2
301+ ]
302+ }
303+ ],
304+ "attrs": [
305+ {
306+ "name": "dim",
307+ "dtype": "int",
308+ "value": null
309+ }
310+ ]
311+ },
312+ {
313+ "bin_filename": "GatherElements_ae1bb983d55cdb4f4fdf0c38b36799d2",
314+ "inputs": [
315+ {
316+ "name": "x",
317+ "index": 0,
318+ "dtype": "int16",
319+ "format": "ND",
320+ "paramType": "required",
321+ "shape": [
322+ -2
323+ ]
324+ },
325+ {
326+ "name": "index",
327+ "index": 1,
328+ "dtype": "int64",
329+ "format": "ND",
330+ "paramType": "required",
331+ "shape": [
332+ -2
333+ ]
334+ }
335+ ],
336+ "outputs": [
337+ {
338+ "name": "y",
339+ "index": 0,
340+ "dtype": "int16",
341+ "format": "ND",
342+ "paramType": "required",
343+ "shape": [
344+ -2
345+ ]
346+ }
347+ ],
348+ "attrs": [
349+ {
350+ "name": "dim",
351+ "dtype": "int",
352+ "value": null
353+ }
354+ ]
355+ },
356+ {
357+ "bin_filename": "GatherElements_8b4ec10fbb39c5c0a65192c606400b29",
358+ "inputs": [
359+ {
360+ "name": "x",
361+ "index": 0,
362+ "dtype": "int32",
363+ "format": "ND",
364+ "paramType": "required",
365+ "shape": [
366+ -2
367+ ]
368+ },
369+ {
370+ "name": "index",
371+ "index": 1,
372+ "dtype": "int32",
373+ "format": "ND",
374+ "paramType": "required",
375+ "shape": [
376+ -2
377+ ]
378+ }
379+ ],
380+ "outputs": [
381+ {
382+ "name": "y",
383+ "index": 0,
384+ "dtype": "int32",
385+ "format": "ND",
386+ "paramType": "required",
387+ "shape": [
388+ -2
389+ ]
390+ }
391+ ],
392+ "attrs": [
393+ {
394+ "name": "dim",
395+ "dtype": "int",
396+ "value": null
397+ }
398+ ]
399+ },
400+ {
401+ "bin_filename": "GatherElements_084655047edb72b366482aa51e18034b",
402+ "inputs": [
403+ {
404+ "name": "x",
405+ "index": 0,
406+ "dtype": "int32",
407+ "format": "ND",
408+ "paramType": "required",
409+ "shape": [
410+ -2
411+ ]
412+ },
413+ {
414+ "name": "index",
415+ "index": 1,
416+ "dtype": "int64",
417+ "format": "ND",
418+ "paramType": "required",
419+ "shape": [
420+ -2
421+ ]
422+ }
423+ ],
424+ "outputs": [
425+ {
426+ "name": "y",
427+ "index": 0,
428+ "dtype": "int32",
429+ "format": "ND",
430+ "paramType": "required",
431+ "shape": [
432+ -2
433+ ]
434+ }
435+ ],
436+ "attrs": [
437+ {
438+ "name": "dim",
439+ "dtype": "int",
440+ "value": null
441+ }
442+ ]
443+ },
444+ {
445+ "bin_filename": "GatherElements_65b8831ee054f9f32f9460360bd29bf1",
446+ "inputs": [
447+ {
448+ "name": "x",
449+ "index": 0,
450+ "dtype": "int64",
451+ "format": "ND",
452+ "paramType": "required",
453+ "shape": [
454+ -2
455+ ]
456+ },
457+ {
458+ "name": "index",
459+ "index": 1,
460+ "dtype": "int32",
461+ "format": "ND",
462+ "paramType": "required",
463+ "shape": [
464+ -2
465+ ]
466+ }
467+ ],
468+ "outputs": [
469+ {
470+ "name": "y",
471+ "index": 0,
472+ "dtype": "int64",
473+ "format": "ND",
474+ "paramType": "required",
475+ "shape": [
476+ -2
477+ ]
478+ }
479+ ],
480+ "attrs": [
481+ {
482+ "name": "dim",
483+ "dtype": "int",
484+ "value": null
485+ }
486+ ]
487+ },
488+ {
489+ "bin_filename": "GatherElements_0d745295987e1c668b2ec8b2844aeada",
490+ "inputs": [
491+ {
492+ "name": "x",
493+ "index": 0,
494+ "dtype": "int64",
495+ "format": "ND",
496+ "paramType": "required",
497+ "shape": [
498+ -2
499+ ]
500+ },
501+ {
502+ "name": "index",
503+ "index": 1,
504+ "dtype": "int64",
505+ "format": "ND",
506+ "paramType": "required",
507+ "shape": [
508+ -2
509+ ]
510+ }
511+ ],
512+ "outputs": [
513+ {
514+ "name": "y",
515+ "index": 0,
516+ "dtype": "int64",
517+ "format": "ND",
518+ "paramType": "required",
519+ "shape": [
520+ -2
521+ ]
522+ }
523+ ],
524+ "attrs": [
525+ {
526+ "name": "dim",
527+ "dtype": "int",
528+ "value": null
529+ }
530+ ]
531+ },
532+ {
533+ "bin_filename": "GatherElements_6ebc118f1f99e8a49d9bc016f5d1c0c3",
534+ "inputs": [
535+ {
536+ "name": "x",
537+ "index": 0,
538+ "dtype": "int8",
539+ "format": "ND",
540+ "paramType": "required",
541+ "shape": [
542+ -2
543+ ]
544+ },
545+ {
546+ "name": "index",
547+ "index": 1,
548+ "dtype": "int32",
549+ "format": "ND",
550+ "paramType": "required",
551+ "shape": [
552+ -2
553+ ]
554+ }
555+ ],
556+ "outputs": [
557+ {
558+ "name": "y",
559+ "index": 0,
560+ "dtype": "int8",
561+ "format": "ND",
562+ "paramType": "required",
563+ "shape": [
564+ -2
565+ ]
566+ }
567+ ],
568+ "attrs": [
569+ {
570+ "name": "dim",
571+ "dtype": "int",
572+ "value": null
573+ }
574+ ]
575+ },
576+ {
577+ "bin_filename": "GatherElements_60c42e561c203eefb1e4955f2afaef3c",
578+ "inputs": [
579+ {
580+ "name": "x",
581+ "index": 0,
582+ "dtype": "int8",
583+ "format": "ND",
584+ "paramType": "required",
585+ "shape": [
586+ -2
587+ ]
588+ },
589+ {
590+ "name": "index",
591+ "index": 1,
592+ "dtype": "int64",
593+ "format": "ND",
594+ "paramType": "required",
595+ "shape": [
596+ -2
597+ ]
598+ }
599+ ],
600+ "outputs": [
601+ {
602+ "name": "y",
603+ "index": 0,
604+ "dtype": "int8",
605+ "format": "ND",
606+ "paramType": "required",
607+ "shape": [
608+ -2
609+ ]
610+ }
611+ ],
612+ "attrs": [
613+ {
614+ "name": "dim",
615+ "dtype": "int",
616+ "value": null
617+ }
618+ ]
619+ },
620+ {
621+ "bin_filename": "GatherElements_4dae835995940675ba29a534fa187699",
622+ "inputs": [
623+ {
624+ "name": "x",
625+ "index": 0,
626+ "dtype": "uint16",
627+ "format": "ND",
628+ "paramType": "required",
629+ "shape": [
630+ -2
631+ ]
632+ },
633+ {
634+ "name": "index",
635+ "index": 1,
636+ "dtype": "int32",
637+ "format": "ND",
638+ "paramType": "required",
639+ "shape": [
640+ -2
641+ ]
642+ }
643+ ],
644+ "outputs": [
645+ {
646+ "name": "y",
647+ "index": 0,
648+ "dtype": "uint16",
649+ "format": "ND",
650+ "paramType": "required",
651+ "shape": [
652+ -2
653+ ]
654+ }
655+ ],
656+ "attrs": [
657+ {
658+ "name": "dim",
659+ "dtype": "int",
660+ "value": null
661+ }
662+ ]
663+ },
664+ {
665+ "bin_filename": "GatherElements_7b5256f2ea67a217fed14356517555de",
666+ "inputs": [
667+ {
668+ "name": "x",
669+ "index": 0,
670+ "dtype": "uint16",
671+ "format": "ND",
672+ "paramType": "required",
673+ "shape": [
674+ -2
675+ ]
676+ },
677+ {
678+ "name": "index",
679+ "index": 1,
680+ "dtype": "int64",
681+ "format": "ND",
682+ "paramType": "required",
683+ "shape": [
684+ -2
685+ ]
686+ }
687+ ],
688+ "outputs": [
689+ {
690+ "name": "y",
691+ "index": 0,
692+ "dtype": "uint16",
693+ "format": "ND",
694+ "paramType": "required",
695+ "shape": [
696+ -2
697+ ]
698+ }
699+ ],
700+ "attrs": [
701+ {
702+ "name": "dim",
703+ "dtype": "int",
704+ "value": null
705+ }
706+ ]
707+ },
708+ {
709+ "bin_filename": "GatherElements_cdf390bfd9c1c2617ad090138fd5a396",
710+ "inputs": [
711+ {
712+ "name": "x",
713+ "index": 0,
714+ "dtype": "uint32",
715+ "format": "ND",
716+ "paramType": "required",
717+ "shape": [
718+ -2
719+ ]
720+ },
721+ {
722+ "name": "index",
723+ "index": 1,
724+ "dtype": "int32",
725+ "format": "ND",
726+ "paramType": "required",
727+ "shape": [
728+ -2
729+ ]
730+ }
731+ ],
732+ "outputs": [
733+ {
734+ "name": "y",
735+ "index": 0,
736+ "dtype": "uint32",
737+ "format": "ND",
738+ "paramType": "required",
739+ "shape": [
740+ -2
741+ ]
742+ }
743+ ],
744+ "attrs": [
745+ {
746+ "name": "dim",
747+ "dtype": "int",
748+ "value": null
749+ }
750+ ]
751+ },
752+ {
753+ "bin_filename": "GatherElements_064b27f3015dfa81e5c1e3521344f8dd",
754+ "inputs": [
755+ {
756+ "name": "x",
757+ "index": 0,
758+ "dtype": "uint32",
759+ "format": "ND",
760+ "paramType": "required",
761+ "shape": [
762+ -2
763+ ]
764+ },
765+ {
766+ "name": "index",
767+ "index": 1,
768+ "dtype": "int64",
769+ "format": "ND",
770+ "paramType": "required",
771+ "shape": [
772+ -2
773+ ]
774+ }
775+ ],
776+ "outputs": [
777+ {
778+ "name": "y",
779+ "index": 0,
780+ "dtype": "uint32",
781+ "format": "ND",
782+ "paramType": "required",
783+ "shape": [
784+ -2
785+ ]
786+ }
787+ ],
788+ "attrs": [
789+ {
790+ "name": "dim",
791+ "dtype": "int",
792+ "value": null
793+ }
794+ ]
795+ },
796+ {
797+ "bin_filename": "GatherElements_b5f9a09a5dd35ccad942b4e69891f7e8",
798+ "inputs": [
799+ {
800+ "name": "x",
801+ "index": 0,
802+ "dtype": "uint64",
803+ "format": "ND",
804+ "paramType": "required",
805+ "shape": [
806+ -2
807+ ]
808+ },
809+ {
810+ "name": "index",
811+ "index": 1,
812+ "dtype": "int32",
813+ "format": "ND",
814+ "paramType": "required",
815+ "shape": [
816+ -2
817+ ]
818+ }
819+ ],
820+ "outputs": [
821+ {
822+ "name": "y",
823+ "index": 0,
824+ "dtype": "uint64",
825+ "format": "ND",
826+ "paramType": "required",
827+ "shape": [
828+ -2
829+ ]
830+ }
831+ ],
832+ "attrs": [
833+ {
834+ "name": "dim",
835+ "dtype": "int",
836+ "value": null
837+ }
838+ ]
839+ },
840+ {
841+ "bin_filename": "GatherElements_1b5b4c9f75262abc7e00b2e9a96cb157",
842+ "inputs": [
843+ {
844+ "name": "x",
845+ "index": 0,
846+ "dtype": "uint64",
847+ "format": "ND",
848+ "paramType": "required",
849+ "shape": [
850+ -2
851+ ]
852+ },
853+ {
854+ "name": "index",
855+ "index": 1,
856+ "dtype": "int64",
857+ "format": "ND",
858+ "paramType": "required",
859+ "shape": [
860+ -2
861+ ]
862+ }
863+ ],
864+ "outputs": [
865+ {
866+ "name": "y",
867+ "index": 0,
868+ "dtype": "uint64",
869+ "format": "ND",
870+ "paramType": "required",
871+ "shape": [
872+ -2
873+ ]
874+ }
875+ ],
876+ "attrs": [
877+ {
878+ "name": "dim",
879+ "dtype": "int",
880+ "value": null
881+ }
882+ ]
883+ },
884+ {
885+ "bin_filename": "GatherElements_b0b54dddeb312b593b50c229b8dea90d",
886+ "inputs": [
887+ {
888+ "name": "x",
889+ "index": 0,
890+ "dtype": "uint8",
891+ "format": "ND",
892+ "paramType": "required",
893+ "shape": [
894+ -2
895+ ]
896+ },
897+ {
898+ "name": "index",
899+ "index": 1,
900+ "dtype": "int32",
901+ "format": "ND",
902+ "paramType": "required",
903+ "shape": [
904+ -2
905+ ]
906+ }
907+ ],
908+ "outputs": [
909+ {
910+ "name": "y",
911+ "index": 0,
912+ "dtype": "uint8",
913+ "format": "ND",
914+ "paramType": "required",
915+ "shape": [
916+ -2
917+ ]
918+ }
919+ ],
920+ "attrs": [
921+ {
922+ "name": "dim",
923+ "dtype": "int",
924+ "value": null
925+ }
926+ ]
927+ },
928+ {
929+ "bin_filename": "GatherElements_da5646da4cde210233b1d50ae2aa5c45",
930+ "inputs": [
931+ {
932+ "name": "x",
933+ "index": 0,
934+ "dtype": "uint8",
935+ "format": "ND",
936+ "paramType": "required",
937+ "shape": [
938+ -2
939+ ]
940+ },
941+ {
942+ "name": "index",
943+ "index": 1,
944+ "dtype": "int64",
945+ "format": "ND",
946+ "paramType": "required",
947+ "shape": [
948+ -2
949+ ]
950+ }
951+ ],
952+ "outputs": [
953+ {
954+ "name": "y",
955+ "index": 0,
956+ "dtype": "uint8",
957+ "format": "ND",
958+ "paramType": "required",
959+ "shape": [
960+ -2
961+ ]
962+ }
963+ ],
964+ "attrs": [
965+ {
966+ "name": "dim",
967+ "dtype": "int",
968+ "value": null
969+ }
970+ ]
971+ }
972+ ]
973+}