Skip to content
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

Rewrite expand_dims implied in vector indices #1138

Open
ricardoV94 opened this issue Dec 26, 2024 · 0 comments
Open

Rewrite expand_dims implied in vector indices #1138

ricardoV94 opened this issue Dec 26, 2024 · 0 comments

Comments

@ricardoV94
Copy link
Member

ricardoV94 commented Dec 26, 2024

Description

The model behind #1132 cannot run in non-obj numba due to an implicit expand_dims in the vector indexing, that looks like:

import pytensor
import pytensor.tensor as pt
import numpy as np

a = pt.tensor(shape=(None, None))
b = a[pt.arange(10)[:, None], pt.arange(10)[:, None]]
c = a[pt.arange(10), pt.arange(10)][:, None]

# Issues UserWarning: Numba will use object mode to run AdvancedSubtensor's perform method
fn_b = pytensor.function([a], b, mode="NUMBA")

# Runs in non-obj mode
fn_c = pytensor.function([a], c, mode="NUMBA")

test_a = pt.random.normal(size=(10, 10)).eval()
np.testing.assert_allclose(fn_b(test_a), fn_c(test_a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant