Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
89afb152
提交
89afb152
authored
10月 14, 2015
作者:
carriepl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't build FunctionGraph to compute cmodule_key
上级
7d749f70
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
40 行增加
和
2 行删除
+40
-2
cc.py
theano/gof/cc.py
+36
-1
scan_op.py
theano/scan_module/scan_op.py
+4
-1
没有找到文件。
theano/gof/cc.py
浏览文件 @
89afb152
...
@@ -1284,6 +1284,34 @@ class CLinker(link.Linker):
...
@@ -1284,6 +1284,34 @@ class CLinker(link.Linker):
c_compiler
=
self
.
c_compiler
(),
c_compiler
=
self
.
c_compiler
(),
)
)
def
cmodule_key_fgraph
(
self
,
inputs
,
outputs
,
no_recycling
,
compile_args
=
None
,
libraries
=
None
,
header_dirs
=
None
,
insert_config_md5
=
True
,
c_compiler
=
None
):
# Assemble a dummy fgraph using the provided inputs and outputs. It is
# only used to compute the cmodule key so it only need to expose an
# `inputs` and an `outputs` attribute as well as a toposort() method
# which returns a deterministic result.
class
FakeFunctionGraph
():
def
__init__
(
self
,
inputs
,
outputs
):
self
.
inputs
=
inputs
self
.
outputs
=
outputs
def
toposort
(
self
):
# Calling io_toposort() here is fine because the results will
# only be used to compute the cmodule key which requires that
# the result of the toposort be deterministic. The ordering
# doesn't need to include information about inplace operations
# because that information will be included explicitly in
# cmodule_key_().
return
graph
.
io_toposort
(
self
.
inputs
,
self
.
outputs
)
fgraph
=
FakeFunctionGraph
(
inputs
,
outputs
)
return
self
.
cmodule_key_
(
fgraph
,
no_recycling
,
compile_args
,
libraries
,
header_dirs
,
insert_config_md5
,
c_compiler
)
def
cmodule_key_
(
self
,
fgraph
,
no_recycling
,
compile_args
=
None
,
def
cmodule_key_
(
self
,
fgraph
,
no_recycling
,
compile_args
=
None
,
libraries
=
None
,
header_dirs
=
None
,
insert_config_md5
=
True
,
libraries
=
None
,
header_dirs
=
None
,
insert_config_md5
=
True
,
c_compiler
=
None
):
c_compiler
=
None
):
...
@@ -1425,8 +1453,15 @@ class CLinker(link.Linker):
...
@@ -1425,8 +1453,15 @@ class CLinker(link.Linker):
fgraph_computed_set
.
update
(
node
.
outputs
)
fgraph_computed_set
.
update
(
node
.
outputs
)
# Add not used input in the key
# Add not used input in the key
# If inputs don't define a 'clients' attribute (as is the case if
# fgraph is not a real FunctionGraph but a FakeFunctionGraph, a
# lightweight class designed to imitate FunctionGraph), pretend they
# have none. This if fine because the goal is only to have all of the
# graph's information used to compute the key. If we mistakenly
# pretend that inputs with clients don't have any, were are only using
# those inputs more than once to compute the key.
for
ipos
,
var
in
[(
i
,
var
)
for
i
,
var
in
enumerate
(
fgraph
.
inputs
)
for
ipos
,
var
in
[(
i
,
var
)
for
i
,
var
in
enumerate
(
fgraph
.
inputs
)
if
not
len
(
var
.
clients
)]:
if
not
len
(
getattr
(
var
,
'clients'
,
[])
)]:
sig
.
append
((
var
.
type
,
in_sig
(
var
,
-
1
,
ipos
)))
sig
.
append
((
var
.
type
,
in_sig
(
var
,
-
1
,
ipos
)))
# crystalize the signature and version
# crystalize the signature and version
...
...
theano/scan_module/scan_op.py
浏览文件 @
89afb152
...
@@ -221,7 +221,10 @@ class Scan(PureOp):
...
@@ -221,7 +221,10 @@ class Scan(PureOp):
tmp_in
,
tmp_out
=
scan_utils
.
reconstruct_graph
(
self
.
inputs
,
tmp_in
,
tmp_out
=
scan_utils
.
reconstruct_graph
(
self
.
inputs
,
self
.
outputs
)
self
.
outputs
)
local_fgraph
=
gof
.
FunctionGraph
(
tmp_in
,
tmp_out
,
clone
=
False
)
local_fgraph
=
gof
.
FunctionGraph
(
tmp_in
,
tmp_out
,
clone
=
False
)
self
.
_cmodule_key
=
gof
.
CLinker
()
.
cmodule_key_
(
local_fgraph
,
[])
self
.
_cmodule_key
=
gof
.
CLinker
()
.
cmodule_key_fgraph
(
self
.
inputs
,
self
.
outputs
,
[])
#self._cmodule_key = gof.CLinker().cmodule_key_(local_fgraph, [])
self
.
_hash_inner_graph
=
hash
(
self
.
_cmodule_key
)
self
.
_hash_inner_graph
=
hash
(
self
.
_cmodule_key
)
# Compute mappings between outer inputs, outer outputs, inner
# Compute mappings between outer inputs, outer outputs, inner
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论