2 years ago
#20040
AlphaF20
Is there any DGEMM-type einsum in python?
In DGEMM
http://www.netlib.org/lapack/explore-html/d1/d54/group__double__blas__level3_gaeda3cbd99c8fb834a60a6412878226e1.html#gaeda3cbd99c8fb834a60a6412878226e1
one can do C = alpha * A.B + beta*C
In eimsum
, there is ij,jk->ik
(or more general indices) for A.B
. Is there any efficient way to incorporate alpha
and beta*C
, presumbly A
and B
are general-rank arrays? or Do I need to write several lines of operations with np.dot
for alpha,beta
and np.add
for beta*C
?
I tried
na = nb = nc = nd = 50
A = np.random.random((na,nb))
B = np.random.random((nb,nc))
C = np.random.random((na,nc))
np.einsum('ab,bc + ac ->ac',A,B)
got
ValueError: invalid subscript '+' in einstein sum subscripts string, subscripts must be letters
It seems scipy.linalg.blas.dgemm
can do it, but only for rank-2 array https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.blas.dgemm.html
python
numpy
blas
numpy-einsum
0 Answers
Your Answer