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

Function min

imperative/python/megengine/functional/math.py:399–437  ·  view source on GitHub ↗

r"""Calculates the minimum of tensor elements over a given axis (or axes). Args: inp: input tensor. Should have a numeric data type. axis: axis or axes along which minimums must be computed. By default, the minimum must be computed over the entire tensor.

(
    inp: Tensor,
    axis: Optional[Union[int, Sequence[int]]] = None,
    keepdims: bool = False,
)

Source from the content-addressed store, hash-verified

397
398
399def min(
400 inp: Tensor,
401 axis: Optional[Union[int, Sequence[int]]] = None,
402 keepdims: bool = False,
403) -> Tensor:
404 r"""Calculates the minimum of tensor elements over a given axis (or axes).
405
406 Args:
407 inp: input tensor. Should have a numeric data type.
408 axis: axis or axes along which minimums must be computed.
409 By default, the minimum must be computed over the entire tensor.
410 If a sequence of integers, minimums must be computed over multiple axes.
411 keepdims: if ``True``, the reduced axes (dimensions) must be included in the result as singleton dimensions,
412 and, accordingly, the result must be compatible with the input tensor (see :ref:`broadcasting-rule`).
413 Otherwise, if ``False``, the reduced axes (dimensions) must not be included in the result.
414
415 Returns:
416 if the minimum was computed over the entire tensor, a zero-dimensional tensor containing the minimum;
417 otherwise, a non-zero-dimensional tensor containing the minimums.
418
419 .. admonition:: Special Cases
420
421 If :math:`x_i` is ``NaN``, the minimum is ``NaN`` (i.e., ``NaN`` values propagate).
422
423 Examples:
424
425 >>> x = Tensor([[1, 2], [3, 4]])
426 >>> F.min(x)
427 Tensor(1, dtype=int32, device=xpux:0)
428
429 Along an axis:
430
431 >>> F.min(x, axis=0)
432 Tensor([1 2], dtype=int32, device=xpux:0)
433 >>> F.min(x, axis=1)
434 Tensor([1 3], dtype=int32, device=xpux:0)
435
436 """
437 return inp.min(axis=axis, keepdims=keepdims)
438
439
440def max(

Callers 15

normFunction · 0.70
get_ndtupleFunction · 0.50
merge_trace_eventsFunction · 0.50
sideeffect_forwardMethod · 0.50
applyMethod · 0.50
_get_shapeMethod · 0.50
_get_shapeMethod · 0.50
_get_coordMethod · 0.50
reduce_lowerFunction · 0.50
minMethod · 0.50
_bmm_shape_helperFunction · 0.50

Calls 1

minMethod · 0.45

Tested by

no test coverage detected