Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a7183bc9
提交
a7183bc9
authored
12月 11, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
12月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Start using graph "rewriting" instead of "optimization" in the docs
上级
56eb73ca
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
30 行增加
和
36 行删除
+30
-36
core_development_guide.rst
doc/core_development_guide.rst
+1
-1
graph_rewriting.rst
doc/extending/graph_rewriting.rst
+17
-25
graphstructures.rst
doc/extending/graphstructures.rst
+1
-3
index.rst
doc/extending/index.rst
+1
-1
scan.rst
doc/extending/scan.rst
+1
-1
glossary.rst
doc/glossary.rst
+8
-3
optimizations.rst
doc/optimizations.rst
+1
-2
没有找到文件。
doc/core_development_guide.rst
浏览文件 @
a7183bc9
...
@@ -17,7 +17,7 @@ some of them might be outdated though:
...
@@ -17,7 +17,7 @@ some of them might be outdated though:
describing how Aesara works internally; it talks about views and inplace
describing how Aesara works internally; it talks about views and inplace
operations.
operations.
* :ref:`
optimization` -- Tutorial on how optimization work
in Aesara.
* :ref:`
graph_rewriting` -- Tutorial on how graph rewriting works
in Aesara.
* :ref:`pipeline` -- Describes the steps of compiling an Aesara Function.
* :ref:`pipeline` -- Describes the steps of compiling an Aesara Function.
...
...
doc/extending/
optimization
.rst
→
doc/extending/
graph_rewriting
.rst
浏览文件 @
a7183bc9
.. _
optimization
:
.. _
graph_rewriting
:
===============
===
===============
Graph
optimization
Graph
Rewriting
===============
===
===============
In this document we will explain how optimizations work and construct a couple examples.
In this document we will explain how graph rewriting works and how graph
optimizations can be constructed using graph rewriting.
.. todo::
.. todo::
The old "optimization" nomenclature is still in use throughout these documents
and the codebase; however, this is being changed to more accurately distinguish
between general graph rewriting for any purpose and the kind that is explicitly
intended to "optimize" a graph in some way.
This tutorial goes way too far under the hood, for someone who just wants
to add yet another pattern to the libraries in :py:mod:`aesara.tensor.basic_opt` for example.
We need another tutorial that covers the decorator syntax, and explains how
to register your optimization right away. That's what you need to get
going.
Later, the rest is more useful for when that decorator syntax type thing
doesn't work. (There are optimizations that don't fit that model).
.. note::
The optimization tag ``cxx_only`` is used for optimizations that insert
:class:`Op`\s which have no Python implementation (so they only have C code).
Optimizations with this tag are skipped when there is no C++ compiler
available.
Global and Local Optimizations
Global and Local Optimizations
==============================
==============================
...
@@ -147,7 +136,7 @@ simplification described above:
...
@@ -147,7 +136,7 @@ simplification described above:
requirements we might want to know about?
requirements we might want to know about?
Here's how it works: first, in :meth:`add_requirements`, we add the
Here's how it works: first, in :meth:`add_requirements`, we add the
:class:`ReplaceValidate` :
ref:`libdoc_graph_fgraphf
eature` located in
:class:`ReplaceValidate` :
class:`F
eature` located in
:ref:`libdoc_graph_features`. This feature adds the :meth:`replace_validate`
:ref:`libdoc_graph_features`. This feature adds the :meth:`replace_validate`
method to ``fgraph``, which is an enhanced version of :meth:`replace` that
method to ``fgraph``, which is an enhanced version of :meth:`replace` that
does additional checks to ensure that we are not messing up the
does additional checks to ensure that we are not messing up the
...
@@ -155,9 +144,7 @@ computation graph (note: if :class:`ReplaceValidate` was already added by
...
@@ -155,9 +144,7 @@ computation graph (note: if :class:`ReplaceValidate` was already added by
another optimizer, ``extend`` will do nothing). In a nutshell,
another optimizer, ``extend`` will do nothing). In a nutshell,
:class:`ReplaceValidate` grants access to :meth:`fgraph.replace_validate`,
:class:`ReplaceValidate` grants access to :meth:`fgraph.replace_validate`,
and :meth:`fgraph.replace_validate` allows us to replace a :class:`Variable` with
and :meth:`fgraph.replace_validate` allows us to replace a :class:`Variable` with
another while respecting certain validation constraints. You can
another while respecting certain validation constraints. As an
browse the list of :ref:`libdoc_graph_fgraphfeaturelist` and see if some of
them might be useful to write optimizations with. For example, as an
exercise, try to rewrite ``Simplify`` using :class:`NodeFinder`. (Hint: you
exercise, try to rewrite ``Simplify`` using :class:`NodeFinder`. (Hint: you
want to use the method it publishes instead of the call to toposort!)
want to use the method it publishes instead of the call to toposort!)
...
@@ -391,6 +378,11 @@ as well as informative tags such as 'stable', 'buggy' or
...
@@ -391,6 +378,11 @@ as well as informative tags such as 'stable', 'buggy' or
'cpu_intensive', all this without compromising the structure of the
'cpu_intensive', all this without compromising the structure of the
optimizations.
optimizations.
For instance, the optimization tag ``cxx_only`` is used for optimizations that
insert :class:`Op`\s that have no Python implementation (i.e. they only have C
implementations). Optimizations with this tag can be skipped when the C backend
is not being used.
Definition of :obj:`optdb`
Definition of :obj:`optdb`
--------------------------
--------------------------
...
...
doc/extending/graphstructures.rst
浏览文件 @
a7183bc9
...
@@ -417,10 +417,8 @@ twice or reformulate parts of the graph to a GPU specific version.
...
@@ -417,10 +417,8 @@ twice or reformulate parts of the graph to a GPU specific version.
For example, one (simple) optimization that Aesara uses is to replace
For example, one (simple) optimization that Aesara uses is to replace
the pattern :math:`\frac{xy}{y}` by *x.*
the pattern :math:`\frac{xy}{y}` by *x.*
Further information regarding the optimization
:ref:`process<optimization>` and the specific :ref:`optimizations<optimizations>` that are applicable
is respectively available in the library and on the entrance page of the documentation.
See :ref:`graph_rewriting` and :ref:`optimizations` for more information.
**Example**
**Example**
...
...
doc/extending/index.rst
浏览文件 @
a7183bc9
...
@@ -32,6 +32,7 @@ with Aesara itself.
...
@@ -32,6 +32,7 @@ with Aesara itself.
.. toctree::
.. toctree::
graph_rewriting
extending_aesara
extending_aesara
extending_aesara_c
extending_aesara_c
pipeline
pipeline
...
@@ -44,7 +45,6 @@ with Aesara itself.
...
@@ -44,7 +45,6 @@ with Aesara itself.
ctype
ctype
cop
cop
using_params
using_params
optimization
tips
tips
unittest
unittest
scan
scan
...
...
doc/extending/scan.rst
浏览文件 @
a7183bc9
...
@@ -39,7 +39,7 @@ The following sections assumes the reader is familiar with the following :
...
@@ -39,7 +39,7 @@ The following sections assumes the reader is familiar with the following :
Additionally, the :ref:`scan_internals_optimizations` section below assumes
Additionally, the :ref:`scan_internals_optimizations` section below assumes
knowledge of:
knowledge of:
3. Aesara's :ref:`graph
optimizations <optimization
>`
3. Aesara's :ref:`graph
rewriting <graph_rewriting
>`
Relevant code files
Relevant code files
...
...
doc/glossary.rst
浏览文件 @
a7183bc9
...
@@ -112,13 +112,18 @@ Glossary
...
@@ -112,13 +112,18 @@ Glossary
See also :term:`Variable`, :term:`Type`, and :term:`Apply`,
See also :term:`Variable`, :term:`Type`, and :term:`Apply`,
or read more about :ref:`graphstructures`.
or read more about :ref:`graphstructures`.
Rewriter
A function or class that transforms an Aesara :term:`graph`.
Optimizer
Optimizer
An instance of
:class:`Optimizer`, which
has the capacity to provide
An instance of
a :term:`rewriter` that
has the capacity to provide
an
:term:`optimization` (or optimizations)
.
an
improvement to the performance of a graph
.
Optimization
Optimization
A :term:`graph` transformation applied by an :term:`optimizer` during
A :term:`graph` transformation applied by an :term:`optimizer` during
the compilation of a :term:`graph` by :term:`aesara.function`.
the compilation of a :term:`graph` by :term:`aesara.function`. These
are graph rewrites that are intended to improve the performance of
a compiled :term:`Graph`.
Pure
Pure
An :term:`Op` is *pure* if it has no :term:`destructive` side-effects.
An :term:`Op` is *pure* if it has no :term:`destructive` side-effects.
...
...
doc/optimizations.rst
浏览文件 @
a7183bc9
...
@@ -13,8 +13,7 @@ The optimizations are listed in roughly chronological order. The table below
...
@@ -13,8 +13,7 @@ The optimizations are listed in roughly chronological order. The table below
gives a quick summary of the optimizations included in the default modes.
gives a quick summary of the optimizations included in the default modes.
The descriptions are brief and point to further reading.
The descriptions are brief and point to further reading.
If you would like to add an additional optimization, refer to
If you would like to add an additional optimization, see :ref:`graph_rewriting`.
:ref:`optimization` in the guide to extending Aesara.
When compiling, we can make a tradeoff between compile-time and run-time.
When compiling, we can make a tradeoff between compile-time and run-time.
Faster compile times will result in fewer optimizations being applied, hence generally slower run-times.
Faster compile times will result in fewer optimizations being applied, hence generally slower run-times.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论