Jittor/jittor

jittor.nn.Pool 的stride接受非法参数异常

PhyllisJi opened this issue · 0 comments

关键错误信息

  1. 当stride小于0时,这里测试取-1,该层不会对此抛出异常,而是会将非法输出传递到底层算子,调用. jt.code() 时出现错误,并返回异常信息。
    
  2. 当stride等于0时,初始化模型时不会报任何错误,而且模型能正常运行,输出相对于数据,这里stride应该能够为0.
    

预期行为

jittor.nn. Pool 的stride非法时,在初始化模型时应该拒绝该参数,并抛出正确的异常信息提醒用户,以防止底层算子出现未知问题,并不影响其他正常运算。

错误日志

Traceback (most recent call last):
  File "D:\课件\研究生\项目\2023-7-5 bug标注\models\jttest.py", line 8, in <module>
    output = maxpool(input)
  File "D:\myvscode\environment\python3.9\lib\site-packages\jittor\__init__.py", line 1172, in __call__
    return self.execute(*args, **kw)
  File "D:\myvscode\environment\python3.9\lib\site-packages\jittor\pool.py", line 108, in execute
    out = jt.code(return_shapes, return_dtypes, [x],
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 0719 22:18:10.278000 08 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: [1,1,-5,-5,]

Process finished with exit code 1

最小复现

maxpool = nn.Pool (3, stride=-1)
input = jt.randn(1, 1, 9, 9)
output = maxpool(input)
print(output.shape)