<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 31, 2021 at 2:35 AM Guillaume Bethouart <<a href="mailto:guillaume.bethouart@eshard.com">guillaume.bethouart@eshard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Is it possible to add a method to perform a dot product and add the result to an existing matrix in a single operation ?</div><div dir="ltr"><br>Like C = dot_add(A, B, C) equivalent to C += A @ B.This behavior is natively proposed by the Blas *gemm primitive.</div><div dir="ltr"><br>The goal is to reduce the peak memory consumption. Indeed, during the computation of C += A @ B, the maximum allocated memory is twice the size of C.Using *gemm to add directly the result , the maximum memory consumption is less than 1.5x the size of C. </div><div dir="ltr">This difference is significant for large matrices.</div><div dir="ltr"><br>Any people interested in it ?<span><span><br></span></span></div></div></div></blockquote><div><br></div><div>Hi Guillaume, such fused operations cannot easily be done with NumPy alone, and it does not make sense to add separate APIs for that purpose because there are so many combinations of function calls that one might want to fuse.</div><div><br></div><div>Instead, Numba, Pythran or numexpr can add this to some extent for numpy code. E.g. search for "loop fusion" in the Numba docs.</div><div><br></div><div>Cheers,<br></div><div>Ralf</div></div></div>