已合并
conv:conv3dv2/extendconv2d/quantconv2d/quantconv3d 新增ascend350平台支持 #10795
conv:conv3dv2/extendconv2d/quantconv2d/quantconv3d 新增ascend350平台支持 #10795
已合并
XianyongWang创建于 9月20日
共 23 个文件变更+5058-32
@@ -167,7 +167,7 @@ void ConvTilingAlgorithmHWmode::GetKhKwL1Tiling()
167 CalcCommFactor(tilingIns_->shapeInfo.singlekW, tilingIns_->shapeInfo.singlekW, this->l1TilingRange.kwL1Range);167 CalcCommFactor(tilingIns_->shapeInfo.singlekW, tilingIns_->shapeInfo.singlekW, this->l1TilingRange.kwL1Range);
168 CalcCommFactor(tilingIns_->shapeInfo.singlekH, tilingIns_->shapeInfo.singlekH, this->l1TilingRange.khL1Range);168 CalcCommFactor(tilingIns_->shapeInfo.singlekH, tilingIns_->shapeInfo.singlekH, this->l1TilingRange.khL1Range);
169 this->l1Params.kwL1 = IterKwL1();169 this->l1Params.kwL1 = IterKwL1();
170- this->l1Params.khL1 = IterKhL1(this->l1Params.kwL1);170+ this->l1Params.khL1 = this->l1Params.kwL1 == 0 ? 0 : IterKhL1(this->l1Params.kwL1);
171 this->l1Flags.isDMAKernelSplit = tilingIns_->isDmaFlag &&171 this->l1Flags.isDMAKernelSplit = tilingIns_->isDmaFlag &&
172 (this->l1Params.kwL1 < static_cast<uint64_t>(tilingIns_->shapeInfo.singlekW) ||172 (this->l1Params.kwL1 < static_cast<uint64_t>(tilingIns_->shapeInfo.singlekW) ||
173 this->l1Params.khL1 < static_cast<uint64_t>(tilingIns_->shapeInfo.singlekH));173 this->l1Params.khL1 < static_cast<uint64_t>(tilingIns_->shapeInfo.singlekH));
@@ -317,6 +317,14 @@ uint64_t ConvTilingAlgorithmHWmode::CalcL1SizeForL0Tiling(uint64_t currHoL0, uin
317 this->fMapDTypeSize;317 this->fMapDTypeSize;
318 bL1Size = AlignB(tmpKhL1 * tmpKwL1 * C04_CIN_SIZE, tilingIns_->cubeInfo.k0) * currNL0 * this->weightDTypeSize;318 bL1Size = AlignB(tmpKhL1 * tmpKwL1 * C04_CIN_SIZE, tilingIns_->cubeInfo.k0) * currNL0 * this->weightDTypeSize;
319 }319 }
320+ // In khkw split mode, InitPingPong has already fixed the AL1/BL1 ping-pong state (the big-kernel template keeps
321+ // it on), and the khkw split search checks the L1 size with these double buffers via CalcCurL1Size. The L0 tiling
322+ // decision must count them in as well, otherwise hoL0/woL0/nL0 may be oversized and even the minimum kwL1 fails
323+ // the later search. For other modes the ping-pong state is still undetermined at this stage, so keep it out.
324+ if (tilingIns_->isKernelSplit) {
325+ aL1Size *= this->dbValue.pbAL1;
326+ bL1Size *= this->dbValue.pbBL1;
327+ }
320 uint64_t usedL1Size = aL1Size + bL1Size + biasSize + scaleSize;328 uint64_t usedL1Size = aL1Size + bL1Size + biasSize + scaleSize;
321 return usedL1Size;329 return usedL1Size;
322}330}
@@ -188,6 +188,7 @@ public:
188 .ExtendCfgInfo("jitCompile.flag", "false");188 .ExtendCfgInfo("jitCompile.flag", "false");
189 189 
190 SetAscendConfig(aicoreConfig95, "ascend950");190 SetAscendConfig(aicoreConfig95, "ascend950");
191+ this->AICore().AddConfig("ascend350", aicoreConfig95);
XianyongWang
XianyongWangXianyongWang9月20日

conv3dv2的def处理方式与conv2dv2不一致

