提交 645d7155 authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Update Cython-generated Scan code

上级 e09e2b1e
This source diff could not be displayed because it is too large. You can view the blob instead.
@@ -6667,7 +6667,7 @@
* cdef list stack
* cdef int offset
*/
- __pyx_t_3 = ((PyObject *)__pyx_v_self->descr);
+ __pyx_t_3 = ((PyObject *)PyArray_DESCR(__pyx_v_self));
__Pyx_INCREF(__pyx_t_3);
__pyx_v_descr = ((PyArray_Descr *)__pyx_t_3);
__pyx_t_3 = 0;
@@ -8237,7 +8237,7 @@
* arr.base = baseptr
*
*/
- Py_XDECREF(__pyx_v_arr->base);
+ Py_XDECREF(PyArray_BASE(__pyx_v_arr));
/* "numpy.pxd":973
* baseptr = <PyObject*>base
@@ -8246,7 +8246,11 @@
*
* cdef inline object get_array_base(ndarray arr):
*/
- __pyx_v_arr->base = __pyx_v_baseptr;
+ #if NPY_API_VERSION < 0x00000007
+ PyArray_BASE(__pyx_v_arr) = __pyx_v_baseptr;
+ #else
+ PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_baseptr);
+ #endif
__Pyx_RefNannyFinishContext();
}
@@ -8285,7 +8285,7 @@
* return None
* else:
*/
- __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0);
+ __pyx_t_1 = ((PyArray_BASE(__pyx_v_arr) == NULL) != 0);
if (__pyx_t_1) {
/* "numpy.pxd":977
@@ -8307,8 +8311,8 @@
* return <object>arr.base # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
- __pyx_r = ((PyObject *)__pyx_v_arr->base);
+ __Pyx_INCREF(((PyObject *)PyArray_BASE(__pyx_v_arr)));
+ __pyx_r = ((PyObject *)PyArray_BASE(__pyx_v_arr));
goto __pyx_L0;
}
__pyx_L3:;
# cython: language_level=3
"""
This code implements the operations that scan has to carry on when called
as a stand alone function.
......@@ -64,7 +65,7 @@ from theano import gof
def get_version():
return 0.296
return 0.297
@cython.boundscheck(False)
def perform(
......@@ -404,14 +405,15 @@ def perform(
# done by raise_with_op is not implemented in C.
if hasattr(fn, 'thunks'):
# For the CVM
gof.link.raise_with_op(fn.nodes[fn.position_of_error],
gof.link.raise_with_op(fn.maker.fgraph,
fn.nodes[fn.position_of_error],
fn.thunks[fn.position_of_error])
else:
# For the c linker
# We don't have access from python to all the
# temps values So for now, we just don't print
# the extra shapes/strides info
gof.vm.raise_with_op(fn.nodes[fn.position_of_error])
gof.link.raise_with_op(fn.maker.fgraph, fn.nodes[fn.position_of_error])
else:
# old-style linkers raise their own exceptions
raise
......
"""
To update the scan Cython code in Theano you must
- update the version in this file and scan_perform.py
- call "cd theano/scan/; cython scan_perform.pyx; patch scan_perform.c numpy_api_changes.diff"
To update the `Scan` Cython code you must
- update the version value in this file and `scan_perform.py`, and
- run `cython scan_perform.pyx; mv scan_perform.c c_code`
"""
......@@ -24,7 +25,7 @@ from theano.gof.compilelock import get_lock, release_lock
_logger = logging.getLogger("theano.scan.scan_perform")
version = 0.296 # must match constant returned in function get_version()
version = 0.297 # must match constant returned in function get_version()
need_reload = False
......@@ -143,7 +144,7 @@ except ImportError:
release_lock()
# This is caused as cython use the old NumPy C-API but we use the new one.
# To fix it completly, we would need to modify Cython to use the new API.
# To fix it completely, we would need to modify Cython to use the new API.
with warnings.catch_warnings():
warnings.filterwarnings("ignore", message="numpy.ndarray size changed")
from scan_perform.scan_perform import get_version, perform # noqa: F401
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论