Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5e11d066
提交
5e11d066
authored
4月 20, 2015
作者:
--global
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reorganize helper functions in scan op
上级
5ef9fec9
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
32 行增加
和
33 行删除
+32
-33
scan_op.py
theano/scan_module/scan_op.py
+32
-33
没有找到文件。
theano/scan_module/scan_op.py
浏览文件 @
5e11d066
...
@@ -1408,37 +1408,6 @@ class Scan(PureOp):
...
@@ -1408,37 +1408,6 @@ class Scan(PureOp):
if
hasattr
(
node
.
tag
,
'connection_pattern'
):
if
hasattr
(
node
.
tag
,
'connection_pattern'
):
return
node
.
tag
.
connection_pattern
return
node
.
tag
.
connection_pattern
# Define helper functions
def
_get_inner_outs_idx
(
oidx
):
"""Given the index of an outer output, return the indices of the
corresponding inner output(s) in a sequence.
"""
s
=
0
e
=
0
for
p
in
xrange
(
oidx
+
1
):
s
=
e
if
p
<
self
.
n_mit_mot
:
e
+=
len
(
self
.
mitmot_out_taps
()[
p
])
else
:
e
+=
1
return
range
(
s
,
e
)
def
_get_inner_inps_idx
(
outer_iidx
):
"""Given the index of an outer input, return the indices of the
corresponding inner input(s) in a sequence.
"""
outer_iidx_from_inner_iidx
=
self
.
get_outer_iidx_from_inner_iidx_seq
()
# For every inner input, if the corresponding outer input is the
# desired one, store the index
inner_iidxs
=
[]
for
i
in
xrange
(
len
(
outer_iidx_from_inner_iidx
)):
if
outer_iidx_from_inner_iidx
[
i
]
==
outer_iidx
:
inner_iidxs
.
append
(
i
)
return
inner_iidxs
# Obtain the connection pattern of the inner function.
# Obtain the connection pattern of the inner function.
inner_connect_pattern
=
self
.
inner_connection_pattern
()
inner_connect_pattern
=
self
.
inner_connection_pattern
()
...
@@ -1451,10 +1420,10 @@ class Scan(PureOp):
...
@@ -1451,10 +1420,10 @@ class Scan(PureOp):
# and inner outputs and, if one such pair of inner variables is
# and inner outputs and, if one such pair of inner variables is
# connected than the pair of outer variables is connected.
# connected than the pair of outer variables is connected.
for
outer_oidx
in
range
(
len
(
node
.
outputs
)):
for
outer_oidx
in
range
(
len
(
node
.
outputs
)):
inner_oidxs
=
_get_inner_outs_
idx
(
outer_oidx
)
inner_oidxs
=
self
.
get_inner_oidx_from_outer_o
idx
(
outer_oidx
)
for
outer_iidx
in
range
(
len
(
node
.
inputs
)):
for
outer_iidx
in
range
(
len
(
node
.
inputs
)):
inner_iidxs
=
_get_inner_inps_
idx
(
outer_iidx
)
inner_iidxs
=
self
.
get_inner_iidx_from_outer_i
idx
(
outer_iidx
)
for
inner_oidx
in
inner_oidxs
:
for
inner_oidx
in
inner_oidxs
:
for
inner_iidx
in
inner_iidxs
:
for
inner_iidx
in
inner_iidxs
:
...
@@ -1490,6 +1459,36 @@ class Scan(PureOp):
...
@@ -1490,6 +1459,36 @@ class Scan(PureOp):
node
.
tag
.
connection_pattern
=
connection_pattern
node
.
tag
.
connection_pattern
=
connection_pattern
return
connection_pattern
return
connection_pattern
def
get_inner_oidx_from_outer_oidx
(
self
,
outer_oidx
):
"""Given the index of an outer output, return the indices of the
corresponding inner output(s) in a sequence.
"""
s
=
0
e
=
0
for
p
in
xrange
(
outer_oidx
+
1
):
s
=
e
if
p
<
self
.
n_mit_mot
:
e
+=
len
(
self
.
mitmot_out_taps
()[
p
])
else
:
e
+=
1
return
range
(
s
,
e
)
def
get_inner_iidx_from_outer_iidx
(
self
,
outer_oidx
):
"""Given the index of an outer input, return the indices of the
corresponding inner input(s) in a sequence.
"""
outer_iidx_from_inner_iidx
=
self
.
get_outer_iidx_from_inner_iidx_seq
()
# For every inner input, if the corresponding outer input is the
# desired one, store the index
inner_iidxs
=
[]
for
i
in
xrange
(
len
(
outer_iidx_from_inner_iidx
)):
if
outer_iidx_from_inner_iidx
[
i
]
==
outer_oidx
:
inner_iidxs
.
append
(
i
)
return
inner_iidxs
def
get_outer_iidx_from_outer_oidx_seq
(
self
):
def
get_outer_iidx_from_outer_oidx_seq
(
self
):
""" Return a sequence where the value at the i-th position is the
""" Return a sequence where the value at the i-th position is the
index of the outer input corresponding to the i-th outer output
index of the outer input corresponding to the i-th outer output
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论