MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / remainder

Function remainder

python/paddle/tensor/math.py:1234–1294  ·  view source on GitHub ↗

r""" Mod two tensors element-wise. The equation is: .. math:: out = x \% y .. note:: Alias Support: The parameter name ``input`` can be used as an alias for ``x``, and ``other`` can be used as an alias for ``y``. Note: ``paddle.remainder`` supports broadca

(
    x: Tensor, y: Tensor, name: str | None = None, *, out: Tensor | None = None
)

Source from the content-addressed store, hash-verified

1232
1233@param_two_alias(["x", "input"], ["y", "other"])
1234def remainder(
1235 x: Tensor, y: Tensor, name: str | None = None, *, out: Tensor | None = None
1236) -> Tensor:
1237 r"""
1238 Mod two tensors element-wise. The equation is:
1239
1240 .. math::
1241
1242 out = x \% y
1243
1244 .. note::
1245 Alias Support: The parameter name ``input`` can be used as an alias for ``x``, and ``other`` can be used as an alias for ``y``.
1246
1247 Note:
1248 ``paddle.remainder`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
1249
1250 .. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
1251
1252 And `mod`, `floor_mod` are all functions with the same name
1253
1254 Args:
1255 x (Tensor): the input tensor, it's data type should be bfloat16, float16, float32, float64, int32, int64.
1256 y (Tensor): the input tensor, it's data type should be bfloat16, float16, float32, float64, int32, int64.
1257 name (str|None, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
1258
1259 Keyword Args:
1260 out (Tensor|None, optional): The output tensor. If set, the result will be stored in this tensor. Default is None.
1261
1262 Returns:
1263 N-D Tensor. A location into which the result is stored. If x, y have different shapes and are "broadcastable", the resulting tensor shape is the shape of x and y after broadcasting. If x, y have the same shape, its shape is the same as x and y.
1264
1265 Examples:
1266
1267 .. code-block:: pycon
1268
1269 >>> import paddle
1270
1271 >>> x = paddle.to_tensor([2, 3, 8, 7])
1272 >>> y = paddle.to_tensor([1, 5, 3, 3])
1273 >>> z = paddle.remainder(x, y)
1274 >>> print(z)
1275 Tensor(shape=[4], dtype=int64, place=Place(cpu), stop_gradient=True,
1276 [0, 3, 2, 1])
1277
1278 >>> z = paddle.floor_mod(x, y)
1279 >>> print(z)
1280 Tensor(shape=[4], dtype=int64, place=Place(cpu), stop_gradient=True,
1281 [0, 3, 2, 1])
1282
1283 >>> z = paddle.mod(x, y)
1284 >>> print(z)
1285 Tensor(shape=[4], dtype=int64, place=Place(cpu), stop_gradient=True,
1286 [0, 3, 2, 1])
1287
1288 """
1289 if in_dynamic_or_pir_mode():
1290 if isinstance(y, (int, float)):
1291 y = paddle.full([], y, dtype=x.dtype)

Callers

nothing calls this directly

Calls 4

in_dynamic_or_pir_modeFunction · 0.85
_elementwise_opFunction · 0.85
LayerHelperClass · 0.85
fullMethod · 0.80

Tested by

no test coverage detected