Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0ba5c0a6
提交
0ba5c0a6
authored
7月 14, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
8月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix type hints in aesara.graph.opt
上级
c736927b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
25 行增加
和
3 行删除
+25
-3
opt.py
aesara/graph/opt.py
+25
-3
没有找到文件。
aesara/graph/opt.py
浏览文件 @
0ba5c0a6
...
@@ -17,7 +17,9 @@ from collections import UserList, defaultdict, deque
...
@@ -17,7 +17,9 @@ from collections import UserList, defaultdict, deque
from
collections.abc
import
Iterable
from
collections.abc
import
Iterable
from
functools
import
_compose_mro
,
partial
,
reduce
# type: ignore
from
functools
import
_compose_mro
,
partial
,
reduce
# type: ignore
from
itertools
import
chain
from
itertools
import
chain
from
typing
import
Dict
,
List
,
Optional
,
Sequence
,
Tuple
,
Union
from
typing
import
Callable
,
Dict
,
List
,
Optional
,
Sequence
,
Tuple
,
Union
from
typing_extensions
import
Literal
import
aesara
import
aesara
from
aesara.configdefaults
import
config
from
aesara.configdefaults
import
config
...
@@ -41,6 +43,17 @@ from aesara.utils import flatten
...
@@ -41,6 +43,17 @@ from aesara.utils import flatten
_logger
=
logging
.
getLogger
(
"aesara.graph.opt"
)
_logger
=
logging
.
getLogger
(
"aesara.graph.opt"
)
FailureCallbackType
=
Callable
[
[
Exception
,
"NavigatorOptimizer"
,
List
[
Tuple
[
Variable
,
None
]],
"LocalOptimizer"
,
Apply
,
],
None
,
]
class
LocalMetaOptimizerSkipAssertionError
(
AssertionError
):
class
LocalMetaOptimizerSkipAssertionError
(
AssertionError
):
"""This is an AssertionError, but instead of having the
"""This is an AssertionError, but instead of having the
...
@@ -1770,7 +1783,12 @@ class NavigatorOptimizer(GlobalOptimizer):
...
@@ -1770,7 +1783,12 @@ class NavigatorOptimizer(GlobalOptimizer):
def
warn_ignore
(
exc
,
nav
,
repl_pairs
,
local_opt
,
node
):
def
warn_ignore
(
exc
,
nav
,
repl_pairs
,
local_opt
,
node
):
"""A failure callback that ignores all errors."""
"""A failure callback that ignores all errors."""
def
__init__
(
self
,
local_opt
,
ignore_newtrees
=
"auto"
,
failure_callback
=
None
):
def
__init__
(
self
,
local_opt
:
LocalOptimizer
,
ignore_newtrees
:
Literal
[
True
,
False
,
"auto"
],
failure_callback
:
Optional
[
FailureCallbackType
]
=
None
,
):
self
.
local_opt
=
local_opt
self
.
local_opt
=
local_opt
if
ignore_newtrees
==
"auto"
:
if
ignore_newtrees
==
"auto"
:
self
.
ignore_newtrees
=
not
getattr
(
local_opt
,
"reentrant"
,
True
)
self
.
ignore_newtrees
=
not
getattr
(
local_opt
,
"reentrant"
,
True
)
...
@@ -1934,7 +1952,11 @@ class TopoOptimizer(NavigatorOptimizer):
...
@@ -1934,7 +1952,11 @@ class TopoOptimizer(NavigatorOptimizer):
"""An optimizer that applies a single `LocalOptimizer` to each node in topological order (or reverse)."""
"""An optimizer that applies a single `LocalOptimizer` to each node in topological order (or reverse)."""
def
__init__
(
def
__init__
(
self
,
local_opt
,
order
=
"in_to_out"
,
ignore_newtrees
=
False
,
failure_callback
=
None
self
,
local_opt
:
LocalOptimizer
,
order
:
Literal
[
"out_to_in"
,
"in_to_out"
]
=
"in_to_out"
,
ignore_newtrees
:
bool
=
False
,
failure_callback
:
Optional
[
FailureCallbackType
]
=
None
,
):
):
if
order
not
in
(
"out_to_in"
,
"in_to_out"
):
if
order
not
in
(
"out_to_in"
,
"in_to_out"
):
raise
ValueError
(
"order must be 'out_to_in' or 'in_to_out'"
)
raise
ValueError
(
"order must be 'out_to_in' or 'in_to_out'"
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论