Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
67b911ab
提交
67b911ab
authored
5月 20, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added gof.op.Dispatch
上级
cca46fc2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
38 行增加
和
5 行删除
+38
-5
__init__.py
gof/__init__.py
+2
-2
op.py
gof/op.py
+36
-3
没有找到文件。
gof/__init__.py
浏览文件 @
67b911ab
...
@@ -15,7 +15,7 @@ from link import \
...
@@ -15,7 +15,7 @@ from link import \
Linker
,
LocalLinker
,
PerformLinker
,
MetaLinker
,
Profiler
Linker
,
LocalLinker
,
PerformLinker
,
MetaLinker
,
Profiler
from
op
import
\
from
op
import
\
Op
,
Macro
Op
,
Macro
,
Dispatch
from
opt
import
\
from
opt
import
\
Optimizer
,
SeqOptimizer
,
\
Optimizer
,
SeqOptimizer
,
\
...
@@ -23,7 +23,7 @@ from opt import \
...
@@ -23,7 +23,7 @@ from opt import \
LocalOptimizer
,
LocalOptGroup
,
LocalOpKeyOptGroup
,
\
LocalOptimizer
,
LocalOptGroup
,
LocalOpKeyOptGroup
,
\
ExpandMacro
,
OpSub
,
OpRemove
,
PatternSub
,
\
ExpandMacro
,
OpSub
,
OpRemove
,
PatternSub
,
\
NavigatorOptimizer
,
TopoOptimizer
,
OpKeyOptimizer
,
\
NavigatorOptimizer
,
TopoOptimizer
,
OpKeyOptimizer
,
\
expand_m
acros
ExpandM
acros
from
toolbox
import
\
from
toolbox
import
\
Bookkeeper
,
History
,
Validator
,
ReplaceValidate
,
NodeFinder
,
PrintListener
Bookkeeper
,
History
,
Validator
,
ReplaceValidate
,
NodeFinder
,
PrintListener
...
...
gof/op.py
浏览文件 @
67b911ab
...
@@ -22,7 +22,7 @@ class Op(utils.object2):
...
@@ -22,7 +22,7 @@ class Op(utils.object2):
This function should return an Apply instance representing the
This function should return an Apply instance representing the
application of this Op on the provided inputs.
application of this Op on the provided inputs.
"""
"""
raise
utils
.
AbstractFunctionError
()
raise
utils
.
AbstractFunctionError
(
self
)
def
__call__
(
self
,
*
inputs
):
def
__call__
(
self
,
*
inputs
):
"""
"""
...
@@ -61,7 +61,7 @@ class Op(utils.object2):
...
@@ -61,7 +61,7 @@ class Op(utils.object2):
by a previous call to impl and impl is free to reuse it as it
by a previous call to impl and impl is free to reuse it as it
sees fit.
sees fit.
"""
"""
raise
utils
.
AbstractFunctionError
()
raise
utils
.
AbstractFunctionError
(
self
)
#####################
#####################
# C code generation #
# C code generation #
...
@@ -132,9 +132,42 @@ class Macro(Op):
...
@@ -132,9 +132,42 @@ class Macro(Op):
into a computable graph with its expand() method.
into a computable graph with its expand() method.
"""
"""
def
expand
(
self
,
*
outputs
):
def
expand
(
self
,
node
):
"""
"""
Returns a node representing the expansion of this macro.
Returns a node representing the expansion of this macro.
"""
"""
raise
utils
.
AbstractFunctionError
()
raise
utils
.
AbstractFunctionError
()
class
Dispatch
(
Macro
):
"""
Dispatches inputs to one of a list of candidate ops.
Tries each candidate in order.
"""
def
__init__
(
self
,
name
,
candidates
):
if
not
isinstance
(
name
,
str
):
raise
TypeError
(
"name should be a string, not:"
,
name
,
type
(
name
))
self
.
candidates
=
candidates
self
.
name
=
name
def
__node
(
self
,
*
inputs
):
for
candidate
in
self
.
candidates
:
try
:
return
candidate
.
make_node
(
*
inputs
)
except
:
continue
raise
TypeError
(
"No suitable candidate found for
%
s(
%
s)"
%
(
self
,
inputs
))
def
make_node
(
self
,
*
inputs
):
node
=
self
.
__node
(
*
inputs
)
node
.
op
=
self
return
node
def
expand
(
self
,
node
):
return
self
.
__node
(
*
node
.
inputs
)
def
__str__
(
self
):
return
self
.
name
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论