Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4c458590
提交
4c458590
authored
7月 14, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
8月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename FromFunctionOptimizer to FromFunctionGraphRewriter
上级
0ce6eceb
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
27 行增加
和
12 行删除
+27
-12
__init__.py
aesara/graph/__init__.py
+1
-1
opt.py
aesara/graph/opt.py
+22
-7
basic.py
aesara/tensor/nnet/basic.py
+3
-3
graph_rewriting.rst
doc/extending/graph_rewriting.rst
+1
-1
没有找到文件。
aesara/graph/__init__.py
浏览文件 @
4c458590
...
@@ -13,7 +13,7 @@ from aesara.graph.basic import (
...
@@ -13,7 +13,7 @@ from aesara.graph.basic import (
from
aesara.graph.op
import
Op
from
aesara.graph.op
import
Op
from
aesara.graph.type
import
Type
from
aesara.graph.type
import
Type
from
aesara.graph.fg
import
FunctionGraph
from
aesara.graph.fg
import
FunctionGraph
from
aesara.graph.opt
import
node_rewriter
,
optimiz
er
from
aesara.graph.opt
import
node_rewriter
,
graph_rewrit
er
from
aesara.graph.opt_utils
import
optimize_graph
from
aesara.graph.opt_utils
import
optimize_graph
from
aesara.graph.optdb
import
OptimizationQuery
from
aesara.graph.optdb
import
OptimizationQuery
...
...
aesara/graph/opt.py
浏览文件 @
4c458590
...
@@ -189,7 +189,7 @@ class NodeRewriter(Rewriter):
...
@@ -189,7 +189,7 @@ class NodeRewriter(Rewriter):
print
(
f
"{' ' * level}{self.__class__.__name__} id={id(self)}"
,
file
=
stream
)
print
(
f
"{' ' * level}{self.__class__.__name__} id={id(self)}"
,
file
=
stream
)
class
FromFunction
Optimiz
er
(
GraphRewriter
):
class
FromFunction
GraphRewrit
er
(
GraphRewriter
):
"""A `GraphRewriter` constructed from a given function."""
"""A `GraphRewriter` constructed from a given function."""
def
__init__
(
self
,
fn
,
requirements
=
()):
def
__init__
(
self
,
fn
,
requirements
=
()):
...
@@ -213,18 +213,18 @@ class FromFunctionOptimizer(GraphRewriter):
...
@@ -213,18 +213,18 @@ class FromFunctionOptimizer(GraphRewriter):
return
self
.
__name__
return
self
.
__name__
def
optimiz
er
(
f
):
def
graph_rewrit
er
(
f
):
"""Decorator for `FromFunction
Optimiz
er`."""
"""Decorator for `FromFunction
GraphRewrit
er`."""
rval
=
FromFunction
Optimiz
er
(
f
)
rval
=
FromFunction
GraphRewrit
er
(
f
)
rval
.
__name__
=
f
.
__name__
rval
.
__name__
=
f
.
__name__
return
rval
return
rval
def
inplace_
optimiz
er
(
f
):
def
inplace_
graph_rewrit
er
(
f
):
"""Decorator for `FromFunction
Optimiz
er` that also adds the `DestroyHandler` features."""
"""Decorator for `FromFunction
GraphRewrit
er` that also adds the `DestroyHandler` features."""
dh_handler
=
dh
.
DestroyHandler
dh_handler
=
dh
.
DestroyHandler
requirements
=
(
lambda
fgraph
:
fgraph
.
attach_feature
(
dh_handler
()),)
requirements
=
(
lambda
fgraph
:
fgraph
.
attach_feature
(
dh_handler
()),)
rval
=
FromFunction
Optimiz
er
(
f
,
requirements
)
rval
=
FromFunction
GraphRewrit
er
(
f
,
requirements
)
rval
.
__name__
=
f
.
__name__
rval
.
__name__
=
f
.
__name__
return
rval
return
rval
...
@@ -3131,6 +3131,21 @@ DEPRECATED_NAMES = [
...
@@ -3131,6 +3131,21 @@ DEPRECATED_NAMES = [
"`pre_greedy_local_optimizer` is deprecated: use `pre_greedy_node_rewriter` instead."
,
"`pre_greedy_local_optimizer` is deprecated: use `pre_greedy_node_rewriter` instead."
,
pre_greedy_node_rewriter
,
pre_greedy_node_rewriter
,
),
),
(
"FromFunctionOptimizer"
,
"`FromFunctionOptimizer` is deprecated: use `FromFunctionGraphRewriter` instead."
,
FromFunctionGraphRewriter
,
),
(
"optimizer"
,
"`optimizer` is deprecated: use `graph_rewriter` instead."
,
graph_rewriter
,
),
(
"inplace_optimizer"
,
"`inplace_optimizer` is deprecated: use `graph_rewriter` instead."
,
graph_rewriter
,
),
]
]
...
...
aesara/tensor/nnet/basic.py
浏览文件 @
4c458590
...
@@ -18,7 +18,7 @@ from aesara.compile import optdb
...
@@ -18,7 +18,7 @@ from aesara.compile import optdb
from
aesara.gradient
import
DisconnectedType
,
grad_not_implemented
from
aesara.gradient
import
DisconnectedType
,
grad_not_implemented
from
aesara.graph.basic
import
Apply
from
aesara.graph.basic
import
Apply
from
aesara.graph.op
import
Op
from
aesara.graph.op
import
Op
from
aesara.graph.opt
import
copy_stack_trace
,
node_rewriter
,
optimiz
er
from
aesara.graph.opt
import
copy_stack_trace
,
graph_rewriter
,
node_rewrit
er
from
aesara.link.c.op
import
COp
from
aesara.link.c.op
import
COp
from
aesara.raise_op
import
Assert
from
aesara.raise_op
import
Assert
from
aesara.scalar
import
UnaryScalarOp
from
aesara.scalar
import
UnaryScalarOp
...
@@ -1847,7 +1847,7 @@ crossentropy_categorical_1hot = CrossentropyCategorical1Hot()
...
@@ -1847,7 +1847,7 @@ crossentropy_categorical_1hot = CrossentropyCategorical1Hot()
@register_stabilize
(
"fast_compile"
)
@register_stabilize
(
"fast_compile"
)
@register_specialize
(
"fast_compile"
)
@register_specialize
(
"fast_compile"
)
@
optimiz
er
@
graph_rewrit
er
def
crossentropy_to_crossentropy_with_softmax_with_bias
(
fgraph
):
def
crossentropy_to_crossentropy_with_softmax_with_bias
(
fgraph
):
def
search_make_one_sub
():
def
search_make_one_sub
():
for
node
in
fgraph
.
toposort
():
for
node
in
fgraph
.
toposort
():
...
@@ -1874,7 +1874,7 @@ def crossentropy_to_crossentropy_with_softmax_with_bias(fgraph):
...
@@ -1874,7 +1874,7 @@ def crossentropy_to_crossentropy_with_softmax_with_bias(fgraph):
return
return
@
optimiz
er
@
graph_rewrit
er
def
crossentropy_to_crossentropy_with_softmax
(
fgraph
):
def
crossentropy_to_crossentropy_with_softmax
(
fgraph
):
"""
"""
This is a stabilization rewrite that is more general than
This is a stabilization rewrite that is more general than
...
...
doc/extending/graph_rewriting.rst
浏览文件 @
4c458590
...
@@ -944,7 +944,7 @@ This will output something like this:
...
@@ -944,7 +944,7 @@ This will output something like this:
validate_time 6.43730163574e-05
validate_time 6.43730163574e-05
callback_time 0.000783205032349
callback_time 0.000783205032349
time_toposort 0.0035240650177
time_toposort 0.0035240650177
0.090089s - ('inplace_elemwise_optimizer', 'FromFunction
Optimiz
er', 30) - 0.019s
0.090089s - ('inplace_elemwise_optimizer', 'FromFunction
GraphRewrit
er', 30) - 0.019s
0.048993s - ('BlasOpt', 'SeqOptimizer', 8) - 0.000s
0.048993s - ('BlasOpt', 'SeqOptimizer', 8) - 0.000s
SeqOptimizer BlasOpt time 0.049s for 81/80 nodes before/after optimization
SeqOptimizer BlasOpt time 0.049s for 81/80 nodes before/after optimization
0.000s for fgraph.validate()
0.000s for fgraph.validate()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论