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.contrib.argmax_pool` #529

Closed x0w3n closed 3 months ago

x0w3n commented 3 months ago

Describe the bug

When input some boundary values to the parameter jt.contrib.argmax_pool, it causes a crash.

Full Log

[i 0512 08:06:46.005275 92 compiler.py:956] Jittor(1.3.9.6) src: /jittor/python/jittor
[i 0512 08:06:46.007794 92 compiler.py:957] g++ at /usr/bin/g++(8.3.0)
[i 0512 08:06:46.007902 92 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:06:46.011709 92 __init__.py:412] Found addr2line(2.31.1) at /usr/bin/addr2line.
[i 0512 08:06:46.229068 92 __init__.py:227] Total mem: 15.43GB, using 5 procs for compiling.
[i 0512 08:06:46.298353 92 jit_compiler.cc:28] Load cc_path: /usr/bin/g++
Traceback (most recent call last):
  File "test.py", line 78, in <module>
    jt.contrib.argmax_pool(x,size=0,stride=-1)
  File "/jittor/python/jittor/contrib.py", line 18, in argmax_pool
    return pool.pool(x, size, 'maximum', padding, stride)
  File "/jittor/python/jittor/pool.py", line 512, in pool
    return Pool(kernel_size, stride, padding, op=op)(x)
  File "/jittor/python/jittor/__init__.py", line 1184, in __call__
    return self.execute(*args, **kw)
  File "/jittor/python/jittor/pool.py", line 176, in execute
    '''])
RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.ops.code)).

Types of your inputs are:
 self   = module,
 args   = (list, NanoString, list, ),
 kwargs = {cuda_header=str, cuda_src=str, cuda_grad_src=list, cpu_header=str, cpu_src=str, cpu_grad_src=list, },

The function declarations are:
 VarHolder* code(NanoVector shape,  NanoString dtype, vector<VarHolder*>&& inputs={},  string&& cpu_src="",  vector<string>&& cpu_grad_src={},  string&& cpu_header="",  string&& cuda_src="",  vector<string>&& cuda_grad_src={},  string&& cuda_header="",  DataMap&& data={})
 vector_to_tuple<VarHolder*> code_(vector<NanoVector>&& shapes,  vector<NanoString>&& dtypes, vector<VarHolder*>&& inputs={},  string&& cpu_src="",  vector<string>&& cpu_grad_src={},  string&& cpu_header="",  string&& cuda_src="",  vector<string>&& cuda_grad_src={},  string&& cuda_header="",  DataMap&& data={})
 vector_to_tuple<VarHolder*> code__(vector<VarHolder*>&& inputs, vector<VarHolder*>&& outputs,  string&& cpu_src="",  vector<string>&& cpu_grad_src={},  string&& cpu_header="",  string&& cuda_src="",  vector<string>&& cuda_grad_src={},  string&& cuda_header="",  DataMap&& data={})

Failed reason:[f 0512 08:06:46.415548 92 code_op.cc:25] Check failed: (i == 0) ^ (v[i] >= 0)  Something wrong... Could you please report this issue?
 Vary shape should only occur in the first dimension: [2,3,-3,-4,]

Minimal Reproduce

import jittor as jt
from jittor import *
x = jt.randn(2,3,4,5)
jt.contrib.argmax_pool(x,size=0,stride=-1)

Expected behavior

The stride parameter to jt.contrib.argmax_pool should not be negative and should be replaced with runtime error instead of direct crash.