Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d0c7808a
提交
d0c7808a
authored
6月 06, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
6月 07, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify in2out and out2in construction
上级
02910f82
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
8 行增加
和
27 行删除
+8
-27
opt.py
aesara/graph/opt.py
+8
-27
没有找到文件。
aesara/graph/opt.py
浏览文件 @
d0c7808a
...
@@ -15,7 +15,7 @@ import traceback
...
@@ -15,7 +15,7 @@ import traceback
import
warnings
import
warnings
from
collections
import
OrderedDict
,
UserList
,
defaultdict
,
deque
from
collections
import
OrderedDict
,
UserList
,
defaultdict
,
deque
from
collections.abc
import
Iterable
from
collections.abc
import
Iterable
from
functools
import
reduce
from
functools
import
partial
,
reduce
from
typing
import
Dict
,
List
,
Optional
,
Tuple
,
Union
from
typing
import
Dict
,
List
,
Optional
,
Tuple
,
Union
import
numpy
as
np
import
numpy
as
np
...
@@ -2172,34 +2172,11 @@ class TopoOptimizer(NavigatorOptimizer):
...
@@ -2172,34 +2172,11 @@ class TopoOptimizer(NavigatorOptimizer):
return
getattr
(
self
,
"__name__"
,
"<TopoOptimizer instance>"
)
return
getattr
(
self
,
"__name__"
,
"<TopoOptimizer instance>"
)
def
out2in
(
*
local_opts
,
**
kwargs
):
def
topogroup_optimizer
(
order
,
*
local_opts
,
name
=
None
,
**
kwargs
):
"""
"""Apply `local_opts` from the input/output nodes to the output/input nodes of a graph.
Uses the TopoOptimizer from the output nodes to input nodes of the graph.
"""
name
=
kwargs
and
kwargs
.
pop
(
"name"
,
None
)
if
len
(
local_opts
)
>
1
:
# Don't wrap it uselessly if their is only 1 optimization.
local_opts
=
LocalOptGroup
(
*
local_opts
)
else
:
(
local_opts
,)
=
local_opts
if
not
name
:
name
=
local_opts
.
__name__
ret
=
TopoOptimizer
(
local_opts
,
order
=
"out_to_in"
,
failure_callback
=
TopoOptimizer
.
warn_inplace
,
**
kwargs
,
)
if
name
:
ret
.
__name__
=
name
return
ret
def
in2out
(
*
local_opts
,
**
kwargs
):
This uses a combination of `LocalOptGroup` and `TopoOptimizer`.
"""
Uses the TopoOptimizer from the input nodes to output nodes of the graph.
"""
"""
name
=
kwargs
and
kwargs
.
pop
(
"name"
,
None
)
if
len
(
local_opts
)
>
1
:
if
len
(
local_opts
)
>
1
:
# Don't wrap it uselessly if their is only 1 optimization.
# Don't wrap it uselessly if their is only 1 optimization.
local_opts
=
LocalOptGroup
(
*
local_opts
)
local_opts
=
LocalOptGroup
(
*
local_opts
)
...
@@ -2218,6 +2195,10 @@ def in2out(*local_opts, **kwargs):
...
@@ -2218,6 +2195,10 @@ def in2out(*local_opts, **kwargs):
return
ret
return
ret
in2out
=
partial
(
topogroup_optimizer
,
"in_to_out"
)
out2in
=
partial
(
topogroup_optimizer
,
"out_to_in"
)
class
OpKeyOptimizer
(
NavigatorOptimizer
):
class
OpKeyOptimizer
(
NavigatorOptimizer
):
r"""An optimizer that applies a `LocalOptimizer` to specific `Op`\s.
r"""An optimizer that applies a `LocalOptimizer` to specific `Op`\s.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论