You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DOC: how to find your way in the code, for instance the dot function #15567
I've been trying to figure out how np.dot works for multi-dimensional arrays (dimension > 2). I couldn't quite locate where this is specified in the source code. I assume this is done in C with multiple calls to cblas gemm. Any pointers will be most appreciated!
While not truly an issue per-se, I think we should discuss adding a "how to browse the code" section to the documentation with this as an example, so I am changing the title and marking this "Documentation"
Reacted by Ross Barnowski, tachukao, Meekail Zain and Frank Facundo
Activity
mattip commentedon Feb 14, 2020
Assuming you are using a BLAS backend, it is
array_dot -> PyArray_MatrixProduct2, which creates an iterator and calls dot. That function is actually part of the descr, and is found as
dot = PyArray_DESCR(out_buf)->f->dotfuncon line 993. So what isdotfunc? It is aPyArray_DotFunc, defined by templated code in https://github.com/numpy/numpy/blob/v1.18.1/numpy/core/src/multiarray/arraytypes.c.src. For float32, float64, the function used is this one, for complex this one, and for ints the non-blas one. Then those functions are assigned to the correct slot in some more templated code. I have not show all of the variants inarraytypes.c.src, but this should get you started.While not truly an issue per-se, I think we should discuss adding a "how to browse the code" section to the documentation with this as an example, so I am changing the title and marking this "Documentation"
[-]dot function source code[/-][+]DOC: how to find your way in the code, for instance the dot function[/+]Kai-Striega commentedon Jan 26, 2023
Maybe the documentation should also link to this video?
tachukao commentedon Jan 26, 2023
thanks @mattip and @Kai-Striega for the pointers!!