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

Function floor

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

r"""Element-wise :math:`\lfloor x \rfloor` function. Rounds each element :math:`x_i` of the input tensor :math:`x` to the greatest integer-valued number that is not greater than :math:`x_i`. Args: x: input tensor. Should have a numeric data type. Returns: a tenso

(x)

Source from the content-addressed store, hash-verified

926
927
928def floor(x):
929 r"""Element-wise :math:`\lfloor x \rfloor` function.
930
931 Rounds each element :math:`x_i` of the input tensor :math:`x` to the greatest integer-valued number that is not greater than :math:`x_i`.
932
933 Args:
934 x: input tensor. Should have a numeric data type.
935
936 Returns:
937 a tensor containing the rounded result for each element in :math:`x`.
938 The returned tensor must have the same data type as :math:`x`.
939
940 .. admonition:: Special cases
941
942 If :math:`x_i` is already integer-valued, the result is :math:`x_i`.
943
944 For floating-point operands,
945
946 * If :math:`x_i` is ``+infinity``, the result is ``+infinity``.
947 * If :math:`x_i` is ``-infinity``, the result is ``-infinity``.
948 * If :math:`x_i` is ``+0``, the result is ``+0``.
949 * If :math:`x_i` is ``-0``, the result is ``-0``.
950 * If :math:`x_i` is NaN, the result is NaN.
951
952 Examples:
953 >>> F.floor(1.5)
954 Tensor(1.0, device=xpux:0)
955
956 Element-wise flooring:
957
958 >>> x = Tensor([1.5, 2.5, 3.5, 4.5])
959 >>> F.floor(x)
960 Tensor([1. 2. 3. 4.], device=xpux:0)
961 """
962 return _elwise(x, mode=Elemwise.Mode.FLOOR)
963
964
965def maximum(x, y):

Callers 4

get_dsizeFunction · 0.70
forwardMethod · 0.50
floor_divFunction · 0.50
resize_linear_helperFunction · 0.50

Calls 1

_elwiseFunction · 0.50

Tested by

no test coverage detected