Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
10845218
提交
10845218
authored
9月 26, 2009
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed cc's cache-key generator in the corner case of multiple constants with
different ids that compare equal.
上级
0b02bf05
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
25 行增加
和
14 行删除
+25
-14
cc.py
theano/gof/cc.py
+25
-14
没有找到文件。
theano/gof/cc.py
浏览文件 @
10845218
...
@@ -781,15 +781,21 @@ class CLinker(link.Linker):
...
@@ -781,15 +781,21 @@ class CLinker(link.Linker):
``a`` is the topological position of the input's owner (-1 for graph inputs),
``a`` is the topological position of the input's owner (-1 for graph inputs),
``b`` is the index of the variable in the owner's output list.
``b`` is the index of the variable in the owner's output list.
The graph position of a Constant is defined as its signature.
The graph position of a Constant instance is defined as its signature, together with
two integers: the topological position of the first Apply using that Constant instance,
and the lowest index into that Apply's inputs that refers to that Constant. (These two
integers are a surrogate for the id() of the Constant. The integers are important
because merge-able constants have the same signature, but require separate containers
in C code.)
If the Op of any Apply in the Env does not have c_code_cache_ok()==True, then this
If the Op of any Apply in the Env does not have c_code_cache_ok()==True, then this
function raises a KeyError exception.
function raises a KeyError exception.
"""
"""
order
=
list
(
self
.
env
.
toposort
())
order
=
list
(
self
.
env
.
toposort
())
env_inputs_
se
t
=
dict
((
i
,
(
-
1
,
pos
))
for
pos
,
i
in
enumerate
(
self
.
env
.
inputs
))
env_inputs_
dic
t
=
dict
((
i
,
(
-
1
,
pos
))
for
pos
,
i
in
enumerate
(
self
.
env
.
inputs
))
env_computed_set
=
set
()
env_computed_set
=
set
()
constant_ids
=
dict
()
op_pos
=
{}
# Apply -> topological position
op_pos
=
{}
# Apply -> topological position
rval
=
[
'CLinker.cmodule_key'
]
# will be cast to tuple on return
rval
=
[
'CLinker.cmodule_key'
]
# will be cast to tuple on return
rval
.
append
(
tuple
(
self
.
compile_args
()))
rval
.
append
(
tuple
(
self
.
compile_args
()))
...
@@ -800,11 +806,15 @@ class CLinker(link.Linker):
...
@@ -800,11 +806,15 @@ class CLinker(link.Linker):
# - an env input
# - an env input
# - an output from a node in the Env
# - an output from a node in the Env
# - a Constant
# - a Constant
def
graphpos
(
i
):
def
graphpos
(
i
,
topological_pos
,
i_idx
):
if
isinstance
(
i
,
graph
.
Constant
):
if
isinstance
(
i
,
graph
.
Constant
):
return
i
.
signature
()
if
id
(
i
)
not
in
constant_ids
:
elif
i
in
env_inputs_set
:
constant_ids
[
id
(
i
)]
=
(
i
.
signature
(),
topological_pos
,
i_idx
)
return
env_inputs_set
[
i
]
return
constant_ids
[
id
(
i
)]
#print 'SIGNATURE', i.signature()
#return i.signature()
elif
i
in
env_inputs_dict
:
return
env_inputs_dict
[
i
]
else
:
else
:
if
i
.
owner
is
None
:
if
i
.
owner
is
None
:
assert
all
(
all
(
out
is
not
None
for
out
in
o
.
outputs
)
for
o
in
order
)
assert
all
(
all
(
out
is
not
None
for
out
in
o
.
outputs
)
for
o
in
order
)
...
@@ -812,15 +822,16 @@ class CLinker(link.Linker):
...
@@ -812,15 +822,16 @@ class CLinker(link.Linker):
raise
Exception
(
'what is this?'
,
(
i
,
type
(
i
),
i
.
clients
,
self
.
env
))
raise
Exception
(
'what is this?'
,
(
i
,
type
(
i
),
i
.
clients
,
self
.
env
))
return
(
op_pos
[
i
.
owner
],
i
.
owner
.
outputs
.
index
(
i
))
return
(
op_pos
[
i
.
owner
],
i
.
owner
.
outputs
.
index
(
i
))
for
opos
,
o
in
enumerate
(
order
):
for
node_pos
,
node
in
enumerate
(
order
):
version
.
append
(
o
.
op
.
c_code_cache_version_apply
(
o
))
version
.
append
(
node
.
op
.
c_code_cache_version_apply
(
node
))
for
i
in
o
.
inputs
:
for
i
in
node
.
inputs
:
version
.
append
(
i
.
type
.
c_code_cache_version
())
version
.
append
(
i
.
type
.
c_code_cache_version
())
for
i
in
o
.
outputs
:
for
o
in
node
.
outputs
:
version
.
append
(
i
.
type
.
c_code_cache_version
())
version
.
append
(
o
.
type
.
c_code_cache_version
())
rval
.
append
((
o
.
op
,
tuple
((
i
.
type
,
graphpos
(
i
))
for
i
in
o
.
inputs
)))
rval
.
append
((
node
.
op
,
tuple
((
i
.
type
,
graphpos
(
i
,
node_pos
,
ipos
))
op_pos
[
o
]
=
opos
for
ipos
,
i
in
enumerate
(
node
.
inputs
))))
env_computed_set
.
update
(
o
.
outputs
)
op_pos
[
node
]
=
node_pos
env_computed_set
.
update
(
node
.
outputs
)
for
v
in
version
:
for
v
in
version
:
if
not
v
:
#one of the ops or types here is unversioned
if
not
v
:
#one of the ops or types here is unversioned
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论