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

Function mult

examples/model_selection/Trails/singa_pkg_code/tensor.py:1267–1297  ·  view source on GitHub ↗

Do matrix-matrix or matrix-vector multiplication. This function returns C = alpha * A * B + beta * C Currently below cases are supported case 1 - matrix * vector: A (Tensor): 2d Tensor B (Tensor): 1d Tensor, GEMV would be invoked case 2 - matrix * matr

(A, B, C=None, alpha=1.0, beta=0.0)

Source from the content-addressed store, hash-verified

1265
1266
1267def mult(A, B, C=None, alpha=1.0, beta=0.0):
1268 '''Do matrix-matrix or matrix-vector multiplication.
1269 This function returns C = alpha * A * B + beta * C
1270 Currently below cases are supported
1271 case 1 - matrix * vector:
1272 A (Tensor): 2d Tensor
1273 B (Tensor): 1d Tensor, GEMV would be invoked
1274 case 2 - matrix * matrix:
1275 A (Tensor): 2d Tensor
1276 B (Tensor): 2d Tensor, GEMM would be invoked
1277 case 3 - batched matrix * batched matrix:
1278 A (Tensor): 3/4d Tensor
1279 B (Tensor): 3/4d Tensor, batched GEMM would be invoked
1280 Where first/first and second dimension(s) of A, B should be exactly the same
1281 e.g. C{2,3,4,6} = A{2,3,4,5} * B{2,3,5,6}
1282
1283 Args:
1284 A: n-d tensor
1285 B: n-d tensor
1286 C (Tensor, optional): for storing the result; If None, a new Tensor would be created.
1287 alpha (float): scaling factor
1288 beta (float): scaling factor
1289
1290 Returns:
1291 the result Tensor
1292 '''
1293 if C is None:
1294 return _call_singa_func(singa.Mult, A.data, B.data)
1295 else:
1296 singa.MultWithScale(alpha, A.data, B.data, beta, C.data)
1297 return C
1298
1299
1300def einsum(ops, *args):

Callers 1

tensordotFunction · 0.70

Calls 1

_call_singa_funcFunction · 0.70

Tested by

no test coverage detected