MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / logical_or

Function logical_or

imperative/python/megengine/functional/elemwise.py:1758–1791  ·  view source on GitHub ↗

r"""Element-wise logical OR. Computes the logical OR for each element :math:`x_i` of the input tensor :math:`x` with the respective element :math:`y_i` of the input tensor :math:`y`. Args: x: first input tensor. Should have a boolean data type. Returns: a tensor co

(x, y)

Source from the content-addressed store, hash-verified

1756
1757
1758def logical_or(x, y):
1759 r"""Element-wise logical OR.
1760
1761 Computes the logical OR for each element :math:`x_i` of the input tensor :math:`x`
1762 with the respective element :math:`y_i` of the input tensor :math:`y`.
1763
1764 Args:
1765 x: first input tensor. Should have a boolean data type.
1766
1767 Returns:
1768 a tensor containing the result of the element-wise logical OR operation.
1769 The returned tensor must have a data type of ``bool``.
1770
1771 .. seealso::
1772
1773 :func:`~.logical_and`, :func:`~.logical_not`, :func:`~.logical_xor`
1774
1775 Examples:
1776 >>> F.logical_or(True, False)
1777 Tensor(True, dtype=bool, device=xpux:0)
1778
1779 Element-wise logical OR:
1780
1781 >>> x = Tensor([True, False, True])
1782 >>> y = Tensor([False, False, True])
1783 >>> F.logical_or(x, y)
1784 Tensor([ True False True], dtype=bool, device=xpux:0)
1785
1786 The ``|`` operator can be used as a shorthand for ``F.logical_or`` on boolean tensors.
1787
1788 >>> x | y
1789 Tensor([ True False True], dtype=bool, device=xpux:0)
1790 """
1791 return _elwise(x, y, mode=Elemwise.Mode.OR)
1792
1793
1794def logical_xor(x, y):

Callers 2

lsq_grad_ruleFunction · 0.85
checknonfinite_lowerFunction · 0.85

Calls 1

_elwiseFunction · 0.50

Tested by

no test coverage detected