mindspore.Tensor.bitwise_and

Tensor.bitwise_and(other) Tensor[source]

Returns bitwise and of two tensors element-wise.

Note

self and other comply with the type conversion rules to make the data types consistent.

Parameters:

other (Tensor, Number.number) – The shape is the same as the self or can be broadcast to the shape of self.

Returns:

Tensor, has the same type as the self and has the same shape as after broadcasting.

Supported Platforms:

Ascend GPU CPU

Examples

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