mindspore.ops.bitwise_and

查看源文件
mindspore.ops.bitwise_and(input, other)[源代码]

逐元素对两个输入tensor做与运算。 如果 inputother 数据类型不同,遵循隐式类型转换规则、类型提升规则。

参数:
  • input (Tensor) - 第一个输入tensor。

  • other (Tensor) - 第二个输入tensor。

返回:

Tensor

支持平台:

Ascend GPU CPU

样例:

>>> import mindspore
>>> input = mindspore.tensor([-1, -2, 3])
>>> other = mindspore.tensor([1, 0, 3])
>>> mindspore.ops.bitwise_and(input, other)
Tensor(shape=[3], dtype=Int64, value= [1, 0, 3])
>>> # Same as calling via the | operator:
>>> input & other
Tensor(shape=[3], dtype=Int64, value= [1, 0, 3])
>>> # When inputs are boolean:
>>> input = mindspore.tensor([True, True, False])
>>> other = mindspore.tensor([False, True, False])
>>> mindspore.ops.bitwise_and(input, other)
Tensor(shape=[3], dtype=Bool, value= [False,  True, False])