Closed x0w3n closed 3 months ago
When negative values are passed to the bin parameter of jt.histc, it causes a crash
[i 0512 08:11:34.189908 36 compiler.py:956] Jittor(1.3.9.6) src: /jittor/python/jittor [i 0512 08:11:34.192376 36 compiler.py:957] g++ at /usr/bin/g++(8.3.0) [i 0512 08:11:34.192441 36 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:11:34.195807 36 __init__.py:412] Found addr2line(2.31.1) at /usr/bin/addr2line. [i 0512 08:11:34.417811 36 __init__.py:227] Total mem: 15.43GB, using 5 procs for compiling. [i 0512 08:11:34.486494 36 jit_compiler.cc:28] Load cc_path: /usr/bin/g++ Traceback (most recent call last): File "test.py", line 82, in <module> jt.histc(inputs, bins=-0) File "/jittor/python/jittor/misc.py", line 2178, in histc hist[-1] += 1 File "/jittor/python/jittor/contrib.py", line 192, in getitem return x.getitem(slices) RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.getitem)). Types of your inputs are: self = Var, args = (int, ), The function declarations are: VarHolder* getitem(VarHolder* x, VarSlices&& slices) vector_to_tuple<VarHolder*> getitem_(VarHolder* x, VarSlices&& slices, int _) Failed reason:[f 0512 08:11:34.626798 36 getitem_op.cc:146] Check failed: v>=0 && v<in_shape_i slice overflow, -1 not in [0,0)
import jittor as jt from jittor import * inputs = jt.randn((40,40)) jt.histc(inputs, bins=-0)
The bin parameter of jt.histc should not accept negative values and should be handled with a runtime error instead of a direct crash
Describe the bug
When negative values are passed to the bin parameter of jt.histc, it causes a crash
Full Log
Minimal Reproduce
Expected behavior
The bin parameter of jt.histc should not accept negative values and should be handled with a runtime error instead of a direct crash