已合并
conv3d反量化支持weight NZ格式 #5107
jinyijian创建于 5月21日
conv3d反量化支持weight NZ格式 #5107
已合并
jinyijian创建于 5月21日
23 个文件变更+371-48
@@ -79,7 +79,8 @@ int64_t ConvTilingBase::CheckTilingRes()
79uint32_t ConvTilingBase::GetBandWidthCof() const79uint32_t ConvTilingBase::GetBandWidthCof() const
80{80{
81 if (descInfo.weightType.format == ConvFormat::FRACTAL_Z ||81 if (descInfo.weightType.format == ConvFormat::FRACTAL_Z ||
82- descInfo.weightType.format == ConvFormat::FRACTAL_Z_C04) {82+ descInfo.weightType.format == ConvFormat::FRACTAL_Z_C04 ||
83+ descInfo.weightType.format == ConvFormat::FRACTAL_Z_3D) {
83 return 1;84 return 1;
84 }85 }
85 86 
@@ -47,7 +47,8 @@ static std::map<ge::Format, std::string> formatToStrTab = {
47 {ge::FORMAT_DHWCN, "DHWCN"}, {ge::FORMAT_NDHWC, "NDHWC"},47 {ge::FORMAT_DHWCN, "DHWCN"}, {ge::FORMAT_NDHWC, "NDHWC"},
48 {ge::FORMAT_NCDHW, "NCDHW"}, {ge::FORMAT_NC1HWC0, "NC1HWC0"},48 {ge::FORMAT_NCDHW, "NCDHW"}, {ge::FORMAT_NC1HWC0, "NC1HWC0"},
49 {ge::FORMAT_ND, "ND"}, {ge::FORMAT_FRACTAL_Z_C04, "FRACTAL_Z_C04"},49 {ge::FORMAT_ND, "ND"}, {ge::FORMAT_FRACTAL_Z_C04, "FRACTAL_Z_C04"},
50- {ge::FORMAT_FRACTAL_Z, "FRACTAL_Z"}50+ {ge::FORMAT_FRACTAL_Z, "FRACTAL_Z"},
51+ {ge::FORMAT_FRACTAL_Z_3D, "FRACTAL_Z_3D"}
51};52};
52 53 
53static std::map<ge::Format, ConvFormat> formatMap = {54static std::map<ge::Format, ConvFormat> formatMap = {
@@ -56,7 +57,8 @@ static std::map<ge::Format, ConvFormat> formatMap = {
56 {ge::FORMAT_DHWNC, ConvFormat::DHWNC}, {ge::FORMAT_DHWCN, ConvFormat::DHWCN},57 {ge::FORMAT_DHWNC, ConvFormat::DHWNC}, {ge::FORMAT_DHWCN, ConvFormat::DHWCN},
57 {ge::FORMAT_NDHWC, ConvFormat::NDHWC}, {ge::FORMAT_NCDHW, ConvFormat::NCDHW},58 {ge::FORMAT_NDHWC, ConvFormat::NDHWC}, {ge::FORMAT_NCDHW, ConvFormat::NCDHW},
58 {ge::FORMAT_NC1HWC0, ConvFormat::NC1HWC0}, {ge::FORMAT_FRACTAL_Z_C04, ConvFormat::FRACTAL_Z_C04},59 {ge::FORMAT_NC1HWC0, ConvFormat::NC1HWC0}, {ge::FORMAT_FRACTAL_Z_C04, ConvFormat::FRACTAL_Z_C04},
59- {ge::FORMAT_FRACTAL_Z, ConvFormat::FRACTAL_Z}60+ {ge::FORMAT_FRACTAL_Z, ConvFormat::FRACTAL_Z},
61+ {ge::FORMAT_FRACTAL_Z_3D, ConvFormat::FRACTAL_Z_3D}
60};62};
61 63 
62// [fmap, weight, output, bias]64// [fmap, weight, output, bias]
@@ -93,7 +93,8 @@ int64_t ConvComputeDo(int64_t di, int64_t dk, int64_t padHead, int64_t padTail,
93 93 
94bool IsWeightNZFormat(ge::Format weightFormat)94bool IsWeightNZFormat(ge::Format weightFormat)
95{95{
96- return weightFormat == ge::Format::FORMAT_FRACTAL_Z || weightFormat == ge::Format::FORMAT_FRACTAL_Z_C04;96+ return weightFormat == ge::Format::FORMAT_FRACTAL_Z || weightFormat == ge::Format::FORMAT_FRACTAL_Z_C04 ||
97+ weightFormat == ge::Format::FORMAT_FRACTAL_Z_3D;
97}98}
98 99 
99ge::graphStatus ConvBaseDeci::GetNumBlocksInfo(ConvAscendcTilingInfo& tilingInfo)100ge::graphStatus ConvBaseDeci::GetNumBlocksInfo(ConvAscendcTilingInfo& tilingInfo)
@@ -247,7 +247,8 @@ __aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>::
247 if constexpr (CONV::A_FORMAT == ConvFormat::NCDHW) {247 if constexpr (CONV::A_FORMAT == ConvFormat::NCDHW) {
248 fmStartAddr += diIdxStart * hwIn;248 fmStartAddr += diIdxStart * hwIn;
249 }249 }
250- if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z || CONV::B_FORMAT == ConvFormat::FRACTAL_Z_C04) {250+ if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z || CONV::B_FORMAT == ConvFormat::FRACTAL_Z_C04 ||
251+ CONV::B_FORMAT == ConvFormat::FRACTAL_Z_3D) {
251 weightStartAddr = convOps->nIdxStart * convOps->k0;252 weightStartAddr = convOps->nIdxStart * convOps->k0;
252 } else {253 } else {
253 weightStartAddr = convOps->nIdxStart * convTilingData->cin * kd * convTilingData->kh * convTilingData->kw;254 weightStartAddr = convOps->nIdxStart * convTilingData->cin * kd * convTilingData->kh * convTilingData->kw;
@@ -297,7 +298,8 @@ __aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>::
297 convOps->singleCoreWiStartPos = wiStartPosTmp;298 convOps->singleCoreWiStartPos = wiStartPosTmp;
298 }299 }
299 300 
300- if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z || CONV::B_FORMAT == ConvFormat::FRACTAL_Z_C04) {301+ if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z || CONV::B_FORMAT == ConvFormat::FRACTAL_Z_C04 ||
302+ CONV::B_FORMAT == ConvFormat::FRACTAL_Z_3D) {
301 weightStartAddr = convOps->nIdxStart * convOps->k0;303 weightStartAddr = convOps->nIdxStart * convOps->k0;
302 } else {304 } else {
303 weightStartAddr = convOps->nIdxStart * convTilingData->cin * kd * convTilingData->kh * convTilingData->kw;305 weightStartAddr = convOps->nIdxStart * convTilingData->cin * kd * convTilingData->kh * convTilingData->kw;
@@ -383,7 +385,11 @@ __aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>::
383 convTilingData->wout * convTilingData->cout + convOps->nIdxStart +385 convTilingData->wout * convTilingData->cout + convOps->nIdxStart +
384 doIdxStart * hwOut * convTilingData->cout;386 doIdxStart * hwOut * convTilingData->cout;
385 }387 }
386- weightStartAddr = convOps->nIdxStart * convTilingData->cin * kd * convTilingData->kh * convTilingData->kw;388+ if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z_3D) {
389+ weightStartAddr = convOps->nIdxStart * (C0_SIZE / sizeof(typename CONV::WEIGHT_T));
390+ } else {
391+ weightStartAddr = convOps->nIdxStart * convTilingData->cin * kd * convTilingData->kh * convTilingData->kw;
392+ }
387}393}
388 394 
389template <class CONV, class CONV_TILING>395template <class CONV, class CONV_TILING>
@@ -238,7 +238,8 @@ struct ConvDataType {
238 constexpr static auto formatOutput = OUTPUT_TYPE::format;238 constexpr static auto formatOutput = OUTPUT_TYPE::format;
239 constexpr static auto formatBias = BIAS_TYPE::format;239 constexpr static auto formatBias = BIAS_TYPE::format;
240 constexpr static bool WEIGHT_NZ_FLAG = WEIGHT_TYPE::format == ConvFormat::FRACTAL_Z ||240 constexpr static bool WEIGHT_NZ_FLAG = WEIGHT_TYPE::format == ConvFormat::FRACTAL_Z ||
241- WEIGHT_TYPE::format == ConvFormat::FRACTAL_Z_C04;241+ WEIGHT_TYPE::format == ConvFormat::FRACTAL_Z_C04 ||
242+ WEIGHT_TYPE::format == ConvFormat::FRACTAL_Z_3D;
242 243 
243 constexpr static auto posFmap = FMAP_TYPE::pos;244 constexpr static auto posFmap = FMAP_TYPE::pos;
244 constexpr static auto posWeight = WEIGHT_TYPE::pos;245 constexpr static auto posWeight = WEIGHT_TYPE::pos;
Rconv/conv2d_v2/op_kernel/arch35/conv2d_v2_instr_fz_impl.hconv/common/op_kernel/arch35/conv_instr_fz_impl.h+9-9
@@ -9,17 +9,17 @@
9 */9 */
J
Jjinyijian5月22日

把格式改动恢复(包括换行与空格之类的)

likedislike
10 10 
11/*!11/*!
12- * \file conv2d_v2_instr_fz_impl.h12+ * \file conv_instr_fz_impl.h
13- * \brief13+ * \brief LoadBL1FZTools for FRACTAL_Z / FRACTAL_Z_C04 / FRACTAL_Z_3D weight formats
14 */14 */
15 15 
16-#ifndef CONV2D_V2_INSTR_FZ_IMPL_H16+#ifndef CONV_INSTR_FZ_IMPL_H
17-#define CONV2D_V2_INSTR_FZ_IMPL_H17+#define CONV_INSTR_FZ_IMPL_H
18 18 
19-#include "conv2d_v2_config.h"19+#include "conv_config.h"
20-#include "conv2d_v2_util.h"20+#include "conv_util.h"
21 21 
22-namespace Conv2dFunc {22+namespace ConvFunc {
23using namespace AscendC;23using namespace AscendC;
24using namespace conv;24using namespace conv;
25 25 
@@ -88,6 +88,6 @@ private:
88 uint32_t orgCoAlignN0 = 0;88 uint32_t orgCoAlignN0 = 0;
89};89};
90 90 
91-};91+} // namespace ConvFunc
92 92 
93-#endif // CONV2D_V2_INSTR_IMPL_H93+#endif // CONV_INSTR_FZ_IMPL_H
@@ -81,7 +81,7 @@ public:
81 ConvFunc::CopyOutToolsMMode<Intf, typename Intf::Output1T, 1>,81 ConvFunc::CopyOutToolsMMode<Intf, typename Intf::Output1T, 1>,
82 ConvFunc::CopyOutToolsHWMode<Intf, typename Intf::Output1T, 1>>::type;82 ConvFunc::CopyOutToolsHWMode<Intf, typename Intf::Output1T, 1>>::type;
83 using LoadBL1Tools = typename Conditional<83 using LoadBL1Tools = typename Conditional<
84- Config::WEIGHT_NZ_FLAG, Conv2dFunc::LoadBL1FZTools<Intf>, Conv2dFunc::LoadBL1Tools<Intf>>::type;84+ Config::WEIGHT_NZ_FLAG, ConvFunc::LoadBL1FZTools<Intf>, Conv2dFunc::LoadBL1Tools<Intf>>::type;
85 85 
86 LoadAL1Tools loadAl1Ins;86 LoadAL1Tools loadAl1Ins;
87 LoadBL1Tools loadBL1Ins;87 LoadBL1Tools loadBL1Ins;
@@ -21,7 +21,7 @@
21 #include "conv2d_v2_instr_c04_impl.h"21 #include "conv2d_v2_instr_c04_impl.h"
22 #include "conv2d_v2_instr_dma_impl.h"22 #include "conv2d_v2_instr_dma_impl.h"
23 #include "conv2d_v2_instr_weight_ub_trans_impl.h"23 #include "conv2d_v2_instr_weight_ub_trans_impl.h"
24- #include "conv2d_v2_instr_fz_impl.h"24+ #include "../../common/arch35/conv_instr_fz_impl.h"
25#endif25#endif
26 26 
27#endif // CONV2D_V2_INSTR_H27#endif // CONV2D_V2_INSTR_H
@@ -292,7 +292,7 @@
292 <td style="text-align:center">BFLOAT16</td>292 <td style="text-align:center">BFLOAT16</td>
293 </tr>293 </tr>
294 <tr>294 <tr>
295- <td rowspan="3" style="text-align:center">数据格式</td>295+ <td rowspan="4" style="text-align:center">数据格式</td>
296 <td style="text-align:center">NCDHW</td>296 <td style="text-align:center">NCDHW</td>
297 <td style="text-align:center">NCDHW</td>297 <td style="text-align:center">NCDHW</td>
298 <td style="text-align:center">ND</td>298 <td style="text-align:center">ND</td>
@@ -313,6 +313,13 @@
313 <td style="text-align:center">ND</td>313 <td style="text-align:center">ND</td>
314 <td style="text-align:center">NDHWC</td>314 <td style="text-align:center">NDHWC</td>
315 </tr>315 </tr>
316+ <tr>
317+ <td style="text-align:center">NCDHW</td>
318+ <td style="text-align:center">FRACTAL_Z_3D</td>
319+ <td style="text-align:center">ND</td>
320+ <td style="text-align:center">ND</td>
321+ <td style="text-align:center">NDHWC</td>
322+ </tr>
316 </table>323 </table>
317 324 
318- `x``filter``bias``scale``y` 中每一组 `tensor` 的每一维大小都应不大于 1000000。325- `x``filter``bias``scale``y` 中每一组 `tensor` 的每一维大小都应不大于 1000000。
@@ -945,6 +945,216 @@
945 "value": null945 "value": null
946 }946 }
947 ]947 ]
948+ },
949+ {
950+ "bin_filename": "Conv3DV2_NCDHW_INT8_FRACTAL_Z_3D_INT8_FP32_NDHWC_FP16",
951+ "inputs": [
952+ {
953+ "name": "x",
954+ "index": 0,
955+ "dtype": "int8",
956+ "format": "NCDHW",
957+ "paramType": "required",
958+ "shape": [-2]
959+ },
960+ {
961+ "name": "filter",
962+ "index": 1,
963+ "dtype": "int8",
964+ "format": "FRACTAL_Z_3D",
965+ "paramType": "required",
966+ "shape": [-2]
967+ },
968+ {
969+ "name": "bias",
970+ "index": 2,
971+ "dtype": "float32",
972+ "format": "ND",
973+ "paramType": "optional",
974+ "shape": [-2]
975+ },
976+ {
977+ "name": "scale",
978+ "index": 3,
979+ "dtype": "float32",
980+ "format": "ND",
981+ "paramType": "optional",
982+ "shape": [-2]
983+ },
984+ {
985+ "name": "offset",
986+ "index": 4,
987+ "dtype": "int8",
988+ "format": "ND",
989+ "paramType": "optional",
990+ "shape": [-2]
991+ },
992+ {
993+ "name": "offset_w",
994+ "index": 5,
995+ "dtype": "int8",
996+ "format": "ND",
997+ "paramType": "optional",
998+ "shape": [-2]
999+ }
1000+ ],
1001+ "outputs": [
1002+ {
1003+ "name": "y",
1004+ "index": 0,
1005+ "dtype": "float16",
1006+ "format": "NDHWC",
1007+ "paramType": "required",
1008+ "shape": [-2]
1009+ }
1010+ ],
1011+ "attrs": [
1012+ {
1013+ "name": "strides",
1014+ "dtype": "list_int",
1015+ "value": null
1016+ },
1017+ {
1018+ "name": "pads",
1019+ "dtype": "list_int",
1020+ "value": null
1021+ },
1022+ {
1023+ "name": "dilations",
1024+ "dtype": "list_int",
1025+ "value": null
1026+ },
1027+ {
1028+ "name": "groups",
1029+ "dtype": "int",
1030+ "value": null
1031+ },
1032+ {
1033+ "name": "data_format",
1034+ "dtype": "string",
1035+ "value": null
1036+ },
1037+ {
1038+ "name": "offset_x",
1039+ "dtype": "int",
1040+ "value": null
1041+ },
1042+ {
1043+ "name": "pad_mode",
1044+ "dtype": "string",
1045+ "value": null
1046+ },
1047+ {
1048+ "name": "enable_hf32",
1049+ "dtype": "bool",
1050+ "value": null
1051+ }
1052+ ]
1053+ },
1054+ {
1055+ "bin_filename": "Conv3DV2_NCDHW_INT8_FRACTAL_Z_3D_INT8_FP32_NDHWC_BF16",
1056+ "inputs": [
1057+ {
1058+ "name": "x",
1059+ "index": 0,
1060+ "dtype": "int8",
1061+ "format": "NCDHW",
1062+ "paramType": "required",
1063+ "shape": [-2]
1064+ },
1065+ {
1066+ "name": "filter",
1067+ "index": 1,
1068+ "dtype": "int8",
1069+ "format": "FRACTAL_Z_3D",
1070+ "paramType": "required",
1071+ "shape": [-2]
1072+ },
1073+ {
1074+ "name": "bias",
1075+ "index": 2,
1076+ "dtype": "float32",
1077+ "format": "ND",
1078+ "paramType": "optional",
1079+ "shape": [-2]
1080+ },
1081+ {
1082+ "name": "scale",
1083+ "index": 3,
1084+ "dtype": "float32",
1085+ "format": "ND",
1086+ "paramType": "optional",
1087+ "shape": [-2]
1088+ },
1089+ {
1090+ "name": "offset",
1091+ "index": 4,
1092+ "dtype": "int8",
1093+ "format": "ND",
1094+ "paramType": "optional",
1095+ "shape": [-2]
1096+ },
1097+ {
1098+ "name": "offset_w",
1099+ "index": 5,
1100+ "dtype": "int8",
1101+ "format": "ND",
1102+ "paramType": "optional",
1103+ "shape": [-2]
1104+ }
1105+ ],
1106+ "outputs": [
1107+ {
1108+ "name": "y",
1109+ "index": 0,
1110+ "dtype": "bfloat16",
1111+ "format": "NDHWC",
1112+ "paramType": "required",
1113+ "shape": [-2]
1114+ }
1115+ ],
1116+ "attrs": [
1117+ {
1118+ "name": "strides",
1119+ "dtype": "list_int",
1120+ "value": null
1121+ },
1122+ {
1123+ "name": "pads",
1124+ "dtype": "list_int",
1125+ "value": null
1126+ },
1127+ {
1128+ "name": "dilations",
1129+ "dtype": "list_int",
1130+ "value": null
1131+ },
1132+ {
1133+ "name": "groups",
1134+ "dtype": "int",
1135+ "value": null
1136+ },
1137+ {
1138+ "name": "data_format",
1139+ "dtype": "string",
1140+ "value": null
1141+ },
1142+ {
1143+ "name": "offset_x",
1144+ "dtype": "int",
1145+ "value": null
1146+ },
1147+ {
1148+ "name": "pad_mode",
1149+ "dtype": "string",
1150+ "value": null
1151+ },
1152+ {
1153+ "name": "enable_hf32",
1154+ "dtype": "bool",
1155+ "value": null
1156+ }
1157+ ]
948 }1158 }
949 ]1159 ]
950}1160}
@@ -22,42 +22,48 @@ static const std::map<std::string, std::vector<ge::DataType>> conv3dv2FmapDataTy
22 ge::DT_FLOAT16, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}},22 ge::DT_FLOAT16, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}},
J
Jjinyijian5月22日

