Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9a2280b8
提交
9a2280b8
authored
8月 08, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
9月 15, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move Scan helper methods to ScanMethodsMixin
上级
e85c7fd0
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
16 行增加
和
12 行删除
+16
-12
printing.py
aesara/printing.py
+3
-1
op.py
aesara/scan/op.py
+0
-0
utils.py
aesara/scan/utils.py
+2
-2
scan.rst
doc/extending/scan.rst
+1
-1
test_basic.py
tests/scan/test_basic.py
+10
-7
test_utils.py
tests/scan/test_utils.py
+0
-1
没有找到文件。
aesara/printing.py
浏览文件 @
9a2280b8
...
@@ -237,7 +237,9 @@ N.B.:
...
@@ -237,7 +237,9 @@ N.B.:
outer_inputs
=
s
.
owner
.
inputs
outer_inputs
=
s
.
owner
.
inputs
inner_to_outer_inputs
=
{
inner_to_outer_inputs
=
{
inner_inputs
[
i
]:
outer_inputs
[
o
]
inner_inputs
[
i
]:
outer_inputs
[
o
]
for
i
,
o
in
s
.
owner
.
op
.
var_mappings
[
"outer_inp_from_inner_inp"
]
.
items
()
for
i
,
o
in
s
.
owner
.
op
.
get_oinp_iinp_iout_oout_mappings
()[
"outer_inp_from_inner_inp"
]
.
items
()
}
}
print
(
""
,
file
=
_file
)
print
(
""
,
file
=
_file
)
...
...
aesara/scan/op.py
浏览文件 @
9a2280b8
差异被折叠。
点击展开。
aesara/scan/utils.py
浏览文件 @
9a2280b8
...
@@ -1069,9 +1069,9 @@ class ScanArgs:
...
@@ -1069,9 +1069,9 @@ class ScanArgs:
@property
@property
def
var_mappings
(
self
):
def
var_mappings
(
self
):
from
aesara.scan.op
import
Scan
from
aesara.scan.op
import
Scan
MethodsMixin
return
Scan
.
get_oinp_iinp_iout_oout_mappings
(
self
)
return
Scan
MethodsMixin
.
get_oinp_iinp_iout_oout_mappings
(
self
)
@property
@property
def
field_names
(
self
):
def
field_names
(
self
):
...
...
doc/extending/scan.rst
浏览文件 @
9a2280b8
...
@@ -299,7 +299,7 @@ If the goal is to navigate between variables that are associated with the same
...
@@ -299,7 +299,7 @@ If the goal is to navigate between variables that are associated with the same
states (ex : going from an outer sequence input to the corresponding inner
states (ex : going from an outer sequence input to the corresponding inner
sequence input, going from an inner output associated with a recurrent state
sequence input, going from an inner output associated with a recurrent state
to the inner input(s) associated with that same recurrent state, etc.), then
to the inner input(s) associated with that same recurrent state, etc.), then
the `
`var_mappings`` attribute of the scan op
can be used.
the `
get_oinp_iinp_iout_oout_mappings_mappings` method of the `Scan` `Op`
can be used.
This attribute is a dictionary with 12 {key/value} pairs. The keys are listed
This attribute is a dictionary with 12 {key/value} pairs. The keys are listed
below :
below :
...
...
tests/scan/test_basic.py
浏览文件 @
9a2280b8
...
@@ -700,11 +700,12 @@ class TestScan:
...
@@ -700,11 +700,12 @@ class TestScan:
# outer_inp_from_inner_inp produce the correct results
# outer_inp_from_inner_inp produce the correct results
scan_node
=
a
.
owner
.
inputs
[
0
]
.
owner
scan_node
=
a
.
owner
.
inputs
[
0
]
.
owner
result
=
scan_node
.
op
.
var_mappings
[
"outer_inp_from_outer_out"
]
var_mappings
=
scan_node
.
op
.
get_oinp_iinp_iout_oout_mappings
()
result
=
var_mappings
[
"outer_inp_from_outer_out"
]
expected_result
=
{
0
:
1
,
1
:
2
}
expected_result
=
{
0
:
1
,
1
:
2
}
assert
result
==
expected_result
assert
result
==
expected_result
result
=
scan_node
.
op
.
var_mappings
[
"outer_inp_from_inner_inp"
]
result
=
var_mappings
[
"outer_inp_from_inner_inp"
]
expected_result
=
{
0
:
1
,
1
:
1
,
2
:
2
,
3
:
2
}
expected_result
=
{
0
:
1
,
1
:
1
,
2
:
2
,
3
:
2
}
assert
result
==
expected_result
assert
result
==
expected_result
...
@@ -733,11 +734,12 @@ class TestScan:
...
@@ -733,11 +734,12 @@ class TestScan:
# outer_inp_from_inner_inp produce the correct results
# outer_inp_from_inner_inp produce the correct results
scan_node
=
out
.
owner
.
inputs
[
0
]
.
owner
scan_node
=
out
.
owner
.
inputs
[
0
]
.
owner
result
=
scan_node
.
op
.
var_mappings
[
"outer_inp_from_outer_out"
]
var_mappings
=
scan_node
.
op
.
get_oinp_iinp_iout_oout_mappings
()
result
=
var_mappings
[
"outer_inp_from_outer_out"
]
expected_result
=
{
0
:
2
}
expected_result
=
{
0
:
2
}
assert
result
==
expected_result
assert
result
==
expected_result
result
=
scan_node
.
op
.
var_mappings
[
"outer_inp_from_inner_inp"
]
result
=
var_mappings
[
"outer_inp_from_inner_inp"
]
expected_result
=
{
0
:
1
,
1
:
2
,
2
:
2
}
expected_result
=
{
0
:
1
,
1
:
2
,
2
:
2
}
assert
result
==
expected_result
assert
result
==
expected_result
...
@@ -1685,11 +1687,12 @@ class TestScan:
...
@@ -1685,11 +1687,12 @@ class TestScan:
# outer_inp_from_inner_inp produce the correct results
# outer_inp_from_inner_inp produce the correct results
scan_node
=
list
(
updates
.
values
())[
0
]
.
owner
scan_node
=
list
(
updates
.
values
())[
0
]
.
owner
result
=
scan_node
.
op
.
var_mappings
[
"outer_inp_from_outer_out"
]
var_mappings
=
scan_node
.
op
.
get_oinp_iinp_iout_oout_mappings
()
result
=
var_mappings
[
"outer_inp_from_outer_out"
]
expected_result
=
{
0
:
3
,
1
:
5
,
2
:
4
}
expected_result
=
{
0
:
3
,
1
:
5
,
2
:
4
}
assert
result
==
expected_result
assert
result
==
expected_result
result
=
scan_node
.
op
.
var_mappings
[
"outer_inp_from_inner_inp"
]
result
=
var_mappings
[
"outer_inp_from_inner_inp"
]
expected_result
=
{
0
:
1
,
1
:
2
,
2
:
3
,
3
:
4
,
4
:
6
}
expected_result
=
{
0
:
1
,
1
:
2
,
2
:
3
,
3
:
4
,
4
:
6
}
assert
result
==
expected_result
assert
result
==
expected_result
...
@@ -3491,7 +3494,7 @@ class TestScan:
...
@@ -3491,7 +3494,7 @@ class TestScan:
# Compare the mappings with the expected values
# Compare the mappings with the expected values
scan_node
=
scan_outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
scan_node
=
scan_outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
mappings
=
scan_node
.
op
.
var_mappings
mappings
=
scan_node
.
op
.
get_oinp_iinp_iout_oout_mappings
()
assert
mappings
[
"inner_inp_from_outer_inp"
]
==
{
assert
mappings
[
"inner_inp_from_outer_inp"
]
==
{
0
:
[],
0
:
[],
...
...
tests/scan/test_utils.py
浏览文件 @
9a2280b8
...
@@ -253,7 +253,6 @@ def test_ScanArgs():
...
@@ -253,7 +253,6 @@ def test_ScanArgs():
# here we make sure it doesn't (and that all the inputs are the same)
# here we make sure it doesn't (and that all the inputs are the same)
assert
scan_args
.
inputs
==
scan_op
.
inputs
assert
scan_args
.
inputs
==
scan_op
.
inputs
assert
scan_args
.
info
==
scan_op
.
info
assert
scan_args
.
info
==
scan_op
.
info
assert
scan_args
.
var_mappings
==
scan_op
.
var_mappings
# Check that `ScanArgs.find_among_fields` works
# Check that `ScanArgs.find_among_fields` works
test_v
=
scan_op
.
inner_seqs
(
scan_op
.
inputs
)[
1
]
test_v
=
scan_op
.
inner_seqs
(
scan_op
.
inputs
)[
1
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论