MCPcopy Create free account
hub / github.com/apache/singa / sum_rows

Function sum_rows

python/singa/tensor.py:1738–1750  ·  view source on GitHub ↗

Sum all rows into a single row. Args: M (Tensor): the input 2d tensor. Returns: a new Tensor as the resulted row.

(M)

Source from the content-addressed store, hash-verified

1736
1737
1738def sum_rows(M):
1739 '''Sum all rows into a single row.
1740
1741 Args:
1742 M (Tensor): the input 2d tensor.
1743
1744 Returns:
1745 a new Tensor as the resulted row.
1746 '''
1747 assert M.ndim() == 2, 'M.nDim() is supposed to be 2'
1748 ret = Tensor((1, M.shape[1]), M.data.device())
1749 singa.SumRows(M.data, ret.data)
1750 return ret
1751
1752
1753''' private functions, internally used

Callers

nothing calls this directly

Calls 3

deviceMethod · 0.80
TensorClass · 0.70
ndimMethod · 0.45

Tested by

no test coverage detected