10000 ENH: create and use indexed inner loops by mattip · Pull Request #23136 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: create and use indexed inner loops #23136

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

Merged
merged 20 commits into from
Feb 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BUG: fixes from review: use iter->nd and adapt to unary ufuncs
  • Loading branch information
mattip committed Feb 6, 2023
commit ff97723de0ff365f5d7f2b30be5ac7987511a584
17 changes: 11 additions & 6 deletions numpy/core/src/umath/ufunc_object.c
BA08
Original file line number Diff line number Diff line change
Expand Up @@ -5039,7 +5039,7 @@ ufunc_geterr(PyObject *NPY_UNUSED(dummy), PyObject *NPY_UNUSED(arg))
{
PyObject *thedict;
PyObject *res;

thedict = PyThreadState_GetDict();
if (thedict == NULL) {
thedict = PyEval_GetBuiltins();
Expand Down Expand Up @@ -5909,9 +5909,14 @@ trivial_at_loop(PyArrayMethodObject *ufuncimpl, NPY_ARRAYMETHOD_FLAGS flags,
char *args[3];
npy_intp steps[3];
args[0] = (char *) iter->baseoffset;
args[2] = (char *)PyArray_DATA(op2_array);
steps[0] = iter->fancy_strides[0];
steps[2] = PyArray_STRIDE(op2_array, 0);
if (ufuncimpl->nin == 1) {
args[2] = NULL;
steps[2] = 0;
} else {
args[2] = (char *)PyArray_DATA(op2_array);
steps[2] = PyArray_STRIDE(op2_array, 0);
}

npy_intp *inner_size = NpyIter_GetInnerLoopSizePtr(iter->outer);

Expand All @@ -5932,7 +5937,7 @@ trivial_at_loop(PyArrayMethodObject *ufuncimpl, NPY_ARRAYMETHOD_FLAGS flags,
}

if (res == 0 && !(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
const char * ufunc_name =
const char * ufunc_name =
ufunc_get_name_cstr((PyUFuncObject *)context->caller);
if (_get_bufsize_errmask(NULL, ufunc_name,
&buffersize, &errormask) < 0) {
Expand Down Expand Up @@ -6435,8 +6440,8 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
*/
if ((ufuncimpl->contiguous_indexed_loop != NULL) &&
(PyArray_NDIM(op1_array) == 1) &&
(ufuncimpl->nin == 1 || PyArray_NDIM(op2_array) == 1) &&
(iter->numiter == 1)) {
(op2_array != NULL && PyArray_NDIM(op2_array) == 1) &&
(iter->nd == 1)) {
res = trivial_at_loop(ufuncimpl, flags, iter, op1_array,
op2_array, &context);

Expand Down
0