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

Function logical_and

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

r"""Element-wise logical AND. Computes the logical AND 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. y: second input tensor.

(x, y)

Source from the content-addressed store, hash-verified

1684
1685
1686def logical_and(x, y):
1687 r"""Element-wise logical AND.
1688
1689 Computes the logical AND for each element :math:`x_i` of the input tensor :math:`x`
1690 with the respective element :math:`y_i` of the input tensor :math:`y`.
1691
1692 Args:
1693 x: first input tensor. Should have a boolean data type.
1694 y: second input tensor. Must be compatible with :math:`x` (see :ref:`broadcasting-rule` ).
1695 Should have a boolean data type.
1696
1697 Returns:
1698 a tensor containing the result of the element-wise logical AND operation.
1699 The returned tensor must have a data type of ``bool``.
1700
1701 .. seealso::
1702
1703 :func:`~.logical_or`, :func:`~.logical_not`, :func:`~.logical_xor`
1704
1705 Examples:
1706 >>> F.logical_and(True, False)
1707 Tensor(False, dtype=bool, device=xpux:0)
1708
1709 Element-wise logical AND:
1710
1711 >>> x = Tensor([True, False, True])
1712 >>> y = Tensor([False, False, True])
1713 >>> F.logical_and(x, y)
1714 Tensor([False False True], dtype=bool, device=xpux:0)
1715
1716 The ``&`` operator can be used as a shorthand for ``F.logical_and`` on boolean tensors.
1717
1718 >>> x & y
1719 Tensor([False False True], dtype=bool, device=xpux:0)
1720 """
1721 return _elwise(x, y, mode=Elemwise.Mode.AND)
1722
1723
1724def logical_not(x):

Callers 1

fakequant_grad_ruleFunction · 0.85

Calls 1

_elwiseFunction · 0.50

Tested by

no test coverage detected