mindspore.Tensor.bitwise_and

mindspore.Tensor.bitwise_and(x)[源代码]

逐元素执行两个Tensor的与运算。

更多细节参考 mindspore.ops.bitwise_and()

参数:
  • x (Tensor) - 输入Tensor,是一个数据类型为uint16、int16或int32的Tensor。

返回:

Tensor,是一个与 x 相同类型的Tensor。

支持平台:

Ascend GPU CPU

样例:

>>> from mindspore import Tensor
>>> import numpy as np
>>> a = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
>>> b = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
>>> output = a.bitwise_and(b)
>>> print(output)
[ 0  0  1 -1  1  0  1]