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

Function SumColumns

src/core/tensor/tensor.cc:1508–1522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1506void SubRow(const Tensor &v, Tensor *M) { AddRow(-1, 1, v, M); }
1507
1508void SumColumns(const Tensor &M, Tensor *v) {
1509 if (M.transpose()) {
1510 Tensor X = Transpose(M);
1511 SumRows(X, v);
1512 } else {
1513 CHECK_EQ(M.nDim(), 2u);
1514 // CHECK_EQ(v->nDim(), 1u); (chonho) shape of v is 2-element tuple
1515 size_t nb_row = M.shape().at(0), nb_col = M.shape().at(1);
1516 CHECK_EQ(nb_row, v->Size());
1517
1518 Tensor one(Shape{nb_col}, M.device(), M.data_type());
1519 one.SetValue(1.0f); // TODO(wangwei) cast type
1520 Mult(M, one, v);
1521 }
1522}
1523void SumRows(const Tensor &M, Tensor *v) {
1524 if (M.transpose()) {
1525 Tensor X = Transpose(M);

Callers 9

TEST_FFunction · 0.85
SumFunction · 0.85
SumRowsFunction · 0.85
Cpp>Method · 0.85
CpuConvBackwardbFunction · 0.85
BackwardMethod · 0.85
BackwardMethod · 0.85
BackwardMethod · 0.85
BackwardMethod · 0.85

Calls 10

SumRowsFunction · 0.85
MultFunction · 0.85
nDimMethod · 0.80
shapeMethod · 0.80
deviceMethod · 0.80
data_typeMethod · 0.80
TransposeFunction · 0.70
transposeMethod · 0.45
SizeMethod · 0.45
SetValueMethod · 0.45

Tested by 1

TEST_FFunction · 0.68