Inadequate Validation for 'chunks' Parameter in paddle.chunk led to Aborted.

kxe2p93d  于 4个月前  发布在  其他
关注(0)|答案(2)|浏览(35)

bug描述 Describe the Bug

您好,

  1. paddle.chunk 是否应该对输入参数 chunks 进行非负检验?

因为当输入的 chunks 为负整数时,会产生 Aborted (core dumped)

这段简单的代码可以复现这个错误:

x = paddle.rand([3, 3, 9])

out0, out1, out2 = paddle.chunk(x, chunks=-1)
print(out0.shape, out1.shape, out2.shape)

报错信息:

WARNING: OMP_NUM_THREADS set to 12, not 1. The computation speed will not be optimized if you use data parallel. It will fail if this PaddlePaddle binary is compiled with OpenBlas since OpenBlas does not support multi-threads.
PLEASE USE OMP_NUM_THREADS WISELY.
3
terminate called after throwing an instance of 'std::length_error'
  what():  vector::reserve
--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0   paddle::pybind::ThrowExceptionToPython(std::__exception_ptr::exception_ptr)
----------------------
Error Message Summary:
----------------------
FatalError: `Process abort signal` is detected by the operating system.
  [TimeInfo: *** Aborted at 1714954193 (unix time) try "date -d @1714954193" if you are using GNU date ***]
  [SignalInfo: *** SIGABRT (@0xa54f1) received by PID 677105 (TID 0x7f56677a0280) from PID 677105 ***]
Aborted (core dumped)

另外,在 paddle.chunk 的API文档中,也可以具体表明 chunks 是一个非负整数。

2.当 chunks 输入为大整数时,同样引起了 Aborted

import paddle

x=paddle.rand(shape=(3, 1, 5), dtype=paddle.float32)
chunks=2609999794
axis=2
paddle.chunk(x=x,chunks=chunks,axis=axis)

Out:

WARNING: OMP_NUM_THREADS set to 12, not 1. The computation speed will not be optimized if you use data parallel. It will fail if this PaddlePaddle binary is compiled with OpenBlas since OpenBlas does not support multi-threads.
PLEASE USE OMP_NUM_THREADS WISELY.
terminate called after throwing an instance of 'std::length_error'
  what():  vector::reserve
--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0   paddle::pybind::ThrowExceptionToPython(std::__exception_ptr::exception_ptr)

----------------------
Error Message Summary:
----------------------
FatalError: `Process abort signal` is detected by the operating system.
  [TimeInfo: *** Aborted at 1715389489 (unix time) try "date -d @1715389489" if you are using GNU date ***]
  [SignalInfo: *** SIGABRT (@0xf1549) received by PID 988489 (TID 0x7fba989f2280) from PID 988489 ***]

Aborted (core dumped)

版本:
paddlepaddle 2.6.1
python 3.9

其他补充信息 Additional Supplementary Information

该问题已于5月9日、5月21日从邮箱反馈,似乎没有收到任何回复。

wh6knrhe

wh6knrhe1#

@Zoeeeeey

  1. chunk 参数是非负的,可以加上value check。
  2. chunk 参数大于切割的维度是无意义的,这块也缺少了value check,另外 paddle.chunk 实际调用的是 paddle.split ,用 split 更灵活。

Paddle/python/paddle/tensor/manipulation.py

Line 3385 in 1319992

| | returnsplit(x, num_or_sections=chunks, axis=axis, name=name) |

fae0ux8s

fae0ux8s2#

@Zoeeeeey 也非常欢迎您提pr帮助修复这些问题

相关问题