-
Notifications
You must be signed in to change notification settings - Fork 149
Open
Labels
Description
Description
This breaks the semantics of ifelse and can even cause errors when trying to mutate a global array which is non-mutable by default in numba:
import pytensor
import pytensor.tensor as pt
from pytensor.compile.mode import Mode
x = pt.vector("x")
out = pytensor.ifelse(x.sum() > 0, x, x)
fn = pytensor.function([x], out, mode=Mode("numba", optimizer=None))
fn.dprint(print_memory_map=True) # Not a view
# if{} [id A] 2
# ├─ Gt [id B] 1
# │ ├─ Sum{axes=None} [id C] 0
# │ │ └─ x [id D]
# │ └─ 0 [id E]
# ├─ x [id D]
# └─ x [id D]
x_test = np.zeros((5,))
assert fn(x_test) is not x_test # Fails