加上API侧json发布两种新组合适配

likedislike
23 {"ascend950", {ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_HIFLOAT8,23 {"ascend950", {ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_HIFLOAT8,
24 ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_INT8,24 ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_INT8,
25- ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}}25+ ge::DT_INT8, ge::DT_INT8, ge::DT_INT8,
26+ ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}}
26};27};
27static const std::map<std::string, std::vector<ge::DataType>> conv3dv2WeightDataType = {28static const std::map<std::string, std::vector<ge::DataType>> conv3dv2WeightDataType = {
28 {"ascend910b", {ge::DT_BF16, ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_BF16, ge::DT_FLOAT,29 {"ascend910b", {ge::DT_BF16, ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_BF16, ge::DT_FLOAT,
29 ge::DT_FLOAT16, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}},30 ge::DT_FLOAT16, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}},
30 {"ascend950", {ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_HIFLOAT8,31 {"ascend950", {ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_HIFLOAT8,
31 ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_INT8,32 ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_INT8,
32- ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}}33+ ge::DT_INT8, ge::DT_INT8, ge::DT_INT8,
34+ ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}}
33};35};
34static const std::map<std::string, std::vector<ge::DataType>> conv3dv2BiasDataType = {36static const std::map<std::string, std::vector<ge::DataType>> conv3dv2BiasDataType = {
35 {"ascend910b", {ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_FLOAT,37 {"ascend910b", {ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_FLOAT,
36 ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_BF16, ge::DT_FLOAT, ge::DT_FLOAT16}},38 ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_BF16, ge::DT_FLOAT, ge::DT_FLOAT16}},
37 {"ascend950", {ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_FLOAT,39 {"ascend950", {ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_FLOAT,
38 ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_FLOAT16,40 ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_FLOAT16,
39- ge::DT_FLOAT, ge::DT_BF16, ge::DT_FLOAT}}41+ ge::DT_FLOAT, ge::DT_BF16, ge::DT_FLOAT,
42+ ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_BF16, ge::DT_FLOAT}}
40};43};
41static const std::map<std::string, std::vector<ge::DataType>> conv3dv2ScaleAndOffsetDataType = {44static const std::map<std::string, std::vector<ge::DataType>> conv3dv2ScaleAndOffsetDataType = {
42 {"ascend910b", {ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT,45 {"ascend910b", {ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT,
43 ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT}},46 ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT}},
44 {"ascend950", {ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT,47 {"ascend950", {ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT,
45 ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT,48 ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT,
46- ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT}}49+ ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT,
50+ ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT}}
47};51};
48static const std::map<std::string, std::vector<ge::DataType>> conv3dv2OffsetWDataType = {52static const std::map<std::string, std::vector<ge::DataType>> conv3dv2OffsetWDataType = {
49 {"ascend910b", {ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8,53 {"ascend910b", {ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8,
50 ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}},54 ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}},
51 {"ascend950", {ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8,55 {"ascend950", {ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8,
52 ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8,56 ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8,
53- ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}}57+ ge::DT_INT8, ge::DT_INT8, ge::DT_INT8,
58+ ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8}}
54};59};
55static const std::map<std::string, std::vector<ge::DataType>> conv3dv2OutputDataType = {60static const std::map<std::string, std::vector<ge::DataType>> conv3dv2OutputDataType = {
56 {"ascend910b", {ge::DT_BF16, ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_BF16,61 {"ascend910b", {ge::DT_BF16, ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_BF16,
57 ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_BF16, ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT16}},62 ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_BF16, ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT16}},
58 {"ascend950", {ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_HIFLOAT8,63 {"ascend950", {ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_HIFLOAT8,
59 ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_FLOAT16,64 ge::DT_BF16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_FLOAT16,
60- ge::DT_FLOAT16, ge::DT_BF16, ge::DT_BF16}}65+ ge::DT_FLOAT16, ge::DT_BF16, ge::DT_BF16,
66+ ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_BF16, ge::DT_BF16}}
61};67};
62static const std::map<std::string, std::vector<ge::Format>> conv3dv2FmapFormat = {68static const std::map<std::string, std::vector<ge::Format>> conv3dv2FmapFormat = {
63 {"ascend910b", {ge::FORMAT_NDC1HWC0, ge::FORMAT_NDC1HWC0, ge::FORMAT_NDC1HWC0, ge::FORMAT_NCDHW,69 {"ascend910b", {ge::FORMAT_NDC1HWC0, ge::FORMAT_NDC1HWC0, ge::FORMAT_NDC1HWC0, ge::FORMAT_NCDHW,
@@ -65,7 +71,8 @@ static const std::map<std::string, std::vector<ge::Format>> conv3dv2FmapFormat =
65 ge::FORMAT_NDC1HWC0, ge::FORMAT_NDC1HWC0}},71 ge::FORMAT_NDC1HWC0, ge::FORMAT_NDC1HWC0}},
66 {"ascend950", {ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW,72 {"ascend950", {ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW,
67 ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NCDHW,73 ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NCDHW,
68- ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW}}74+ ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW,
75+ ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW}}
69};76};
70static const std::map<std::string, std::vector<ge::Format>> conv3dv2WeightFormat = {77static const std::map<std::string, std::vector<ge::Format>> conv3dv2WeightFormat = {
71 {"ascend910b", {ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_NCDHW,78 {"ascend910b", {ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_NCDHW,
@@ -73,28 +80,32 @@ static const std::map<std::string, std::vector<ge::Format>> conv3dv2WeightFormat
73 ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_FRACTAL_Z_3D}},80 ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_FRACTAL_Z_3D}},
74 {"ascend950", {ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW,81 {"ascend950", {ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW,
75 ge::FORMAT_DHWCN, ge::FORMAT_DHWCN, ge::FORMAT_DHWCN, ge::FORMAT_NCDHW,82 ge::FORMAT_DHWCN, ge::FORMAT_DHWCN, ge::FORMAT_DHWCN, ge::FORMAT_NCDHW,
76- ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW}}83+ ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW,
84+ ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_FRACTAL_Z_3D, ge::FORMAT_FRACTAL_Z_3D}}
77};85};
78static const std::map<std::string, std::vector<ge::Format>> conv3dv2BiasFormat = {86static const std::map<std::string, std::vector<ge::Format>> conv3dv2BiasFormat = {
79 {"ascend910b", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,87 {"ascend910b", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
80 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}},88 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}},
81 {"ascend950", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,89 {"ascend950", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
82 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,90 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
83- ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}}91+ ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
92+ ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}}
84};93};
85static const std::map<std::string, std::vector<ge::Format>> conv3dv2ScaleAndOffsetFormat = {94static const std::map<std::string, std::vector<ge::Format>> conv3dv2ScaleAndOffsetFormat = {
86 {"ascend910b", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,95 {"ascend910b", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
87 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}},96 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}},
88 {"ascend950", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,97 {"ascend950", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
89 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,98 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
90- ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}}99+ ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
100+ ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}}
91};101};
92static const std::map<std::string, std::vector<ge::Format>> conv3dv2OffsetWFormat = {102static const std::map<std::string, std::vector<ge::Format>> conv3dv2OffsetWFormat = {
93 {"ascend910b", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,103 {"ascend910b", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
94 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}},104 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}},
95 {"ascend950", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,105 {"ascend950", {ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
96 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,106 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
97- ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}}107+ ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
108+ ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}}
98};109};
99static const std::map<std::string, std::vector<ge::Format>> conv3dv2OutputFormat = {110static const std::map<std::string, std::vector<ge::Format>> conv3dv2OutputFormat = {
100 {"ascend910b", {ge::FORMAT_NDC1HWC0, ge::FORMAT_NDC1HWC0, ge::FORMAT_NDC1HWC0, ge::FORMAT_NCDHW,111 {"ascend910b", {ge::FORMAT_NDC1HWC0, ge::FORMAT_NDC1HWC0, ge::FORMAT_NDC1HWC0, ge::FORMAT_NCDHW,
@@ -102,7 +113,8 @@ static const std::map<std::string, std::vector<ge::Format>> conv3dv2OutputFormat
102 ge::FORMAT_NCDHW, ge::FORMAT_NCDHW}},113 ge::FORMAT_NCDHW, ge::FORMAT_NCDHW}},
103 {"ascend950", {ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW,114 {"ascend950", {ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW, ge::FORMAT_NCDHW,
104 ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NDHWC,115 ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NDHWC,
105- ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NDHWC}}116+ ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NDHWC,
117+ ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NDHWC, ge::FORMAT_NDHWC}}
106};118};
107 119 
108class Conv3DV2 : public OpDef {120class Conv3DV2 : public OpDef {
@@ -109,7 +109,8 @@ void Conv3dTiling::Infer5hdShape()
109bool Conv3dTiling::CheckInputFormat()109bool Conv3dTiling::CheckInputFormat()
110{110{
111 std::set<std::pair<ConvFormat, ConvFormat>> conv3dSupportFormatSet = {111 std::set<std::pair<ConvFormat, ConvFormat>> conv3dSupportFormatSet = {
112- {ConvFormat::NCDHW, ConvFormat::NCDHW}, {ConvFormat::NDHWC, ConvFormat::DHWCN}112+ {ConvFormat::NCDHW, ConvFormat::NCDHW}, {ConvFormat::NDHWC, ConvFormat::DHWCN},
113+ {ConvFormat::NCDHW, ConvFormat::FRACTAL_Z_3D}
J
Jjinyijian5月22日

ConvFormat枚举是否增加了FRACTAL_Z_3D

likedislike
113 };114 };
114 115 
115 if (conv3dSupportFormatSet.find({descInfo.fMapType.format, descInfo.weightType.format}) ==116 if (conv3dSupportFormatSet.find({descInfo.fMapType.format, descInfo.weightType.format}) ==
@@ -101,7 +101,7 @@ void Conv3dBaseTilingV2::GetDescInfo()
101 descInfo_.scaleFormat = context_->GetOptionalInputDesc(tmpScaleIdx)->GetStorageFormat();101 descInfo_.scaleFormat = context_->GetOptionalInputDesc(tmpScaleIdx)->GetStorageFormat();
102 }102 }
103 flagInfo_.isConv3dDequant = !flagInfo_.quantFlag && descInfo_.fMapDtype == ge::DataType::DT_INT8;103 flagInfo_.isConv3dDequant = !flagInfo_.quantFlag && descInfo_.fMapDtype == ge::DataType::DT_INT8;
104- paramInfo_.paramsFormat = {descInfo_.fMapFormat, descInfo_.weightFormat, descInfo_.outFormat};104+ paramInfo_.paramsFormat = {descInfo_.fMapFormat, GetWeightFormat(), descInfo_.outFormat};
105}105}
106 106
107ge::graphStatus Conv3dBaseTilingV2::CheckNullPtr()107ge::graphStatus Conv3dBaseTilingV2::CheckNullPtr()
@@ -210,6 +210,26 @@ void Conv3dBaseTilingV2::SetQuantFlag()
210 flagInfo_.quantFlag = isQuantConv3D(context_->GetNodeType());210 flagInfo_.quantFlag = isQuantConv3D(context_->GetNodeType());
211}211}
212 212 
213+ge::Format Conv3dBaseTilingV2::GetWeightFormat() const
214+{
215+ auto weightDesc = context_->GetInputDesc(INPUT_WEIGHT_INDEX);
216+ auto weightStorageFormat = static_cast<ge::Format>(GetPrimaryFormat(weightDesc->GetStorageFormat()));
217+ if (IsWeightNZFormat(weightStorageFormat)) {
218+ return static_cast<ge::Format>(GetPrimaryFormat(weightDesc->GetOriginFormat()));
219+ }
220+ return weightStorageFormat;
221+}
222+ 
223+gert::Shape Conv3dBaseTilingV2::GetWeightShape(const gert::StorageShape* weightShapePtr) const
224+{
225+ auto weightDesc = context_->GetInputDesc(INPUT_WEIGHT_INDEX);
226+ auto weightStorageFormat = static_cast<ge::Format>(GetPrimaryFormat(weightDesc->GetStorageFormat()));
227+ if (IsWeightNZFormat(weightStorageFormat)) {
228+ return weightShapePtr->GetOriginShape();
229+ }
230+ return weightShapePtr->GetStorageShape();
231+}
232+ 
213ge::graphStatus Conv3dBaseTilingV2::GetConv3DAxisPosInfo()233ge::graphStatus Conv3dBaseTilingV2::GetConv3DAxisPosInfo()
214{234{
215 auto fMapDesc = context_->GetInputDesc(INPUT_FMAP_INDEX);235 auto fMapDesc = context_->GetInputDesc(INPUT_FMAP_INDEX);
@@ -114,6 +114,7 @@ private:
114 ge::graphStatus CheckFmapShape();114 ge::graphStatus CheckFmapShape();
115 ge::graphStatus ParseWeightShape();115 ge::graphStatus ParseWeightShape();
116 ge::graphStatus CheckWeightShape();116 ge::graphStatus CheckWeightShape();
117+ ge::graphStatus CheckWeightNZFormatShape();
117 ge::graphStatus ParseBiasShape();118 ge::graphStatus ParseBiasShape();
118 ge::graphStatus ParseOutputShape();119 ge::graphStatus ParseOutputShape();
119 ge::graphStatus CheckOutputShape();120 ge::graphStatus CheckOutputShape();
@@ -160,6 +161,8 @@ private:
160 void SetQuantFlag();161 void SetQuantFlag();
161 void SetScaleBiasFlag();162 void SetScaleBiasFlag();
162 ge::graphStatus GetConv3DAxisPosInfo();163 ge::graphStatus GetConv3DAxisPosInfo();
164+ ge::Format GetWeightFormat() const;
165+ gert::Shape GetWeightShape(const gert::StorageShape* weightShapePtr) const;
163 ge::graphStatus ApplySamesPad(const string& padMode);166 ge::graphStatus ApplySamesPad(const string& padMode);
164 ge::graphStatus PrepareTiling();167 ge::graphStatus PrepareTiling();
165 void SetApiInputPlatformInfo();168 void SetApiInputPlatformInfo();
@@ -43,7 +43,7 @@ ge::graphStatus Conv3dBaseTilingV2::ParseFmapShape()
43ge::graphStatus Conv3dBaseTilingV2::ParseWeightShape()43ge::graphStatus Conv3dBaseTilingV2::ParseWeightShape()
44{44{
45 auto weightShapePtr = context_->GetInputShape(INPUT_WEIGHT_INDEX);45 auto weightShapePtr = context_->GetInputShape(INPUT_WEIGHT_INDEX);
46- auto weightShape = weightShapePtr->GetStorageShape();46+ auto weightShape = GetWeightShape(weightShapePtr);
47 if (weightShape.GetDimNum() != CONV3D_DIM_SIZE_LIMIT) {47 if (weightShape.GetDimNum() != CONV3D_DIM_SIZE_LIMIT) {
48 OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeType(), "filter",48 OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeType(), "filter",
49 std::to_string(weightShape.GetDimNum()).c_str(),49 std::to_string(weightShape.GetDimNum()).c_str(),
@@ -143,6 +143,46 @@ ge::graphStatus Conv3dBaseTilingV2::CheckWeightShape()
143 paramInfo_.paramsIdxVec[paramInfo_.WEIGHT_PARAM_IDX][IDX_LIST_N_IDX], 1, MAX_COUT_BF16_SHAPE).c_str());143 paramInfo_.paramsIdxVec[paramInfo_.WEIGHT_PARAM_IDX][IDX_LIST_N_IDX], 1, MAX_COUT_BF16_SHAPE).c_str());
144 return ge::GRAPH_FAILED;144 return ge::GRAPH_FAILED;
145 }145 }
146+ if (IsWeightNZFormat(descInfo_.weightFormat)) {
147+ auto ret = CheckWeightNZFormatShape();
148+ if (ret != ge::GRAPH_SUCCESS) {
149+ return ret;
150+ }
151+ }
152+ return ge::GRAPH_SUCCESS;
153+}
154+ 
155+ge::graphStatus Conv3dBaseTilingV2::CheckWeightNZFormatShape()
156+{
157+ auto weightStorageShape = context_->GetInputShape(INPUT_WEIGHT_INDEX)->GetStorageShape();
158+ auto storageDimNum = weightStorageShape.GetDimNum();
159+ if (storageDimNum != FORMAT_FRACTAL_3D_DIM) {
160+ OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeType(), "filter",
161+ std::to_string(storageDimNum).c_str(),
162+ std::to_string(FORMAT_FRACTAL_3D_DIM).c_str());
163+ return ge::GRAPH_FAILED;
164+ }
165+ auto c0 = static_cast<int64_t>(CUBE_MKN_MAP.GetMKN(dtypeMap.at(descInfo_.weightDtype), MKN_K_IDX));
166+ auto n0 = static_cast<int64_t>(CUBE_MKN_MAP.GetMKN(dtypeMap.at(descInfo_.weightDtype), MKN_N_IDX));
167+ if (c0 == 0 || n0 == 0) {
168+ OP_LOGE(context_->GetNodeName(), "%s AscendC: Get c0 or n0 = 0.", paramInfo_.nodeType.c_str());
169+ return ge::GRAPH_FAILED;
170+ }
171+ int64_t n1 = (oriShapeAttrInfo_.oriWeightN + n0 - 1) / n0;
172+ int64_t dc1hw = oriShapeAttrInfo_.oriWeightD *
173+ ((oriShapeAttrInfo_.oriWeightC + c0 - 1) / c0) *
174+ oriShapeAttrInfo_.oriWeightH *
175+ oriShapeAttrInfo_.oriWeightW;
176+ if (weightStorageShape.GetDim(FORMAT_FRACTAL_3D_DKCIN1KHKW_INDEX) != dc1hw ||
177+ weightStorageShape.GetDim(FORMAT_FRACTAL_3D_N1_INDEX) != n1 ||
178+ weightStorageShape.GetDim(FORMAT_FRACTAL_3D_N0_INDEX) != n0 ||
179+ weightStorageShape.GetDim(FORMAT_FRACTAL_3D_C0_INDEX) != c0) {
180+ OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeType(), "filter",
181+ VectorToString(GetInputShapeVec(context_, INPUT_WEIGHT_INDEX), IntToString<int64_t>).c_str(),
182+ FormatString("FRACTAL_Z_3D storage shape must correspond with origin shape, "
183+ "expected [%ld, %ld, %ld, %ld]", dc1hw, n1, n0, c0).c_str());
184+ return ge::GRAPH_FAILED;
185+ }
146 return ge::GRAPH_SUCCESS;186 return ge::GRAPH_SUCCESS;
147}187}
148 188 
@@ -188,7 +228,8 @@ ge::graphStatus Conv3dBaseTilingV2::ParseBiasShape()
188 if (biasDimNum == CONV3D_DIM_SIZE_LIMIT && !GetPosByFormat(biasFormat, "C", "Bias", idxC)) {228 if (biasDimNum == CONV3D_DIM_SIZE_LIMIT && !GetPosByFormat(biasFormat, "C", "Bias", idxC)) {
189 return ge::GRAPH_FAILED;229 return ge::GRAPH_FAILED;
190 }230 }
191- auto weightShape = context_->GetInputShape(INPUT_WEIGHT_INDEX)->GetStorageShape();231+ auto weightShapePtr = context_->GetInputShape(INPUT_WEIGHT_INDEX);
232+ auto weightShape = GetWeightShape(weightShapePtr);
192 size_t weightIdx = paramInfo_.paramsIdxVec[paramInfo_.WEIGHT_PARAM_IDX][IDX_LIST_N_IDX];233 size_t weightIdx = paramInfo_.paramsIdxVec[paramInfo_.WEIGHT_PARAM_IDX][IDX_LIST_N_IDX];
193 for (size_t i = 0; i < biasDimNum; i++) {234 for (size_t i = 0; i < biasDimNum; i++) {
194 if (i == idxC) {235 if (i == idxC) {
@@ -239,10 +280,11 @@ ge::graphStatus Conv3dBaseTilingV2::CheckOutputShape()
239ge::graphStatus Conv3dBaseTilingV2::CheckInputDesc()280ge::graphStatus Conv3dBaseTilingV2::CheckInputDesc()
240{281{
241 bool isConv3dDequantFormatLegal = descInfo_.fMapFormat == ge::FORMAT_NCDHW &&282 bool isConv3dDequantFormatLegal = descInfo_.fMapFormat == ge::FORMAT_NCDHW &&
242- descInfo_.weightFormat == ge::FORMAT_NCDHW &&283+ (descInfo_.weightFormat == ge::FORMAT_NCDHW ||
243- descInfo_.outFormat == ge::FORMAT_NDHWC;284+ descInfo_.weightFormat == ge::FORMAT_FRACTAL_Z_3D) &&
J
Jjinyijian5月22日

tiling侧检验FRACTAL_Z_3D具体的储存数据,参考aclnnweightnzgetworkspace

likedislike
285+ descInfo_.outFormat == ge::FORMAT_NDHWC;
244 std::stringstream ss;286 std::stringstream ss;
245- ss << "[NCDHW, NCDHW, NDHWC]";287+ ss << "[[NCDHW, NCDHW, NDHWC], [NCDHW, FRACTAL_Z_3D, NDHWC]]";
246 if (flagInfo_.isConv3dDequant && !isConv3dDequantFormatLegal) {288 if (flagInfo_.isConv3dDequant && !isConv3dDequantFormatLegal) {
247 string incorrectFormats = formatToStrTab.at(descInfo_.fMapFormat) + ", " +289 string incorrectFormats = formatToStrTab.at(descInfo_.fMapFormat) + ", " +
248 formatToStrTab.at(descInfo_.weightFormat) + ", " +290 formatToStrTab.at(descInfo_.weightFormat) + ", " +
@@ -76,9 +76,11 @@ public:
76 ConvParam::outputOrder == static_cast<int8_t>(ConvOutputOrder::M_MODE),76 ConvParam::outputOrder == static_cast<int8_t>(ConvOutputOrder::M_MODE),
77 ConvFunc::CopyOutToolsMMode<Intf, typename Intf::OutputT>,77 ConvFunc::CopyOutToolsMMode<Intf, typename Intf::OutputT>,
78 ConvFunc::CopyOutToolsHWMode<Intf, typename Intf::OutputT>>::type;78 ConvFunc::CopyOutToolsHWMode<Intf, typename Intf::OutputT>>::type;
79+ using LoadBL1Tools = typename Conditional<
80+ Config::WEIGHT_NZ_FLAG, ConvFunc::LoadBL1FZTools<Intf>, Conv3dFunc::LoadBL1Tools<Intf>>::type;
79 81 
80 LoadAL1Tools loadAl1Ins;82 LoadAL1Tools loadAl1Ins;
81- Conv3dFunc::LoadBL1Tools<Intf> loadBL1Ins;83+ LoadBL1Tools loadBL1Ins;
82 ConvFunc::LoadChannelWiseL1Tools<Intf, typename Config::BiasT> loadBiasL1Ins;84 ConvFunc::LoadChannelWiseL1Tools<Intf, typename Config::BiasT> loadBiasL1Ins;
83 ConvFunc::LoadChannelWiseL1Tools<Intf, typename Config::ScaleT> loadScaleL1Ins;85 ConvFunc::LoadChannelWiseL1Tools<Intf, typename Config::ScaleT> loadScaleL1Ins;
84 LoadAL0Tools loadAL0Ins;86 LoadAL0Tools loadAL0Ins;
@@ -56,6 +56,12 @@ __aicore__ inline void InitKDirectionValue(Intf *self)
56 self->ctx.maxKBL1Iter = CeilDiv(alignCinKhKwKd, self->ctx.convTilingData->kBL1) - 1;56 self->ctx.maxKBL1Iter = CeilDiv(alignCinKhKwKd, self->ctx.convTilingData->kBL1) - 1;
57 self->ctx.multiKBL1 = self->ctx.convTilingData->kBL1 / self->ctx.convTilingData->kL0;57 self->ctx.multiKBL1 = self->ctx.convTilingData->kBL1 / self->ctx.convTilingData->kL0;
58 58 
59+ if constexpr (Intf::WEIGHT_NZ_FLAG) {
60+ self->ctx.kBL1AlignK0Tail = alignCinKhKwKd % self->ctx.convTilingData->kBL1;
61+ self->ctx.kBL1AlignK0Tail = self->ctx.kBL1AlignK0Tail == 0 ?
62+ self->ctx.convTilingData->kBL1 : self->ctx.kBL1AlignK0Tail;
63+ }
64+ 
59 self->ctx.kL0Tail = alignCinKhKwKd % self->ctx.convTilingData->kL0;65 self->ctx.kL0Tail = alignCinKhKwKd % self->ctx.convTilingData->kL0;
60 self->ctx.kL0Tail = self->ctx.kL0Tail == 0 ? self->ctx.convTilingData->kL0 : self->ctx.kL0Tail;66 self->ctx.kL0Tail = self->ctx.kL0Tail == 0 ? self->ctx.convTilingData->kL0 : self->ctx.kL0Tail;
61 self->ctx.multiKAL1 = self->ctx.convTilingData->kAL1 / self->ctx.convTilingData->kL0;67 self->ctx.multiKAL1 = self->ctx.convTilingData->kAL1 / self->ctx.convTilingData->kL0;
@@ -18,6 +18,7 @@
18 18 
19#include "conv3d_v2_config.h"19#include "conv3d_v2_config.h"
20#include "conv3d_v2_util.h"20#include "conv3d_v2_util.h"
21+#include "../../common/arch35/conv_instr_fz_impl.h"
21 22 
22namespace Conv3dFunc {23namespace Conv3dFunc {
23using namespace AscendC;24using namespace AscendC;
@@ -71,7 +71,7 @@ struct Conv3dIntf {
71 constexpr static auto formatWeight = Config::formatWeight;71 constexpr static auto formatWeight = Config::formatWeight;
72 constexpr static auto formatOutput = Config::formatOutput;72 constexpr static auto formatOutput = Config::formatOutput;
73 constexpr static auto posOutput = Config::posOutput;73 constexpr static auto posOutput = Config::posOutput;
74- constexpr static bool WEIGHT_NZ_FLAG = false;74+ constexpr static bool WEIGHT_NZ_FLAG = Config::WEIGHT_NZ_FLAG;
75 constexpr static bool isFixedPoint = false;75 constexpr static bool isFixedPoint = false;
76 constexpr static uint64_t k0 = C0_SIZE / sizeof(WeightT);76 constexpr static uint64_t k0 = C0_SIZE / sizeof(WeightT);
77 constexpr static uint64_t k0FmapTail = C0_SIZE / sizeof(FmapT);77 constexpr static uint64_t k0FmapTail = C0_SIZE / sizeof(FmapT);
@@ -50,6 +50,14 @@ constexpr ConvFormat filterFormat = ConvFormat::DHWCN;
50constexpr ConvFormat outputFormat = ConvFormat::NDHWC;50constexpr ConvFormat outputFormat = ConvFormat::NDHWC;
51#endif51#endif
52 52 
53+#if defined(FORMAT_X) && FORMAT_X == FORMAT_NCDHW && \
54+ defined(FORMAT_FILTER) && FORMAT_FILTER == FORMAT_FRACTAL_Z_3D && \
55+ defined(FORMAT_Y) && FORMAT_Y == FORMAT_NDHWC
56+constexpr ConvFormat fmapFormat = ConvFormat::NCDHW;
57+constexpr ConvFormat filterFormat = ConvFormat::FRACTAL_Z_3D;
58+constexpr ConvFormat outputFormat = ConvFormat::NDHWC;
59+#endif
60+ 
53#else61#else
54 62 
55#if defined(FORMAT_X) && FORMAT_X == FORMAT_NCDHW && defined(FORMAT_FILTER) && FORMAT_FILTER == FORMAT_NCDHW && \63#if defined(FORMAT_X) && FORMAT_X == FORMAT_NCDHW && defined(FORMAT_FILTER) && FORMAT_FILTER == FORMAT_NCDHW && \
@@ -6,7 +6,7 @@
6 6 
7| 产品 | 是否支持 |7| 产品 | 是否支持 |
8| :----------------------------------------------------------- | :------: |8| :----------------------------------------------------------- | :------: |
9-| <term>Ascend 950PR/Ascend 950DT</term> | × |9+| <term>Ascend 950PR/Ascend 950DT</term> | |
10| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |10| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |
11| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |11| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |
12| <term>Atlas 200I/500 A2 推理产品</term> | × |12| <term>Atlas 200I/500 A2 推理产品</term> | × |
@@ -951,7 +951,7 @@ public:
951 aclnnStatus Check(QuantConvEngine &engine) override951 aclnnStatus Check(QuantConvEngine &engine) override
952 {952 {
953 SocVersion socVersion = GetCurrentPlatformInfo().GetSocVersion();953 SocVersion socVersion = GetCurrentPlatformInfo().GetSocVersion();
954- if (!engine.params.isWeightNz && GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_3510) {954+ if (GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_3510) {
955 OP_LOGD("Get Current NpuArch: DAV_3510.");955 OP_LOGD("Get Current NpuArch: DAV_3510.");
956 return ACLNN_SUCCESS;956 return ACLNN_SUCCESS;
957 }957 }
@@ -13,11 +13,11 @@
13</tr>13</tr>
14<tr>14<tr>
15<td><term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term></td>15<td><term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term></td>
16-<td style="text-align:center">x</td>16+<td style="text-align:center">×</td>
17</tr>17</tr>
18<tr>18<tr>
19<td><term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term></td>19<td><term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term></td>
20-<td style="text-align:center">x</td>20+<td style="text-align:center">×</td>
21</tr>21</tr>
22<tr>22<tr>
23<td><term>Atlas 200I/500 A2 推理产品</term></td>23<td><term>Atlas 200I/500 A2 推理产品</term></td>
@@ -111,7 +111,7 @@
111<td>dtype</td>111<td>dtype</td>
112<td>属性</td>112<td>属性</td>
113<td>表示输出 y 的数据类型。支持的列表包括 [-1(默认),0(FLOAT),1(FLOAT16),27(BFLOAT16),34(HIFLOAT8),36(FLOAT8_E4M3FN)]。</td>113<td>表示输出 y 的数据类型。支持的列表包括 [-1(默认),0(FLOAT),1(FLOAT16),27(BFLOAT16),34(HIFLOAT8),36(FLOAT8_E4M3FN)]。</td>
114-<td>BOOL</td>114+<td>INT8</td>
115<td>-</td>115<td>-</td>
116</tr>116</tr>
117<tr>117<tr>
@@ -145,7 +145,7 @@
145<tr>145<tr>
146<td>data_format</td>146<td>data_format</td>
147<td>可选属性</td>147<td>可选属性</td>
148-<td>输入数据格式,支持 "NCDHW"。</td>148+<td>输入数据格式,支持 "NCDHW" 与 "NDHWC"。</td>
149<td>STRING</td>149<td>STRING</td>
150<td>-</td>150<td>-</td>
151</tr>151</tr>
@@ -166,7 +166,7 @@
166<tr>166<tr>
167<td>pad_mode</td>167<td>pad_mode</td>
168<td>可选属性</td>168<td>可选属性</td>
169-<td>填充模式,支持 "SPECIFIC"、"SAME"、"VALID"、"SAME_UPPER", "SAME_LOWER"。</td>169+<td>填充模式,支持 "SPECIFIC"、"SAME"、"VALID"、"SAME_UPPER""SAME_LOWER"。</td>
170<td>STRING</td>170<td>STRING</td>
171<td>-</td>171<td>-</td>
172</tr>172</tr>