Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: how to find your way in the code, for instance the dot function #15567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tachukao opened this issue Feb 14, 2020 · 3 comments
Open

DOC: how to find your way in the code, for instance the dot function #15567

tachukao opened this issue Feb 14, 2020 · 3 comments
Labels
04 - Documentation component: numpy._core sprintable Issue fits the time-frame and setting of a sprint

Comments

@tachukao
Copy link

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!

@mattip
Copy link
Member

mattip commented 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->dotfunc on line 993. So what is dotfunc ? It is a PyArray_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 in arraytypes.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"

@mattip mattip changed the title dot function source code DOC: how to find your way in the code, for instance the dot function Feb 14, 2020
@InessaPawson InessaPawson added the sprintable Issue fits the time-frame and setting of a sprint label Jan 6, 2022
@Kai-Striega
Copy link
Member

Maybe the documentation should also link to this video?

@tachukao
Copy link
Author

thanks @mattip and @Kai-Striega for the pointers!!

@tachukao tachukao reopened this Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
04 - Documentation component: numpy._core sprintable Issue fits the time-frame and setting of a sprint
Projects
None yet
Development

No branches or pull requests

4 participants