已合并
MapIndex支持下一代实现 #1191
Guoqh创建于 1月29日
MapIndex支持下一代实现 #1191
已合并
共 15 个文件变更+1664-1
| @@ -0,0 +1,16 @@ | |||
| 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 | +set(SUPPORT_COMPUTE_UNIT "ascend910_95") | ||
| 13 | +# 设置每种芯片类型对应的tiling文件目录,即采用op_host目录下哪个文件夹下的tiling文件编译 | ||
| 14 | +set(SUPPORT_TILING_DIR "arch35") | ||
| 15 | +add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE map_index ACLNNTYPE aclnn_exclude | ||
| 16 | + COMPUTE_UNIT ${SUPPORT_COMPUTE_UNIT} TILING_DIR ${SUPPORT_TILING_DIR} DISABLE_IN_OPP TRUE) | ||
| @@ -0,0 +1,3 @@ | |||
| 1 | +# MapIndex | ||
| 2 | + | ||
| 3 | +本目录仅包含MapIndex算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | ||
| @@ -0,0 +1,63 @@ | |||
| 1 | +{ | ||
| 2 | + "op_type": "MapIndex", | ||
| 3 | + "op_list": [ | ||
| 4 | + { | ||
| 5 | + "bin_filename": "MapIndex_int32_int32_int32", | ||
| 6 | + "inputs": [ | ||
| 7 | + { | ||
| 8 | + "name": "x", | ||
| 9 | + "index": 0, | ||
| 10 | + "dtype": "int32", | ||
| 11 | + "format": "ND", | ||
| 12 | + "paramType": "required", | ||
| 13 | + "shape": [ | ||
| 14 | + -2 | ||
| 15 | + ], | ||
| 16 | + "format_match_mode": "FormatAgnostic" | ||
| 17 | + }, | ||
| 18 | + { | ||
| 19 | + "name": "data_seq", | ||
| 20 | + "index": 1, | ||
| 21 | + "dtype": "int32", | ||
| 22 | + "format": "ND", | ||
| 23 | + "paramType": "required", | ||
| 24 | + "shape": [ | ||
| 25 | + -2 | ||
| 26 | + ], | ||
| 27 | + "format_match_mode": "FormatAgnostic" | ||
| 28 | + }, | ||
| 29 | + { | ||
| 30 | + "name": "level_index", | ||
| 31 | + "index": 2, | ||
| 32 | + "dtype": "int32", | ||
| 33 | + "format": "ND", | ||
| 34 | + "paramType": "optional", | ||
| 35 | + "shape": [ | ||
| 36 | + -2 | ||
| 37 | + ], | ||
| 38 | + "format_match_mode": "FormatAgnostic" | ||
| 39 | + } | ||
| 40 | + ], | ||
| 41 | + "outputs": [ | ||
| 42 | + { | ||
| 43 | + "name": "y", | ||
| 44 | + "index": 0, | ||
| 45 | + "dtype": "int32", | ||
| 46 | + "format": "ND", | ||
| 47 | + "paramType": "required", | ||
| 48 | + "shape": [ | ||
| 49 | + -2 | ||
| 50 | + ], | ||
| 51 | + "format_match_mode": "FormatAgnostic" | ||
| 52 | + } | ||
| 53 | + ], | ||
| 54 | + "attrs": [ | ||
| 55 | + { | ||
| 56 | + "name": "transpose", | ||
| 57 | + "dtype": "bool", | ||
| 58 | + "value": false | ||
| 59 | + } | ||
| 60 | + ] | ||
| 61 | + } | ||
| 62 | + ] | ||
| 63 | +} | ||
| @@ -0,0 +1,13 @@ | |||
| 1 | +; 该文件主要影响 opc 工具 编译二进制kernel时, --simplified_key_mode 选项中填写的值,格式如下所示: | ||
| 2 | +; [某算子] | ||
| 3 | +; default=xx | ||
| 4 | +; ascendxx=xx | ||
| 5 | +; 其中,default为默认mode,ascnedxx为可选mode,如果不同芯片有差异化要求时,需要配置; | ||
| 6 | +; 1)如果没有配置:非ascendC算子继续按空处理,即opc编译命令中不添加 --simplified_key_mode 选项,AscendC算子按照 simplified_key_mode=0 处理 | ||
| 7 | +; 2)如果仅有default配置:各个版本按default配置 | ||
| 8 | +; 3)如果仅有某些平台的配置,没有default配置:对应平台的按照配置的值传递,非对应平台的:非AscendC算子继续按空处理,AscendC算子按照 simplified_key_mode=0 处理 | ||
| 9 | +; 4)如果default配置和平台配置都有:对应平台的使用平台的配置,非对应的平台的以default值配置。 | ||
| 10 | +; 5)对于自定义simplified key的情况,需要在binary_simplified_key_mode.ini 文件中显式配置为None,不传入 --simplified_key_mode 选项,由opc工具和FE框架自行判断使用何种模式 | ||
| 11 | +; 6)是否是AscendC算子,由 ops/build-in/tbe/op_info_cfg/parser/ascendc_config.json 中配置的算子名字和对于的平台决定 | ||
| 12 | +[MapIndex] | ||
| 13 | +default=0 | ||
| @@ -0,0 +1,62 @@ | |||
| 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 map_index_def.cpp | ||
| 13 | + * \brief | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +namespace ops { | ||
| 19 | + class MapIndex : public OpDef { | ||
| 20 | + public: | ||
| 21 | + explicit MapIndex(const char* name) : OpDef(name) | ||
| 22 | + { | ||
| 23 | + this->Input("x") | ||
| 24 | + .ParamType(REQUIRED) | ||
| 25 | + .DataType({ge::DT_INT32}) | ||
| 26 | + .Format({ge::FORMAT_ND}) | ||
| 27 | + .UnknownShapeFormat({ge::FORMAT_ND}) | ||
| 28 | + .AutoContiguous(); | ||
| 29 | + this->Input("data_seq") | ||
| 30 | + .ParamType(REQUIRED) | ||
| 31 | + .DataType({ge::DT_INT32}) | ||
| 32 | + .Format({ge::FORMAT_ND}) | ||
| 33 | + .UnknownShapeFormat({ge::FORMAT_ND}) | ||
| 34 | + .AutoContiguous(); | ||
| 35 | + this->Input("level_index") | ||
| 36 | + .ParamType(OPTIONAL) | ||
| 37 | + .DataType({ge::DT_INT32}) | ||
| 38 | + .Format({ge::FORMAT_ND}) | ||
| 39 | + .UnknownShapeFormat({ge::FORMAT_ND}) | ||
| 40 | + .AutoContiguous(); | ||
| 41 | + this->Output("y") | ||
| 42 | + .ParamType(REQUIRED) | ||
| 43 | + .DataType({ge::DT_INT32}) | ||
| 44 | + .Format({ge::FORMAT_ND}) | ||
| 45 | + .UnknownShapeFormat({ge::FORMAT_ND}); | ||
| 46 | + | ||
| 47 | + this->Attr("transpose").AttrType(OPTIONAL).Bool(false); | ||
| 48 | + | ||
| 49 | + OpAICoreConfig aicoreConfig; | ||
| 50 | + aicoreConfig.DynamicCompileStaticFlag(true) | ||
| 51 | + .DynamicFormatFlag(false) | ||
| 52 | + .DynamicRankSupportFlag(true) | ||
| 53 | + .DynamicShapeSupportFlag(true) | ||
| 54 | + .NeedCheckSupportFlag(false) | ||
| 55 | + .PrecisionReduceFlag(true) | ||
| 56 | + .ExtendCfgInfo("opFile.value", "map_index_apt"); | ||
| 57 | + this->AICore().AddConfig("ascend950", aicoreConfig); | ||
| 58 | + } | ||
| 59 | + }; | ||
| 60 | + | ||
| 61 | + OP_ADD(MapIndex); | ||
| 62 | + } // namespace ops | ||
| @@ -0,0 +1,304 @@ | |||
| 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 map_index_tiling_arch35.cpp | ||
| 13 | +* \brief | ||
| 14 | +*/ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +using namespace std; | ||
| 24 | +using namespace ge; | ||
| 25 | + | ||
| 26 | +namespace optiling { | ||
| 27 | + | ||
| 28 | +constexpr int64_t DIGIT_EIGHT = 8; | ||
| 29 | +constexpr int64_t X_MAX_DIM0 = 24000; | ||
| 30 | +constexpr int64_t DATA_SEQ_MAX_DIM0 = 256; | ||
| 31 | +constexpr int64_t VL_NUMS = 64; | ||
| 32 | +constexpr size_t WORKSPACE_SIZE = 32; | ||
| 33 | +constexpr size_t LEVEL_INDEX_INDEX = 2; | ||
| 34 | +constexpr int64_t NUM_TWO_DB = 2; | ||
| 35 | +constexpr int64_t RESERVED_UB_SIZE = static_cast<int64_t>(8) * 1024; // 8k | ||
| 36 | +constexpr int64_t WORKSPACE_BUFFER = static_cast<int64_t>(20) * 1024 * 1024; | ||
| 37 | +constexpr int64_t ATTR_INDEX_TRANSPOSE = 0; | ||
| 38 | +const std::set<ge::DataType> INPUT_SUPPORT_DTYPE_SET = { ge::DT_INT32 }; | ||
| 39 | + | ||
| 40 | +template <class T> T inline CeilDivide(T num1, T num2) | ||
| 41 | +{ | ||
| 42 | + if (num2 == 0) { | ||
| 43 | + return 0; | ||
| 44 | + } | ||
| 45 | + return (num1 + num2 - 1) / num2; | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +static ge::graphStatus CheckDtype(const gert::TilingContext *context, MapIndexTilingParam &tilingParam) | ||
| 49 | +{ | ||
| 50 | + OP_LOGD(context->GetNodeName(), "CheckDtype begin."); | ||
| 51 | + auto inputXPtr = context->GetInputDesc(0); | ||
| 52 | + OP_CHECK_NULL_WITH_CONTEXT(context, inputXPtr); | ||
| 53 | + auto xDtype = inputXPtr->GetDataType(); | ||
| 54 | + OP_CHECK_IF(INPUT_SUPPORT_DTYPE_SET.count(xDtype) == 0, | ||
| 55 | + OP_LOGE(context->GetNodeName(), | ||
| 56 | + "Input x's data type is [%s], only supports INT32.", | ||
| 57 | + Ops::Base::ToString(static_cast<ge::DataType>(xDtype)).c_str()), | ||
| 58 | + return ge::GRAPH_FAILED); | ||
| 59 | + | ||
| 60 | + auto inputDataSeqPtr = context->GetInputDesc(1); | ||
| 61 | + OP_CHECK_NULL_WITH_CONTEXT(context, inputDataSeqPtr); | ||
| 62 | + auto dataSeqDtype = inputDataSeqPtr->GetDataType(); | ||
| 63 | + OP_CHECK_IF(INPUT_SUPPORT_DTYPE_SET.count(dataSeqDtype) == 0, | ||
| 64 | + OP_LOGE(context->GetNodeName(), | ||
| 65 | + "Input dataSeq's data type is [%s], only supports INT32.", | ||
| 66 | + Ops::Base::ToString(static_cast<ge::DataType>(dataSeqDtype)).c_str()), | ||
| 67 | + return ge::GRAPH_FAILED); | ||
| 68 | + | ||
| 69 | + auto levelIndexInput = context->GetOptionalInputDesc(LEVEL_INDEX_INDEX); | ||
| 70 | + if (levelIndexInput == nullptr) { | ||
| 71 | + tilingParam.hasLevelIndex = false; | ||
| 72 | + } else { | ||
| 73 | + auto levelIndexDtype = levelIndexInput->GetDataType(); | ||
| 74 | + OP_CHECK_IF(INPUT_SUPPORT_DTYPE_SET.count(levelIndexDtype) == 0, | ||
| 75 | + OP_LOGE(context->GetNodeName(), | ||
| 76 | + "Input levelIndex's data type is [%s], only supports INT32.", | ||
| 77 | + Ops::Base::ToString(static_cast<ge::DataType>(levelIndexDtype)).c_str()), | ||
| 78 | + return ge::GRAPH_FAILED); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + auto outputYPtr = context->GetOutputDesc(0); | ||
| 82 | + OP_CHECK_NULL_WITH_CONTEXT(context, outputYPtr); | ||
| 83 | + auto yDtype = outputYPtr->GetDataType(); | ||
| 84 | + OP_CHECK_IF(INPUT_SUPPORT_DTYPE_SET.count(yDtype) == 0, | ||
| 85 | + OP_LOGE(context->GetNodeName(), | ||
| 86 | + "Output y's data type is [%s], only supports INT32.", | ||
| 87 | + Ops::Base::ToString(static_cast<ge::DataType>(yDtype)).c_str()), | ||
| 88 | + return ge::GRAPH_FAILED); | ||
| 89 | + | ||
| 90 | + return ge::GRAPH_SUCCESS; | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +static ge::graphStatus CheckShape(const gert::TilingContext *context, MapIndexTilingParam &tilingParam) | ||
| 94 | +{ | ||
| 95 | + OP_LOGD(context->GetNodeName(), "CheckShape begin."); | ||
| 96 | + auto xShapePtr = context->GetInputShape(0); | ||
| 97 | + OP_CHECK_NULL_WITH_CONTEXT(context, xShapePtr); | ||
| 98 | + auto xShape = xShapePtr->GetStorageShape(); | ||
| 99 | + | ||
| 100 | + auto dataSeqShapePtr = context->GetInputShape(1); | ||
| 101 | + OP_CHECK_NULL_WITH_CONTEXT(context, dataSeqShapePtr); | ||
| 102 | + auto dataSeqShape = dataSeqShapePtr->GetStorageShape(); | ||
| 103 | + | ||
| 104 | + auto yShapePtr = context->GetOutputShape(0); | ||
| 105 | + OP_CHECK_NULL_WITH_CONTEXT(context, yShapePtr); | ||
| 106 | + auto yShape = Ops::NN::OpTiling::EnsureNotScalar(yShapePtr->GetStorageShape()); | ||
| 107 | + OP_CHECK_IF(yShape.GetDimNum() != 1, | ||
| 108 | + OP_LOGE(context->GetNodeName(), | ||
| 109 | + "The shape of output y must be 1D."), | ||
| 110 | + return ge::GRAPH_FAILED); | ||
| 111 | + | ||
| 112 | + OP_CHECK_IF(yShape.GetDim(0) != 1, | ||
| 113 | + OP_LOGE(context->GetNodeName(), | ||
| 114 | + "The shape of output y must be [1]."), | ||
| 115 | + return ge::GRAPH_FAILED); | ||
| 116 | + | ||
| 117 | + OP_CHECK_IF(xShape.GetDimNum() != 1, | ||
| 118 | + OP_LOGE(context->GetNodeName(), | ||
| 119 | + "The shape of input x must be 1D."), | ||
| 120 | + return ge::GRAPH_FAILED); | ||
| 121 | + OP_CHECK_IF(xShape.GetDim(0) > X_MAX_DIM0, | ||
| 122 | + OP_LOGE(context->GetNodeName(), | ||
| 123 | + "The shape of input x must be less than 24000."), | ||
| 124 | + return ge::GRAPH_FAILED); | ||
| 125 | + OP_CHECK_IF(dataSeqShape.GetDimNum() != 1, | ||
| 126 | + OP_LOGE(context->GetNodeName(), | ||
| 127 | + "The shape of input data_seq must be 1D."), | ||
| 128 | + return ge::GRAPH_FAILED); | ||
| 129 | + | ||
| 130 | + tilingParam.Dim1Size = xShape.GetDim(0); | ||
| 131 | + OP_CHECK_IF(dataSeqShape.GetDim(0) % xShape.GetDim(0) != 0, | ||
| 132 | + OP_LOGE(context->GetNodeName(), | ||
| 133 | + "the length of data_seq must be multiple of the length of x"), | ||
| 134 | + return ge::GRAPH_FAILED); | ||
| 135 | + | ||
| 136 | + tilingParam.Dim0Size = dataSeqShape.GetDim(0) / xShape.GetDim(0); | ||
| 137 | + | ||
| 138 | + OP_CHECK_IF(tilingParam.Dim0Size > DATA_SEQ_MAX_DIM0, | ||
| 139 | + OP_LOGE(context->GetNodeName(), | ||
| 140 | + "The input length of dataseq, which is a multiple of x, should be less than 256."), | ||
| 141 | + return ge::GRAPH_FAILED); | ||
| 142 | + | ||
| 143 | + if(tilingParam.hasLevelIndex) { | ||
| 144 | + auto levelIndexShapePtr = context->GetOptionalInputShape(LEVEL_INDEX_INDEX); | ||
| 145 | + OP_CHECK_NULL_WITH_CONTEXT(context, levelIndexShapePtr); | ||
| 146 | + auto levelIndexShape = levelIndexShapePtr->GetStorageShape(); | ||
| 147 | + OP_CHECK_IF(levelIndexShape.GetDimNum() != 1, | ||
| 148 | + OP_LOGE(context->GetNodeName(), | ||
| 149 | + "The shape of input level_index must be 1D."), | ||
| 150 | + return ge::GRAPH_FAILED); | ||
| 151 | + OP_CHECK_IF(tilingParam.Dim0Size != levelIndexShape.GetDim(0), | ||
| 152 | + OP_LOGE(context->GetNodeName(), | ||
| 153 | + "The input levelindex shape should be a multiple of dataseq, which should be a multiple of x."), | ||
| 154 | + return ge::GRAPH_FAILED); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + return ge::GRAPH_SUCCESS; | ||
| 158 | +} | ||
| 159 | + | ||
| 160 | +static ge::graphStatus CheckAttr(const gert::TilingContext *context) | ||
| 161 | +{ | ||
| 162 | + OP_LOGD(context->GetNodeName(), "checkAttr begin."); | ||
| 163 | + | ||
| 164 | + auto attrs = context->GetAttrs(); | ||
| 165 | + OP_CHECK_NULL_WITH_CONTEXT(context, attrs); | ||
| 166 | + | ||
| 167 | + auto* attrTransPose = attrs->GetAttrPointer<bool>(ATTR_INDEX_TRANSPOSE); | ||
| 168 | + OP_CHECK_NULL_WITH_CONTEXT(context, attrTransPose); | ||
| 169 | + OP_CHECK_IF((*attrTransPose), | ||
| 170 | + OP_LOGE( | ||
| 171 | + context->GetNodeName(), "The attr transpose should be false on A5, please check"), | ||
| 172 | + return ge::GRAPH_FAILED); | ||
| 173 | + | ||
| 174 | + return ge::GRAPH_SUCCESS; | ||
| 175 | +} | ||
| 176 | + | ||
| 177 | +static ge::graphStatus GetPlatInfo(const gert::TilingContext *context, MapIndexTilingParam &tilingParam) | ||
| 178 | +{ | ||
| 179 | + OP_LOGD(context->GetNodeName(), "GetPlatInfo begin."); | ||
| 180 | + auto platformInfo = context->GetPlatformInfo(); | ||
| 181 | + OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo); | ||
| 182 | + auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); | ||
| 183 | + tilingParam.totalCoreNum = ascendcPlatform.GetCoreNumAiv(); | ||
| 184 | + OP_CHECK_IF((tilingParam.totalCoreNum <= 0), | ||
| 185 | + OP_LOGE(context->GetNodeName(), "Failed to get core num."), return ge::GRAPH_FAILED); | ||
| 186 | + uint64_t ubSize; | ||
| 187 | + ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize); | ||
| 188 | + tilingParam.ubSize = static_cast<int64_t>(ubSize) - RESERVED_UB_SIZE; | ||
| 189 | + OP_CHECK_IF((tilingParam.ubSize <= 0), | ||
| 190 | + OP_LOGE(context->GetNodeName(), "Failed to get ub size."), return ge::GRAPH_FAILED); | ||
| 191 | + tilingParam.vfLen = Ops::Base::GetVRegSize(context); | ||
| 192 | + tilingParam.workspaceSize = ascendcPlatform.GetLibApiWorkSpaceSize(); | ||
| 193 | + return ge::GRAPH_SUCCESS; | ||
| 194 | +} | ||
| 195 | + | ||
| 196 | +static ge::graphStatus DoTiling(const gert::TilingContext *context, MapIndexTilingParam &tilingParam) | ||
| 197 | +{ | ||
| 198 | + OP_LOGD(context->GetNodeName(), "DoTiling begin."); | ||
| 199 | + tilingParam.normalCoreProcessNum = CeilDivide(tilingParam.Dim0Size, tilingParam.totalCoreNum); | ||
| 200 | + tilingParam.usedCoreNum = CeilDivide(tilingParam.Dim0Size, tilingParam.normalCoreProcessNum); | ||
| 201 | + tilingParam.tailCoreProcessNum = tilingParam.Dim0Size - tilingParam.normalCoreProcessNum * (tilingParam.usedCoreNum - 1); | ||
| 202 | + tilingParam.Dim1SizeAlign = Ops::Base::CeilAlign(tilingParam.Dim1Size, VL_NUMS); | ||
| 203 | + | ||
| 204 | + int64_t OneRowUB = tilingParam.Dim1SizeAlign * sizeof(int32_t); | ||
| 205 | + int64_t rowsNums = tilingParam.ubSize / OneRowUB; | ||
| 206 | + int64_t dataSeqNums = rowsNums - 1; | ||
| 207 | + | ||
| 208 | + if (dataSeqNums > tilingParam.normalCoreProcessNum){ | ||
| 209 | + tilingParam.CopyInDim0 = tilingParam.normalCoreProcessNum; | ||
| 210 | + tilingParam.CopyInDim0Times = 1; | ||
| 211 | + } else { | ||
| 212 | + tilingParam.CopyInDim0 = dataSeqNums; | ||
| 213 | + tilingParam.CopyInDim0Times = CeilDivide(tilingParam.normalCoreProcessNum, dataSeqNums); | ||
| 214 | + tilingParam.tailCopyInDim0Times = CeilDivide(tilingParam.tailCoreProcessNum, dataSeqNums); | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + if (tilingParam.CopyInDim0 < NUM_TWO_DB ){ | ||
| 218 | + tilingParam.doubleBuffNum = 1; | ||
| 219 | + } else { | ||
| 220 | + tilingParam.doubleBuffNum = NUM_TWO_DB; | ||
| 221 | + tilingParam.CopyInDim0 = Ops::Base::CeilAlign(tilingParam.CopyInDim0, tilingParam.doubleBuffNum); | ||
| 222 | + } | ||
| 223 | + | ||
| 224 | + return ge::GRAPH_SUCCESS; | ||
| 225 | +} | ||
| 226 | + | ||
| 227 | +inline static ge::graphStatus SetTilingData(gert::TilingContext *context, | ||
| 228 | + const MapIndexTilingParam &tilingParam, MapIndexTilingData &tilingData) | ||
| 229 | +{ | ||
| 230 | + OP_LOGD(context->GetNodeName(), "SetTilingData begin."); | ||
| 231 | + tilingData.set_totalCoreNum(tilingParam.totalCoreNum); | ||
| 232 | + tilingData.set_usedCoreNum(tilingParam.usedCoreNum); | ||
| 233 | + tilingData.set_normalCoreProcessNum(tilingParam.normalCoreProcessNum); | ||
| 234 | + tilingData.set_tailCoreProcessNum(tilingParam.tailCoreProcessNum); | ||
| 235 | + tilingData.set_Dim1Size(tilingParam.Dim1Size); | ||
| 236 | + tilingData.set_Dim1SizeAlign(tilingParam.Dim1SizeAlign); | ||
| 237 | + tilingData.set_CopyInDim0(tilingParam.CopyInDim0); | ||
| 238 | + tilingData.set_CopyInDim0Times(tilingParam.CopyInDim0Times); | ||
| 239 | + tilingData.set_tailCopyInDim0Times(tilingParam.tailCopyInDim0Times); | ||
| 240 | + tilingData.set_doubleBuffNum(tilingParam.doubleBuffNum); | ||
| 241 | + | ||
| 242 | + OP_CHECK_IF(tilingData.GetDataSize() > context->GetRawTilingData()->GetCapacity(), | ||
| 243 | + OP_LOGE(context->GetNodeName(), "tiling datasize: %zu is bigger than %zu", | ||
| 244 | + tilingData.GetDataSize(), context->GetRawTilingData()->GetCapacity()), | ||
| 245 | + return ge::GRAPH_FAILED); | ||
| 246 | + tilingData.SaveToBuffer(context->GetRawTilingData()->GetData(), context->GetRawTilingData()->GetCapacity()); | ||
| 247 | + context->GetRawTilingData()->SetDataSize(tilingData.GetDataSize()); | ||
| 248 | + context->SetBlockDim(tilingData.get_totalCoreNum()); | ||
| 249 | + context->SetTilingKey(1); | ||
| 250 | + size_t *workspaces = context->GetWorkspaceSizes(1); | ||
| 251 | + OP_CHECK_NULL_WITH_CONTEXT(context, workspaces); | ||
| 252 | + workspaces[0] = static_cast<size_t>(WORKSPACE_BUFFER); | ||
| 253 | + return ge::GRAPH_SUCCESS; | ||
| 254 | +} | ||
| 255 | + | ||
| 256 | +inline static void PrintTilingData(const gert::TilingContext *context, MapIndexTilingData &tilingData) | ||
| 257 | +{ | ||
| 258 | + OP_LOGI(context->GetNodeName(), "tilingData is totalCoreNum:%ld, usedCoreNum:%ld, normalCoreProcessNum:%ld, \ | ||
| 259 | + tailCoreProcessNum:%ld, Dim1Size:%ld, Dim1SizeAlign:%ld, CopyInDim0:%ld, CopyInDim0Times:%ld, tailCopyInDim0Times:%ld, doubleBuffNum:%ld", | ||
| 260 | + tilingData.get_totalCoreNum(), tilingData.get_usedCoreNum(), tilingData.get_normalCoreProcessNum(), | ||
| 261 | + tilingData.get_tailCoreProcessNum(), tilingData.get_Dim1Size(), tilingData.get_Dim1SizeAlign(), | ||
| 262 | + tilingData.get_CopyInDim0(), tilingData.get_CopyInDim0Times(), tilingData.get_tailCopyInDim0Times(), tilingData.get_doubleBuffNum()); | ||
| 263 | +} | ||
| 264 | + | ||
| 265 | +ge::graphStatus Tiling4MapIndex(gert::TilingContext *context) | ||
| 266 | +{ | ||
| 267 | + OP_LOGD(context->GetNodeName(), "Tiling4MapIndex running begin."); | ||
| 268 | + | ||
| 269 | + MapIndexTilingParam tilingParam; | ||
| 270 | + | ||
| 271 | + OP_CHECK_IF(CheckDtype(context, tilingParam) != ge::GRAPH_SUCCESS, | ||
| 272 | + OP_LOGE(context->GetNodeName(), "The data type check failed."), return ge::GRAPH_FAILED); | ||
| 273 | + | ||
| 274 | + OP_CHECK_IF(CheckShape(context, tilingParam) != ge::GRAPH_SUCCESS, | ||
| 275 | + OP_LOGE(context->GetNodeName(), "The shape check failed."), return ge::GRAPH_FAILED); | ||
| 276 | + | ||
| 277 | + OP_CHECK_IF(GetPlatInfo(context, tilingParam) != ge::GRAPH_SUCCESS, | ||
| 278 | + OP_LOGE(context->GetNodeName(), "GetPlatInfo failed."), return ge::GRAPH_FAILED); | ||
| 279 | + | ||
| 280 | + OP_CHECK_IF(DoTiling(context, tilingParam) != ge::GRAPH_SUCCESS, | ||
| 281 | + OP_LOGE(context->GetNodeName(), "DoTiling failed."), return ge::GRAPH_FAILED); | ||
| 282 | + | ||
| 283 | + OP_CHECK_IF(CheckAttr(context) != ge::GRAPH_SUCCESS, | ||
| 284 | + OP_LOGE(context->GetNodeName(), "check attr failed."), return ge::GRAPH_FAILED); | ||
| 285 | + | ||
| 286 | + MapIndexTilingData tilingData; | ||
| 287 | + OP_CHECK_IF(SetTilingData(context, tilingParam, tilingData) != ge::GRAPH_SUCCESS, | ||
| 288 | + OP_LOGE(context->GetNodeName(), "SetContext fail."), | ||
| 289 | + return ge::GRAPH_FAILED); | ||
| 290 | + | ||
| 291 | + PrintTilingData(context, tilingData); | ||
| 292 | + return ge::GRAPH_SUCCESS; | ||
| 293 | +} | ||
| 294 | + | ||
| 295 | +ge::graphStatus TilingPrepare4MapIndex(gert::TilingParseContext *context) | ||
| 296 | +{ | ||
| 297 | + OP_LOGD(context->GetNodeName(), "TilingPrepare4MapIndex entering."); | ||
| 298 | + return ge::GRAPH_SUCCESS; | ||
| 299 | +} | ||
| 300 | + | ||
| 301 | +IMPL_OP_OPTILING(MapIndex) | ||
| 302 | + .Tiling(Tiling4MapIndex) | ||
| 303 | + .TilingParse<MapIndexCompileInfo>(TilingPrepare4MapIndex); | ||
| 304 | +} | ||
| @@ -0,0 +1,64 @@ | |||
| 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 | +/* ! | ||
| 13 | + * \file map_index_tiling_arch35.h | ||
| 14 | + * \brief | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +namespace optiling { | ||
| 22 | + | ||
| 23 | +BEGIN_TILING_DATA_DEF(MapIndexTilingData) | ||
| 24 | + TILING_DATA_FIELD_DEF(int64_t, totalCoreNum); | ||
| 25 | + TILING_DATA_FIELD_DEF(int64_t, usedCoreNum); // 实际使用的核数 | ||
| 26 | + TILING_DATA_FIELD_DEF(int64_t, normalCoreProcessNum); // 单核循环次数 | ||
| 27 | + TILING_DATA_FIELD_DEF(int64_t, tailCoreProcessNum); // 尾核循环次数 | ||
| 28 | + TILING_DATA_FIELD_DEF(int64_t, Dim1Size); | ||
| 29 | + TILING_DATA_FIELD_DEF(int64_t, Dim1SizeAlign); | ||
| 30 | + TILING_DATA_FIELD_DEF(int64_t, CopyInDim0); // 一次最多搬几行 | ||
| 31 | + TILING_DATA_FIELD_DEF(int64_t, CopyInDim0Times); // 需要搬运几次 | ||
| 32 | + TILING_DATA_FIELD_DEF(int64_t, tailCopyInDim0Times); // 尾块需要搬运几次 | ||
| 33 | + TILING_DATA_FIELD_DEF(int64_t, doubleBuffNum); | ||
| 34 | +END_TILING_DATA_DEF; | ||
| 35 | + | ||
| 36 | +REGISTER_TILING_DATA_CLASS(MapIndex, MapIndexTilingData) | ||
| 37 | + | ||
| 38 | +struct MapIndexCompileInfo | ||
| 39 | +{ | ||
| 40 | + int64_t coreNum = 0; | ||
| 41 | + int64_t ubSize = 0; | ||
| 42 | +}; | ||
| 43 | + | ||
| 44 | +struct MapIndexTilingParam | ||
| 45 | +{ | ||
| 46 | + int64_t totalCoreNum{ 0 }; | ||
| 47 | + int64_t ubSize { 0 }; | ||
| 48 | + uint32_t vfLen { 0 }; | ||
| 49 | + uint32_t workspaceSize { 0 }; | ||
| 50 | + int64_t usedCoreNum { 0 }; | ||
| 51 | + int64_t normalCoreProcessNum {0}; | ||
| 52 | + int64_t tailCoreProcessNum {0}; | ||
| 53 | + int64_t Dim0Size {0}; | ||
| 54 | + int64_t Dim1Size {0}; | ||
| 55 | + int64_t Dim1SizeAlign {0}; | ||
| 56 | + int64_t CopyInDim0 {1}; | ||
| 57 | + int64_t CopyInDim0Times {1}; | ||
| 58 | + int64_t tailCopyInDim0Times {1}; | ||
| 59 | + int64_t doubleBuffNum {0}; | ||
| 60 | + bool hasLevelIndex = true; | ||
| 61 | +}; | ||
| 62 | + | ||
| 63 | +} | ||
| 64 | + | ||
| @@ -0,0 +1,39 @@ | |||
| 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 map_index_apt.cpp | ||
| 13 | + * \brief kernel file of map_index | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | +using namespace MapIndexOp; | ||
| 20 | + | ||
| 21 | +extern "C" __global__ __aicore__ void map_index( | ||
| 22 | + GM_ADDR x, GM_ADDR data_seq, GM_ADDR level_index, GM_ADDR y, GM_ADDR workspace, GM_ADDR tiling) { | ||
| 23 | + if (workspace == nullptr) { | ||
| 24 | + return; | ||
| 25 | + } | ||
| 26 | + SetSysWorkspace(workspace); | ||
| 27 | + GM_ADDR userWs = AscendC::GetUserWorkspace(workspace); | ||
| 28 | + if (userWs == nullptr) { | ||
| 29 | + return; | ||
| 30 | + } | ||
| 31 | + GET_TILING_DATA(tilingData, tiling); | ||
| 32 | + KERNEL_TASK_TYPE_DEFAULT(KERNEL_TYPE_MIX_AIV_1_0); | ||
| 33 | + TPipe pipe; | ||
| 34 | + if (TILING_KEY_IS(1)) { | ||
| 35 | + MapIndex op; | ||
| 36 | + op.Init(x, data_seq, y, userWs, tilingData, &pipe); | ||
| 37 | + op.Process(); | ||
| 38 | + } | ||
| 39 | +} | ||
| @@ -0,0 +1,18 @@ | |||
| 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 | +message(STATUS "=== Debug: start ops.index.map_index.tests.CMakeLists.txt ") | ||
| 12 | +file(GLOB CURRENT_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) | ||
| 13 | +message(STATUS "=== Debug: CURRENT_DIRS =${CURRENT_DIRS} ") | ||
| 14 | +foreach(SUB_DIR ${CURRENT_DIRS}) | ||
| 15 | + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUB_DIR}/CMakeLists.txt") | ||
| 16 | + add_subdirectory(${SUB_DIR}) | ||
| 17 | + endif() | ||
| 18 | +endforeach() | ||
| @@ -0,0 +1,17 @@ | |||
| 1 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 2 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | +# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | +# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 10 | + | ||
| 11 | +file(GLOB CURRENT_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) | ||
| 12 | +message(STATUS "=== Debug: CURRENT_DIRS =${CURRENT_DIRS} ") | ||
| 13 | +foreach(SUB_DIR ${CURRENT_DIRS}) | ||
| 14 | + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUB_DIR}/CMakeLists.txt") | ||
| 15 | + add_subdirectory(${SUB_DIR}) | ||
| 16 | + endif() | ||
| 17 | +endforeach() | ||
| @@ -0,0 +1,15 @@ | |||
| 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(GLOB CURRENT_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) | ||
| 12 | +if(UT_TEST_ALL OR OP_HOST_UT) | ||
| 13 | + add_modules_ut_sources(HOSTNAME ${OP_TILING_MODULE_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
| 14 | + add_modules_ut_sources(HOSTNAME ${OP_INFERSHAPE_MODULE_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
| 15 | +endif() | ||
| @@ -0,0 +1,765 @@ | |||
| 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 test_map_index_tiling.cpp | ||
| 13 | + * \brief | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + using namespace std; | ||
| 32 | + | ||
| 33 | +class MapIndexTiling : public testing::Test | ||
| 34 | +{ | ||
| 35 | +protected: | ||
| 36 | + static void SetUpTestCase() | ||
| 37 | + { | ||
| 38 | + std::cout << "MapIndexTiling SetUp" << std::endl; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + static void TearDownTestCase() | ||
| 42 | + { | ||
| 43 | + std::cout << "MapIndexTiling TearDown" << std::endl; | ||
| 44 | + } | ||
| 45 | +}; | ||
| 46 | + | ||
| 47 | +TEST_F(MapIndexTiling, test_tiling_pass_01) { | ||
| 48 | + std::string opType("MapIndex"); | ||
| 49 | + ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str()), nullptr); | ||
| 50 | + auto tilingFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling; | ||
| 51 | + auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | ||
| 52 | + | ||
| 53 | + string compileInfoString = R"({ | ||
| 54 | + "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", | ||
| 55 | + "Intrinsic_fix_pipe_l0c2out": false, | ||
| 56 | + "Intrinsic_data_move_l12ub": true, | ||
| 57 | + "Intrinsic_data_move_l0c2ub": true, | ||
| 58 | + "Intrinsic_data_move_out2l1_nd2nz": false, | ||
| 59 | + "UB_SIZE": 253952, "L2_SIZE": 33554432, "L1_SIZE": 524288, | ||
| 60 | + "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072, | ||
| 61 | + "CORE_NUM": 64} | ||
| 62 | + })"; | ||
| 63 | + map<string, string> socInfos; | ||
| 64 | + map<string, string> aicoreSpec; | ||
| 65 | + map<string, string> intrinsics; | ||
| 66 | + GetPlatFormInfos(compileInfoString.c_str(), socInfos, aicoreSpec, intrinsics); | ||
| 67 | + | ||
| 68 | + // platform info | ||
| 69 | + fe::PlatFormInfos platformInfo; | ||
| 70 | + platformInfo.Init(); | ||
| 71 | + // compile info | ||
| 72 | + optiling::MapIndexCompileInfo compileInfo; | ||
| 73 | + compileInfo.coreNum = 64; | ||
| 74 | + compileInfo.ubSize = 253952; | ||
| 75 | + | ||
| 76 | + // tilingFunc simulate | ||
| 77 | + auto param = gert::TilingData::CreateCap(4096); | ||
| 78 | + ASSERT_NE(param, nullptr); | ||
| 79 | + auto workspaceSizeHoler = gert::ContinuousVector::Create<size_t>(4096); | ||
| 80 | + auto wsSize = reinterpret_cast<gert::ContinuousVector*>(workspaceSizeHoler.get()); | ||
| 81 | + gert::StorageShape xShape = {{64}, {64}}; | ||
| 82 | + gert::StorageShape dataSeqShape = {{640}, {640}}; | ||
| 83 | + gert::StorageShape levelIndexShape = {{10}, {10}}; | ||
| 84 | + gert::StorageShape yShape = {{1}, {1}}; | ||
| 85 | + auto holder = gert::TilingContextFaker() | ||
| 86 | + .NodeIoNum(3, 1) | ||
| 87 | + .IrInstanceNum({1, 1, 1}) | ||
| 88 | + .InputShapes({&xShape, &dataSeqShape, &levelIndexShape}) | ||
| 89 | + .OutputShapes({&yShape}) | ||
| 90 | + .CompileInfo(&compileInfo) | ||
| 91 | + .PlatformInfo(reinterpret_cast<char*>(&platformInfo)) | ||
| 92 | + .NodeInputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 93 | + .NodeInputTd(1, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 94 | + .NodeInputTd(2, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 95 | + .NodeOutputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 96 | + .NodeAttrs({{"transpose", Ops::NN::AnyValue::CreateFrom<bool>(false)}}) | ||
| 97 | + .TilingData(param.get()) | ||
| 98 | + .Workspace(wsSize) | ||
| 99 | + .Build(); | ||
| 100 | + gert::TilingContext* tilingContext = holder.GetContext<gert::TilingContext>(); | ||
| 101 | + ASSERT_NE(tilingContext->GetPlatformInfo(), nullptr); | ||
| 102 | + | ||
| 103 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", socInfos); | ||
| 104 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | ||
| 105 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | ||
| 106 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | ||
| 107 | + | ||
| 108 | + // workspaces nullptr return failed | ||
| 109 | + std::cout << "test>> holder.GetContext end" << std::endl; | ||
| 110 | + | ||
| 111 | + if (tilingFunc == nullptr) { | ||
| 112 | + std::cout << "test>> tilingFunc is invalid" << std::endl; | ||
| 113 | + } else { | ||
| 114 | + std::cout << "test>> tilingFunc is valid" << std::endl; | ||
| 115 | + EXPECT_EQ(tilingFunc(tilingContext), ge::GRAPH_SUCCESS); | ||
| 116 | + } | ||
| 117 | +} | ||
| 118 | + | ||
| 119 | +TEST_F(MapIndexTiling, test_tiling_dtype_dataSeq_dtype_fail_02) { | ||
| 120 | + std::string opType("MapIndex"); | ||
| 121 | + ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str()), nullptr); | ||
| 122 | + auto tilingFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling; | ||
| 123 | + auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | ||
| 124 | + | ||
| 125 | + string compileInfoString = R"({ | ||
| 126 | + "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", | ||
| 127 | + "Intrinsic_fix_pipe_l0c2out": false, | ||
| 128 | + "Intrinsic_data_move_l12ub": true, | ||
| 129 | + "Intrinsic_data_move_l0c2ub": true, | ||
| 130 | + "Intrinsic_data_move_out2l1_nd2nz": false, | ||
| 131 | + "UB_SIZE": 253952, "L2_SIZE": 33554432, "L1_SIZE": 524288, | ||
| 132 | + "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072, | ||
| 133 | + "CORE_NUM": 64} | ||
| 134 | + })"; | ||
| 135 | + map<string, string> socInfos; | ||
| 136 | + map<string, string> aicoreSpec; | ||
| 137 | + map<string, string> intrinsics; | ||
| 138 | + GetPlatFormInfos(compileInfoString.c_str(), socInfos, aicoreSpec, intrinsics); | ||
| 139 | + | ||
| 140 | + // platform info | ||
| 141 | + fe::PlatFormInfos platformInfo; | ||
| 142 | + platformInfo.Init(); | ||
| 143 | + // compile info | ||
| 144 | + optiling::MapIndexCompileInfo compileInfo; | ||
| 145 | + compileInfo.coreNum = 64; | ||
| 146 | + compileInfo.ubSize = 253952; | ||
| 147 | + | ||
| 148 | + // tilingFunc simulate | ||
| 149 | + auto param = gert::TilingData::CreateCap(4096); | ||
| 150 | + ASSERT_NE(param, nullptr); | ||
| 151 | + auto workspaceSizeHoler = gert::ContinuousVector::Create<size_t>(4096); | ||
| 152 | + auto wsSize = reinterpret_cast<gert::ContinuousVector*>(workspaceSizeHoler.get()); | ||
| 153 | + gert::StorageShape xShape = {{64}, {64}}; | ||
| 154 | + gert::StorageShape dataSeqShape = {{640}, {640}}; | ||
| 155 | + gert::StorageShape levelIndexShape = {{10}, {10}}; | ||
| 156 | + gert::StorageShape yShape = {{1}, {1}}; | ||
| 157 | + auto holder = gert::TilingContextFaker() | ||
| 158 | + .NodeIoNum(3, 1) | ||
| 159 | + .IrInstanceNum({1, 1, 1}) | ||
| 160 | + .InputShapes({&xShape, &dataSeqShape, &levelIndexShape}) | ||
| 161 | + .OutputShapes({&yShape}) | ||
| 162 | + .CompileInfo(&compileInfo) | ||
| 163 | + .PlatformInfo(reinterpret_cast<char*>(&platformInfo)) | ||
| 164 | + .NodeInputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 165 | + .NodeInputTd(1, ge::DT_INT64, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 166 | + .NodeInputTd(2, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 167 | + .NodeOutputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 168 | + .NodeAttrs({{"transpose", Ops::NN::AnyValue::CreateFrom<bool>(false)}}) | ||
| 169 | + .TilingData(param.get()) | ||
| 170 | + .Workspace(wsSize) | ||
| 171 | + .Build(); | ||
| 172 | + gert::TilingContext* tilingContext = holder.GetContext<gert::TilingContext>(); | ||
| 173 | + ASSERT_NE(tilingContext->GetPlatformInfo(), nullptr); | ||
| 174 | + | ||
| 175 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", socInfos); | ||
| 176 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | ||
| 177 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | ||
| 178 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | ||
| 179 | + | ||
| 180 | + // workspaces nullptr return failed | ||
| 181 | + std::cout << "test>> holder.GetContext end" << std::endl; | ||
| 182 | + | ||
| 183 | + if (tilingFunc == nullptr) { | ||
| 184 | + std::cout << "test>> tilingFunc is invalid" << std::endl; | ||
| 185 | + } else { | ||
| 186 | + std::cout << "test>> tilingFunc is valid" << std::endl; | ||
| 187 | + EXPECT_EQ(tilingFunc(tilingContext), ge::GRAPH_FAILED); | ||
| 188 | + } | ||
| 189 | +} | ||
| 190 | + | ||
| 191 | +TEST_F(MapIndexTiling, test_tiling_dtype_y_dtype_fail_03) { | ||
| 192 | + std::string opType("MapIndex"); | ||
| 193 | + ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str()), nullptr); | ||
| 194 | + auto tilingFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling; | ||
| 195 | + auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | ||
| 196 | + | ||
| 197 | + string compileInfoString = R"({ | ||
| 198 | + "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", | ||
| 199 | + "Intrinsic_fix_pipe_l0c2out": false, | ||
| 200 | + "Intrinsic_data_move_l12ub": true, | ||
| 201 | + "Intrinsic_data_move_l0c2ub": true, | ||
| 202 | + "Intrinsic_data_move_out2l1_nd2nz": false, | ||
| 203 | + "UB_SIZE": 253952, "L2_SIZE": 33554432, "L1_SIZE": 524288, | ||
| 204 | + "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072, | ||
| 205 | + "CORE_NUM": 64} | ||
| 206 | + })"; | ||
| 207 | + map<string, string> socInfos; | ||
| 208 | + map<string, string> aicoreSpec; | ||
| 209 | + map<string, string> intrinsics; | ||
| 210 | + GetPlatFormInfos(compileInfoString.c_str(), socInfos, aicoreSpec, intrinsics); | ||
| 211 | + | ||
| 212 | + // platform info | ||
| 213 | + fe::PlatFormInfos platformInfo; | ||
| 214 | + platformInfo.Init(); | ||
| 215 | + // compile info | ||
| 216 | + optiling::MapIndexCompileInfo compileInfo; | ||
| 217 | + compileInfo.coreNum = 64; | ||
| 218 | + compileInfo.ubSize = 253952; | ||
| 219 | + | ||
| 220 | + // tilingFunc simulate | ||
| 221 | + auto param = gert::TilingData::CreateCap(4096); | ||
| 222 | + ASSERT_NE(param, nullptr); | ||
| 223 | + auto workspaceSizeHoler = gert::ContinuousVector::Create<size_t>(4096); | ||
| 224 | + auto wsSize = reinterpret_cast<gert::ContinuousVector*>(workspaceSizeHoler.get()); | ||
| 225 | + gert::StorageShape xShape = {{64}, {64}}; | ||
| 226 | + gert::StorageShape dataSeqShape = {{640}, {640}}; | ||
| 227 | + gert::StorageShape levelIndexShape = {{10}, {10}}; | ||
| 228 | + gert::StorageShape yShape = {{1}, {1}}; | ||
| 229 | + auto holder = gert::TilingContextFaker() | ||
| 230 | + .NodeIoNum(3, 1) | ||
| 231 | + .IrInstanceNum({1, 1, 1}) | ||
| 232 | + .InputShapes({&xShape, &dataSeqShape, &levelIndexShape}) | ||
| 233 | + .OutputShapes({&yShape}) | ||
| 234 | + .CompileInfo(&compileInfo) | ||
| 235 | + .PlatformInfo(reinterpret_cast<char*>(&platformInfo)) | ||
| 236 | + .NodeInputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 237 | + .NodeInputTd(1, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 238 | + .NodeInputTd(2, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 239 | + .NodeOutputTd(0, ge::DT_INT64, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 240 | + .NodeAttrs({{"transpose", Ops::NN::AnyValue::CreateFrom<bool>(false)}}) | ||
| 241 | + .TilingData(param.get()) | ||
| 242 | + .Workspace(wsSize) | ||
| 243 | + .Build(); | ||
| 244 | + gert::TilingContext* tilingContext = holder.GetContext<gert::TilingContext>(); | ||
| 245 | + ASSERT_NE(tilingContext->GetPlatformInfo(), nullptr); | ||
| 246 | + | ||
| 247 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", socInfos); | ||
| 248 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | ||
| 249 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | ||
| 250 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | ||
| 251 | + | ||
| 252 | + // workspaces nullptr return failed | ||
| 253 | + std::cout << "test>> holder.GetContext end" << std::endl; | ||
| 254 | + | ||
| 255 | + if (tilingFunc == nullptr) { | ||
| 256 | + std::cout << "test>> tilingFunc is invalid" << std::endl; | ||
| 257 | + } else { | ||
| 258 | + std::cout << "test>> tilingFunc is valid" << std::endl; | ||
| 259 | + EXPECT_EQ(tilingFunc(tilingContext), ge::GRAPH_FAILED); | ||
| 260 | + } | ||
| 261 | +} | ||
| 262 | + | ||
| 263 | +TEST_F(MapIndexTiling, test_tiling_dtype_dataSeq_shape_fail_03) { | ||
| 264 | + std::string opType("MapIndex"); | ||
| 265 | + ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str()), nullptr); | ||
| 266 | + auto tilingFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling; | ||
| 267 | + auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | ||
| 268 | + | ||
| 269 | + string compileInfoString = R"({ | ||
| 270 | + "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", | ||
| 271 | + "Intrinsic_fix_pipe_l0c2out": false, | ||
| 272 | + "Intrinsic_data_move_l12ub": true, | ||
| 273 | + "Intrinsic_data_move_l0c2ub": true, | ||
| 274 | + "Intrinsic_data_move_out2l1_nd2nz": false, | ||
| 275 | + "UB_SIZE": 253952, "L2_SIZE": 33554432, "L1_SIZE": 524288, | ||
| 276 | + "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072, | ||
| 277 | + "CORE_NUM": 64} | ||
| 278 | + })"; | ||
| 279 | + map<string, string> socInfos; | ||
| 280 | + map<string, string> aicoreSpec; | ||
| 281 | + map<string, string> intrinsics; | ||
| 282 | + GetPlatFormInfos(compileInfoString.c_str(), socInfos, aicoreSpec, intrinsics); | ||
| 283 | + | ||
| 284 | + // platform info | ||
| 285 | + fe::PlatFormInfos platformInfo; | ||
| 286 | + platformInfo.Init(); | ||
| 287 | + // compile info | ||
| 288 | + optiling::MapIndexCompileInfo compileInfo; | ||
| 289 | + compileInfo.coreNum = 64; | ||
| 290 | + compileInfo.ubSize = 253952; | ||
| 291 | + | ||
| 292 | + // tilingFunc simulate | ||
| 293 | + auto param = gert::TilingData::CreateCap(4096); | ||
| 294 | + ASSERT_NE(param, nullptr); | ||
| 295 | + auto workspaceSizeHoler = gert::ContinuousVector::Create<size_t>(4096); | ||
| 296 | + auto wsSize = reinterpret_cast<gert::ContinuousVector*>(workspaceSizeHoler.get()); | ||
| 297 | + gert::StorageShape xShape = {{64}, {64}}; | ||
| 298 | + gert::StorageShape dataSeqShape = {{641}, {641}}; | ||
| 299 | + gert::StorageShape levelIndexShape = {{10}, {10}}; | ||
| 300 | + gert::StorageShape yShape = {{1}, {1}}; | ||
| 301 | + auto holder = gert::TilingContextFaker() | ||
| 302 | + .NodeIoNum(3, 1) | ||
| 303 | + .IrInstanceNum({1, 1, 1}) | ||
| 304 | + .InputShapes({&xShape, &dataSeqShape, &levelIndexShape}) | ||
| 305 | + .OutputShapes({&yShape}) | ||
| 306 | + .CompileInfo(&compileInfo) | ||
| 307 | + .PlatformInfo(reinterpret_cast<char*>(&platformInfo)) | ||
| 308 | + .NodeInputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 309 | + .NodeInputTd(1, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 310 | + .NodeInputTd(2, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 311 | + .NodeOutputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 312 | + .NodeAttrs({{"transpose", Ops::NN::AnyValue::CreateFrom<bool>(false)}}) | ||
| 313 | + .TilingData(param.get()) | ||
| 314 | + .Workspace(wsSize) | ||
| 315 | + .Build(); | ||
| 316 | + gert::TilingContext* tilingContext = holder.GetContext<gert::TilingContext>(); | ||
| 317 | + ASSERT_NE(tilingContext->GetPlatformInfo(), nullptr); | ||
| 318 | + | ||
| 319 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", socInfos); | ||
| 320 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | ||
| 321 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | ||
| 322 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | ||
| 323 | + | ||
| 324 | + // workspaces nullptr return failed | ||
| 325 | + std::cout << "test>> holder.GetContext end" << std::endl; | ||
| 326 | + | ||
| 327 | + if (tilingFunc == nullptr) { | ||
| 328 | + std::cout << "test>> tilingFunc is invalid" << std::endl; | ||
| 329 | + } else { | ||
| 330 | + std::cout << "test>> tilingFunc is valid" << std::endl; | ||
| 331 | + EXPECT_EQ(tilingFunc(tilingContext), ge::GRAPH_FAILED); | ||
| 332 | + } | ||
| 333 | +} | ||
| 334 | + | ||
| 335 | +TEST_F(MapIndexTiling, test_tiling_dtype_y_shape_fail_04) { | ||
| 336 | + std::string opType("MapIndex"); | ||
| 337 | + ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str()), nullptr); | ||
| 338 | + auto tilingFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling; | ||
| 339 | + auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | ||
| 340 | + | ||
| 341 | + string compileInfoString = R"({ | ||
| 342 | + "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", | ||
| 343 | + "Intrinsic_fix_pipe_l0c2out": false, | ||
| 344 | + "Intrinsic_data_move_l12ub": true, | ||
| 345 | + "Intrinsic_data_move_l0c2ub": true, | ||
| 346 | + "Intrinsic_data_move_out2l1_nd2nz": false, | ||
| 347 | + "UB_SIZE": 253952, "L2_SIZE": 33554432, "L1_SIZE": 524288, | ||
| 348 | + "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072, | ||
| 349 | + "CORE_NUM": 64} | ||
| 350 | + })"; | ||
| 351 | + map<string, string> socInfos; | ||
| 352 | + map<string, string> aicoreSpec; | ||
| 353 | + map<string, string> intrinsics; | ||
| 354 | + GetPlatFormInfos(compileInfoString.c_str(), socInfos, aicoreSpec, intrinsics); | ||
| 355 | + | ||
| 356 | + // platform info | ||
| 357 | + fe::PlatFormInfos platformInfo; | ||
| 358 | + platformInfo.Init(); | ||
| 359 | + // compile info | ||
| 360 | + optiling::MapIndexCompileInfo compileInfo; | ||
| 361 | + compileInfo.coreNum = 64; | ||
| 362 | + compileInfo.ubSize = 253952; | ||
| 363 | + | ||
| 364 | + // tilingFunc simulate | ||
| 365 | + auto param = gert::TilingData::CreateCap(4096); | ||
| 366 | + ASSERT_NE(param, nullptr); | ||
| 367 | + auto workspaceSizeHoler = gert::ContinuousVector::Create<size_t>(4096); | ||
| 368 | + auto wsSize = reinterpret_cast<gert::ContinuousVector*>(workspaceSizeHoler.get()); | ||
| 369 | + gert::StorageShape xShape = {{64}, {64}}; | ||
| 370 | + gert::StorageShape dataSeqShape = {{640}, {640}}; | ||
| 371 | + gert::StorageShape levelIndexShape = {{10}, {10}}; | ||
| 372 | + gert::StorageShape yShape = {{8}, {8}}; | ||
| 373 | + auto holder = gert::TilingContextFaker() | ||
| 374 | + .NodeIoNum(3, 1) | ||
| 375 | + .IrInstanceNum({1, 1, 1}) | ||
| 376 | + .InputShapes({&xShape, &dataSeqShape, &levelIndexShape}) | ||
| 377 | + .OutputShapes({&yShape}) | ||
| 378 | + .CompileInfo(&compileInfo) | ||
| 379 | + .PlatformInfo(reinterpret_cast<char*>(&platformInfo)) | ||
| 380 | + .NodeInputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 381 | + .NodeInputTd(1, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 382 | + .NodeInputTd(2, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 383 | + .NodeOutputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 384 | + .NodeAttrs({{"transpose", Ops::NN::AnyValue::CreateFrom<bool>(false)}}) | ||
| 385 | + .TilingData(param.get()) | ||
| 386 | + .Workspace(wsSize) | ||
| 387 | + .Build(); | ||
| 388 | + gert::TilingContext* tilingContext = holder.GetContext<gert::TilingContext>(); | ||
| 389 | + ASSERT_NE(tilingContext->GetPlatformInfo(), nullptr); | ||
| 390 | + | ||
| 391 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", socInfos); | ||
| 392 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | ||
| 393 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | ||
| 394 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | ||
| 395 | + | ||
| 396 | + // workspaces nullptr return failed | ||
| 397 | + std::cout << "test>> holder.GetContext end" << std::endl; | ||
| 398 | + | ||
| 399 | + if (tilingFunc == nullptr) { | ||
| 400 | + std::cout << "test>> tilingFunc is invalid" << std::endl; | ||
| 401 | + } else { | ||
| 402 | + std::cout << "test>> tilingFunc is valid" << std::endl; | ||
| 403 | + EXPECT_EQ(tilingFunc(tilingContext), ge::GRAPH_FAILED); | ||
| 404 | + } | ||
| 405 | +} | ||
| 406 | + | ||
| 407 | +TEST_F(MapIndexTiling, test_tiling_dtype_x_shape_fail_05) { | ||
| 408 | + std::string opType("MapIndex"); | ||
| 409 | + ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str()), nullptr); | ||
| 410 | + auto tilingFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling; | ||
| 411 | + auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | ||
| 412 | + | ||
| 413 | + string compileInfoString = R"({ | ||
| 414 | + "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", | ||
| 415 | + "Intrinsic_fix_pipe_l0c2out": false, | ||
| 416 | + "Intrinsic_data_move_l12ub": true, | ||
| 417 | + "Intrinsic_data_move_l0c2ub": true, | ||
| 418 | + "Intrinsic_data_move_out2l1_nd2nz": false, | ||
| 419 | + "UB_SIZE": 253952, "L2_SIZE": 33554432, "L1_SIZE": 524288, | ||
| 420 | + "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072, | ||
| 421 | + "CORE_NUM": 64} | ||
| 422 | + })"; | ||
| 423 | + map<string, string> socInfos; | ||
| 424 | + map<string, string> aicoreSpec; | ||
| 425 | + map<string, string> intrinsics; | ||
| 426 | + GetPlatFormInfos(compileInfoString.c_str(), socInfos, aicoreSpec, intrinsics); | ||
| 427 | + | ||
| 428 | + // platform info | ||
| 429 | + fe::PlatFormInfos platformInfo; | ||
| 430 | + platformInfo.Init(); | ||
| 431 | + // compile info | ||
| 432 | + optiling::MapIndexCompileInfo compileInfo; | ||
| 433 | + compileInfo.coreNum = 64; | ||
| 434 | + compileInfo.ubSize = 253952; | ||
| 435 | + | ||
| 436 | + // tilingFunc simulate | ||
| 437 | + auto param = gert::TilingData::CreateCap(4096); | ||
| 438 | + ASSERT_NE(param, nullptr); | ||
| 439 | + auto workspaceSizeHoler = gert::ContinuousVector::Create<size_t>(4096); | ||
| 440 | + auto wsSize = reinterpret_cast<gert::ContinuousVector*>(workspaceSizeHoler.get()); | ||
| 441 | + gert::StorageShape xShape = {{64,1}, {64,1}}; | ||
| 442 | + gert::StorageShape dataSeqShape = {{640}, {640}}; | ||
| 443 | + gert::StorageShape levelIndexShape = {{10}, {10}}; | ||
| 444 | + gert::StorageShape yShape = {{1}, {1}}; | ||
| 445 | + auto holder = gert::TilingContextFaker() | ||
| 446 | + .NodeIoNum(3, 1) | ||
| 447 | + .IrInstanceNum({1, 1, 1}) | ||
| 448 | + .InputShapes({&xShape, &dataSeqShape, &levelIndexShape}) | ||
| 449 | + .OutputShapes({&yShape}) | ||
| 450 | + .CompileInfo(&compileInfo) | ||
| 451 | + .PlatformInfo(reinterpret_cast<char*>(&platformInfo)) | ||
| 452 | + .NodeInputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 453 | + .NodeInputTd(1, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 454 | + .NodeInputTd(2, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 455 | + .NodeOutputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 456 | + .NodeAttrs({{"transpose", Ops::NN::AnyValue::CreateFrom<bool>(false)}}) | ||
| 457 | + .TilingData(param.get()) | ||
| 458 | + .Workspace(wsSize) | ||
| 459 | + .Build(); | ||
| 460 | + gert::TilingContext* tilingContext = holder.GetContext<gert::TilingContext>(); | ||
| 461 | + ASSERT_NE(tilingContext->GetPlatformInfo(), nullptr); | ||
| 462 | + | ||
| 463 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", socInfos); | ||
| 464 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | ||
| 465 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | ||
| 466 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | ||
| 467 | + | ||
| 468 | + // workspaces nullptr return failed | ||
| 469 | + std::cout << "test>> holder.GetContext end" << std::endl; | ||
| 470 | + | ||
| 471 | + if (tilingFunc == nullptr) { | ||
| 472 | + std::cout << "test>> tilingFunc is invalid" << std::endl; | ||
| 473 | + } else { | ||
| 474 | + std::cout << "test>> tilingFunc is valid" << std::endl; | ||
| 475 | + EXPECT_EQ(tilingFunc(tilingContext), ge::GRAPH_FAILED); | ||
| 476 | + } | ||
| 477 | +} | ||
| 478 | + | ||
| 479 | +TEST_F(MapIndexTiling, test_tiling_dtype_x_shape_fail_06) { | ||
| 480 | + std::string opType("MapIndex"); | ||
| 481 | + ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str()), nullptr); | ||
| 482 | + auto tilingFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling; | ||
| 483 | + auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | ||
| 484 | + | ||
| 485 | + string compileInfoString = R"({ | ||
| 486 | + "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", | ||
| 487 | + "Intrinsic_fix_pipe_l0c2out": false, | ||
| 488 | + "Intrinsic_data_move_l12ub": true, | ||
| 489 | + "Intrinsic_data_move_l0c2ub": true, | ||
| 490 | + "Intrinsic_data_move_out2l1_nd2nz": false, | ||
| 491 | + "UB_SIZE": 253952, "L2_SIZE": 33554432, "L1_SIZE": 524288, | ||
| 492 | + "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072, | ||
| 493 | + "CORE_NUM": 64} | ||
| 494 | + })"; | ||
| 495 | + map<string, string> socInfos; | ||
| 496 | + map<string, string> aicoreSpec; | ||
| 497 | + map<string, string> intrinsics; | ||
| 498 | + GetPlatFormInfos(compileInfoString.c_str(), socInfos, aicoreSpec, intrinsics); | ||
| 499 | + | ||
| 500 | + // platform info | ||
| 501 | + fe::PlatFormInfos platformInfo; | ||
| 502 | + platformInfo.Init(); | ||
| 503 | + // compile info | ||
| 504 | + optiling::MapIndexCompileInfo compileInfo; | ||
| 505 | + compileInfo.coreNum = 64; | ||
| 506 | + compileInfo.ubSize = 253952; | ||
| 507 | + | ||
| 508 | + // tilingFunc simulate | ||
| 509 | + auto param = gert::TilingData::CreateCap(4096); | ||
| 510 | + ASSERT_NE(param, nullptr); | ||
| 511 | + auto workspaceSizeHoler = gert::ContinuousVector::Create<size_t>(4096); | ||
| 512 | + auto wsSize = reinterpret_cast<gert::ContinuousVector*>(workspaceSizeHoler.get()); | ||
| 513 | + gert::StorageShape xShape = {{25000}, {25000}}; | ||
| 514 | + gert::StorageShape dataSeqShape = {{640}, {640}}; | ||
| 515 | + gert::StorageShape levelIndexShape = {{10}, {10}}; | ||
| 516 | + gert::StorageShape yShape = {{1}, {1}}; | ||
| 517 | + auto holder = gert::TilingContextFaker() | ||
| 518 | + .NodeIoNum(3, 1) | ||
| 519 | + .IrInstanceNum({1, 1, 1}) | ||
| 520 | + .InputShapes({&xShape, &dataSeqShape, &levelIndexShape}) | ||
| 521 | + .OutputShapes({&yShape}) | ||
| 522 | + .CompileInfo(&compileInfo) | ||
| 523 | + .PlatformInfo(reinterpret_cast<char*>(&platformInfo)) | ||
| 524 | + .NodeInputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 525 | + .NodeInputTd(1, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 526 | + .NodeInputTd(2, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 527 | + .NodeOutputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 528 | + .NodeAttrs({{"transpose", Ops::NN::AnyValue::CreateFrom<bool>(false)}}) | ||
| 529 | + .TilingData(param.get()) | ||
| 530 | + .Workspace(wsSize) | ||
| 531 | + .Build(); | ||
| 532 | + gert::TilingContext* tilingContext = holder.GetContext<gert::TilingContext>(); | ||
| 533 | + ASSERT_NE(tilingContext->GetPlatformInfo(), nullptr); | ||
| 534 | + | ||
| 535 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", socInfos); | ||
| 536 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | ||
| 537 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | ||
| 538 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | ||
| 539 | + | ||
| 540 | + // workspaces nullptr return failed | ||
| 541 | + std::cout << "test>> holder.GetContext end" << std::endl; | ||
| 542 | + | ||
| 543 | + if (tilingFunc == nullptr) { | ||
| 544 | + std::cout << "test>> tilingFunc is invalid" << std::endl; | ||
| 545 | + } else { | ||
| 546 | + std::cout << "test>> tilingFunc is valid" << std::endl; | ||
| 547 | + EXPECT_EQ(tilingFunc(tilingContext), ge::GRAPH_FAILED); | ||
| 548 | + } | ||
| 549 | +} | ||
| 550 | + | ||
| 551 | +TEST_F(MapIndexTiling, test_tiling_dtype_dataSeq_shape_fail_07) { | ||
| 552 | + std::string opType("MapIndex"); | ||
| 553 | + ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str()), nullptr); | ||
| 554 | + auto tilingFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling; | ||
| 555 | + auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | ||
| 556 | + | ||
| 557 | + string compileInfoString = R"({ | ||
| 558 | + "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", | ||
| 559 | + "Intrinsic_fix_pipe_l0c2out": false, | ||
| 560 | + "Intrinsic_data_move_l12ub": true, | ||
| 561 | + "Intrinsic_data_move_l0c2ub": true, | ||
| 562 | + "Intrinsic_data_move_out2l1_nd2nz": false, | ||
| 563 | + "UB_SIZE": 253952, "L2_SIZE": 33554432, "L1_SIZE": 524288, | ||
| 564 | + "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072, | ||
| 565 | + "CORE_NUM": 64} | ||
| 566 | + })"; | ||
| 567 | + map<string, string> socInfos; | ||
| 568 | + map<string, string> aicoreSpec; | ||
| 569 | + map<string, string> intrinsics; | ||
| 570 | + GetPlatFormInfos(compileInfoString.c_str(), socInfos, aicoreSpec, intrinsics); | ||
| 571 | + | ||
| 572 | + // platform info | ||
| 573 | + fe::PlatFormInfos platformInfo; | ||
| 574 | + platformInfo.Init(); | ||
| 575 | + // compile info | ||
| 576 | + optiling::MapIndexCompileInfo compileInfo; | ||
| 577 | + compileInfo.coreNum = 64; | ||
| 578 | + compileInfo.ubSize = 253952; | ||
| 579 | + | ||
| 580 | + // tilingFunc simulate | ||
| 581 | + auto param = gert::TilingData::CreateCap(4096); | ||
| 582 | + ASSERT_NE(param, nullptr); | ||
| 583 | + auto workspaceSizeHoler = gert::ContinuousVector::Create<size_t>(4096); | ||
| 584 | + auto wsSize = reinterpret_cast<gert::ContinuousVector*>(workspaceSizeHoler.get()); | ||
| 585 | + gert::StorageShape xShape = {{64}, {64}}; | ||
| 586 | + gert::StorageShape dataSeqShape = {{19200}, {19200}}; | ||
| 587 | + gert::StorageShape levelIndexShape = {{10}, {10}}; | ||
| 588 | + gert::StorageShape yShape = {{1}, {1}}; | ||
| 589 | + auto holder = gert::TilingContextFaker() | ||
| 590 | + .NodeIoNum(3, 1) | ||
| 591 | + .IrInstanceNum({1, 1, 1}) | ||
| 592 | + .InputShapes({&xShape, &dataSeqShape, &levelIndexShape}) | ||
| 593 | + .OutputShapes({&yShape}) | ||
| 594 | + .CompileInfo(&compileInfo) | ||
| 595 | + .PlatformInfo(reinterpret_cast<char*>(&platformInfo)) | ||
| 596 | + .NodeInputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 597 | + .NodeInputTd(1, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 598 | + .NodeInputTd(2, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 599 | + .NodeOutputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 600 | + .NodeAttrs({{"transpose", Ops::NN::AnyValue::CreateFrom<bool>(false)}}) | ||
| 601 | + .TilingData(param.get()) | ||
| 602 | + .Workspace(wsSize) | ||
| 603 | + .Build(); | ||
| 604 | + gert::TilingContext* tilingContext = holder.GetContext<gert::TilingContext>(); | ||
| 605 | + ASSERT_NE(tilingContext->GetPlatformInfo(), nullptr); | ||
| 606 | + | ||
| 607 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", socInfos); | ||
| 608 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | ||
| 609 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | ||
| 610 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | ||
| 611 | + | ||
| 612 | + // workspaces nullptr return failed | ||
| 613 | + std::cout << "test>> holder.GetContext end" << std::endl; | ||
| 614 | + | ||
| 615 | + if (tilingFunc == nullptr) { | ||
| 616 | + std::cout << "test>> tilingFunc is invalid" << std::endl; | ||
| 617 | + } else { | ||
| 618 | + std::cout << "test>> tilingFunc is valid" << std::endl; | ||
| 619 | + EXPECT_EQ(tilingFunc(tilingContext), ge::GRAPH_FAILED); | ||
| 620 | + } | ||
| 621 | +} | ||
| 622 | + | ||
| 623 | +TEST_F(MapIndexTiling, test_tiling_dtype_dataSeq_shape_fail_08) { | ||
| 624 | + std::string opType("MapIndex"); | ||
| 625 | + ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str()), nullptr); | ||
| 626 | + auto tilingFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling; | ||
| 627 | + auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | ||
| 628 | + | ||
| 629 | + string compileInfoString = R"({ | ||
| 630 | + "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", | ||
| 631 | + "Intrinsic_fix_pipe_l0c2out": false, | ||
| 632 | + "Intrinsic_data_move_l12ub": true, | ||
| 633 | + "Intrinsic_data_move_l0c2ub": true, | ||
| 634 | + "Intrinsic_data_move_out2l1_nd2nz": false, | ||
| 635 | + "UB_SIZE": 253952, "L2_SIZE": 33554432, "L1_SIZE": 524288, | ||
| 636 | + "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072, | ||
| 637 | + "CORE_NUM": 64} | ||
| 638 | + })"; | ||
| 639 | + map<string, string> socInfos; | ||
| 640 | + map<string, string> aicoreSpec; | ||
| 641 | + map<string, string> intrinsics; | ||
| 642 | + GetPlatFormInfos(compileInfoString.c_str(), socInfos, aicoreSpec, intrinsics); | ||
| 643 | + | ||
| 644 | + // platform info | ||
| 645 | + fe::PlatFormInfos platformInfo; | ||
| 646 | + platformInfo.Init(); | ||
| 647 | + // compile info | ||
| 648 | + optiling::MapIndexCompileInfo compileInfo; | ||
| 649 | + compileInfo.coreNum = 64; | ||
| 650 | + compileInfo.ubSize = 253952; | ||
| 651 | + | ||
| 652 | + // tilingFunc simulate | ||
| 653 | + auto param = gert::TilingData::CreateCap(4096); | ||
| 654 | + ASSERT_NE(param, nullptr); | ||
| 655 | + auto workspaceSizeHoler = gert::ContinuousVector::Create<size_t>(4096); | ||
| 656 | + auto wsSize = reinterpret_cast<gert::ContinuousVector*>(workspaceSizeHoler.get()); | ||
| 657 | + gert::StorageShape xShape = {{64}, {64}}; | ||
| 658 | + gert::StorageShape dataSeqShape = {{240, 64}, {240, 64}}; | ||
| 659 | + gert::StorageShape levelIndexShape = {{10}, {10}}; | ||
| 660 | + gert::StorageShape yShape = {{1}, {1}}; | ||
| 661 | + auto holder = gert::TilingContextFaker() | ||
| 662 | + .NodeIoNum(3, 1) | ||
| 663 | + .IrInstanceNum({1, 1, 1}) | ||
| 664 | + .InputShapes({&xShape, &dataSeqShape, &levelIndexShape}) | ||
| 665 | + .OutputShapes({&yShape}) | ||
| 666 | + .CompileInfo(&compileInfo) | ||
| 667 | + .PlatformInfo(reinterpret_cast<char*>(&platformInfo)) | ||
| 668 | + .NodeInputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 669 | + .NodeInputTd(1, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 670 | + .NodeInputTd(2, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 671 | + .NodeOutputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 672 | + .NodeAttrs({{"transpose", Ops::NN::AnyValue::CreateFrom<bool>(false)}}) | ||
| 673 | + .TilingData(param.get()) | ||
| 674 | + .Workspace(wsSize) | ||
| 675 | + .Build(); | ||
| 676 | + gert::TilingContext* tilingContext = holder.GetContext<gert::TilingContext>(); | ||
| 677 | + ASSERT_NE(tilingContext->GetPlatformInfo(), nullptr); | ||
| 678 | + | ||
| 679 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", socInfos); | ||
| 680 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | ||
| 681 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | ||
| 682 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | ||
| 683 | + | ||
| 684 | + // workspaces nullptr return failed | ||
| 685 | + std::cout << "test>> holder.GetContext end" << std::endl; | ||
| 686 | + | ||
| 687 | + if (tilingFunc == nullptr) { | ||
| 688 | + std::cout << "test>> tilingFunc is invalid" << std::endl; | ||
| 689 | + } else { | ||
| 690 | + std::cout << "test>> tilingFunc is valid" << std::endl; | ||
| 691 | + EXPECT_EQ(tilingFunc(tilingContext), ge::GRAPH_FAILED); | ||
| 692 | + } | ||
| 693 | +} | ||
| 694 | + | ||
| 695 | +TEST_F(MapIndexTiling, test_tiling_dtype_dataSeq_shape_fail_09) { | ||
| 696 | + std::string opType("MapIndex"); | ||
| 697 | + ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str()), nullptr); | ||
| 698 | + auto tilingFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling; | ||
| 699 | + auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | ||
| 700 | + | ||
| 701 | + string compileInfoString = R"({ | ||
| 702 | + "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", | ||
| 703 | + "Intrinsic_fix_pipe_l0c2out": false, | ||
| 704 | + "Intrinsic_data_move_l12ub": true, | ||
| 705 | + "Intrinsic_data_move_l0c2ub": true, | ||
| 706 | + "Intrinsic_data_move_out2l1_nd2nz": false, | ||
| 707 | + "UB_SIZE": 253952, "L2_SIZE": 33554432, "L1_SIZE": 524288, | ||
| 708 | + "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072, | ||
| 709 | + "CORE_NUM": 64} | ||
| 710 | + })"; | ||
| 711 | + map<string, string> socInfos; | ||
| 712 | + map<string, string> aicoreSpec; | ||
| 713 | + map<string, string> intrinsics; | ||
| 714 | + GetPlatFormInfos(compileInfoString.c_str(), socInfos, aicoreSpec, intrinsics); | ||
| 715 | + | ||
| 716 | + // platform info | ||
| 717 | + fe::PlatFormInfos platformInfo; | ||
| 718 | + platformInfo.Init(); | ||
| 719 | + // compile info | ||
| 720 | + optiling::MapIndexCompileInfo compileInfo; | ||
| 721 | + compileInfo.coreNum = 64; | ||
| 722 | + compileInfo.ubSize = 253952; | ||
| 723 | + | ||
| 724 | + // tilingFunc simulate | ||
| 725 | + auto param = gert::TilingData::CreateCap(4096); | ||
| 726 | + ASSERT_NE(param, nullptr); | ||
| 727 | + auto workspaceSizeHoler = gert::ContinuousVector::Create<size_t>(4096); | ||
| 728 | + auto wsSize = reinterpret_cast<gert::ContinuousVector*>(workspaceSizeHoler.get()); | ||
| 729 | + gert::StorageShape xShape = {{64}, {64}}; | ||
| 730 | + gert::StorageShape dataSeqShape = {{640}, {640}}; | ||
| 731 | + gert::StorageShape levelIndexShape = {{12}, {12}}; | ||
| 732 | + gert::StorageShape yShape = {{1}, {1}}; | ||
| 733 | + auto holder = gert::TilingContextFaker() | ||
| 734 | + .NodeIoNum(3, 1) | ||
| 735 | + .IrInstanceNum({1, 1, 1}) | ||
| 736 | + .InputShapes({&xShape, &dataSeqShape, &levelIndexShape}) | ||
| 737 | + .OutputShapes({&yShape}) | ||
| 738 | + .CompileInfo(&compileInfo) | ||
| 739 | + .PlatformInfo(reinterpret_cast<char*>(&platformInfo)) | ||
| 740 | + .NodeInputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 741 | + .NodeInputTd(1, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 742 | + .NodeInputTd(2, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 743 | + .NodeOutputTd(0, ge::DT_INT32, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 744 | + .NodeAttrs({{"transpose", Ops::NN::AnyValue::CreateFrom<bool>(false)}}) | ||
| 745 | + .TilingData(param.get()) | ||
| 746 | + .Workspace(wsSize) | ||
| 747 | + .Build(); | ||
| 748 | + gert::TilingContext* tilingContext = holder.GetContext<gert::TilingContext>(); | ||
| 749 | + ASSERT_NE(tilingContext->GetPlatformInfo(), nullptr); | ||
| 750 | + | ||
| 751 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", socInfos); | ||
| 752 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | ||
| 753 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | ||
| 754 | + holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | ||
| 755 | + | ||
| 756 | + // workspaces nullptr return failed | ||
| 757 | + std::cout << "test>> holder.GetContext end" << std::endl; | ||
| 758 | + | ||
| 759 | + if (tilingFunc == nullptr) { | ||
| 760 | + std::cout << "test>> tilingFunc is invalid" << std::endl; | ||
| 761 | + } else { | ||
| 762 | + std::cout << "test>> tilingFunc is valid" << std::endl; | ||
| 763 | + EXPECT_EQ(tilingFunc(tilingContext), ge::GRAPH_FAILED); | ||
| 764 | + } | ||
| 765 | +} | ||
| @@ -236,11 +236,11 @@ | |||
| 236 | {"name":"DynamicMxQuantWithDualAxis", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, | 236 | {"name":"DynamicMxQuantWithDualAxis", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, |
| 237 | {"name":"DynamicDualLevelMxQuant", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, | 237 | {"name":"DynamicDualLevelMxQuant", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, |
| 238 | {"name":"GroupedDynamicBlockQuant", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, | 238 | {"name":"GroupedDynamicBlockQuant", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, |
| 239 | + {"name":"MapIndex", "compute_units": ["ascend950"], "auto_sync": false, "impl_mode": "", "compile_options": {"ascend950": ["-mllvm -cce-aicore-dcci-before-kernel-end=false"]}}, | ||
| 239 | {"name":"GeluGradV2", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, | 240 | {"name":"GeluGradV2", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, |
| 240 | {"name":"GeluV2", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, | 241 | {"name":"GeluV2", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, |
| 241 | {"name":"PRelu", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, | 242 | {"name":"PRelu", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, |
| 242 | {"name":"DynamicQuantV3", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, | 243 | {"name":"DynamicQuantV3", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, |
| 243 | - {"name":"MapIndex", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, | ||
| 244 | {"name":"DynamicBlockQuant", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, | 244 | {"name":"DynamicBlockQuant", "compute_units": ["ascend950"], "auto_sync" : false, "impl_mode" : ""}, |
| 245 | {"name":"GroupedDynamicMxQuant", "compute_units": ["ascend950"], "auto_sync": false, "impl_mode": "", "compile_options": {"ascend950": ["-mllvm -cce-aicore-dcci-before-kernel-end=false"]}}, | 245 | {"name":"GroupedDynamicMxQuant", "compute_units": ["ascend950"], "auto_sync": false, "impl_mode": "", "compile_options": {"ascend950": ["-mllvm -cce-aicore-dcci-before-kernel-end=false"]}}, |
| 246 | {"name":"SiluGrad", "compute_units": ["ascend950"], "auto_sync": false, "impl_mode": "", "compile_options": {"ascend950": ["-mllvm -cce-aicore-dcci-before-kernel-end=false"]}}, | 246 | {"name":"SiluGrad", "compute_units": ["ascend950"], "auto_sync": false, "impl_mode": "", "compile_options": {"ascend950": ["-mllvm -cce-aicore-dcci-before-kernel-end=false"]}}, |


注释与命名: 函数/操作符的注释格式存在不一致:1)@brief部分与详细描述之间缺少空行;2)@par Inputs部分使用了项目符号列表(@li),但属性(@par Attributes)和输出(@par Outputs)部分未使用统一格式;3)注释中存在换行不一致(如第31行结尾有换行符\n,但其他地方没有)。
问题类型: 注释与命名 文件路径:
index/map_index/op_graph/map_index_proto.h行号: 27 问题代码:修改建议:
此评论由代码审查工具自动生成