mindspore.ops.LogicalAnd

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

Computes the “logical AND” of two tensors element-wise.

Inputs of input_x and input_y comply with the implicit type conversion rules to make the data types consistent. The inputs must be two tensors or one tensor and one bool. When the inputs are two tensors, the shapes of them could be broadcast, and the data types of them must be bool. When the inputs are one tensor and one bool, the bool object could only be a constant, and the data type of the tensor must be bool.

Inputs:
  • input_x (Union[Tensor, bool]) - The first input is a bool or a tensor whose data type is bool.

  • input_y (Union[Tensor, bool]) - The second input is a bool when the first input is a tensor or a tensor whose data type is bool.

Outputs:

Tensor, the shape is the same as the one after broadcasting, and the data type is bool.

Raises

TypeError – If neither input_x nor input_y is a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor(np.array([True, False, True]), mindspore.bool_)
>>> input_y = Tensor(np.array([True, True, False]), mindspore.bool_)
>>> logical_and = ops.LogicalAnd()
>>> output = logical_and(input_x, input_y)
>>> print(output)
[ True False False]