mindspore.ops.BitwiseAnd

class mindspore.ops.BitwiseAnd(*args, **kwargs)[source]

Returns bitwise and of two tensors element-wise.

Inputs of x1 and x2 comply with the implicit type conversion rules to make the data types consistent. If they have different data types, lower priority data type will be converted to relatively highest priority data type. RuntimeError exception will be thrown when the data type conversion of Parameter is required.

Inputs:
  • x1 (Tensor) - The input tensor with int16, int32 or uint16 data type.

  • x2 (Tensor) - The input tensor with same type as the x1.

Outputs:

Tensor, has the same type as the x1.

Raises

TypeError – If x1 or x2 is not a Tensor.

Supported Platforms:

Ascend

Examples

>>> x1 = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
>>> x2 = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
>>> bitwise_and = ops.BitwiseAnd()
>>> output = bitwise_and(x1, x2)
>>> print(output)
[ 0  0  1 -1  1  0  1]