关于gittor的misc.py 下面的cub_cumsum方法是否需要改进?

你好,jittor的团队,我在测试jittor的yolact的时候出现了执行错误。具体log如下:错误位置在ittor的misc.py 下面的cub_cumsum方法。 我可以理解为yolact的数据集造成的错误,但是不知道是什么错误。
数据集是来着yolact的官方。感觉需要在cub_cumsum的方法进行深度处理一下,能否返回错误详情。
同时我做了测试
x[2], x[-1] = x[-1], x[2]
Traceback (most recent call last):
File “”, line 1, in
TypeError: ‘range’ object does not support item assignment
这种写法在python3下面是不支持的
需要对x = range(50)在python3下面转为list(range(50))的形式
希望能够增加代码的兼容性

wjq@air-007:~/Projects/Yolact.jittor$ python3 eval.py --trained_model=oldmodels/yolact_plus_resnet50_54_800000.pth --score_threshold=0.15 --top_k=15 --image=test.jpg:output_result.jpg
[i 0222 15:29:13.322317 88 compiler.py:944] Jittor(1.3.1.39) src: /home/wjq/.local/lib/python3.8/site-packages/jittor
[i 0222 15:29:13.324922 88 compiler.py:945] g++ at /usr/bin/g++(9.4.0)
[i 0222 15:29:13.324982 88 compiler.py:946] cache_path: /home/wjq/.cache/jittor/jt1.3.1/g++9.4.0/py3.8.10/Linux-5.13.0-3x4f/IntelRCoreTMi7x8f/default
[i 0222 15:29:13.332197 88 install_cuda.py:51] cuda_driver_version: [11, 6]
[i 0222 15:29:13.336487 88 __init__.py:372] Found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/bin/nvcc(11.2.152) at /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/bin/nvcc.
[i 0222 15:29:13.370268 88 __init__.py:372] Found gdb(20.04.1) at /usr/bin/gdb.
[i 0222 15:29:13.374193 88 __init__.py:372] Found addr2line(2.34) at /usr/bin/addr2line.
[i 0222 15:29:13.460486 88 compiler.py:999] cuda key:cu11.2.152_sm_86
[i 0222 15:29:13.552961 88 __init__.py:187] Total mem: 125.70GB, using 16 procs for compiling.
[i 0222 15:29:13.616858 88 jit_compiler.cc:27] Load cc_path: /usr/bin/g++
[i 0222 15:29:16.408216 88 init.cc:62] Found cuda archs: [86,]
[i 0222 15:29:16.471940 88 compile_extern.py:497] mpicc not found, distribution disabled.
[i 0222 15:29:16.549161 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/include/cublas.h
[i 0222 15:29:16.607005 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/lib64/libcublas.so
[i 0222 15:29:16.607076 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/lib64/libcublasLt.so.11
[i 0222 15:29:16.985030 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/include/cudnn.h
[i 0222 15:29:17.046606 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/lib64/libcudnn.so.8
[i 0222 15:29:17.046686 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/lib64/libcudnn_ops_infer.so.8
[i 0222 15:29:17.048270 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/lib64/libcudnn_ops_train.so.8
[i 0222 15:29:17.048562 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/lib64/libcudnn_cnn_infer.so.8
[i 0222 15:29:17.060114 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/lib64/libcudnn_cnn_train.so.8
[i 0222 15:29:17.425633 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/include/curand.h
[i 0222 15:29:17.494294 88 compile_extern.py:29] found /home/wjq/.cache/jittor/jtcuda/cuda11.2_cudnn8_linux/lib64/libcurand.so
[i 0222 15:29:17.878659 88 cuda_flags.cc:32] CUDA enabled.
Config not specified. Parsed yolact_plus_resnet50_config from the file name.

Loading model… Done.
range(0, 4)
Traceback (most recent call last):
File “eval.py”, line 1110, in
evaluate(net, dataset)
File “eval.py”, line 888, in evaluate
evalimage(net, inp, out)
File “eval.py”, line 615, in evalimage
img_numpy = prep_display(preds, frame, None, None, undo_transform=False)
File “eval.py”, line 209, in prep_display
inv_alph_cumul = inv_alph_masks[:(num_dets_to_consider-1)].cumprod(dim=0)
File “/home/wjq/.local/lib/python3.8/site-packages/jittor/misc.py”, line 727, in cumprod
x = cumsum(x,dim=dim)
File “/home/wjq/.local/lib/python3.8/site-packages/jittor/misc.py”, line 719, in cumsum
return cub_cumsum(x, dim)
File “/home/wjq/.local/lib/python3.8/site-packages/jittor/misc.py”, line 692, in cub_cumsum
order[dim], order[-1] = order[-1], order[dim]
TypeError: ‘range’ object does not support item assignment
wjq@air-007:~/Projects/Yolact.jittor$

def cub_cumsum(x, dim=None):
if (dim == None):
dim = -1

shape_count = len(x.shape)
assert(dim >= -1 and dim < shape_count)

//修改处:
shape = list(x.shape)
if (dim != -1 and dim != shape_count - 1 and shape_count > 1):

    //修改处:
    order = list(range(shape_count))
    print(order[0:shape_count])
    order[dim], order[-1] = order[-1], order[dim]
    shape[dim], shape[-1] = shape[-1], shape[dim]
    x = x.permute(order)
if (shape_count > 2):
    x = x.reshape([-1, shape[-1]])
x = jt.compile_extern.cub_ops.cub_cumsum(x)
if (shape_count > 2):
    x = x.reshape(shape)
if (dim != -1 and dim != shape_count - 1):
    x = x.permute(order)
return x

非常感谢反馈,最新版已经修复,从github拉取最新的代码安装即可。 :smiley: