Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b70504c9
提交
b70504c9
authored
8月 13, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numpydoc for theano/gof/optdb.py
上级
46d46d76
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
52 行增加
和
28 行删除
+52
-28
optdb.py
theano/gof/optdb.py
+52
-28
没有找到文件。
theano/gof/optdb.py
浏览文件 @
b70504c9
...
@@ -36,11 +36,17 @@ class DB(object):
...
@@ -36,11 +36,17 @@ class DB(object):
def
register
(
self
,
name
,
obj
,
*
tags
,
**
kwargs
):
def
register
(
self
,
name
,
obj
,
*
tags
,
**
kwargs
):
"""
"""
:param name: name of the optimizer.
:param obj: the optimizer to register.
Parameters
:param tags: tag name that allow to select the optimizer.
----------
:param kwargs: If non empty, should contain
name : str
only use_db_name_as_tag=False.
Name of the optimizer.
obj
The optimizer to register.
tags
Tag name that allow to select the optimizer.
kwargs
If non empty, should contain only use_db_name_as_tag=False.
By default, all optimizations registered in EquilibriumDB
By default, all optimizations registered in EquilibriumDB
are selected when the EquilibriumDB name is used as a
are selected when the EquilibriumDB name is used as a
tag. We do not want this behavior for some optimizer like
tag. We do not want this behavior for some optimizer like
...
@@ -156,14 +162,18 @@ multiple time in a DB. Tryed to register "%s" again under the new name "%s".
...
@@ -156,14 +162,18 @@ multiple time in a DB. Tryed to register "%s" again under the new name "%s".
class
Query
(
object
):
class
Query
(
object
):
"""
Parameters
----------
position_cutoff : float
Used by SequenceDB to keep only optimizer that are positioned before
the cut_off point.
"""
def
__init__
(
self
,
include
,
require
=
None
,
exclude
=
None
,
def
__init__
(
self
,
include
,
require
=
None
,
exclude
=
None
,
subquery
=
None
,
position_cutoff
=
None
):
subquery
=
None
,
position_cutoff
=
None
):
"""
:type position_cutoff: float
:param position_cutoff: Used by SequenceDB to keep only optimizer that
are positioned before the cut_off point.
"""
self
.
include
=
OrderedSet
(
include
)
self
.
include
=
OrderedSet
(
include
)
self
.
require
=
require
or
OrderedSet
()
self
.
require
=
require
or
OrderedSet
()
self
.
exclude
=
exclude
or
OrderedSet
()
self
.
exclude
=
exclude
or
OrderedSet
()
...
@@ -206,22 +216,26 @@ class Query(object):
...
@@ -206,22 +216,26 @@ class Query(object):
class
EquilibriumDB
(
DB
):
class
EquilibriumDB
(
DB
):
"""A set of potential optimizations which should be applied in an
"""
arbitrary order until equilibrium is reached.
A set of potential optimizations which should be applied in an arbitrary
order until equilibrium is reached.
Canonicalize, Stabilize, and Specialize are all equilibrium optimizations.
Canonicalize, Stabilize, and Specialize are all equilibrium optimizations.
:param ignore_newtrees: If False, we will apply local opt on new
Parameters
node introduced during local optimization application. This
----------
could result in less fgraph iterations, but this don't mean it
ignore_newtrees
will be faster globally.
If False, we will apply local opt on new node introduced during local
optimization application. This could result in less fgraph iterations,
but this doesn't mean it will be faster globally.
.. note::
Notes
-----
We can put LocalOptimizer and Optimizer as EquilibriumOptimizer
We can put LocalOptimizer and Optimizer as EquilibriumOptimizer
suppor both.
suppor both.
"""
"""
def
__init__
(
self
,
ignore_newtrees
=
True
):
def
__init__
(
self
,
ignore_newtrees
=
True
):
super
(
EquilibriumDB
,
self
)
.
__init__
()
super
(
EquilibriumDB
,
self
)
.
__init__
()
self
.
ignore_newtrees
=
ignore_newtrees
self
.
ignore_newtrees
=
ignore_newtrees
...
@@ -253,7 +267,8 @@ class EquilibriumDB(DB):
...
@@ -253,7 +267,8 @@ class EquilibriumDB(DB):
class
SequenceDB
(
DB
):
class
SequenceDB
(
DB
):
"""A sequence of potential optimizations.
"""
A sequence of potential optimizations.
Retrieve a sequence of optimizations (a SeqOptimizer) by calling query().
Retrieve a sequence of optimizations (a SeqOptimizer) by calling query().
...
@@ -265,6 +280,7 @@ class SequenceDB(DB):
...
@@ -265,6 +280,7 @@ class SequenceDB(DB):
other tags) fast_run and fast_compile optimizers are drawn is a SequenceDB.
other tags) fast_run and fast_compile optimizers are drawn is a SequenceDB.
"""
"""
seq_opt
=
opt
.
SeqOptimizer
seq_opt
=
opt
.
SeqOptimizer
def
__init__
(
self
,
failure_callback
=
opt
.
SeqOptimizer
.
warn
):
def
__init__
(
self
,
failure_callback
=
opt
.
SeqOptimizer
.
warn
):
...
@@ -278,9 +294,12 @@ class SequenceDB(DB):
...
@@ -278,9 +294,12 @@ class SequenceDB(DB):
def
query
(
self
,
*
tags
,
**
kwtags
):
def
query
(
self
,
*
tags
,
**
kwtags
):
"""
"""
:type position_cutoff: float or int
:param position_cutoff: only optimizations with position less than
Parameters
the cutoff are returned.
----------
position_cutoff : float or int
Only optimizations with position less than the cutoff are returned.
"""
"""
opts
=
super
(
SequenceDB
,
self
)
.
query
(
*
tags
,
**
kwtags
)
opts
=
super
(
SequenceDB
,
self
)
.
query
(
*
tags
,
**
kwtags
)
...
@@ -326,11 +345,14 @@ class SequenceDB(DB):
...
@@ -326,11 +345,14 @@ class SequenceDB(DB):
class
LocalGroupDB
(
SequenceDB
):
class
LocalGroupDB
(
SequenceDB
):
"""This generate a local optimizer of type LocalOptGroup instead
"""
Generate a local optimizer of type LocalOptGroup instead
of a global optimizer.
of a global optimizer.
It support the tracks, to only get applied to some Op.
It supports the tracks, to only get applied to some Op.
"""
"""
seq_opt
=
opt
.
LocalOptGroup
seq_opt
=
opt
.
LocalOptGroup
def
__init__
(
self
,
failure_callback
=
opt
.
SeqOptimizer
.
warn
):
def
__init__
(
self
,
failure_callback
=
opt
.
SeqOptimizer
.
warn
):
...
@@ -342,9 +364,11 @@ class ProxyDB(DB):
...
@@ -342,9 +364,11 @@ class ProxyDB(DB):
"""
"""
Wrap an existing proxy.
Wrap an existing proxy.
This is needed as we can't register the same DB mutiple time in
This is needed as we can't register the same DB mutiple times in
different position in a SequentialDB
different positions in a SequentialDB.
"""
"""
def
__init__
(
self
,
db
):
def
__init__
(
self
,
db
):
assert
isinstance
(
db
,
DB
),
""
assert
isinstance
(
db
,
DB
),
""
self
.
db
=
db
self
.
db
=
db
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论