mindspore.ops.intopk

View Source On Gitee
mindspore.ops.intopk(x1, x2, k)[source]

Return whether the elements in second input tensor exist among the top k elements of the first input tensor.

Parameters
  • x1 (Tensor) – The 2-D input tensor.

  • x2 (Tensor) – The 1-D input tensor, should satisfy x2.shape[0]=x1.shape[0] .

  • k (int) – Top k elements.

Returns

A 1-D tensor whose data type is bool, has the same shape with x2.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> x1 = mindspore.tensor([[1, 8, 5, 2, 7], [4, 9, 1, 3, 5]], mindspore.float32)
>>> x2 = mindspore.tensor([1, 3], mindspore.int32)
>>> mindspore.ops.intopk(x1, x2, 3)
Tensor(shape=[2], dtype=Bool, value= [ True, False])