mindspore.mint.masked_select
- mindspore.mint.masked_select(input, mask)[source]
Return a new 1-D tensor which indexes the input tensor according to the boolean mask.
Support broadcast.
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> import numpy as np >>> x = mindspore.tensor(np.array([1, 2, 3, 4]), mindspore.int64) >>> mask = mindspore.tensor(np.array([1, 0, 1, 0]), mindspore.bool_) >>> output = mindspore.mint.masked_select(x, mask) >>> print(output) [1 3]