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

Function equal

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

r"""Element-wise equality comparison. Computes the truth value of :math:`x_i == y_i` 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. May have any data type. y:

(x, y)

Source from the content-addressed store, hash-verified

1834
1835
1836def equal(x, y):
1837 r"""Element-wise equality comparison.
1838
1839 Computes the truth value of :math:`x_i == y_i` for each element :math:`x_i` of the input tensor :math:`x`
1840 with the respective element :math:`y_i` of the input tensor :math:`y`.
1841
1842 Args:
1843 x: first input tensor. May have any data type.
1844 y: second input tensor. Must be compatible with :math:`x` (see :ref:`broadcasting-rule` ). May have any data type.
1845
1846 Returns:
1847 a tensor containing the result of the element-wise results.
1848 The returned tensor must have a data type of ``bool``.
1849
1850 .. seealso::
1851
1852 :func:`~.not_equal`, :func:`~.greater_equal`, :func:`~.less_equal`, :func:`~.greater`, :func:`~.less`
1853
1854 Examples:
1855
1856 Element-wise equality comparison:
1857
1858 >>> x = Tensor([1, 2, 3])
1859 >>> y = Tensor([1, 2, 4])
1860 >>> F.equal(x, y)
1861 Tensor([ True True False], dtype=bool, device=xpux:0)
1862
1863 The ``==`` operator can be used as a shorthand for ``F.equal`` on boolean tensors.
1864
1865 >>> x == y
1866 Tensor([ True True False], dtype=bool, device=xpux:0)
1867 """
1868 return x == y
1869
1870
1871def not_equal(x, y):

Callers 6

__eq__Method · 0.85
ctc_lossFunction · 0.85
TESTFunction · 0.85
eq_shape0Function · 0.85
eq_layout0Function · 0.85
operator==Method · 0.85

Calls

no outgoing calls

Tested by 3

TESTFunction · 0.68
eq_shape0Function · 0.68
eq_layout0Function · 0.68