Jittor / jittor

Jittor is a high-performance deep learning framework based on JIT compiling and meta-operators.
https://cg.cs.tsinghua.edu.cn/jittor/
Apache License 2.0
3.07k stars 307 forks source link

Crash with error happend during compilatio in `jt.nn.conv_transpose/conv_transpose2d/conv_transpose3d` #528

Closed x0w3n closed 3 months ago

x0w3n commented 3 months ago

Describe the bug

When negative values are passed to the stride parameter of jt.nn.conv_transpose/conv_transpose2d/conv_transpose3d, it causes a crash

Full Log

conv_transpose:

[i 0512 08:02:28.069702 48 compiler.py:956] Jittor(1.3.9.6) src: /jittor/python/jittor
[i 0512 08:02:28.072192 48 compiler.py:957] g++ at /usr/bin/g++(8.3.0)
[i 0512 08:02:28.072258 48 compiler.py:958] cache_path: /root/.cache/jittor/jt1.3.9/g++8.3.0/py3.7.4/Linux-5.15.153x56/13thGenIntelRCx56/8c5a/master
[i 0512 08:02:28.076299 48 __init__.py:412] Found addr2line(2.31.1) at /usr/bin/addr2line.
[i 0512 08:02:28.294965 48 __init__.py:227] Total mem: 15.43GB, using 5 procs for compiling.
[i 0512 08:02:28.362284 48 jit_compiler.cc:28] Load cc_path: /usr/bin/g++
Traceback (most recent call last):
  File "test.py", line 69, in <module>
    jt.nn.conv_transpose(x,w,stride=-1)
  File "/jittor/python/jittor/nn.py", line 1505, in conv_transpose
    f'i4*{stride_w}-{padding_w}+i6*{dilation_w}', # Wid+KWid
RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.reindex_reduce)).

Types of your inputs are:
 self   = Var,
 args   = (str, tuple, list, ),

The function declarations are:
 VarHolder* reindex_reduce(VarHolder* y,  NanoString op,  NanoVector shape,  vector<string>&& indexes,  vector<string>&& overflow_conditions={}, vector<VarHolder*>&& extras={})

Failed reason:[f 0512 08:02:28.484698 48 reindex_reduce_op.cc:69] Check failed v(-1) >= 0u(0) Shape should greater than 0.

conv_transpose2d:

[i 0512 08:03:29.284409 72 compiler.py:956] Jittor(1.3.9.6) src: /jittor/python/jittor
[i 0512 08:03:29.286923 72 compiler.py:957] g++ at /usr/bin/g++(8.3.0)
[i 0512 08:03:29.286994 72 compiler.py:958] cache_path: /root/.cache/jittor/jt1.3.9/g++8.3.0/py3.7.4/Linux-5.15.153x56/13thGenIntelRCx56/8c5a/master
[i 0512 08:03:29.290450 72 __init__.py:412] Found addr2line(2.31.1) at /usr/bin/addr2line.
[i 0512 08:03:29.513396 72 __init__.py:227] Total mem: 15.43GB, using 5 procs for compiling.
[i 0512 08:03:29.582321 72 jit_compiler.cc:28] Load cc_path: /usr/bin/g++
Traceback (most recent call last):
  File "test.py", line 64, in <module>
    jt.nn.conv_transpose2d(x,w,stride=-1)  # 文档错误 记得报送
  File "/jittor/python/jittor/nn.py", line 1505, in conv_transpose
    f'i4*{stride_w}-{padding_w}+i6*{dilation_w}', # Wid+KWid
RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.reindex_reduce)).

Types of your inputs are:
 self   = Var,
 args   = (str, tuple, list, ),

The function declarations are:
 VarHolder* reindex_reduce(VarHolder* y,  NanoString op,  NanoVector shape,  vector<string>&& indexes,  vector<string>&& overflow_conditions={}, vector<VarHolder*>&& extras={})

Failed reason:[f 0512 08:03:29.700841 72 reindex_reduce_op.cc:69] Check failed v(-1) >= 0u(0) Shape should greater than 0.

conv_transpose3d:

[i 0512 08:03:59.634914 60 compiler.py:956] Jittor(1.3.9.6) src: /jittor/python/jittor
[i 0512 08:03:59.637434 60 compiler.py:957] g++ at /usr/bin/g++(8.3.0)
[i 0512 08:03:59.637502 60 compiler.py:958] cache_path: /root/.cache/jittor/jt1.3.9/g++8.3.0/py3.7.4/Linux-5.15.153x56/13thGenIntelRCx56/8c5a/master
[i 0512 08:03:59.641174 60 __init__.py:412] Found addr2line(2.31.1) at /usr/bin/addr2line.
[i 0512 08:03:59.861700 60 __init__.py:227] Total mem: 15.43GB, using 5 procs for compiling.
[i 0512 08:03:59.930089 60 jit_compiler.cc:28] Load cc_path: /usr/bin/g++
Traceback (most recent call last):
  File "test.py", line 74, in <module>
    jt.nn.conv_transpose3d(x,w,stride=-1)
  File "/jittor/python/jittor/nn.py", line 1597, in conv_transpose3d
    f'i5*{stride_w}-{padding_w}+i8*{dilation_w}', # Wid+KWid
RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.reindex_reduce)).

Types of your inputs are:
 self   = Var,
 args   = (str, tuple, list, ),

The function declarations are:
 VarHolder* reindex_reduce(VarHolder* y,  NanoString op,  NanoVector shape,  vector<string>&& indexes,  vector<string>&& overflow_conditions={}, vector<VarHolder*>&& extras={})

Failed reason:[f 0512 08:04:00.068543 60 reindex_reduce_op.cc:69] Check failed v(-1) >= 0u(0) Shape should greater than 0.

Minimal Reproduce

conv_transpose:

import jittor as jt
from jittor import *
x = jt.ones(2,3,4,5)
w = jt.ones(3,6,3,3)
jt.nn.conv_transpose(x,w,stride=-1)

conv_transpose2d:

import jittor as jt
from jittor import *
x = jt.ones(2,3,4,5)
w = jt.ones(3,6,3,3)
jt.nn.conv_transpose2d(x,w,stride=-1)

conv_transpose3d:

import jittor as jt
from jittor import *
x = jt.ones(2,3,4,5,6)
w = jt.ones(3,6,3,3,6)
jt.nn.conv_transpose3d(x,w,stride=-1)

Expected behavior

The stride parameter of jt.nn.conv_transpose/conv_transpose2d/conv_transpose3d should not have a negative value and should be replaced by runtime error instead of direct crash