Merged
feat(operation): Conv api support relu and support unaligned cout #5312
luyakun_hwAdd on Aug 6
feat(operation): Conv api support relu and support unaligned cout #5312
Merged
Merged fromluyakun_hw/pyptoconv_reluintocann/pyptomaster
Total: 9 files changed+67-69
| @@ -14,12 +14,11 @@ | |||
| 14 | 14 | ||
| 15 | ## 功能说明 | 15 | ## 功能说明 |
| 16 | 16 | ||
| 17 | -实现输入input_conv、weight完成卷积运算,支持bias参数,计算公式为:out = input_conv @ weight + bias (@表示为卷积处理) | 17 | +实现输入input_conv、weight完成卷积运算,支持bias参数,计算公式为:out = input_conv @ weight + bias (@表示为卷积处理)。 |
| 18 | 18 | ||
| 19 | -- input_conv 、weight、bias为源操作数;input_conv为输入矩阵,weight为权重矩阵,bias为输入的偏置 | 19 | +- input_conv、weight、bias为源操作数;input_conv为输入矩阵,weight为权重矩阵,bias为输入的偏置。 |
| 20 | -- out为目的操作数,存放卷积处理结果的矩阵 | 20 | +- out为目的操作数,存放卷积处理结果的矩阵。 |
| 21 | -- 当前暂不支持量化场景 | 21 | +- 当前暂不支持量化场景。 |
| 22 | -- 当前暂不支持Relu功能 | ||
| 23 | 22 | ||
| 24 | ## 函数原型 | 23 | ## 函数原型 |
| 25 | 24 | ||
| @@ -31,7 +30,7 @@ conv(input_conv, weight, out_dtype, strides, paddings, dilations, *, groups=1, t | |||
| 31 | 30 | ||
| 32 | | 参数名 | 输入/输出 | 说明 | | 31 | | 参数名 | 输入/输出 | 说明 | |
| 33 | |-------------------|-----------|----------------------------------------------------------------------| | 32 | |-------------------|-----------|----------------------------------------------------------------------| |
| 34 | -| input_conv | 输入 | 输入特征图Tensor。<br>不支持空Tensor。<br>支持维度:3D(1D conv)、4D(2D conv)、5D(3D conv)。<br>支持格式:NCL、NCHW、NCDHW。<br>支持数据类型:DT_FP16、DT_BF16、DT_FP32。<br>shape约束:各维度取值范围 [1, 1000000]。input_conv的cin需满足:weight的cin * groups = input_conv的cin。 | | 33 | +| input_conv | 输入 | 输入特征图Tensor。<br>不支持空Tensor。<br>支持维度:3D(1D conv)、4D(2D conv)、5D(3D conv)。<br>支持格式:NCL、NCHW、NCDHW。<br>支持数据类型:DT_FP16、DT_BF16、DT_FP32。<br>shape约束:各维度取值范围 [1, 1000000]。input_conv的Cin需满足:weight的Cin * groups = input_conv的Cin。 | |
| 35 | | weight | 输入 | 卷积核Tensor。<br>维度必须与input_conv一致(3D/4D/5D)。<br>数据类型必须与input_conv一致。<br>shape约束:各维度取值范围 [1, 1000000]。不同型号存在额外约束,详细请参见[约束说明](#约束说明)。 | | 34 | | weight | 输入 | 卷积核Tensor。<br>维度必须与input_conv一致(3D/4D/5D)。<br>数据类型必须与input_conv一致。<br>shape约束:各维度取值范围 [1, 1000000]。不同型号存在额外约束,详细请参见[约束说明](#约束说明)。 | |
| 36 | | out_dtype | 输入 | 输出Tensor数据类型。<br>支持:DT_FP16、DT_BF16、DT_FP32。<br>必须与input_conv一致;fixpipe量化场景可单独指定。 | | 35 | | out_dtype | 输入 | 输出Tensor数据类型。<br>支持:DT_FP16、DT_BF16、DT_FP32。<br>必须与input_conv一致;fixpipe量化场景可单独指定。 | |
| 37 | | strides | 输入 | 卷积步长,单向参数。<br>- 1D(1D conv)<br>- 2D(2D conv)<br>- 3D(3D conv)<br>取值范围:[1, 63]。 | | 36 | | strides | 输入 | 卷积步长,单向参数。<br>- 1D(1D conv)<br>- 2D(2D conv)<br>- 3D(3D conv)<br>取值范围:[1, 63]。 | |
| @@ -40,7 +39,7 @@ conv(input_conv, weight, out_dtype, strides, paddings, dilations, *, groups=1, t | |||
| 40 | | groups | 输入 | 分组卷积组数,默认1。<br>取值范围:[1, 65535]。<br>Cin、Cout必须可被groups整除。 | | 39 | | groups | 输入 | 分组卷积组数,默认1。<br>取值范围:[1, 65535]。<br>Cin、Cout必须可被groups整除。 | |
| 41 | | transposed | 输入 | 是否为转置卷积(反卷积),默认False。<br>当前暂不支持True。 | | 40 | | transposed | 输入 | 是否为转置卷积(反卷积),默认False。<br>当前暂不支持True。 | |
| 42 | | output_paddings | 输入 | 转置卷积输出端填充,仅transposed=True时使用。<br>当前暂不支持。 | | 41 | | output_paddings | 输入 | 转置卷积输出端填充,仅transposed=True时使用。<br>当前暂不支持。 | |
| 43 | -| extend_params | 输入 | 扩展参数字典,支持bias、scale、relu、scale_tensor:<br>- bias_tensor:可选的偏置张量,形状为(C_out,),仅支持ND格式,不同型号支持的数据类型有所差异,详细请参见[约束说明](#约束说明)。<br>- scale:浮点型,per-tensor缩放因子。<br>- scale_tensor:uint64类型,per-channel缩放Tensor,shape [1, Cout],仅ND格式。<br>- relu_type:激活类型,支持RELU/NO_RELU等(当前暂不支持,详见功能说明)。 | | 42 | +| extend_params | 输入 | 扩展参数字典,支持bias_tensor、scale、relu_type、scale_tensor:<br>- bias_tensor:可选的偏置张量,形状为(Cout,),仅支持ND格式,不同型号支持的数据类型有所差异,详细请参见[约束说明](#约束说明)。<br>- scale:浮点型,per-tensor缩放因子。<br>- scale_tensor:uint64类型,per-channel缩放Tensor,shape [1, Cout],仅ND格式。<br>- relu_type:激活类型,支持RELU/NO_RELU等。 | |
| 44 | 43 | ||
| 45 | ## 返回值说明 | 44 | ## 返回值说明 |
| 46 | 45 | ||
| @@ -59,36 +58,26 @@ conv(input_conv, weight, out_dtype, strides, paddings, dilations, *, groups=1, t | |||
| 59 | - 输入特征图(input_conv):Batch、Cin、Hin、Win、Din维度必须在 [1, 1000000] 范围内; | 58 | - 输入特征图(input_conv):Batch、Cin、Hin、Win、Din维度必须在 [1, 1000000] 范围内; |
| 60 | - 卷积核(weight):Cout、Kh、Kw、Kd维度必须在 [1, 1000000] 范围内; | 59 | - 卷积核(weight):Cout、Kh、Kw、Kd维度必须在 [1, 1000000] 范围内; |
| 61 | - 偏置(bias_tensor):shape必须等于 [Cout],否则校验失败; | 60 | - 偏置(bias_tensor):shape必须等于 [Cout],否则校验失败; |
| 62 | -- 输出特征图:H_out、W_out、D_out维度必须在 [1, 1000000] 范围内。 | 61 | +- 输出特征图:Hout、Wout、Dout维度必须在 [1, 1000000] 范围内。 |
| 63 | 62 | ||
| 64 | ### 2. 属性参数合法性约束 | 63 | ### 2. 属性参数合法性约束 |
| 65 | 64 | ||
| 66 | - 基础维度匹配约束: | 65 | - 基础维度匹配约束: |
| 67 | - strides维度数必须与卷积维度匹配(2D conv长度=2,3D conv长度=3); | 66 | - strides维度数必须与卷积维度匹配(2D conv长度=2,3D conv长度=3); |
| 68 | - dilations维度数必须与卷积维度匹配(2D conv长度=2,3D conv长度=3); | 67 | - dilations维度数必须与卷积维度匹配(2D conv长度=2,3D conv长度=3); |
| 69 | - - paddings维度数必须为2×卷积维度(2D conv长度=4,3D conv长度=6); | 68 | + - paddings维度数必须为2×卷积维度(2D conv长度=4,3D conv长度=6)。 |
| 70 | - 数值范围约束: | 69 | - 数值范围约束: |
| 71 | - strides取值范围 [1, 63]; | 70 | - strides取值范围 [1, 63]; |
| 72 | - dilations取值范围 [1, 63]; | 71 | - dilations取值范围 [1, 63]; |
| 73 | - paddings取值范围 [0, 255],且每维填充值 < 对应卷积核维度大小(如padding_h < Kh、padding_w < Kw); | 72 | - paddings取值范围 [0, 255],且每维填充值 < 对应卷积核维度大小(如padding_h < Kh、padding_w < Kw); |
| 74 | - - groups取值范围 [1, 65535]; | 73 | + - groups取值范围 [1, 65535]。 |
| 75 | - 卷积核约束: | 74 | - 卷积核约束: |
| 76 | - Kh ≤ 255、Kw ≤ 255; | 75 | - Kh ≤ 255、Kw ≤ 255; |
| 77 | - - Kh × Kw × 32bytes/dtype ≤ 65535;dtype为input_conv的数据类型所占bit数,如FP16是16,FP32是32等 | 76 | + - Kh × Kw × 32bytes/dtype ≤ 65535;dtype为input_conv的数据类型所占bit数,如FP16是16,FP32是32等。 |
| 78 | - 通道数约束: | 77 | - 通道数约束: |
| 79 | - Cin(输入通道数)必须能被groups整除; | 78 | - Cin(输入通道数)必须能被groups整除; |
| 80 | - Cout(输出通道数)必须能被groups整除; | 79 | - Cout(输出通道数)必须能被groups整除; |
| 81 | - CinFmap = CinWeight × groups。 | 80 | - CinFmap = CinWeight × groups。 |
| 82 | -- 不同型号的使用约束: | ||
| 83 | - <!-- npu="950" id4 --> | ||
| 84 | - - Ascend 950PR/Ascend 950DT:暂无。 | ||
| 85 | - <!-- end id4 --> | ||
| 86 | - <!-- npu="A3" id5 --> | ||
| 87 | - - Atlas A3 训练系列产品/Atlas A3 推理系列产品:weight的N轴(cout)除以groups后必须为C0的整数倍(C0 = ALIGN_SIZE_32 / sizeof(dtype),ALIGN_SIZE_32 = 32);如果配置cout动态轴切分,切分后的cout除以groups后也必须为C0的整数倍。若input_conv的数据类型为DT_BF16,则bias的数据类型应为DT_FP32。 | ||
| 88 | - <!-- end id5 --> | ||
| 89 | - <!-- npu="910b" id6 --> | ||
| 90 | - - Atlas A2 训练系列产品/Atlas A2 推理系列产品:weight的N轴(cout)除以groups后必须为C0的整数倍(C0 = ALIGN_SIZE_32 / sizeof(dtype),ALIGN_SIZE_32 = 32);如果配置cout动态轴切分,切分后的cout除以groups后也必须为C0的整数倍。若input_conv的数据类型为DT_BF16,则bias的数据类型应为DT_FP32。 | ||
| 91 | - <!-- end id6 --> | ||
| 92 | 81 | ||
| 93 | ### 3. 缓存空间约束 | 82 | ### 3. 缓存空间约束 |
| 94 | 83 | ||
| @@ -111,7 +100,7 @@ conv(input_conv, weight, out_dtype, strides, paddings, dilations, *, groups=1, t | |||
| 111 | | Dout | √ | TileShape动态切分 + 前端循环 | 仅3D卷积支持,Dout维度动态切分 | | 100 | | Dout | √ | TileShape动态切分 + 前端循环 | 仅3D卷积支持,Dout维度动态切分 | |
| 112 | | Hout | √ | TileShape动态切分 + 前端循环 | Hout维度动态切分,配合前端循环实现完整覆盖 | | 101 | | Hout | √ | TileShape动态切分 + 前端循环 | Hout维度动态切分,配合前端循环实现完整覆盖 | |
| 113 | | Wout | √ | TileShape动态切分 + 前端循环 | Wout维度动态切分,配合前端循环实现完整覆盖 | | 102 | | Wout | √ | TileShape动态切分 + 前端循环 | Wout维度动态切分,配合前端循环实现完整覆盖 | |
| 114 | -| Cin | × | - | Cin维度暂不支持动态轴切分,请使用set_conv_tile_shapes()进行k的tile切分实现 | | 103 | +| Cin | × | - | Cin维度暂不支持动态轴切分,请使用set_conv_tile_shapes接口实现Cin和k的tile切分 | |
| 115 | 104 | ||
| 116 | <!-- npu="A3" id7 --> | 105 | <!-- npu="A3" id7 --> |
| 117 | - Atlas A3 训练系列产品/Atlas A3 推理系列产品: | 106 | - Atlas A3 训练系列产品/Atlas A3 推理系列产品: |
| @@ -121,7 +110,7 @@ conv(input_conv, weight, out_dtype, strides, paddings, dilations, *, groups=1, t | |||
| 121 | <!-- end id7 --> | 110 | <!-- end id7 --> |
| 122 | <!-- npu="910b" id8 --> | 111 | <!-- npu="910b" id8 --> |
| 123 | - Atlas A2 训练系列产品/Atlas A2 推理系列产品: | 112 | - Atlas A2 训练系列产品/Atlas A2 推理系列产品: |
| 124 | - - 对于1D 卷积,设置vec_tile_shapes为:{n, c, w},其中,n为16整数倍,c为C0整数倍,C0 = ALIGN_SIZE_32 / sizeof(dtype),ALIGN_SIZE_32 = 32,w为32B对齐。 | 113 | + - 对于1D卷积,设置vec_tile_shapes为:{n, c, w},其中,n为16整数倍,c为C0整数倍,C0 = ALIGN_SIZE_32 / sizeof(dtype),ALIGN_SIZE_32 = 32,w为32B对齐。 |
| 125 | - 对于2D卷积,设置vec_tile_shapes为:{n, c, h, w},其中,n为16整数倍,c为C0整数倍,C0同上,w为32B对齐。 | 114 | - 对于2D卷积,设置vec_tile_shapes为:{n, c, h, w},其中,n为16整数倍,c为C0整数倍,C0同上,w为32B对齐。 |
| 126 | - 对于3D卷积,设置vec_tile_shapes为:{n, c, d, h, w},其中,n为16整数倍,c为C0整数倍,C0同上,w为32B对齐。 | 115 | - 对于3D卷积,设置vec_tile_shapes为:{n, c, d, h, w},其中,n为16整数倍,c为C0整数倍,C0同上,w为32B对齐。 |
| 127 | <!-- end id8 --> | 116 | <!-- end id8 --> |
| @@ -129,13 +118,13 @@ conv(input_conv, weight, out_dtype, strides, paddings, dilations, *, groups=1, t | |||
| 129 | ### 6. 数据类型约束 | 118 | ### 6. 数据类型约束 |
| 130 | 119 | ||
| 131 | <!-- npu="950" id9 --> | 120 | <!-- npu="950" id9 --> |
| 132 | -- Ascend 950PR/Ascend 950DT:支持的数据类型为DT_FP16、DT_BF16、DT_FP32。input、weight、bias和output的数据类型需要相同。 | 121 | +- Ascend 950PR/Ascend 950DT:支持的数据类型为DT_FP16、DT_BF16、DT_FP32。input_conv、weight、bias和out的数据类型需要相同。 |
| 133 | <!-- end id9 --> | 122 | <!-- end id9 --> |
| 134 | <!-- npu="A3" id10 --> | 123 | <!-- npu="A3" id10 --> |
| 135 | -- Atlas A3 训练系列产品/Atlas A3 推理系列产品:支持的数据类型为DT_FP16、DT_BF16、DT_FP32。对于DT_FP16和DT_FP32类型,input、weight、bias和output的数据类型需要相同;对于DT_BF16类型,input、weight和output为BF16类型,bias需为DT_FP32类型。 | 124 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:支持的数据类型为DT_FP16、DT_BF16、DT_FP32。对于DT_FP16和DT_FP32类型,input_conv、weight、bias和out的数据类型需要相同;对于DT_BF16类型,input_conv、weight和out为DT_BF16类型,bias需为DT_FP32类型。 |
| 136 | <!-- end id10 --> | 125 | <!-- end id10 --> |
| 137 | <!-- npu="910b" id11 --> | 126 | <!-- npu="910b" id11 --> |
| 138 | -- Atlas A2 训练系列产品/Atlas A2 推理系列产品:支持的数据类型为DT_FP16、DT_BF16、DT_FP32。对于DT_FP16和DT_FP32类型,input、weight、bias和output的数据类型需要相同;对于DT_BF16类型,input、weight和output为BF16类型,bias需为DT_FP32类型。 | 127 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:支持的数据类型为DT_FP16、DT_BF16、DT_FP32。对于DT_FP16和DT_FP32类型,input_conv、weight、bias和out的数据类型需要相同;对于DT_BF16类型,input_conv、weight和out为DT_BF16类型,bias需为DT_FP32类型。 |
| 139 | <!-- end id11 --> | 128 | <!-- end id11 --> |
| 140 | 129 | ||
| 141 | ## 调用示例 | 130 | ## 调用示例 |
| @@ -150,11 +139,11 @@ out = pypto.conv(input_conv, weight, pypto.DT_FP16, | |||
| 150 | paddings=[0, 0, 0, 0], | 139 | paddings=[0, 0, 0, 0], |
| 151 | dilations=[1, 1]) | 140 | dilations=[1, 1]) |
| 152 | 141 | ||
| 153 | -# 2D卷积带bias | 142 | +# 2D卷积带bias和ReLu |
| 154 | input_conv = pypto.tensor((1, 32, 8, 16), pypto.DT_FP16, "input_conv") | 143 | input_conv = pypto.tensor((1, 32, 8, 16), pypto.DT_FP16, "input_conv") |
| 155 | weight = pypto.tensor((32, 32, 1, 1), pypto.DT_FP16, "weight") | 144 | weight = pypto.tensor((32, 32, 1, 1), pypto.DT_FP16, "weight") |
| 156 | bias = pypto.tensor((32,), pypto.DT_FP16, "bias") | 145 | bias = pypto.tensor((32,), pypto.DT_FP16, "bias") |
| 157 | -extend_params = {'bias_tensor': bias} | 146 | +extend_params = {'bias_tensor': bias, 'relu_type': pypto.ConvReLuType.RELU} |
| 158 | 147 | ||
| 159 | out = pypto.conv(input_conv, weight, pypto.DT_FP16, | 148 | out = pypto.conv(input_conv, weight, pypto.DT_FP16, |
| 160 | strides=[1, 1], | 149 | strides=[1, 1], |
| @@ -260,6 +260,8 @@ std::string CodeGenOpNPU::GenMemL0CCopyOutConv() const | |||
| 260 | 260 | ||
| 261 | bool isConv3D = false; | 261 | bool isConv3D = false; |
| 262 | GetOpAttr(Conv::LoadStoreConvOpAttributeKey::isConv3D, isConv3D); | 262 | GetOpAttr(Conv::LoadStoreConvOpAttributeKey::isConv3D, isConv3D); |
| 263 | + int64_t reluType = 0; | ||
| 264 | + GetOpAttr(Conv::LoadStoreConvOpAttributeKey::reluType, reluType); | ||
| 263 | 265 | ||
| 264 | // 获取cutW参数,默认值为0 | 266 | // 获取cutW参数,默认值为0 |
| 265 | int64_t cutW = 0; | 267 | int64_t cutW = 0; |
| @@ -290,7 +292,7 @@ std::string CodeGenOpNPU::GenMemL0CCopyOutConv() const | |||
| 290 | staticOffsets, realM, realN, realCutW, std::to_string(cutW)); | 292 | staticOffsets, realM, realN, realCutW, std::to_string(cutW)); |
| 291 | 293 | ||
| 292 | std::ostringstream oss; | 294 | std::ostringstream oss; |
| 293 | - oss << tileOpName << WrapParamByAngleBrackets({copyOutModeStr, std::to_string(isConv3D)}); | 295 | + oss << tileOpName << WrapParamByAngleBrackets({copyOutModeStr, std::to_string(isConv3D), std::to_string(reluType)}); |
| 294 | oss << WrapParamByParentheses(tileOpParamList) << STMT_END; | 296 | oss << WrapParamByParentheses(tileOpParamList) << STMT_END; |
| 295 | return oss.str(); | 297 | return oss.str(); |
| 296 | } | 298 | } |
| @@ -37,6 +37,7 @@ const std::string LoadStoreConvOpAttributeKey::copyInMode = "COPY_IN_MODE"; | |||
| 37 | const std::string LoadStoreConvOpAttributeKey::copyOutMode = "COPY_OUT_MODE"; | 37 | const std::string LoadStoreConvOpAttributeKey::copyOutMode = "COPY_OUT_MODE"; |
| 38 | const std::string LoadStoreConvOpAttributeKey::isFmap = "IS_FMAP"; | 38 | const std::string LoadStoreConvOpAttributeKey::isFmap = "IS_FMAP"; |
| 39 | const std::string LoadStoreConvOpAttributeKey::isConv3D = "IS_CONV3D"; | 39 | const std::string LoadStoreConvOpAttributeKey::isConv3D = "IS_CONV3D"; |
| 40 | +const std::string LoadStoreConvOpAttributeKey::reluType = "RELU_TYPE"; | ||
| 40 | 41 | ||
| 41 | bool IsArch32Platform() { return Platform::Instance().GetSoc().GetNPUArch() == NPUArch::DAV_2201; } | 42 | bool IsArch32Platform() { return Platform::Instance().GetSoc().GetNPUArch() == NPUArch::DAV_2201; } |
| 42 | std::vector<int64_t> rotateVector(const std::vector<int64_t>& input, size_t shift) | 43 | std::vector<int64_t> rotateVector(const std::vector<int64_t>& input, size_t shift) |
| @@ -472,16 +473,6 @@ void CheckAttrShape(DataType outType, const Tensor& inputTensor, const Tensor& w | |||
| 472 | } | 473 | } |
| 473 | CheckGroupsShape(cinFmap, cinWeight, cOut, groups); | 474 | CheckGroupsShape(cinFmap, cinWeight, cOut, groups); |
| 474 | CheckLoad3dShape(outType, weightTensor, attrParam); | 475 | CheckLoad3dShape(outType, weightTensor, attrParam); |
| 475 | - if (IsArch32Platform()) { | ||
| 476 | - // 由于transdata对于output的转换没有实现消除多余pad,所以当前cout只支持coutPerGroup % c0 = 0 | ||
| 477 | - int64_t c0 = ALIGN_SIZE_32 / BytesOf(weightTensor.GetStorage()->Datatype()); | ||
| 478 | - int64_t coutPerGroup = weightTensor.GetShape()[NCHW_N_IDX] / groups; | ||
| 479 | - CHECK(ExternalError::INVALID_VAL, coutPerGroup % c0 == 0) | ||
| 480 | - << "The tiled Cout per group (" << coutPerGroup << ") must be a multiple of " << c0 | ||
| 481 | - << " (c0 = 32 / sizeof(dtype)). " | ||
| 482 | - << "Current tiled Cout(" << weightTensor.GetShape()[NCHW_N_IDX] << ") / groups(" << groups | ||
| 483 | - << ") = " << coutPerGroup << " is not divisible by " << c0 << "."; | ||
| 484 | - } | ||
| 485 | } | 476 | } |
| 486 | 477 | ||
| 487 | void CheckOriginShape(const Tensor& inputTensor, const Tensor& weightTensor, const Tensor& biasTensor) | 478 | void CheckOriginShape(const Tensor& inputTensor, const Tensor& weightTensor, const Tensor& biasTensor) |
| @@ -528,6 +519,7 @@ void SetTensorOpAttr(Operation& op, const LogicalTensorPtr& inputTensor, const L | |||
| 528 | op.SetAttribute(CONV_ORI_WEIGHT_SHAPE_ATTR, weightTensor->GetShape()); | 519 | op.SetAttribute(CONV_ORI_WEIGHT_SHAPE_ATTR, weightTensor->GetShape()); |
| 529 | op.SetAttribute(CONV_ORI_RES_SHAPE_ATTR, resTensor->GetShape()); | 520 | op.SetAttribute(CONV_ORI_RES_SHAPE_ATTR, resTensor->GetShape()); |
| 530 | op.SetAttribute("dynamicResValidShape", resTensor->GetDynValidShape()); | 521 | op.SetAttribute("dynamicResValidShape", resTensor->GetDynValidShape()); |
| 522 | + op.SetAttribute(CONV_RELU_ATTR, convAttrParam.reluType); | ||
| 531 | } | 523 | } |
| 532 | 524 | ||
| 533 | std::vector<LogicalTensorPtr> GetOperandVecIn(std::vector<LogicalTensorPtr> operandVecIn, | 525 | std::vector<LogicalTensorPtr> GetOperandVecIn(std::vector<LogicalTensorPtr> operandVecIn, |
| @@ -715,6 +707,7 @@ void SetConvAttrParam(const Operation& op, ConvAttrParam& convAttrParam) | |||
| 715 | CONV2D_ATTR_DEFAULT_LIST; | 707 | CONV2D_ATTR_DEFAULT_LIST; |
| 716 | convAttrParam.groups = (op.HasAttr(CONV_GROUPS_ATTR)) ? op.GetIntAttribute(CONV_GROUPS_ATTR) : 1; | 708 | convAttrParam.groups = (op.HasAttr(CONV_GROUPS_ATTR)) ? op.GetIntAttribute(CONV_GROUPS_ATTR) : 1; |
| 717 | convAttrParam.hasBias = (op.HasAttr(CONV_BIAS_ATTR)) ? op.GetBoolAttribute(CONV_BIAS_ATTR) : false; | 709 | convAttrParam.hasBias = (op.HasAttr(CONV_BIAS_ATTR)) ? op.GetBoolAttribute(CONV_BIAS_ATTR) : false; |
| 710 | + convAttrParam.reluType = (op.HasAttr(CONV_RELU_ATTR)) ? op.GetIntAttribute(CONV_RELU_ATTR) : 0; | ||
| 718 | convAttrParam.isInOutTensorNZ = false; | 711 | convAttrParam.isInOutTensorNZ = false; |
| 719 | ASSERT(ConvExpandFuncError::EXPANDFUNC_TENSOR_ATTR_GET_FAILED, op.HasAttr(CONV_ORI_FMAP_SHAPE_ATTR)) | 712 | ASSERT(ConvExpandFuncError::EXPANDFUNC_TENSOR_ATTR_GET_FAILED, op.HasAttr(CONV_ORI_FMAP_SHAPE_ATTR)) |
| 720 | << "Conv ori fmapshape should be set when InOut Tensor NZ mode."; | 713 | << "Conv ori fmapshape should be set when InOut Tensor NZ mode."; |
| @@ -1245,6 +1238,7 @@ void ConstrucCopyOutTile(Function& function, const ConvAttrParam& convAttrParam, | |||
| 1245 | {tensorGraphNodes.resTensorPtr}); | 1238 | {tensorGraphNodes.resTensorPtr}); |
| 1246 | fixpipeOpRes.SetAttribute(OpAttributeKey::isConv, true); | 1239 | fixpipeOpRes.SetAttribute(OpAttributeKey::isConv, true); |
| 1247 | fixpipeOpRes.SetAttribute(LoadStoreConvOpAttributeKey::isConv3D, convAttrParam.isConv3D); | 1240 | fixpipeOpRes.SetAttribute(LoadStoreConvOpAttributeKey::isConv3D, convAttrParam.isConv3D); |
| 1241 | + fixpipeOpRes.SetAttribute(LoadStoreConvOpAttributeKey::reluType, convAttrParam.reluType); | ||
| 1248 | 1242 | ||
| 1249 | resCl0TensorPtr->UpdateDynValidShape(dstCL0DynValidShape); | 1243 | resCl0TensorPtr->UpdateDynValidShape(dstCL0DynValidShape); |
| 1250 | 1244 | ||
| @@ -1258,11 +1252,16 @@ void ConstrucCopyOutTile(Function& function, const ConvAttrParam& convAttrParam, | |||
| 1258 | if (IsArch32Platform()) { | 1252 | if (IsArch32Platform()) { |
| 1259 | fixpipeOpRes.SetAttribute(LoadStoreConvOpAttributeKey::copyOutMode, | 1253 | fixpipeOpRes.SetAttribute(LoadStoreConvOpAttributeKey::copyOutMode, |
| 1260 | static_cast<int64_t>(CopyOutMode::COPY_MOD_NZ2NZ)); | 1254 | static_cast<int64_t>(CopyOutMode::COPY_MOD_NZ2NZ)); |
| 1255 | + std::vector<SymbolicScalar> dstCL0DynValidShapeAlignedN = std::vector<SymbolicScalar>{ | ||
| 1256 | + convTileInfo.dynValidBatchL0 * convTileInfo.dynValidDoutL0 * convTileInfo.dynValidHoutL0 * | ||
| 1257 | + convTileInfo.dynValidWoutL0, | ||
| 1258 | + (convTileInfo.dynValidCoutL0 + convTileInfo.cin0 - 1) / convTileInfo.cin0 * convTileInfo.cin0}; | ||
| 1259 | + fixpipeOpRes.SetAttribute(OpAttributeKey::l0cValidMN, dstCL0DynValidShapeAlignedN); | ||
| 1261 | } else { | 1260 | } else { |
| 1262 | fixpipeOpRes.SetAttribute(LoadStoreConvOpAttributeKey::copyOutMode, | 1261 | fixpipeOpRes.SetAttribute(LoadStoreConvOpAttributeKey::copyOutMode, |
| 1263 | static_cast<int64_t>(CopyOutMode::COPY_MOD_NZ2DN)); | 1262 | static_cast<int64_t>(CopyOutMode::COPY_MOD_NZ2DN)); |
| 1263 | + fixpipeOpRes.SetAttribute(OpAttributeKey::l0cValidMN, dstCL0DynValidShape); | ||
| 1264 | } | 1264 | } |
| 1265 | - fixpipeOpRes.SetAttribute(OpAttributeKey::l0cValidMN, dstCL0DynValidShape); | ||
| 1266 | 1265 | ||
| 1267 | std::vector<int64_t> dstResGmOffset = GetCopyOutDstOffset(convAttrParam, convTileInfo, iterInfo); | 1266 | std::vector<int64_t> dstResGmOffset = GetCopyOutDstOffset(convAttrParam, convTileInfo, iterInfo); |
| 1268 | auto copyAttr = std::make_shared<CopyOpAttribute>( | 1267 | auto copyAttr = std::make_shared<CopyOpAttribute>( |
| @@ -1559,6 +1558,7 @@ Tensor Conv(DataType outType, const Tensor& inputTensor, const Tensor& weightTen | |||
| 1559 | const Tensor& biasTensor = extendParam.biasTensor; | 1558 | const Tensor& biasTensor = extendParam.biasTensor; |
| 1560 | // init and set attr | 1559 | // init and set attr |
| 1561 | ConvAttrParam convAttrParam(finalPaddings, finalStrides, finalDilations, groups); | 1560 | ConvAttrParam convAttrParam(finalPaddings, finalStrides, finalDilations, groups); |
| 1561 | + convAttrParam.reluType = static_cast<int64_t>(extendParam.reluType); | ||
| 1562 | CheckConvOperands(outType, inputTensor, weightTensor, biasTensor, convAttrParam); | 1562 | CheckConvOperands(outType, inputTensor, weightTensor, biasTensor, convAttrParam); |
| 1563 | std::vector<int64_t> resTensorShape = GetResTensorShape(outType, inputTensor, weightTensor, convAttrParam); | 1563 | std::vector<int64_t> resTensorShape = GetResTensorShape(outType, inputTensor, weightTensor, convAttrParam); |
| 1564 | std::vector<SymbolicScalar> resTensorDynValidShape = GetResTensorDynValidShape(outType, inputTensor, weightTensor, | 1564 | std::vector<SymbolicScalar> resTensorDynValidShape = GetResTensorDynValidShape(outType, inputTensor, weightTensor, |
| @@ -237,6 +237,7 @@ const std::string A_MUL_B_ACT_M = OP_ATTR_PREFIX + "act_m"; | |||
| 237 | const std::string A_MUL_B_ACT_K = OP_ATTR_PREFIX + "act_k"; | 237 | const std::string A_MUL_B_ACT_K = OP_ATTR_PREFIX + "act_k"; |
| 238 | const std::string A_MUL_B_ACT_N = OP_ATTR_PREFIX + "act_n"; | 238 | const std::string A_MUL_B_ACT_N = OP_ATTR_PREFIX + "act_n"; |
| 239 | const std::string A_MUL_B_BIAS_ATTR = OP_ATTR_PREFIX + "has_bias"; | 239 | const std::string A_MUL_B_BIAS_ATTR = OP_ATTR_PREFIX + "has_bias"; |
| 240 | +const std::string CONV_RELU_ATTR = OP_ATTR_PREFIX + "relu_type"; | ||
| 240 | const std::vector<int64_t> CONV2D_ATTR_DEFAULT_LIST = {1, 1}; | 241 | const std::vector<int64_t> CONV2D_ATTR_DEFAULT_LIST = {1, 1}; |
| 241 | const std::vector<int64_t> CONV3D_ATTR_DEFAULT_LIST = {1, 1, 1}; | 242 | const std::vector<int64_t> CONV3D_ATTR_DEFAULT_LIST = {1, 1, 1}; |
| 242 | const std::vector<int64_t> CONV2D_PAD_ATTR_DEFAULT_LIST = {0, 0, 0, 0}; | 243 | const std::vector<int64_t> CONV2D_PAD_ATTR_DEFAULT_LIST = {0, 0, 0, 0}; |
| @@ -250,6 +251,7 @@ public: | |||
| 250 | static const std::string isConv3D; | 251 | static const std::string isConv3D; |
| 251 | static const std::string cutW; // L0C M方向(hw合轴)的w大小 | 252 | static const std::string cutW; // L0C M方向(hw合轴)的w大小 |
| 252 | static const std::string realCutW; // L0C M方向(hw合轴)的w的validshape | 253 | static const std::string realCutW; // L0C M方向(hw合轴)的w的validshape |
| 254 | + static const std::string reluType; | ||
| 253 | }; | 255 | }; |
| 254 | 256 | ||
| 255 | enum class CopyInMode : int { | 257 | enum class CopyInMode : int { |
| @@ -281,6 +283,7 @@ struct ConvAttrParam { | |||
| 281 | bool isConv1D = false; | 283 | bool isConv1D = false; |
| 282 | bool isConv3D = false; | 284 | bool isConv3D = false; |
| 283 | bool hasBias = false; | 285 | bool hasBias = false; |
| 286 | + int64_t reluType = 0; | ||
| 284 | bool isInOutTensorNZ = false; | 287 | bool isInOutTensorNZ = false; |
| 285 | 288 | ||
| 286 | ConvAttrParam() = default; | 289 | ConvAttrParam() = default; |
| @@ -45,7 +45,7 @@ TILEOP void TLoadConv(T& dst, U& src, const int64_t& offset0, const int64_t& off | |||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | // Copy data from L0C to DDR | 47 | // Copy data from L0C to DDR |
| 48 | -template <CopyOutMode mode, bool isConv3D, typename T, typename U> | 48 | +template <CopyOutMode mode, bool isConv3D, int64_t reluType, typename T, typename U> |
| 49 | TILEOP void TStoreConv(T& dst, U& src, const int64_t& offset0, const int64_t& offset1, const int64_t& offset2, | 49 | TILEOP void TStoreConv(T& dst, U& src, const int64_t& offset0, const int64_t& offset1, const int64_t& offset2, |
| 50 | const int64_t& offset3, const int64_t& offset4, const int64_t& realM, const int64_t& realN, | 50 | const int64_t& offset3, const int64_t& offset4, const int64_t& realM, const int64_t& realN, |
| 51 | const int64_t& realCutW, const int64_t& cutW) | 51 | const int64_t& realCutW, const int64_t& cutW) |
| @@ -57,9 +57,9 @@ TILEOP void TStoreConv(T& dst, U& src, const int64_t& offset0, const int64_t& of | |||
| 57 | OffsetInfo offsetInfo = {offset0, offset1, offset2, offset3, offset4}; | 57 | OffsetInfo offsetInfo = {offset0, offset1, offset2, offset3, offset4}; |
| 58 | if constexpr (mode == CopyOutMode::NZ2ND) { | 58 | if constexpr (mode == CopyOutMode::NZ2ND) { |
| 59 | } else if constexpr (mode == CopyOutMode::NZ2DN) { | 59 | } else if constexpr (mode == CopyOutMode::NZ2DN) { |
| 60 | - TStoreConvNZ2DN<isConv3D>(dst, src, offsetInfo, realM, realN, realCutW, cutW); | 60 | + TStoreConvNZ2DN<isConv3D, reluType>(dst, src, offsetInfo, realM, realN, realCutW, cutW); |
| 61 | } else if constexpr (mode == CopyOutMode::NZ2NZ) { | 61 | } else if constexpr (mode == CopyOutMode::NZ2NZ) { |
| 62 | - TStoreConvNZ2NZ<isConv3D>(dst, src, offsetInfo, realM, realN, realCutW, cutW); | 62 | + TStoreConvNZ2NZ<isConv3D, reluType>(dst, src, offsetInfo, realM, realN, realCutW, cutW); |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | 65 | ||
| @@ -27,7 +27,7 @@ | |||
| 27 | * offset3: dst_w_offset | 27 | * offset3: dst_w_offset |
| 28 | * offset4: 0 (占位) | 28 | * offset4: 0 (占位) |
| 29 | */ | 29 | */ |
| 30 | -template <typename T, typename U> | 30 | +template <int64_t reluType, typename T, typename U> |
| 31 | INLINE void TStoreConv2DNZ2DN(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, | 31 | INLINE void TStoreConv2DNZ2DN(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, |
| 32 | const int64_t& realCutW, const int64_t& cutW) | 32 | const int64_t& realCutW, const int64_t& cutW) |
| 33 | { | 33 | { |
| @@ -56,7 +56,8 @@ INLINE void TStoreConv2DNZ2DN(T& dst, U& src, const OffsetInfo& offsetInfo, cons | |||
| 56 | strideDim4(dstStrideN, dstStrideC, dstStrideH, dstStrideW)); | 56 | strideDim4(dstStrideN, dstStrideC, dstStrideH, dstStrideW)); |
| 57 | tileData srcL0C(realCutW, realN); | 57 | tileData srcL0C(realCutW, realN); |
| 58 | pto::TASSIGN(srcL0C, (uint64_t)src.GetAddr() + loopH * cutW * BLOCK_CUBE_M_N * sizeof(typename U::Type)); | 58 | pto::TASSIGN(srcL0C, (uint64_t)src.GetAddr() + loopH * cutW * BLOCK_CUBE_M_N * sizeof(typename U::Type)); |
| 59 | - pto::TSTORE(dstGlobal, srcL0C); | 59 | + pto::TSTORE<tileData, globalData, pto::AtomicType::AtomicNone, |
| 60 | + reluType == 0 ? pto::ReluPreMode::NoRelu : pto::ReluPreMode::NormalRelu>(dstGlobal, srcL0C); | ||
| 60 | gmOffset += dstW; | 61 | gmOffset += dstW; |
| 61 | } | 62 | } |
| 62 | } | 63 | } |
| @@ -71,7 +72,7 @@ INLINE void TStoreConv2DNZ2DN(T& dst, U& src, const OffsetInfo& offsetInfo, cons | |||
| 71 | * offset3: dst_h_offset | 72 | * offset3: dst_h_offset |
| 72 | * offset4: dst_w_offset | 73 | * offset4: dst_w_offset |
| 73 | */ | 74 | */ |
| 74 | -template <typename T, typename U> | 75 | +template <int64_t reluType, typename T, typename U> |
| 75 | INLINE void TStoreConv3DNZ2DN(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, | 76 | INLINE void TStoreConv3DNZ2DN(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, |
| 76 | const int64_t& realCutW, const int64_t& cutW) | 77 | const int64_t& realCutW, const int64_t& cutW) |
| 77 | { | 78 | { |
| @@ -102,18 +103,19 @@ INLINE void TStoreConv3DNZ2DN(T& dst, U& src, const OffsetInfo& offsetInfo, cons | |||
| 102 | strideDim5(dstStrideN, dstStrideC, dstStrideD, dstStrideH, dstStrideW)); | 103 | strideDim5(dstStrideN, dstStrideC, dstStrideD, dstStrideH, dstStrideW)); |
| 103 | tileData srcL0C(realCutW, realN); | 104 | tileData srcL0C(realCutW, realN); |
| 104 | pto::TASSIGN(srcL0C, (uint64_t)src.GetAddr() + loopH * cutW * BLOCK_CUBE_M_N * sizeof(typename U::Type)); | 105 | pto::TASSIGN(srcL0C, (uint64_t)src.GetAddr() + loopH * cutW * BLOCK_CUBE_M_N * sizeof(typename U::Type)); |
| 105 | - pto::TSTORE(dstGlobal, srcL0C); | 106 | + pto::TSTORE<tileData, globalData, pto::AtomicType::AtomicNone, |
| 107 | + reluType == 0 ? pto::ReluPreMode::NoRelu : pto::ReluPreMode::NormalRelu>(dstGlobal, srcL0C); | ||
| 106 | } | 108 | } |
| 107 | } | 109 | } |
| 108 | 110 | ||
| 109 | -template <bool isConv3D, typename T, typename U> | 111 | +template <bool isConv3D, int64_t reluType, typename T, typename U> |
| 110 | INLINE void TStoreConvNZ2DN(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, | 112 | INLINE void TStoreConvNZ2DN(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, |
| 111 | const int64_t& realCutW, const int64_t& cutW) | 113 | const int64_t& realCutW, const int64_t& cutW) |
| 112 | { | 114 | { |
| 113 | if constexpr (isConv3D) { | 115 | if constexpr (isConv3D) { |
| 114 | - TStoreConv3DNZ2DN(dst, src, offsetInfo, realM, realN, realCutW, cutW); | 116 | + TStoreConv3DNZ2DN<reluType>(dst, src, offsetInfo, realM, realN, realCutW, cutW); |
| 115 | } else { | 117 | } else { |
| 116 | - TStoreConv2DNZ2DN(dst, src, offsetInfo, realM, realN, realCutW, cutW); | 118 | + TStoreConv2DNZ2DN<reluType>(dst, src, offsetInfo, realM, realN, realCutW, cutW); |
| 117 | } | 119 | } |
| 118 | } | 120 | } |
| 119 | 121 | ||
| @@ -28,7 +28,7 @@ | |||
| 28 | * offset3: W | 28 | * offset3: W |
| 29 | * offset4: 0 | 29 | * offset4: 0 |
| 30 | */ | 30 | */ |
| 31 | -template <typename T, typename U> | 31 | +template <int64_t reluType, typename T, typename U> |
| 32 | INLINE void TStoreConv2DNZ2NZ(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, | 32 | INLINE void TStoreConv2DNZ2NZ(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, |
| 33 | const int64_t& realCutW, const int64_t& cutW) | 33 | const int64_t& realCutW, const int64_t& cutW) |
| 34 | { | 34 | { |
| @@ -60,7 +60,8 @@ INLINE void TStoreConv2DNZ2NZ(T& dst, U& src, const OffsetInfo& offsetInfo, cons | |||
| 60 | strideDim(dstStrideN, dstStrideC1, dstStrideH, dstStrideW, dstStrideC0)); | 60 | strideDim(dstStrideN, dstStrideC1, dstStrideH, dstStrideW, dstStrideC0)); |
| 61 | tileData srcL0C(realCutW, realN); | 61 | tileData srcL0C(realCutW, realN); |
| 62 | pto::TASSIGN(srcL0C, (uint64_t)src.GetAddr() + loopH * cutW * BLOCK_CUBE_M_N * sizeof(typename U::Type)); | 62 | pto::TASSIGN(srcL0C, (uint64_t)src.GetAddr() + loopH * cutW * BLOCK_CUBE_M_N * sizeof(typename U::Type)); |
| 63 | - pto::TSTORE(dstGlobal, srcL0C); | 63 | + pto::TSTORE<tileData, globalData, pto::AtomicType::AtomicNone, |
| 64 | + reluType == 0 ? pto::ReluPreMode::NoRelu : pto::ReluPreMode::NormalRelu>(dstGlobal, srcL0C); | ||
| 64 | gmOffset += dstStrideH; | 65 | gmOffset += dstStrideH; |
| 65 | } | 66 | } |
| 66 | } | 67 | } |
| @@ -76,7 +77,7 @@ INLINE void TStoreConv2DNZ2NZ(T& dst, U& src, const OffsetInfo& offsetInfo, cons | |||
| 76 | * offset3: H | 77 | * offset3: H |
| 77 | * offset4: W | 78 | * offset4: W |
| 78 | */ | 79 | */ |
| 79 | -template <typename T, typename U> | 80 | +template <int64_t reluType, typename T, typename U> |
| 80 | INLINE void TStoreConv3DNZ2NZ(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, | 81 | INLINE void TStoreConv3DNZ2NZ(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, |
| 81 | const int64_t& realCutW, const int64_t& cutW) | 82 | const int64_t& realCutW, const int64_t& cutW) |
| 82 | { | 83 | { |
| @@ -108,19 +109,20 @@ INLINE void TStoreConv3DNZ2NZ(T& dst, U& src, const OffsetInfo& offsetInfo, cons | |||
| 108 | strideDim(dstStrideN, dstStrideD, dstStrideC1, dstStrideH, dstStrideW)); | 109 | strideDim(dstStrideN, dstStrideD, dstStrideC1, dstStrideH, dstStrideW)); |
| 109 | tileData srcL0C(realCutW, realN); | 110 | tileData srcL0C(realCutW, realN); |
| 110 | pto::TASSIGN(srcL0C, (uint64_t)src.GetAddr() + loopH * cutW * BLOCK_CUBE_M_N * sizeof(typename U::Type)); | 111 | pto::TASSIGN(srcL0C, (uint64_t)src.GetAddr() + loopH * cutW * BLOCK_CUBE_M_N * sizeof(typename U::Type)); |
| 111 | - pto::TSTORE(dstGlobal, srcL0C); | 112 | + pto::TSTORE<tileData, globalData, pto::AtomicType::AtomicNone, |
| 113 | + reluType == 0 ? pto::ReluPreMode::NoRelu : pto::ReluPreMode::NormalRelu>(dstGlobal, srcL0C); | ||
| 112 | gmOffset += dstStrideH; | 114 | gmOffset += dstStrideH; |
| 113 | } | 115 | } |
| 114 | } | 116 | } |
| 115 | 117 | ||
| 116 | -template <bool isConv3D, typename T, typename U> | 118 | +template <bool isConv3D, int64_t reluType, typename T, typename U> |
| 117 | INLINE void TStoreConvNZ2NZ(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, | 119 | INLINE void TStoreConvNZ2NZ(T& dst, U& src, const OffsetInfo& offsetInfo, const int64_t& realM, const int64_t& realN, |
| 118 | const int64_t& realCutW, const int64_t& cutW) | 120 | const int64_t& realCutW, const int64_t& cutW) |
| 119 | { | 121 | { |
| 120 | if constexpr (isConv3D) { | 122 | if constexpr (isConv3D) { |
| 121 | - TStoreConv3DNZ2NZ(dst, src, offsetInfo, realM, realN, realCutW, cutW); | 123 | + TStoreConv3DNZ2NZ<reluType>(dst, src, offsetInfo, realM, realN, realCutW, cutW); |
| 122 | } else { | 124 | } else { |
| 123 | - TStoreConv2DNZ2NZ(dst, src, offsetInfo, realM, realN, realCutW, cutW); | 125 | + TStoreConv2DNZ2NZ<reluType>(dst, src, offsetInfo, realM, realN, realCutW, cutW); |
| 124 | } | 126 | } |
| 125 | } | 127 | } |
| 126 | 128 | ||
| @@ -250,8 +250,8 @@ TEST_F(TestCodegenDynConv, L0COutTileTensorConv2D) | |||
| 250 | std::vector<int64_t> gmShape = {1, 16, 2, 32}; | 250 | std::vector<int64_t> gmShape = {1, 16, 2, 32}; |
| 251 | std::string res = TestConvL0COutBody("L0COutTileTensorConv2D", l0cShape, SymbolicScalar::FromConcrete(l0cShape), | 251 | std::string res = TestConvL0COutBody("L0COutTileTensorConv2D", l0cShape, SymbolicScalar::FromConcrete(l0cShape), |
| 252 | gmShape); | 252 | gmShape); |
| 253 | - std::string | 253 | + std::string expect = |
| 254 | - expect = R"!!!(TStoreConv<CopyOutMode::NZ2DN, 0>(gmTensor_9, l0cTensor_10, 0, 0, 0, 0, 0, 32, 16, 16, 16);)!!!"; | 254 | + R"!!!(TStoreConv<CopyOutMode::NZ2DN, 0, 0>(gmTensor_9, l0cTensor_10, 0, 0, 0, 0, 0, 32, 16, 16, 16);)!!!"; |
| 255 | CheckStringExist(expect, res); | 255 | CheckStringExist(expect, res); |
| 256 | } | 256 | } |
| 257 | 257 | ||
| @@ -261,8 +261,8 @@ TEST_F(TestCodegenDynConv, L0COutTileTensorConv2DTailTensor) | |||
| 261 | std::vector<SymbolicScalar> l0cValidShape = {16, 16}; | 261 | std::vector<SymbolicScalar> l0cValidShape = {16, 16}; |
| 262 | std::vector<int64_t> gmShape = {1, 32, 2, 32}; | 262 | std::vector<int64_t> gmShape = {1, 32, 2, 32}; |
| 263 | std::string res = TestConvL0COutBody("L0COutTileTensorConv2D", l0cShape, l0cValidShape, gmShape); | 263 | std::string res = TestConvL0COutBody("L0COutTileTensorConv2D", l0cShape, l0cValidShape, gmShape); |
| 264 | - std::string | 264 | + std::string expect = |
| 265 | - expect = R"!!!(TStoreConv<CopyOutMode::NZ2DN, 0>(gmTensor_9, l0cTensor_10, 0, 0, 0, 0, 0, 16, 16, 16, 16);)!!!"; | 265 | + R"!!!(TStoreConv<CopyOutMode::NZ2DN, 0, 0>(gmTensor_9, l0cTensor_10, 0, 0, 0, 0, 0, 16, 16, 16, 16);)!!!"; |
| 266 | CheckStringExist(expect, res); | 266 | CheckStringExist(expect, res); |
| 267 | } | 267 | } |
| 268 | 268 | ||
| @@ -272,8 +272,8 @@ TEST_F(TestCodegenDynConv, L0COutTileTensorConv3D) | |||
| 272 | std::vector<int64_t> gmShape = {1, 16, 1, 2, 32}; | 272 | std::vector<int64_t> gmShape = {1, 16, 1, 2, 32}; |
| 273 | std::string res = TestConvL0COutBody("L0COutTileTensorConv3D", l0cShape, SymbolicScalar::FromConcrete(l0cShape), | 273 | std::string res = TestConvL0COutBody("L0COutTileTensorConv3D", l0cShape, SymbolicScalar::FromConcrete(l0cShape), |
| 274 | gmShape, COPY_OUT_MODE_NZ2DN, true); | 274 | gmShape, COPY_OUT_MODE_NZ2DN, true); |
| 275 | - std::string | 275 | + std::string expect = |
| 276 | - expect = R"!!!(TStoreConv<CopyOutMode::NZ2DN, 1>(gmTensor_9, l0cTensor_10, 0, 0, 0, 0, 0, 32, 16, 16, 16);)!!!"; | 276 | + R"!!!(TStoreConv<CopyOutMode::NZ2DN, 1, 0>(gmTensor_9, l0cTensor_10, 0, 0, 0, 0, 0, 32, 16, 16, 16);)!!!"; |
| 277 | CheckStringExist(expect, res); | 277 | CheckStringExist(expect, res); |
| 278 | } | 278 | } |
| 279 | 279 | ||
| @@ -283,8 +283,8 @@ TEST_F(TestCodegenDynConv, L0COutNZ2NZConv2D) | |||
| 283 | std::vector<int64_t> gmShape = {16, 16}; | 283 | std::vector<int64_t> gmShape = {16, 16}; |
| 284 | std::string res = TestConvL0COutBody("L0COutNZ2NZConv2D", l0cShape, SymbolicScalar::FromConcrete(l0cShape), gmShape, | 284 | std::string res = TestConvL0COutBody("L0COutNZ2NZConv2D", l0cShape, SymbolicScalar::FromConcrete(l0cShape), gmShape, |
| 285 | COPY_OUT_MODE_NZ2NZ, false); | 285 | COPY_OUT_MODE_NZ2NZ, false); |
| 286 | - std::string | 286 | + std::string expect = |
| 287 | - expect = R"!!!(TStoreConv<CopyOutMode::NZ2NZ, 0>(gmTensor_9, l0cTensor_10, 0, 0, 0, 0, 0, 16, 16, 16, 16);)!!!"; | 287 | + R"!!!(TStoreConv<CopyOutMode::NZ2NZ, 0, 0>(gmTensor_9, l0cTensor_10, 0, 0, 0, 0, 0, 16, 16, 16, 16);)!!!"; |
| 288 | CheckStringExist(expect, res); | 288 | CheckStringExist(expect, res); |
| 289 | } | 289 | } |
| 290 | 290 | ||
| @@ -294,8 +294,8 @@ TEST_F(TestCodegenDynConv, L0COutNZ2NZConv3D) | |||
| 294 | std::vector<int64_t> gmShape = {16, 16}; | 294 | std::vector<int64_t> gmShape = {16, 16}; |
| 295 | std::string res = TestConvL0COutBody("L0COutNZ2NZConv3D", l0cShape, SymbolicScalar::FromConcrete(l0cShape), gmShape, | 295 | std::string res = TestConvL0COutBody("L0COutNZ2NZConv3D", l0cShape, SymbolicScalar::FromConcrete(l0cShape), gmShape, |
| 296 | COPY_OUT_MODE_NZ2NZ, true); | 296 | COPY_OUT_MODE_NZ2NZ, true); |
| 297 | - std::string | 297 | + std::string expect = |
| 298 | - expect = R"!!!(TStoreConv<CopyOutMode::NZ2NZ, 1>(gmTensor_9, l0cTensor_10, 0, 0, 0, 0, 0, 16, 16, 16, 16);)!!!"; | 298 | + R"!!!(TStoreConv<CopyOutMode::NZ2NZ, 1, 0>(gmTensor_9, l0cTensor_10, 0, 0, 0, 0, 0, 16, 16, 16, 16);)!!!"; |
| 299 | CheckStringExist(expect, res); | 299 | CheckStringExist(expect, res); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| @@ -114,8 +114,8 @@ def conv( | |||
| 114 | Per-tensor scale value for dequantization, quantization, or requantization operations. | 114 | Per-tensor scale value for dequantization, quantization, or requantization operations. |
| 115 | - 'scale_tensor': Tensor | 115 | - 'scale_tensor': Tensor |
| 116 | Per-channel scale tensor for dequantization or requantization operations. | 116 | Per-channel scale tensor for dequantization or requantization operations. |
| 117 | - - 'relu_type': ReLuType | 117 | + - 'relu_type': ConvReLuType |
| 118 | - Type of ReLU activation to apply in fixpipe (e.g., ReLuType.RELU, ReLuType.LEAKY_RELU, ReLuType.PRELU). | 118 | + Type of ReLU activation to apply in fixpipe (e.g., ConvReLuType.RELU). |
| 119 | 119 | ||
| 120 | Returns | 120 | Returns |
| 121 | ------- | 121 | ------- |