Skip to content

Conversation

@ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Jan 13, 2026

Closes #1760

Inner functions of Blockwise will always get 0d arrays and not scalars, unlike Elemwise/RandomVariable inner functions.

This is also what the python impl of Blockwise already did, although it's not what numpy vectorize does. AFAICT there's no syntax to distinguish, but 0d array should be more robust (if more wasteful). It will also avoid numba/numba#10358

Most Blockwise Ops shouldn't have scalar inputs, or if they do, the cost of accessing them shouldn't dominate the runtime.

Cherry picked from #1806

*safe,
)
if core_ndim == 0:
if core_scalar and core_ndim == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if core_ndim == 0 but not core_scalar (the old case)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old case is this branch, it's what happens with elemwise. In that case the inner function gets a scalar not a 0d array.

@ricardoV94 ricardoV94 merged commit f360122 into pymc-devs:main Jan 13, 2026
66 checks passed
@ricardoV94 ricardoV94 deleted the numba_fix_scalar_blockwise branch January 13, 2026 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Numba obj fallback fails for Blockwise with scalar outputs

2 participants