Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a0cc7932
提交
a0cc7932
authored
2月 23, 2015
作者:
Pierre Luc Carrier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update cython backend to match python backend
上级
5c65d8b9
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
39 行增加
和
20 行删除
+39
-20
numpy_api_changes.diff
theano/scan_module/numpy_api_changes.diff
+14
-16
scan_perform.c
theano/scan_module/scan_perform.c
+0
-0
scan_perform.pyx
theano/scan_module/scan_perform.pyx
+25
-4
没有找到文件。
theano/scan_module/numpy_api_changes.diff
浏览文件 @
a0cc7932
diff --git a/theano/scan_module/scan_perform.c b/theano/scan_module/scan_perform.c
@@ -5597,7 +5597,7 @@
index aaebb43..2d06b29 100644
--- a/theano/scan_module/scan_perform.c
+++ b/theano/scan_module/scan_perform.c
@@ -5595,7 +5595,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* cdef list stack
* cdef list stack
* cdef int offset
* cdef int offset
*/
*/
...
@@ -11,29 +7,29 @@ index aaebb43..2d06b29 100644
...
@@ -11,29 +7,29 @@ index aaebb43..2d06b29 100644
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(__pyx_t_4);
__pyx_v_descr = ((PyArray_Descr *)__pyx_t_4);
__pyx_v_descr = ((PyArray_Descr *)__pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_4 = 0;
@@ -71
47,7 +7147,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
@@ -71
26,7 +7126,7 @@
* arr.base = baseptr
* arr.base = baseptr
*
*
*/
*/
- Py_XDECREF(__pyx_v_arr->base);
- Py_XDECREF(__pyx_v_arr->base);
+ Py_XDECREF(PyArray_BASE(__pyx_v_arr));
+ Py_XDECREF(PyArray_BASE(__pyx_v_arr));
/* "
/home/anakha/.local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974
/* "
numpy.pxd":973
* baseptr = <PyObject*>base
* baseptr = <PyObject*>base
@@ -71
56,7 +7156,11 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
@@ -71
35,7 +7135,11 @@
*
*
* cdef inline object get_array_base(ndarray arr):
* cdef inline object get_array_base(ndarray arr):
*/
*/
- __pyx_v_arr->base = __pyx_v_baseptr;
- __pyx_v_arr->base = __pyx_v_baseptr;
+#if NPY_API_VERSION < 0x00000007
+
#if NPY_API_VERSION < 0x00000007
+ PyArray_BASE(__pyx_v_arr) = __pyx_v_baseptr;
+ PyArray_BASE(__pyx_v_arr) = __pyx_v_baseptr;
+#else
+
#else
+ PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_baseptr);
+ PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_baseptr);
+#endif
+
#endif
/* "/home/anakha/.local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966
__Pyx_RefNannyFinishContext();
*
}
@@ -71
91,7 +7195,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py
@@ -71
61,7 +7165,7 @@
* return None
* return None
* else:
* else:
*/
*/
...
@@ -41,8 +37,8 @@ index aaebb43..2d06b29 100644
...
@@ -41,8 +37,8 @@ index aaebb43..2d06b29 100644
+ __pyx_t_1 = ((PyArray_BASE(__pyx_v_arr) == NULL) != 0);
+ __pyx_t_1 = ((PyArray_BASE(__pyx_v_arr) == NULL) != 0);
if (__pyx_t_1) {
if (__pyx_t_1) {
/* "
/home/anakha/.local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":978
/* "
numpy.pxd":977
@@ -7
214,8 +7218,8 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py
@@ -7
185,8 +7189,8 @@
* return <object>arr.base # <<<<<<<<<<<<<<
* return <object>arr.base # <<<<<<<<<<<<<<
*/
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_XDECREF(__pyx_r);
...
@@ -52,4 +48,6 @@ index aaebb43..2d06b29 100644
...
@@ -52,4 +48,6 @@ index aaebb43..2d06b29 100644
+ __pyx_r = ((PyObject *)PyArray_BASE(__pyx_v_arr));
+ __pyx_r = ((PyObject *)PyArray_BASE(__pyx_v_arr));
goto __pyx_L0;
goto __pyx_L0;
}
}
__pyx_L3:;
theano/scan_module/scan_perform.c
浏览文件 @
a0cc7932
This source diff could not be displayed because it is too large. You can
view the blob
instead.
theano/scan_module/scan_perform.pyx
浏览文件 @
a0cc7932
...
@@ -191,6 +191,10 @@ def perform(
...
@@ -191,6 +191,10 @@ def perform(
cdef unsigned int begin
cdef unsigned int begin
cdef unsigned int end
cdef unsigned int end
cdef int cond
cdef int cond
cdef unsigned int len_output_storage = (n_mit_mot_outs + n_mit_sot +
n_sit_sot + n_nit_sot +
n_shared_outs)
cdef int output_reused[500] # max 500 outputs
if n_steps < 0:
if n_steps < 0:
...
@@ -304,11 +308,14 @@ def perform(
...
@@ -304,11 +308,14 @@ def perform(
offset += 1
offset += 1
# 4. collecting slices where the output should be stored
# 4. collecting slices where the output should be stored
# 4.1. Collect slices for mitmots
for idx in range(n_mit_mot_outs):
for idx in range(n_mit_mot_outs):
output_storage[idx].storage[0] = None
output_storage[idx].storage[0] = None
# 4.2. Collect slices for mitsots, sitsots and nitsots
offset = n_mit_mot_outs
offset = n_mit_mot_outs
if i !=
0 and n_nit_sot >
0:
if i !=
0:
for idx in range(n_outs + n_nit_sot - n_mit_mot):
for idx in range(n_outs + n_nit_sot - n_mit_mot):
if ( store_steps[<unsigned int>(idx+n_mit_mot)] == 1 or
if ( store_steps[<unsigned int>(idx+n_mit_mot)] == 1 or
vector_outs[<unsigned int>(idx+n_mit_mot)] == 1):
vector_outs[<unsigned int>(idx+n_mit_mot)] == 1):
...
@@ -321,12 +328,21 @@ def perform(
...
@@ -321,12 +328,21 @@ def perform(
for idx in range(n_outs + n_nit_sot - n_mit_mot):
for idx in range(n_outs + n_nit_sot - n_mit_mot):
output_storage[<unsigned int>(idx+offset)].storage[0] = None
output_storage[<unsigned int>(idx+offset)].storage[0] = None
# 4.3. Collect slices for shared outputs
offset += n_outs+n_nit_sot - n_mit_mot
offset += n_outs+n_nit_sot - n_mit_mot
for idx in range(n_shared_outs):
for idx in range(n_shared_outs):
output_storage[<unsigned int>(idx+offset)].storage[0] = None
output_storage[<unsigned int>(idx+offset)].storage[0] = None
# 4.4. If there is a condition add it to the mix
if as_while:
if as_while:
pdx = offset + n_shared_outs
pdx = offset + n_shared_outs
output_storage[<unsigned int>pdx].storage[0] = None
output_storage[<unsigned int>pdx].storage[0] = None
# 4.5. Keep a reference to the variables currently in the
# output_storage to be able to compare them with the actual
# outputs of the inner function after its execution
old_output_storage = [o.storage[0] for o in output_storage]
# 5. compute outputs
# 5. compute outputs
t0_fn = time.time()
t0_fn = time.time()
...
@@ -348,6 +364,11 @@ def perform(
...
@@ -348,6 +364,11 @@ def perform(
pdx = offset + n_shared_outs
pdx = offset + n_shared_outs
cond = output_storage[pdx].storage[0] == 0
cond = output_storage[pdx].storage[0] == 0
# Check which of the pre-allocated outputs (if applicable) have
# been reused by the inner function
for j in range(len_output_storage):
output_reused[j] = (old_output_storage[j] is
output_storage[j].storage[0])
offset_out = 0
offset_out = 0
# 5.1 Copy over the values for mit_mot outputs
# 5.1 Copy over the values for mit_mot outputs
...
@@ -363,8 +384,8 @@ def perform(
...
@@ -363,8 +384,8 @@ def perform(
offset_out -= n_mit_mot
offset_out -= n_mit_mot
for j in range(begin, end):
for j in range(begin, end):
if (
store_steps[j] == 1 or vector_outs[j] ==
1 or
if (
store_steps[j] == 1 or vector_outs[j] ==
1 or
outs[j][0][pos[j]] is not output_storage[<unsigned int>(offset_out+j)].storage[0
]):
not output_reused[<unsigned int>(offset_out+j)
]):
outs[j][0][pos[j]] = output_storage[<unsigned int>(offset_out+j)].storage[0]
outs[j][0][pos[j]] = output_storage[<unsigned int>(offset_out+j)].storage[0]
...
@@ -387,7 +408,7 @@ def perform(
...
@@ -387,7 +408,7 @@ def perform(
outs[j][0] = outs[j][0][:store_steps[j]]
outs[j][0] = outs[j][0][:store_steps[j]]
outs[j][0][pos[j]] = output_storage[jout].storage[0]
outs[j][0][pos[j]] = output_storage[jout].storage[0]
elif (store_steps[j] == 1 or vector_outs[j] == 1 or
elif (store_steps[j] == 1 or vector_outs[j] == 1 or
outs[j][0][pos[j]] is not output_storage[j+offset_out].storage[0
]):
not output_reused[<unsigned int>(offset_out+j)
]):
outs[j][0][pos[j]] = output_storage[j+offset_out].storage[0]
outs[j][0][pos[j]] = output_storage[j+offset_out].storage[0]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论