-
Notifications
You must be signed in to change notification settings - Fork 139
Remove uses of numba_basic.global_numba_func
#1535
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
Changes from 1 commit
dcd2576
7f61fb8
7051623
173a5ba
9dfd496
9c42383
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
from pytensor.graph.fg import FunctionGraph | ||
from pytensor.graph.type import Type | ||
from pytensor.ifelse import IfElse | ||
from pytensor.link.numba.dispatch import basic as numba_basic | ||
from pytensor.link.numba.dispatch.sparse import CSCMatrixType, CSRMatrixType | ||
from pytensor.link.utils import ( | ||
compile_function_src, | ||
|
@@ -42,14 +43,6 @@ | |
from pytensor.tensor.type_other import MakeSlice, NoneConst | ||
|
||
|
||
def global_numba_func(func): | ||
"""Use to return global numba functions in numba_funcify_*. | ||
|
||
This allows tests to remove the compilation using mock. | ||
""" | ||
return func | ||
|
||
|
||
def numba_njit(*args, fastmath=None, **kwargs): | ||
kwargs.setdefault("cache", config.numba__cache) | ||
kwargs.setdefault("no_cpython_wrapper", True) | ||
|
@@ -402,24 +395,22 @@ | |
return deepcopyop | ||
|
||
|
||
@numba_njit | ||
def makeslice(*x): | ||
return slice(*x) | ||
|
||
|
||
@numba_funcify.register(MakeSlice) | ||
def numba_funcify_MakeSlice(op, **kwargs): | ||
return global_numba_func(makeslice) | ||
@numba_basic.numba_njit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. numba_njit is defined in this module There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, cutting and pasting from the other file one without reading 😓 |
||
def makeslice(*x): | ||
return slice(*x) | ||
|
||
|
||
@numba_njit | ||
def shape(x): | ||
return np.asarray(np.shape(x)) | ||
return makeslice | ||
|
||
|
||
@numba_funcify.register(Shape) | ||
def numba_funcify_Shape(op, **kwargs): | ||
return global_numba_func(shape) | ||
@numba_basic.numba_njit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed, same above |
||
def shape(x): | ||
return np.asarray(np.shape(x)) | ||
|
||
return shape | ||
|
||
|
||
@numba_funcify.register(Shape_i) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,18 +175,9 @@ def inner_vec(*args): | |
else: | ||
return wrap | ||
|
||
def py_global_numba_func(func): | ||
if hasattr(func, "py_func"): | ||
return func.py_func | ||
return func | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes seem unrelated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rolled back these changes. |
||
|
||
mocks = [ | ||
mock.patch("numba.njit", njit_noop), | ||
mock.patch("numba.vectorize", vectorize_noop), | ||
mock.patch( | ||
"pytensor.link.numba.dispatch.basic.global_numba_func", | ||
py_global_numba_func, | ||
), | ||
mock.patch( | ||
"pytensor.link.numba.dispatch.basic.tuple_setitem", py_tuple_setitem | ||
), | ||
|
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.
basic is the file where we are?