Skip to content

Conversation

@FlyingQianMM
Copy link
Contributor

PR types

Bug fixes

PR changes

OPs

Describe

  • get_item() raise a error as bellow when the index is a bool scalar tensor:

code:

import paddle data = paddle.to_tensor([[1,2]]) mask = paddle.to_tensor([1], dtype='bool') print(data[mask]) 

error:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/conda/lib/python3.7/site-packages/paddle/fluid/dygraph/varbase_patch_methods.py", line 719, in __getitem__ return _getitem_impl_(self, item) File "/opt/conda/lib/python3.7/site-packages/paddle/fluid/variable_index.py", line 474, in _getitem_impl_ attrs=attrs) File "/opt/conda/lib/python3.7/site-packages/paddle/fluid/framework.py", line 3480, in append_op inplace_map) File "/opt/conda/lib/python3.7/site-packages/paddle/fluid/dygraph/tracer.py", line 130, in trace_op not stop_gradient, inplace_map if inplace_map else {}) ValueError: (InvaidArgument) The dtype of Tensor in list must be int32 or int64, but received: 0 (at /idg/paddle/Paddle/paddle/fluid/operators/utils.h:87) [operator < slice > error] 
  • after we fix this error, the output can been returned correctly:
    code:
import paddle data = paddle.to_tensor([[1,2]]) mask = paddle.to_tensor([1], dtype='bool') print(data[mask]) 

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants