1. 系统环境
硬件环境(Ascend/GPU/CPU): Ascend910
MindSpore版本: 2.6.0
执行模式(PyNative/ Graph): PyNative
Python版本: Python=3.10
操作系统平台: Ubuntu18.04
2. 问题信息
2.1 问题描述
使用的mindyolo里的yolov5模型,对比mindspore的yolov5和yolov8,yolov5的推理速度明显缓慢,似乎比yolov8慢了10倍左右,与其它昇腾的om格式的yolov5相比,也明显缓慢。
2.2 脚本信息
class YOLOv5Head(nn.Cell):
def __init__(self, nc=80, anchors=(), stride=(), ch=()): # detection layer
self.m = nn.CellList(
[nn.Conv2d(x, self.no * self.na, 1, pad_mode="valid", has_bias=True) for x in ch]
) # output conv
def construct(self, x):
z = () # inference output
outs = ()
for i in range(self.nl):
out = self.m[i](x[i]) # conv
bs, _, ny, nx = out.shape # (bs, 255, 20, 20)
out = ops.Transpose()(out.view(bs, self.na, self.no, ny, nx), (0, 1, 3, 4, 2)) # (bs, 3, 20, 20, 85)
out = out
outs += (out,)
if not self.training: # inference
grid_tensor = self._make_grid(nx, ny, out.dtype)
y = ops.Sigmoid()(out)
y[..., 0:2] = (y[..., :2] * 2.0 - 0.5 + grid_tensor) * self.stride[i] # xy
y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
z = (y.view(bs, -1, self.no),)
# return outs
return outs if self.training else (ops.concat(z, 1), outs)
3. 根因分析
此处由用户填写
4. 解决方案
此处由用户填写
- 包含文字方案和最终脚本代码
- 请将正确的脚本打包并上传附件