paddle不支持tensor负的索引,而torch支持

jtjikinw  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(43)

bug描述 Describe the Bug

import torch
a = torch.randn((2000,))
b = torch.tensor([0, 0, 0, 0])
a[b-1]
# tensor([-0.3665, -0.3665, -0.3665, -0.3665])
# develop 报错
import paddle
a = paddle.randn((2000,))
b = paddle.to_tensor([0, 0, 0, 0])
a[b-1]
# # Error: ../paddle/phi/kernels/funcs/gather.cu.h:67 Assertion `index_value >= 0 && index_value < input_dims[j]` failed. The index is out of bounds, please check whether the dimensions of index and input meet the requirements. It should be less than [2000] and greater than or equal to 0, but received [0]
# # Error: ../paddle/phi/kernels/funcs/gather.cu.h:67 Assertion `index_value >= 0 && index_value < input_dims[j]` failed. The index is out of bounds, please check whether the dimensions of index and input meet the requirements. It should be less than [2000] and greater than or equal to 0, but received [0]
# # Error: ../paddle/phi/kernels/funcs/gather.cu.h:67 Assertion `index_value >= 0 && index_value < input_dims[j]` failed. The index is out of bounds, please check whether the dimensions of index and input meet the requirements. It should be less than [2000] and greater than or equal to 0, but received [0]
# # Error: ../paddle/phi/kernels/funcs/gather.cu.h:67 Assertion `index_value >= 0 && index_value < input_dims[j]` failed. The index is out of bounds, please check whether the dimensions of index and input meet the requirements. It should be less than [2000] and greater than or equal to 0, but received [0]
# 2.5.1 结果异常,不报错,都输出了0
import paddle
a = paddle.randn((2000,))
b = paddle.to_tensor([0, 0, 0, 0])
a[b-1]
# Tensor(shape=[4], dtype=float32, place=Place(gpu:0), stop_gradient=True,
#        [0., 0., 0., 0.])

其他补充信息 Additional Supplementary Information

No response

oipij1gg

oipij1gg1#

你好,感谢反馈,该问题属于功能缺失,这边需求已记录,后续会更新

相关问题