Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8867db3c
提交
8867db3c
authored
1月 20, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Whitespace fix.
上级
c6209b93
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
20 行增加
和
21 行删除
+20
-21
cc.py
theano/gof/cc.py
+20
-21
没有找到文件。
theano/gof/cc.py
浏览文件 @
8867db3c
...
@@ -64,7 +64,7 @@ def get_persistent_module_cache():
...
@@ -64,7 +64,7 @@ def get_persistent_module_cache():
if
_persistent_module_cache
is
None
:
if
_persistent_module_cache
is
None
:
_persistent_module_cache
=
CallCache
(
os
.
path
.
join
(
config
.
compiledir
,
'persistent_cache'
))
_persistent_module_cache
=
CallCache
(
os
.
path
.
join
(
config
.
compiledir
,
'persistent_cache'
))
return
_persistent_module_cache
return
_persistent_module_cache
class
CodeBlock
:
class
CodeBlock
:
"""WRITEME
"""WRITEME
Represents a computation unit composed of declare, behavior, and cleanup.
Represents a computation unit composed of declare, behavior, and cleanup.
...
@@ -520,7 +520,7 @@ class CLinker(link.Linker):
...
@@ -520,7 +520,7 @@ class CLinker(link.Linker):
assert
isinstance
(
c_support_code_apply
[
-
1
],
str
),
(
assert
isinstance
(
c_support_code_apply
[
-
1
],
str
),
(
str
(
node
.
op
)
+
" didn't returned a string for c_support_code_apply"
)
str
(
node
.
op
)
+
" didn't returned a string for c_support_code_apply"
)
# emit c_code
# emit c_code
try
:
try
:
behavior
=
op
.
c_code
(
node
,
name
,
isyms
,
osyms
,
sub
)
behavior
=
op
.
c_code
(
node
,
name
,
isyms
,
osyms
,
sub
)
except
utils
.
MethodNotDefined
:
except
utils
.
MethodNotDefined
:
...
@@ -619,11 +619,11 @@ class CLinker(link.Linker):
...
@@ -619,11 +619,11 @@ class CLinker(link.Linker):
except
utils
.
MethodNotDefined
:
pass
except
utils
.
MethodNotDefined
:
pass
ret
=
list
(
set
(
ret
))
#to remove duplicate
ret
=
list
(
set
(
ret
))
#to remove duplicate
for
x
in
[
y
.
type
for
y
in
self
.
variables
]
+
[
y
.
op
for
y
in
self
.
node_order
]:
for
x
in
[
y
.
type
for
y
in
self
.
variables
]
+
[
y
.
op
for
y
in
self
.
node_order
]:
try
:
try
:
for
i
in
x
.
c_no_compile_args
():
for
i
in
x
.
c_no_compile_args
():
try
:
try
:
ret
.
remove
(
i
)
ret
.
remove
(
i
)
except
ValueError
:
except
ValueError
:
pass
# in case the value is not there
pass
# in case the value is not there
except
utils
.
MethodNotDefined
:
pass
except
utils
.
MethodNotDefined
:
pass
return
ret
return
ret
...
@@ -742,7 +742,7 @@ class CLinker(link.Linker):
...
@@ -742,7 +742,7 @@ class CLinker(link.Linker):
if
v
in
self
.
orphans
and
isinstance
(
v
,
graph
.
Constant
):
if
v
in
self
.
orphans
and
isinstance
(
v
,
graph
.
Constant
):
try
:
try
:
v
.
type
.
c_literal
(
v
.
data
)
#constant will be inlined, no need to get
v
.
type
.
c_literal
(
v
.
data
)
#constant will be inlined, no need to get
continue
continue
except
(
utils
.
MethodNotDefined
,
NotImplementedError
):
except
(
utils
.
MethodNotDefined
,
NotImplementedError
):
pass
pass
init_tasks
.
append
((
v
,
'init'
,
id
))
init_tasks
.
append
((
v
,
'init'
,
id
))
...
@@ -750,7 +750,7 @@ class CLinker(link.Linker):
...
@@ -750,7 +750,7 @@ class CLinker(link.Linker):
id
+=
2
id
+=
2
for
node
in
self
.
node_order
:
for
node
in
self
.
node_order
:
tasks
.
append
((
node
,
'code'
,
id
))
tasks
.
append
((
node
,
'code'
,
id
))
id
+=
1
id
+=
1
return
init_tasks
,
tasks
return
init_tasks
,
tasks
def
make_thunk
(
self
,
input_storage
=
None
,
output_storage
=
None
):
def
make_thunk
(
self
,
input_storage
=
None
,
output_storage
=
None
):
...
@@ -813,7 +813,7 @@ class CLinker(link.Linker):
...
@@ -813,7 +813,7 @@ class CLinker(link.Linker):
Each element identifies the type of the node input, and the nature of that input in the
Each element identifies the type of the node input, and the nature of that input in the
graph.
graph.
The nature of a typical variable is encoded by integer pairs ``((a,b),c)``:
The nature of a typical variable is encoded by integer pairs ``((a,b),c)``:
``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.
``c`` is a flag indicating whether the variable is in the no_recycling set.
``c`` is a flag indicating whether the variable is in the no_recycling set.
...
@@ -834,10 +834,10 @@ class CLinker(link.Linker):
...
@@ -834,10 +834,10 @@ class CLinker(link.Linker):
The outputs of a node are entirely determined by the node's Op and the nature of the
The outputs of a node are entirely determined by the node's Op and the nature of the
inputs, but the set of outputs that may be re-used by the computation (the elements of
inputs, but the set of outputs that may be re-used by the computation (the elements of
self.no_recycling) can affect the code that is generated.
self.no_recycling) can affect the code that is generated.
The format of each Op's output signature is simply a list of booleans, indicating
The format of each Op's output signature is simply a list of booleans, indicating
whether each output is in the no_recycling set.
whether each output is in the no_recycling set.
"""
"""
return
self
.
cmodule_key_
(
self
.
env
,
self
.
no_recycling
,
return
self
.
cmodule_key_
(
self
.
env
,
self
.
no_recycling
,
compile_args
=
self
.
compile_args
(),
compile_args
=
self
.
compile_args
(),
...
@@ -852,7 +852,7 @@ class CLinker(link.Linker):
...
@@ -852,7 +852,7 @@ class CLinker(link.Linker):
order
=
list
(
env
.
toposort
())
order
=
list
(
env
.
toposort
())
#set of variables that have been computed by nodes we have
#set of variables that have been computed by nodes we have
# seen 'so far' in the loop below
# seen 'so far' in the loop below
env_computed_set
=
set
()
env_computed_set
=
set
()
env_inputs_dict
=
dict
((
i
,
(
-
1
,
pos
))
for
pos
,
i
in
enumerate
(
env
.
inputs
))
env_inputs_dict
=
dict
((
i
,
(
-
1
,
pos
))
for
pos
,
i
in
enumerate
(
env
.
inputs
))
constant_ids
=
dict
()
constant_ids
=
dict
()
op_pos
=
{}
# Apply -> topological position
op_pos
=
{}
# Apply -> topological position
...
@@ -917,13 +917,13 @@ class CLinker(link.Linker):
...
@@ -917,13 +917,13 @@ class CLinker(link.Linker):
#add the signature for this node
#add the signature for this node
sig
.
append
((
sig
.
append
((
node
.
op
,
node
.
op
,
tuple
((
i
.
type
,
in_sig
(
i
,
node_pos
,
ipos
))
tuple
((
i
.
type
,
in_sig
(
i
,
node_pos
,
ipos
))
for
ipos
,
i
in
enumerate
(
node
.
inputs
)),
for
ipos
,
i
in
enumerate
(
node
.
inputs
)),
tuple
(
o
in
no_recycling
for
o
in
node
.
outputs
)))
tuple
(
o
in
no_recycling
for
o
in
node
.
outputs
)))
if
error_on_play
[
0
]:
if
error_on_play
[
0
]:
# if one of the signatures is not hashable
# if one of the signatures is not hashable
# then bypass the cache mechanism and
# then bypass the cache mechanism and
# compile fresh every time
# compile fresh every time
return
None
return
None
...
@@ -934,8 +934,8 @@ class CLinker(link.Linker):
...
@@ -934,8 +934,8 @@ class CLinker(link.Linker):
sig
=
tuple
(
sig
)
sig
=
tuple
(
sig
)
version
=
tuple
(
version
)
version
=
tuple
(
version
)
for
v
in
version
:
for
v
in
version
:
if
not
v
:
if
not
v
:
# one of the ops or types here is unversioned,
# one of the ops or types here is unversioned,
# so this env is entirely unversioned
# so this env is entirely unversioned
return
((),
sig
)
return
((),
sig
)
return
version
,
sig
return
version
,
sig
...
@@ -1052,7 +1052,7 @@ class CLinker(link.Linker):
...
@@ -1052,7 +1052,7 @@ class CLinker(link.Linker):
orphd
=
[[
orphan
.
data
]
for
orphan
in
self
.
orphans
]
orphd
=
[[
orphan
.
data
]
for
orphan
in
self
.
orphans
]
ret
=
module
.
instantiate
(
error_storage
,
*
(
in_storage
+
out_storage
+
orphd
))
ret
=
module
.
instantiate
(
error_storage
,
*
(
in_storage
+
out_storage
+
orphd
))
return
ret
return
ret
def
instantiate_code
(
self
,
n_args
):
def
instantiate_code
(
self
,
n_args
):
...
@@ -1127,8 +1127,8 @@ class OpWiseCLinker(link.LocalLinker):
...
@@ -1127,8 +1127,8 @@ class OpWiseCLinker(link.LocalLinker):
__cache__
=
{}
__cache__
=
{}
def
__init__
(
self
,
def
__init__
(
self
,
fallback_on_perform
=
True
,
fallback_on_perform
=
True
,
allow_gc
=
True
,
allow_gc
=
True
,
nice_errors
=
True
):
nice_errors
=
True
):
self
.
env
=
None
self
.
env
=
None
...
@@ -1202,7 +1202,7 @@ class OpWiseCLinker(link.LocalLinker):
...
@@ -1202,7 +1202,7 @@ class OpWiseCLinker(link.LocalLinker):
raise
raise
if
self
.
allow_gc
:
if
self
.
allow_gc
:
post_thunk_old_storage
.
append
([
storage_map
[
input
]
post_thunk_old_storage
.
append
([
storage_map
[
input
]
for
input
in
node
.
inputs
for
input
in
node
.
inputs
if
(
input
in
computed
)
and
(
input
not
in
env
.
outputs
)
and
node
==
last_user
[
input
]])
if
(
input
in
computed
)
and
(
input
not
in
env
.
outputs
)
and
node
==
last_user
[
input
]])
...
@@ -1212,9 +1212,9 @@ class OpWiseCLinker(link.LocalLinker):
...
@@ -1212,9 +1212,9 @@ class OpWiseCLinker(link.LocalLinker):
else
:
else
:
no_recycling
=
[
storage_map
[
r
]
for
r
in
no_recycling
if
r
not
in
env
.
inputs
]
no_recycling
=
[
storage_map
[
r
]
for
r
in
no_recycling
if
r
not
in
env
.
inputs
]
f
=
link
.
streamline
(
env
,
thunks
,
order
,
f
=
link
.
streamline
(
env
,
thunks
,
order
,
post_thunk_old_storage
,
post_thunk_old_storage
,
no_recycling
=
no_recycling
,
no_recycling
=
no_recycling
,
nice_errors
=
self
.
nice_errors
)
nice_errors
=
self
.
nice_errors
)
f
.
allow_gc
=
self
.
allow_gc
f
.
allow_gc
=
self
.
allow_gc
...
@@ -1313,4 +1313,3 @@ class DualLinker(link.Linker):
...
@@ -1313,4 +1313,3 @@ class DualLinker(link.Linker):
link
.
raise_with_op
(
node1
)
link
.
raise_with_op
(
node1
)
return
f
,
i1
,
o1
return
f
,
i1
,
o1
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论