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.random/randn/randint` #526

Closed x0w3n closed 3 months ago

x0w3n commented 3 months ago

Describe the bug

When input some boundary values to the parameters of jt.random/randn/randint, it causes a crash

Full Log

random:

[i 0512 07:51:58.351861 28 compiler.py:956] Jittor(1.3.9.6) src: /jittor/python/jittor
[i 0512 07:51:58.354515 28 compiler.py:957] g++ at /usr/bin/g++(8.3.0)
[i 0512 07:51:58.354621 28 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 07:51:58.358237 28 __init__.py:412] Found addr2line(2.31.1) at /usr/bin/addr2line.
[i 0512 07:51:58.580834 28 __init__.py:227] Total mem: 15.43GB, using 5 procs for compiling.
[i 0512 07:51:58.649792 28 jit_compiler.cc:28] Load cc_path: /usr/bin/g++
Traceback (most recent call last):
  File "test.py", line 48, in <module>
    jt.random((1,-3,4,5))
  File "/jittor/python/jittor/__init__.py", line 432, in random
    ret = ops.random(shape, "float32", type)
RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.ops.random)).

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

The function declarations are:
 VarHolder* random(NanoVector shape,  NanoString dtype=ns_float32,  NanoString type=ns_uniform)

Failed reason:[f 0512 07:51:58.775427 28 op.cc:91] Check failed: need_sync->num >= 0  Var(2:1:1:1:i0:o0:s1:n0:g1,float32,,56420b2f6a40)[1,-3,4,5,] 's shape is error

randn:

[i 0512 07:52:16.735800 64 compiler.py:956] Jittor(1.3.9.6) src: /jittor/python/jittor
[i 0512 07:52:16.737952 64 compiler.py:957] g++ at /usr/bin/g++(8.3.0)
[i 0512 07:52:16.738009 64 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 07:52:16.741575 64 __init__.py:412] Found addr2line(2.31.1) at /usr/bin/addr2line.
[i 0512 07:52:16.958147 64 __init__.py:227] Total mem: 15.43GB, using 5 procs for compiling.
[i 0512 07:52:17.024833 64 jit_compiler.cc:28] Load cc_path: /usr/bin/g++
Traceback (most recent call last):
  File "test.py", line 50, in <module>
    a  = jt.randn([[ 2.7771e+38, -1.7855e+38]])
  File "/jittor/python/jittor/__init__.py", line 920, in randn
    arr = jt.random(size, dtype, "normal")
  File "/jittor/python/jittor/__init__.py", line 432, in random
    ret = ops.random(shape, "float32", type)
RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.ops.random)).

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

The function declarations are:
 VarHolder* random(NanoVector shape,  NanoString dtype=ns_float32,  NanoString type=ns_uniform)

Failed reason:[f 0512 07:52:17.138342 64 py_converter.h:303] Check failed: is_type<int64>(oi)

randint:

[i 0512 07:52:36.918085 16 compiler.py:956] Jittor(1.3.9.6) src: /jittor/python/jittor
[i 0512 07:52:36.920170 16 compiler.py:957] g++ at /usr/bin/g++(8.3.0)
[i 0512 07:52:36.920228 16 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 07:52:36.923602 16 __init__.py:412] Found addr2line(2.31.1) at /usr/bin/addr2line.
[i 0512 07:52:37.143934 16 __init__.py:227] Total mem: 15.43GB, using 5 procs for compiling.
[i 0512 07:52:37.214837 16 jit_compiler.cc:28] Load cc_path: /usr/bin/g++
Traceback (most recent call last):
  File "test.py", line 52, in <module>
    a  = jt.randint(3, shape=(3, -3))
  File "/jittor/python/jittor/__init__.py", line 1016, in randint
    v = (jt.random(shape) * (high - low) + low).clamp(low, high-0.5)
  File "/jittor/python/jittor/__init__.py", line 432, in random
    ret = ops.random(shape, "float32", type)
RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.ops.random)).

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

The function declarations are:
 VarHolder* random(NanoVector shape,  NanoString dtype=ns_float32,  NanoString type=ns_uniform)

Failed reason:[f 0512 07:52:37.343886 16 op.cc:91] Check failed: need_sync->num >= 0  Var(2:1:1:1:i0:o0:s1:n0:g1,float32,,557795014a40)[3,-3,] 's shape is error

Minimal Reproduce

random:

import jittor as jt
from jittor import *
jt.random((1,-3,4,5))

randn:

import jittor as jt
from jittor import *
a  = jt.randn([[ 2.7771e+38, -1.7855e+38]])

randint:

import jittor as jt
from jittor import *
a  = jt.randint(3, shape=(3, -3))

Expected behavior

Should do boundary value checking on jt.random/randn/randint arguments, e.g. not allow negative numbers, and should be replaced with runtime error instead of direct crash.