Jittor/jittor

jittor.nn.Conv2d会接受非法参数并导致底层算子崩溃

PhyllisJi opened this issue · 0 comments

关键错误信息

jittor.nn.Conv2d的padding设置为-1(或者其他非法值)时,该层不会对此抛出异常,而是会将非法输出传递到底层算子x.reindex(),并导致底层算子因进行一些非法运算而崩溃

与此同时,若输入一个张量进行计算,将得到一个不合法形状的输出,且其中data将改变为其他类型,最终导致后续运算过程的出错

预期行为

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

错误日志

其中,算子非法运算报错为:

Types of your inputs are:
 self	= Var,

The function declarations are:
 inline DataView data()

Failed reason:[f 0718 22:44:47.965000 60 parallel_compiler.cc:331] Error happend during compilation:
 [Error] source file location:C:\Users\EdisonChen\.cache\jittor\jt1.3.8\cl\py3.9.9\Windows-10-10.x0e\IntelRCoreTMi5x25\default\cu11.2.67\jit\__opkey0_broadcast_to__Tx_float32__DIM_7__BCAST_19__opkey1_reindex__Tx_float32__XDIM_4__YD___hash_fdaee25eb8edd675_op.cc
Compile fused operator(4/6)failed:[Op(41:1:1:1:i1:o1:s0,broadcast_to->42),Op(39:1:1:1:i1:o1:s0,reindex->40),Op(43:2:1:1:i2:o1:s0,binary.multiply->44),Op(45:1:1:1:i1:o1:s0,reduce.add->46),]

Reason: [f 0718 22:44:47.964000 60 expr.cc:394] Op -- 2 1 not support


Process finished with exit code 1

最小复现

conv = nn.Conv2d(24, 32, 3, stride=2, padding=-1)
input1 = jt.randn(4, 24, 100, 100)
output = conv(input1)
print(output)