# megengine.functional.logical_or¶

logical_or(x, y)[源代码]

Element-wise logical OR.

Computes the logical OR for each element $$x_i$$ of the input tensor $$x$$ with the respective element $$y_i$$ of the input tensor $$y$$.

x – first input tensor. Should have a boolean data type.

a tensor containing the result of the element-wise logical OR operation. The returned tensor must have a data type of bool.

>>> F.logical_or(True, False)
Tensor(True, dtype=bool, device=xpux:0)


Element-wise logical OR:

>>> x = Tensor([True, False, True])
>>> y = Tensor([False, False, True])
>>> F.logical_or(x, y)
Tensor([ True False  True], dtype=bool, device=xpux:0)


The | operator can be used as a shorthand for F.logical_or on boolean tensors.

>>> x | y
Tensor([ True False  True], dtype=bool, device=xpux:0)