logical_or

paddle. logical_or ( x, y, out=None, name=None ) [source]

logical_or operator computes element-wise logical OR on x and y, and returns out. out is N-dim boolean Tensor. Each element of out is calculated by

\[out = x || y\]

Note

paddle.logical_or supports broadcasting. If you want know more about broadcasting, please refer to Introduction to Tensor .

Parameters
  • x (Tensor) – the input tensor, it’s data type should be one of bool, int8, int16, in32, in64, float16, float32, float64, complex64, complex128.

  • y (Tensor) – the input tensor, it’s data type should be one of bool, int8, int16, in32, in64, float16, float32, float64, complex64, complex128.

  • out (Tensor) – The Variable that specifies the output of the operator, which can be any Tensor that has been created in the program. The default value is None, and a new Tensor will be created to save the output.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

N-D Tensor. A location into which the result is stored. It’s dimension equals with x.

Examples

>>> import paddle

>>> x = paddle.to_tensor([True, False], dtype="bool").reshape([2, 1])
>>> y = paddle.to_tensor([True, False, True, False], dtype="bool").reshape([2, 2])
>>> res = paddle.logical_or(x, y)
>>> print(res)
Tensor(shape=[2, 2], dtype=bool, place=Place(cpu), stop_gradient=True,
[[True , True ],
 [True , False]])