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

Function cumsum

imperative/python/megengine/functional/tensor.py:1296–1321  ·  view source on GitHub ↗

r"""Calculates the cumulative sum of tensor elements over a given axis. Args: inp: input tensor. Should have a numeric data type. axis: axis along which cumulative sums must be computed. Returns: a tensor containing the cumulative sums. Examples: If :m

(inp: Tensor, axis: int)

Source from the content-addressed store, hash-verified

1294
1295
1296def cumsum(inp: Tensor, axis: int):
1297 r"""Calculates the cumulative sum of tensor elements over a given axis.
1298
1299 Args:
1300 inp: input tensor. Should have a numeric data type.
1301 axis: axis along which cumulative sums must be computed.
1302
1303 Returns:
1304 a tensor containing the cumulative sums.
1305
1306 Examples:
1307
1308 If :math:`x_i` is ``NaN``, the cumulative sums is ``NaN`` (i.e., ``NaN`` values propagate).
1309
1310 Examples:
1311 >>> x = Tensor([[1, 2, 3], [4, 5, 6]])
1312 >>> F.cumsum(x, axis = 0)
1313 Tensor([[1 2 3]
1314 [5 7 9]], dtype=int32, device=xpux:0)
1315 >>> F.cumsum(x, axis = 1)
1316 Tensor([[ 1 3 6]
1317 [ 4 9 15]], dtype=int32, device=xpux:0)
1318
1319 """
1320 op = builtin.Cumsum(axis=axis, exclusive=False, reverse=False)
1321 return apply(op, inp)[0]
1322
1323
1324def meshgrid(*inputs: Tensor, indexing: str = "xy") -> List[Tensor]:

Callers 3

__init__Method · 0.85
_gen_repeat_idxFunction · 0.85
_gen_tile_idxFunction · 0.85

Calls 2

CumsumMethod · 0.80
applyFunction · 0.50

Tested by

no test coverage detected