-
Notifications
You must be signed in to change notification settings - Fork 149
Fix non-inplace IfElse on numba mode #1765
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -109,22 +109,28 @@ def numba_funcify_IfElse(op, **kwargs): | |||||||
| @numba_basic.numba_njit | ||||||||
| def ifelse(cond, *args): | ||||||||
| if cond: | ||||||||
| res = args[:n_outs] | ||||||||
| selected = args[:n_outs] | ||||||||
| else: | ||||||||
| res = args[n_outs:] | ||||||||
| selected = args[n_outs:] | ||||||||
|
|
||||||||
| return res | ||||||||
| # Return a tuple of copies | ||||||||
| out = [None] * n_outs | ||||||||
| for i in range(n_outs): | ||||||||
| out[i] = selected[i].copy() | ||||||||
|
|
||||||||
| return tuple(out) | ||||||||
|
|
||||||||
| else: | ||||||||
|
|
||||||||
| @numba_basic.numba_njit | ||||||||
| def ifelse(cond, *args): | ||||||||
| if cond: | ||||||||
| res = args[:n_outs] | ||||||||
| arr = args[0] | ||||||||
|
||||||||
| else: | ||||||||
| res = args[n_outs:] | ||||||||
| arr = args[1] | ||||||||
|
|
||||||||
| return res[0] | ||||||||
| # Return a copy | ||||||||
| return arr.copy() | ||||||||
|
|
||||||||
| return ifelse | ||||||||
|
||||||||
| return ifelse | |
| cache_version = 1 | |
| return ifelse, cache_version |
We need to tell PyTensor the implementation of ifelse changed to invalidate old caches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only make a copy if not op.inplace