likedislike
XianyongWang
XianyongWang
28 天前 评论:
191 }192 }
192 193 
193private:194private:
@@ -238,4 +239,4 @@ private:
238};239};
239 240 
240OP_ADD(Conv3DV2);241OP_ADD(Conv3DV2);
241-} // namespace ops242+} // namespace ops
@@ -16,7 +16,7 @@ add_kernel_sources(
16 16 
17add_kernel_sources(17add_kernel_sources(
18 KERNEL_SRC conv3d_v2.cpp18 KERNEL_SRC conv3d_v2.cpp
19- COMPUTE_UNITS ascend95019+ COMPUTE_UNITS ascend950 ascend350
20 AUTO_SYNC false20 AUTO_SYNC false
21 OPTIONS "--cce-no-dcache-flush"21 OPTIONS "--cce-no-dcache-flush"
22)22)
@@ -179,7 +179,7 @@ def to_NDC1HWC0(data, ori_format, target_shape):
179 179 
180def is_ascend950(short_soc_version):180def is_ascend950(short_soc_version):
181 """Check if the target is Ascend 950PR/950DT"""181 """Check if the target is Ascend 950PR/950DT"""
182- return short_soc_version == "Ascend950"182+ return short_soc_version in ("Ascend950", "Ascend350")
183 183 
184 184 
185def process_formats_a2_a3(x, filter, input_formats, input_ori_shapes, groups):185def process_formats_a2_a3(x, filter, input_formats, input_ori_shapes, groups):
@@ -1,13 +1,13 @@
1# ----------------------------------------------------------------------------1# ----------------------------------------------------------------------------
2# Copyright (c) 2025 Huawei Technologies Co., Ltd.2# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of 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").4# CANN Open Software License Agreement Version 2.0 (the "License").
5# Please refer to the License for details. You may not use this file except in compliance with the License.5# Please refer to the License for details. You may not use this file except in compliance with the License.
6-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 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.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.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------9# ----------------------------------------------------------------------------
10 10 
11if ((UT_TEST_ALL OR OP_KERNEL_UT) AND NOT UT_DONE)11if ((UT_TEST_ALL OR OP_KERNEL_UT) AND NOT UT_DONE)
12- AddOpTestCase(conv3d_v2 "ascend910B1" "-DDTYPE_X=half -DDTYPE_FILTER=half -DDTYPE_Y=half")12+ AddOpTestCase(conv3d_v2 "ascend910B1;ascend350_355e" "-DDTYPE_X=half -DDTYPE_FILTER=half -DDTYPE_Y=half")
13endif()13endif()
@@ -39,7 +39,8 @@ const ge::AscendString SCALE_1 = "scale1";
39const ge::AscendString RELU_WEIGHT_0 = "relu_weight0";39const ge::AscendString RELU_WEIGHT_0 = "relu_weight0";
40const ge::AscendString RELU_WEIGHT_1 = "relu_weight1";40const ge::AscendString RELU_WEIGHT_1 = "relu_weight1";
41 41 
42-const std::map<std::string, NpuArch> SUPPORT_SOC_LIST = {{"Ascend950", NpuArch::DAV_3510}};42+const std::map<std::string, NpuArch> SUPPORT_SOC_LIST = {{"Ascend950", NpuArch::DAV_3510},
43+ {"Ascend350", NpuArch::DAV_3510}};
43const std::string FUSION_NAME = "Conv2DPostCubeToExtendConv2DFusionPass";44const std::string FUSION_NAME = "Conv2DPostCubeToExtendConv2DFusionPass";
44 45 
45constexpr int32_t EXTENDCONV2D_QUANT_SCALE_0_INDEX = 4;46constexpr int32_t EXTENDCONV2D_QUANT_SCALE_0_INDEX = 4;
@@ -1,5 +1,5 @@
1/**1/**
2- * Copyright (c) 2026 Huawei Technologies Co., Ltd.2+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of3 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 * CANN Open Software License Agreement Version 2.0 (the "License").4 * CANN Open Software License Agreement Version 2.0 (the "License").
5 * Please refer to the License for details. You may not use this file except in compliance with the License.5 * Please refer to the License for details. You may not use this file except in compliance with the License.
@@ -194,6 +194,7 @@ public:
194 .ExtendCfgInfo("jitCompile.flag", "false");194 .ExtendCfgInfo("jitCompile.flag", "false");
195 195 
196 SetAscendConfig(aicoreConfig, "ascend950");196 SetAscendConfig(aicoreConfig, "ascend950");
197+ this->AICore().AddConfig("ascend350", aicoreConfig);
197 }198 }
198 199 
199private:200private:
@@ -10,7 +10,7 @@
10 10 
11add_kernel_sources(11add_kernel_sources(
12 KERNEL_SRC extend_conv2d.cpp12 KERNEL_SRC extend_conv2d.cpp
13- COMPUTE_UNITS ascend950 mc6213+ COMPUTE_UNITS ascend950 ascend350 mc62
14 AUTO_SYNC false14 AUTO_SYNC false
15 OPTIONS "--cce-no-dcache-flush" "-DFORCE_TILING_CONST_PROPAGATION"15 OPTIONS "--cce-no-dcache-flush" "-DFORCE_TILING_CONST_PROPAGATION"
16)16)
@@ -130,7 +130,7 @@ def convert_output_dtype(out, output_dtype, enable_hf32=False, short_soc_version
130 130 
131def is_ascend950(short_soc_version):131def is_ascend950(short_soc_version):
132 """Check if target SoC is Ascend 950PR/950DT."""132 """Check if target SoC is Ascend 950PR/950DT."""
133- return short_soc_version == "Ascend950"133+ return short_soc_version in ("Ascend950", "Ascend350")
134 134 
135 135 
136def process_input_format(x, filter, input_formats):136def process_input_format(x, filter, input_formats):
@@ -1,13 +1,13 @@
1# ----------------------------------------------------------------------------1# ----------------------------------------------------------------------------
2# Copyright (c) 2026 Huawei Technologies Co., Ltd.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 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").4# CANN Open Software License Agreement Version 2.0 (the "License").
5# Please refer to the License for details. You may not use this file except in compliance with the License.5# Please refer to the License for details. You may not use this file except in compliance with the License.
6-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 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.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.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------9# ----------------------------------------------------------------------------
10 10 
11if ((UT_TEST_ALL OR OP_KERNEL_UT) AND NOT UT_DONE)11if ((UT_TEST_ALL OR OP_KERNEL_UT) AND NOT UT_DONE)
12- AddOpTestCase(extend_conv2d "ascend950pr_9599" "-DDTYPE_X=half -DDTYPE_FILTER=half -DDTYPE_Y0=half" conv2d_v2)12+ AddOpTestCase(extend_conv2d "ascend950pr_9599;ascend350_355e" "-DDTYPE_X=half -DDTYPE_FILTER=half -DDTYPE_Y0=half" conv2d_v2)
13-endif()13+endif()
@@ -9,8 +9,8 @@
9# ----------------------------------------------------------------------------9# ----------------------------------------------------------------------------
10 10 
11# 设置算子定义时支持的芯片类型11# 设置算子定义时支持的芯片类型
12-set(SUPPORT_COMPUTE_UNIT "ascend950")12+set(SUPPORT_COMPUTE_UNIT "ascend950" "ascend350")
13# 设置每种芯片类型对应的tiling文件目录13# 设置每种芯片类型对应的tiling文件目录
14-set(SUPPORT_TILING_DIR "arch35")14+set(SUPPORT_TILING_DIR "arch35" "arch35")
15add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE quant_conv2d ACLNNTYPE aclnn_exclude15add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE quant_conv2d ACLNNTYPE aclnn_exclude
16 COMPUTE_UNIT ${SUPPORT_COMPUTE_UNIT} TILING_DIR ${SUPPORT_TILING_DIR} DISABLE_IN_OPP TRUE DEPENDENCIES conv2d_v2)16 COMPUTE_UNIT ${SUPPORT_COMPUTE_UNIT} TILING_DIR ${SUPPORT_TILING_DIR} DISABLE_IN_OPP TRUE DEPENDENCIES conv2d_v2)
@@ -105,6 +105,7 @@ public:
105 .ExtendCfgInfo("jitCompile.flag", "false");105 .ExtendCfgInfo("jitCompile.flag", "false");
106 106 
107 this->AICore().AddConfig("ascend950", aicore_config);107 this->AICore().AddConfig("ascend950", aicore_config);
108+ this->AICore().AddConfig("ascend350", aicore_config);
108 }109 }
109};110};
110 111 
@@ -10,7 +10,7 @@
10 10 
11add_kernel_sources(11add_kernel_sources(
12 KERNEL_SRC quant_conv2d.cpp12 KERNEL_SRC quant_conv2d.cpp
13- COMPUTE_UNITS ascend95013+ COMPUTE_UNITS ascend950 ascend350
14 AUTO_SYNC false14 AUTO_SYNC false
15 OPTIONS "--cce-no-dcache-flush"15 OPTIONS "--cce-no-dcache-flush"
16)16)
@@ -9,5 +9,5 @@
9# ----------------------------------------------------------------------------9# ----------------------------------------------------------------------------
10 10 
11if ((UT_TEST_ALL OR OP_KERNEL_UT) AND NOT UT_DONE)11if ((UT_TEST_ALL OR OP_KERNEL_UT) AND NOT UT_DONE)
12- AddOpTestCase(quant_conv2d "ascend950pr_9599" "-DDTYPE_X=half -DDTYPE_FILTER=half -DDTYPE_Y=half" conv2d_v2)12+ AddOpTestCase(quant_conv2d "ascend950pr_9599;ascend350_355e" "-DDTYPE_X=half -DDTYPE_FILTER=half -DDTYPE_Y=half" conv2d_v2)
13endif()13endif()
@@ -31,6 +31,7 @@ const ge::AscendString RINT = "rint";
31 31 
32const std::map<std::string, NpuArch> SUPPORT_SOC_LIST = {32const std::map<std::string, NpuArch> SUPPORT_SOC_LIST = {
33 {"Ascend950", NpuArch::DAV_3510},33 {"Ascend950", NpuArch::DAV_3510},
34+ {"Ascend350", NpuArch::DAV_3510},
34};35};
35const std::string FUSION_NAME = "Conv3DDequantToQuantConv3DFusionPass";36const std::string FUSION_NAME = "Conv3DDequantToQuantConv3DFusionPass";
36 37 
@@ -1,12 +1,11 @@
1/**1/**
2- * This program is free software, you can redistribute it and/or modify.
3 * Copyright (c) 2025 Huawei Technologies Co., Ltd.2 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
4- * This file is a part of the CANN Open Software.3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5- * Licensed under CANN Open Software License Agreement Version 2.0 (the "License").4+ * CANN Open Software License Agreement Version 2.0 (the "License").
6 * Please refer to the License for details. You may not use this file except in compliance with the License.5 * Please refer to the License for details. You may not use this file except in compliance with the License.
7- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8- * BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. See LICENSE in the root of7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9- * the software repository for the full text of the License.8+ * See LICENSE in the root of the software repository for the full text of the License.
10 */9 */
11 10 
12/*!11/*!
@@ -107,8 +106,9 @@ public:
107 .ExtendCfgInfo("jitCompile.flag", "false");106 .ExtendCfgInfo("jitCompile.flag", "false");
108 107 
109 this->AICore().AddConfig("ascend950", aicore_config);108 this->AICore().AddConfig("ascend950", aicore_config);
109+ this->AICore().AddConfig("ascend350", aicore_config);
110 }110 }
111};111};
112 112 
113OP_ADD(QuantConv3D);113OP_ADD(QuantConv3D);
114-} // namespace ops114+} // namespace ops
@@ -10,7 +10,7 @@
10 10 
11add_kernel_sources(11add_kernel_sources(
12 KERNEL_SRC quant_conv3d.cpp12 KERNEL_SRC quant_conv3d.cpp
13- COMPUTE_UNITS ascend95013+ COMPUTE_UNITS ascend950 ascend350
14 AUTO_SYNC false14 AUTO_SYNC false
15 OPTIONS "--cce-no-dcache-flush"15 OPTIONS "--cce-no-dcache-flush"
16)16)
@@ -56,7 +56,7 @@ def simulate_hf32_precision(data, short_soc_version=None):
56 56 
57def is_ascend950(short_soc_version):57def is_ascend950(short_soc_version):
58 """Check if the target is Ascend 950PR/950DT"""58 """Check if the target is Ascend 950PR/950DT"""
59- return short_soc_version == "Ascend950"59+ return short_soc_version in ("Ascend950", "Ascend350")
60 60 
61 61 
62def process_formats(x, filter, input_formats):62def process_formats(x, filter, input_formats):
@@ -1,13 +1,13 @@
1# ----------------------------------------------------------------------------1# ----------------------------------------------------------------------------
2# Copyright (c) 2026 Huawei Technologies Co., Ltd.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 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").4# CANN Open Software License Agreement Version 2.0 (the "License").
5# Please refer to the License for details. You may not use this file except in compliance with the License.5# Please refer to the License for details. You may not use this file except in compliance with the License.
6-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 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.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.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------9# ----------------------------------------------------------------------------
10 10 
11if ((UT_TEST_ALL OR OP_KERNEL_UT) AND NOT UT_DONE)11if ((UT_TEST_ALL OR OP_KERNEL_UT) AND NOT UT_DONE)
12- AddOpTestCase(quant_conv3d "ascend950pr_9599" "-DDTYPE_X=half -DDTYPE_FILTER=half -DDTYPE_Y=half" conv3d_v2)12+ AddOpTestCase(quant_conv3d "ascend950pr_9599;ascend350_355e" "-DDTYPE_X=half -DDTYPE_FILTER=half -DDTYPE_Y=half" conv3d_v2)
13-endif()13+endif()