Conv3DBackpropFilter 算子 API 描述【免费下载链接】cann-bench评测AI在处理CANN领域代码任务的能力涵盖算子生成、算子优化等领域支撑模型选型、训练效果评估统一量化评估标准识别Agent能力短板构建CANN领域评测平台推动AI能力在CANN领域的持续演进。项目地址: https://gitcode.com/cann/cann-bench1. 算子简介Conv3D的filter梯度。主要应用场景3D 卷积神经网络训练中的反向传播视频理解模型中 Conv3D 层的权重梯度计算医学影像 3D 分割模型的训练过程算子特征难度等级L3Contraction双输入输入特征图和输出梯度单输出filter 梯度输入 x 为 [N, C_in, D, H, W] 5维张量输入 grad 为 [N, C_out, D_out, H_out, W_out] 5维张量2. 算子定义数学公式$$ y \text{conv3d_filter_grad}(x, \text{grad}, \text{filter_size}) $$计算 Conv3D 操作中卷积核filter的梯度。给定前向传播的输入特征图 $x$ 和来自下游的输出梯度 $\text{grad}$通过反向传播计算得到 filter 的梯度 $y$。输出 shape 计算输出 filter 梯度的 shape 由filter_size参数指定$$ \text{shape}(y) [C_{out}, C_{in}/groups, K_d, K_h, K_w] $$其中 grad 的 spatial 维度需满足$$ D_{out} \frac{D_{in} 2 \cdot \text{pad}_d - \text{dilation}_d \cdot (K_d - 1) - 1}{\text{stride}_d} 1 $$3. 接口规范算子原型cann_bench.conv_3d_backprop_filter(Tensor x, Tensor grad, int[] strides, int[] pads, int[] dilations, int groups, int[] filter_size) - Tensor y输入参数说明参数类型默认值描述xTensor必选输入特征图shape 为 [N, C_in, D, H, W]gradTensor必选输出梯度shape 为 [N, C_out, D_out, H_out, W_out]stridesint[]必选步长3元素 [stride_d, stride_h, stride_w]padsint[]必选填充6元素格式 [D_front, D_back, H_top, H_bottom, W_left, W_right]dilationsint[]必选膨胀率3元素 [dilation_d, dilation_h, dilation_w]groupsint1分组数filter_sizeint[]必选filter的shape [C_out, C_in/groups, K_d, K_h, K_w]输出参数Shapedtype描述y[C_out, C_in/groups, K_d, K_h, K_w]与输入 x 相同filter梯度数据类型输入 (x, grad) dtype输出 dtypefloat16float16bfloat16bfloat16规则与约束x 的 shape 格式为 [N, C_in, D, H, W]grad 的 shape 格式为 [N, C_out, D_out, H_out, W_out]x 和 grad 的 dtype 须一致strides 指定 3D 卷积的步长为 3 元素列表pads 指定填充值为 6 元素列表 [D_front, D_back, H_top, H_bottom, W_left, W_right]dilations 指定膨胀率为 3 元素列表groups 指定分组数C_in 和 C_out 都须能被 groups 整除filter_size 指定输出 filter 梯度的 shapegrad 的 spatial 维度必须与 x、filter_size、strides、pads、dilations 计算的输出维度一致支持范围输入 tensor 各维度与参数的支持范围维度 / 参数范围备注Nbatch1 ~ 16cases.csv 实测 2 ~ 5C_in输入通道1 ~ 256cases.csv 实测 7 ~ 128须能被groups整除C_out输出通道1 ~ 512cases.csv 实测 14 ~ 256须能被groups整除Ddepth4 ~ 32cases.csv 实测 4 ~ 17H,W空间8 ~ 256cases.csv 实测 13 ~ 128K_ddepth 卷积核1 ~ 8cases.csv 实测 1 / 3 / 5K_h,K_w空间卷积核1 ~ 16cases.csv 实测 1 / 3 / 5strides[i]1 ~ 4cases.csv 实测 (1,1,1) 和 (2,2,2)pads[i]0 ~ 8cases.csv 实测 0 ~ 2对称dilations[i]1 ~ 16cases.csv 实测 1 / 2groups1 ~ 64cases.csv 实测 1 / 2 / 64须同时整除C_in和C_out约束grad的 spatial 维度(D_out, H_out, W_out)必须与正向 conv3d 由(x.shape, filter_size, strides, pads, dilations)计算出的输出维度一致见 §2 公式。4. 精度要求采用生态算子精度标准进行验证。误差指标平均相对误差MERE采样点中相对误差平均值$$ \text{MERE} \text{avg}(\frac{\text{abs}(actual - golden)}{\text{abs}(golden)\text{1e-7}}) $$最大相对误差MARE采样点中相对误差最大值$$ \text{MARE} \max(\frac{\text{abs}(actual - golden)}{\text{abs}(golden)\text{1e-7}}) $$通过标准数据类型FLOAT16BFLOAT16FLOAT32HiFLOAT32FLOAT8 E4M3FLOAT8 E5M2通过阈值(Threshold)2^-102^-72^-132^-112^-32^-2当平均相对误差 MERE Threshold最大相对误差 MARE 10 * Threshold 时判定为通过。5. 标准 Golden 代码import torch import torch.nn.functional as F Conv3DBackpropFilter算子Torch Golden参考实现 Conv3D的filter梯度 公式: y conv3d_filter_grad(x, grad, filter_size) def conv_3d_backprop_filter( x: torch.Tensor, grad: torch.Tensor, strides: list, pads: list, dilations: list, groups: int 1, filter_size: list None ) - torch.Tensor: Conv3D的filter梯度 公式: y conv3d_filter_grad(x, grad, filter_size) Args: x: 输入特征图shape为[N, C_in, D, H, W] grad: 输出梯度shape为[N, C_out, D_out, H_out, W_out] strides: 步长3元素 [stride_d, stride_h, stride_w] pads: 填充6元素 [D_front, D_back, H_top, H_bottom, W_left, W_right]对称时取front/top/left dilations: 膨胀率3元素 [dilation_d, dilation_h, dilation_w] groups: 分组数 filter_size: filter的shape [C_out, C_in/groups, K_d, K_h, K_w] Returns: filter梯度shape与filter_size相同 # pads 是 6 元素格式对称 padding 时取 (D_front, H_top, W_left) # 即 pads[0], pads[2], pads[4] padding (pads[0], pads[2], pads[4]) stride (strides[0], strides[1], strides[2]) dilation (dilations[0], dilations[1], dilations[2]) # 使用 torch.nn.grad.conv3d_weight 计算 filter 梯度 y F.grad.conv3d_weight(x, tuple(filter_size), grad, stridestride, paddingpadding, dilationdilation, groupsgroups) return y6. 额外信息算子调用示例import torch import cann_bench x torch.randn(2, 64, 8, 16, 16, dtypetorch.float16, devicenpu) grad torch.randn(2, 128, 6, 14, 14, dtypetorch.float16, devicenpu) # filter_size: [C_out, C_in/groups, K_d, K_h, K_w] y cann_bench.conv_3d_backprop_filter(x, grad, strides[1, 1, 1], pads[1, 1, 1, 1, 1, 1], dilations[1, 1, 1], groups1, filter_size[128, 64, 3, 3, 3])【免费下载链接】cann-bench评测AI在处理CANN领域代码任务的能力涵盖算子生成、算子优化等领域支撑模型选型、训练效果评估统一量化评估标准识别Agent能力短板构建CANN领域评测平台推动AI能力在CANN领域的持续演进。项目地址: https://gitcode.com/cann/cann-bench创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
CANN算子:Conv3D反向滤波
发布时间:2026/5/20 19:10:17
Conv3DBackpropFilter 算子 API 描述【免费下载链接】cann-bench评测AI在处理CANN领域代码任务的能力涵盖算子生成、算子优化等领域支撑模型选型、训练效果评估统一量化评估标准识别Agent能力短板构建CANN领域评测平台推动AI能力在CANN领域的持续演进。项目地址: https://gitcode.com/cann/cann-bench1. 算子简介Conv3D的filter梯度。主要应用场景3D 卷积神经网络训练中的反向传播视频理解模型中 Conv3D 层的权重梯度计算医学影像 3D 分割模型的训练过程算子特征难度等级L3Contraction双输入输入特征图和输出梯度单输出filter 梯度输入 x 为 [N, C_in, D, H, W] 5维张量输入 grad 为 [N, C_out, D_out, H_out, W_out] 5维张量2. 算子定义数学公式$$ y \text{conv3d_filter_grad}(x, \text{grad}, \text{filter_size}) $$计算 Conv3D 操作中卷积核filter的梯度。给定前向传播的输入特征图 $x$ 和来自下游的输出梯度 $\text{grad}$通过反向传播计算得到 filter 的梯度 $y$。输出 shape 计算输出 filter 梯度的 shape 由filter_size参数指定$$ \text{shape}(y) [C_{out}, C_{in}/groups, K_d, K_h, K_w] $$其中 grad 的 spatial 维度需满足$$ D_{out} \frac{D_{in} 2 \cdot \text{pad}_d - \text{dilation}_d \cdot (K_d - 1) - 1}{\text{stride}_d} 1 $$3. 接口规范算子原型cann_bench.conv_3d_backprop_filter(Tensor x, Tensor grad, int[] strides, int[] pads, int[] dilations, int groups, int[] filter_size) - Tensor y输入参数说明参数类型默认值描述xTensor必选输入特征图shape 为 [N, C_in, D, H, W]gradTensor必选输出梯度shape 为 [N, C_out, D_out, H_out, W_out]stridesint[]必选步长3元素 [stride_d, stride_h, stride_w]padsint[]必选填充6元素格式 [D_front, D_back, H_top, H_bottom, W_left, W_right]dilationsint[]必选膨胀率3元素 [dilation_d, dilation_h, dilation_w]groupsint1分组数filter_sizeint[]必选filter的shape [C_out, C_in/groups, K_d, K_h, K_w]输出参数Shapedtype描述y[C_out, C_in/groups, K_d, K_h, K_w]与输入 x 相同filter梯度数据类型输入 (x, grad) dtype输出 dtypefloat16float16bfloat16bfloat16规则与约束x 的 shape 格式为 [N, C_in, D, H, W]grad 的 shape 格式为 [N, C_out, D_out, H_out, W_out]x 和 grad 的 dtype 须一致strides 指定 3D 卷积的步长为 3 元素列表pads 指定填充值为 6 元素列表 [D_front, D_back, H_top, H_bottom, W_left, W_right]dilations 指定膨胀率为 3 元素列表groups 指定分组数C_in 和 C_out 都须能被 groups 整除filter_size 指定输出 filter 梯度的 shapegrad 的 spatial 维度必须与 x、filter_size、strides、pads、dilations 计算的输出维度一致支持范围输入 tensor 各维度与参数的支持范围维度 / 参数范围备注Nbatch1 ~ 16cases.csv 实测 2 ~ 5C_in输入通道1 ~ 256cases.csv 实测 7 ~ 128须能被groups整除C_out输出通道1 ~ 512cases.csv 实测 14 ~ 256须能被groups整除Ddepth4 ~ 32cases.csv 实测 4 ~ 17H,W空间8 ~ 256cases.csv 实测 13 ~ 128K_ddepth 卷积核1 ~ 8cases.csv 实测 1 / 3 / 5K_h,K_w空间卷积核1 ~ 16cases.csv 实测 1 / 3 / 5strides[i]1 ~ 4cases.csv 实测 (1,1,1) 和 (2,2,2)pads[i]0 ~ 8cases.csv 实测 0 ~ 2对称dilations[i]1 ~ 16cases.csv 实测 1 / 2groups1 ~ 64cases.csv 实测 1 / 2 / 64须同时整除C_in和C_out约束grad的 spatial 维度(D_out, H_out, W_out)必须与正向 conv3d 由(x.shape, filter_size, strides, pads, dilations)计算出的输出维度一致见 §2 公式。4. 精度要求采用生态算子精度标准进行验证。误差指标平均相对误差MERE采样点中相对误差平均值$$ \text{MERE} \text{avg}(\frac{\text{abs}(actual - golden)}{\text{abs}(golden)\text{1e-7}}) $$最大相对误差MARE采样点中相对误差最大值$$ \text{MARE} \max(\frac{\text{abs}(actual - golden)}{\text{abs}(golden)\text{1e-7}}) $$通过标准数据类型FLOAT16BFLOAT16FLOAT32HiFLOAT32FLOAT8 E4M3FLOAT8 E5M2通过阈值(Threshold)2^-102^-72^-132^-112^-32^-2当平均相对误差 MERE Threshold最大相对误差 MARE 10 * Threshold 时判定为通过。5. 标准 Golden 代码import torch import torch.nn.functional as F Conv3DBackpropFilter算子Torch Golden参考实现 Conv3D的filter梯度 公式: y conv3d_filter_grad(x, grad, filter_size) def conv_3d_backprop_filter( x: torch.Tensor, grad: torch.Tensor, strides: list, pads: list, dilations: list, groups: int 1, filter_size: list None ) - torch.Tensor: Conv3D的filter梯度 公式: y conv3d_filter_grad(x, grad, filter_size) Args: x: 输入特征图shape为[N, C_in, D, H, W] grad: 输出梯度shape为[N, C_out, D_out, H_out, W_out] strides: 步长3元素 [stride_d, stride_h, stride_w] pads: 填充6元素 [D_front, D_back, H_top, H_bottom, W_left, W_right]对称时取front/top/left dilations: 膨胀率3元素 [dilation_d, dilation_h, dilation_w] groups: 分组数 filter_size: filter的shape [C_out, C_in/groups, K_d, K_h, K_w] Returns: filter梯度shape与filter_size相同 # pads 是 6 元素格式对称 padding 时取 (D_front, H_top, W_left) # 即 pads[0], pads[2], pads[4] padding (pads[0], pads[2], pads[4]) stride (strides[0], strides[1], strides[2]) dilation (dilations[0], dilations[1], dilations[2]) # 使用 torch.nn.grad.conv3d_weight 计算 filter 梯度 y F.grad.conv3d_weight(x, tuple(filter_size), grad, stridestride, paddingpadding, dilationdilation, groupsgroups) return y6. 额外信息算子调用示例import torch import cann_bench x torch.randn(2, 64, 8, 16, 16, dtypetorch.float16, devicenpu) grad torch.randn(2, 128, 6, 14, 14, dtypetorch.float16, devicenpu) # filter_size: [C_out, C_in/groups, K_d, K_h, K_w] y cann_bench.conv_3d_backprop_filter(x, grad, strides[1, 1, 1], pads[1, 1, 1, 1, 1, 1], dilations[1, 1, 1], groups1, filter_size[128, 64, 3, 3, 3])【免费下载链接】cann-bench评测AI在处理CANN领域代码任务的能力涵盖算子生成、算子优化等领域支撑模型选型、训练效果评估统一量化评估标准识别Agent能力短板构建CANN领域评测平台推动AI能力在CANN领域的持续演进。项目地址: https://gitcode.com/cann/cann-bench创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考