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

Function MultRow

src/core/tensor/tensor.cc:1488–1502  ·  view source on GitHub ↗

Multiply row 'v' with each row of matrix M; write results into 'out'

Source from the content-addressed store, hash-verified

1486
1487/// Multiply row 'v' with each row of matrix M; write results into 'out'
1488void MultRow(const Tensor &v, Tensor *M) {
1489 // CHECK(!M->transpose()) << "Not supported yet";
1490 CHECK_EQ(M->nDim(), 2u);
1491 // CHECK_EQ(v.nDim(), 1u); (chonho) shape of v is 2-element tuple
1492 CHECK_EQ(v.Size(), M->shape(1));
1493 CheckDataTypeAndLang(*M, v);
1494 TYPE_LANG_SWITCH(v.data_type(), DType, v.device()->lang(), Lang, {
1495 Tensor &MRef = *M;
1496 v.device()->Exec(
1497 [MRef, v](Context *ctx) mutable {
1498 DGMM<DType, Lang>(true, MRef, v, &MRef, ctx);
1499 },
1500 {M->block(), v.block()}, {M->block()}, "MultRow");
1501 });
1502}
1503
1504void SubColumn(const Tensor &v, Tensor *M) { AddColumn(-1, 1, v, M); }
1505

Callers 6

TEST_FFunction · 0.85
DivRowFunction · 0.85
ForwardMethod · 0.85
BackwardMethod · 0.85
ForwardMethod · 0.85
BackwardMethod · 0.85

Calls 9

CheckDataTypeAndLangFunction · 0.85
nDimMethod · 0.80
shapeMethod · 0.80
data_typeMethod · 0.80
langMethod · 0.80
deviceMethod · 0.80
ExecMethod · 0.80
SizeMethod · 0.45
blockMethod · 0.45

Tested by 1

TEST_FFunction · 0.68