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

Function sum_columns

python/singa/tensor.py:1723–1735  ·  view source on GitHub ↗

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

(M)

Source from the content-addressed store, hash-verified

1721
1722
1723def sum_columns(M):
1724 '''Sum all columns into a single column.
1725
1726 Args:
1727 M (Tensor): the input 2d tensor.
1728
1729 Returns:
1730 a new Tensor as the resulted column.
1731 '''
1732 assert M.ndim() == 2, 'M.nDim() is supposed to be 2'
1733 ret = Tensor((M.shape[0], 1), M.data.device())
1734 singa.SumColumns(M.data, ret.data)
1735 return ret
1736
1737
1738def sum_rows(M):

Callers

nothing calls this directly

Calls 3

deviceMethod · 0.80
TensorClass · 0.70
ndimMethod · 0.45

Tested by

no test coverage detected