Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
678816fa
提交
678816fa
authored
8月 01, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix updates in CVM
Changed the semantics of update_storage in CVM, so it contains only the input storage cells to update, and ensure they are in the same order as the computed outputs.
上级
d1e06e3a
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
16 行增加
和
13 行删除
+16
-13
lazylinker_c.c.txt
theano/gof/lazylinker_c.c.txt
+5
-10
lazylinker_c.py
theano/gof/lazylinker_c.py
+1
-1
vm.py
theano/gof/vm.py
+10
-2
没有找到文件。
theano/gof/lazylinker_c.c.txt
浏览文件 @
678816fa
...
@@ -103,7 +103,7 @@ typedef struct {
...
@@ -103,7 +103,7 @@ typedef struct {
Py_ssize_t * node_n_prereqs;
Py_ssize_t * node_n_prereqs;
Py_ssize_t ** node_prereqs;
Py_ssize_t ** node_prereqs;
Py_ssize_t * update_storage; //
dst0, src0, dst1, src1, ... cells to switch after a call
Py_ssize_t * update_storage; //
input cells to update with the last outputs in output_vars
Py_ssize_t n_updates;
Py_ssize_t n_updates;
void ** thunk_cptr_fn;
void ** thunk_cptr_fn;
...
@@ -467,8 +467,6 @@ CLazyLinker_init(CLazyLinker *self, PyObject *args, PyObject *kwds)
...
@@ -467,8 +467,6 @@ CLazyLinker_init(CLazyLinker *self, PyObject *args, PyObject *kwds)
if (unpack_list_of_ssize_t(update_storage, &self->update_storage, &self->n_updates,
if (unpack_list_of_ssize_t(update_storage, &self->update_storage, &self->n_updates,
"updates_storage"))
"updates_storage"))
return -1;
return -1;
assert((self->n_updates % 2) == 0);
self->n_updates /= 2;
return 0;
return 0;
}
}
static void set_position_of_error(CLazyLinker * self, int owner_idx)
static void set_position_of_error(CLazyLinker * self, int owner_idx)
...
@@ -841,8 +839,6 @@ CLazyLinker_call(PyObject *_self, PyObject *args, PyObject *kwds)
...
@@ -841,8 +839,6 @@ CLazyLinker_call(PyObject *_self, PyObject *args, PyObject *kwds)
if (!err)
if (!err)
{
{
// save references to outputs prior to updating storage containers
// save references to outputs prior to updating storage containers
if ((call_i + 1) == n_calls)
{
assert (self->n_output_vars >= self->n_updates);
assert (self->n_output_vars >= self->n_updates);
Py_DECREF(rval);
Py_DECREF(rval);
rval = PyList_New(self->n_output_vars);
rval = PyList_New(self->n_output_vars);
...
@@ -853,14 +849,13 @@ CLazyLinker_call(PyObject *_self, PyObject *args, PyObject *kwds)
...
@@ -853,14 +849,13 @@ CLazyLinker_call(PyObject *_self, PyObject *args, PyObject *kwds)
Py_INCREF(item);
Py_INCREF(item);
PyList_SetItem(rval, i, item);
PyList_SetItem(rval, i, item);
}
}
}
// Update the inputs that have an update rule
for (int i = 0; i < self->n_updates; ++i)
for (int i = 0; i < self->n_updates; ++i)
{
{
Py_ssize_t dst = self->update_storage[2*i];
PyObject* tmp = PyList_GetItem(rval, self->n_output_vars - self->n_updates + i);
Py_ssize_t src = self->update_storage[2*i+1];
PyObject* tmp = PyList_GetItem(self->var_value_cells[src], 0);
Py_INCREF(tmp);
Py_INCREF(tmp);
Py_ssize_t dst = self->update_storage[i];
PyList_SetItem(self->var_value_cells[dst], 0, tmp);
PyList_SetItem(self->var_value_cells[dst], 0, tmp);
}
}
}
}
...
@@ -973,7 +968,7 @@ static PyTypeObject lazylinker_ext_CLazyLinkerType = {
...
@@ -973,7 +968,7 @@ static PyTypeObject lazylinker_ext_CLazyLinkerType = {
static PyObject * get_version(PyObject *dummy, PyObject *args)
static PyObject * get_version(PyObject *dummy, PyObject *args)
{
{
PyObject *result = PyFloat_FromDouble(0.1
8
);
PyObject *result = PyFloat_FromDouble(0.1
9
);
return result;
return result;
}
}
...
...
theano/gof/lazylinker_c.py
浏览文件 @
678816fa
...
@@ -13,7 +13,7 @@ if config.compiledir not in sys.path:
...
@@ -13,7 +13,7 @@ if config.compiledir not in sys.path:
sys
.
path
.
append
(
config
.
compiledir
)
sys
.
path
.
append
(
config
.
compiledir
)
force_compile
=
False
force_compile
=
False
version
=
0.1
8
# must match constant returned in function get_version()
version
=
0.1
9
# must match constant returned in function get_version()
try
:
try
:
...
...
theano/gof/vm.py
浏览文件 @
678816fa
...
@@ -707,11 +707,19 @@ class VM_Linker(link.LocalLinker):
...
@@ -707,11 +707,19 @@ class VM_Linker(link.LocalLinker):
prereq_var_idxs
.
sort
()
# TODO: why sort?
prereq_var_idxs
.
sort
()
# TODO: why sort?
node_prereqs
.
append
(
prereq_var_idxs
)
node_prereqs
.
append
(
prereq_var_idxs
)
# Builds the list of input storage to update (according to update
# rules) when the outputs are computed.
# They are in the same order as the second part of output_vars
# (output_vars contains first the returned outputs, then the
# values of the update expressions).
update_storage
=
[]
update_storage
=
[]
update_in_from_out
=
{}
for
(
ivar
,
ovar
)
in
updated_vars
.
items
():
for
(
ivar
,
ovar
)
in
updated_vars
.
items
():
if
ivar
!=
ovar
:
if
ivar
!=
ovar
:
update_storage
.
append
(
vars_idx
[
ivar
])
# dst
update_in_from_out
[
vars_idx
[
ovar
]]
=
vars_idx
[
ivar
]
update_storage
.
append
(
vars_idx
[
ovar
])
# src
for
oidx
in
output_vars
:
if
oidx
in
update_in_from_out
:
update_storage
.
append
(
update_in_from_out
[
oidx
])
c0
=
sys
.
getrefcount
(
node_n_inputs
)
c0
=
sys
.
getrefcount
(
node_n_inputs
)
vm
=
CVM
(
vm
=
CVM
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论