Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
69ec63f0
提交
69ec63f0
authored
10月 13, 2009
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code cleanup and fuse more case of elemwise.
上级
0d9b26fc
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
8 行增加
和
21 行删除
+8
-21
opt.py
theano/tensor/opt.py
+8
-21
没有找到文件。
theano/tensor/opt.py
浏览文件 @
69ec63f0
...
@@ -1242,9 +1242,10 @@ def local_elemwise_fusion(node):
...
@@ -1242,9 +1242,10 @@ def local_elemwise_fusion(node):
s_inputs
=
[]
#inputs of the new scalar op.
s_inputs
=
[]
#inputs of the new scalar op.
s_g
=
[]
#graph of scalar, what will by done in the inner loop.
s_g
=
[]
#graph of scalar, what will by done in the inner loop.
for
i
in
node
.
inputs
:
for
i
in
node
.
inputs
:
if
i
.
owner
and
isinstance
(
i
.
owner
.
op
,
T
.
Elemwise
):
if
i
.
owner
and
isinstance
(
i
.
owner
.
op
,
T
.
Elemwise
)
and
len
(
i
.
clients
)
<=
1
:
if
len
(
i
.
clients
)
>
1
:
if
len
(
i
.
clients
)
>
1
:
#should we put this in the first if, then we would go to the elif to don't fuse it?
#should we put this in the first if, then we would go to the elif to don't fuse it?
#if one of the inputs have more then 1 clients and it is an intermediate result. We don't fuse.
print
"local_elemwise_fusion: Elemwise inputs have more then 1 client. Don't optimise for now"
print
"local_elemwise_fusion: Elemwise inputs have more then 1 client. Don't optimise for now"
return
False
return
False
...
@@ -1254,36 +1255,22 @@ def local_elemwise_fusion(node):
...
@@ -1254,36 +1255,22 @@ def local_elemwise_fusion(node):
s_inputs
.
extend
(
s_input
)
s_inputs
.
extend
(
s_input
)
s_op
=
i
.
owner
.
op
.
scalar_op
(
*
s_input
)
s_op
=
i
.
owner
.
op
.
scalar_op
(
*
s_input
)
s_g
.
append
(
s_op
)
s_g
.
append
(
s_op
)
elif
not
i
.
owner
:
else
:
if
i
.
owner
and
isinstance
(
i
.
owner
.
op
,
T
.
Elemwise
)
and
len
(
i
.
clients
)
>
1
:
#should we put this in the first if, then we would go to the elif to don't fuse it?
print
"local_elemwise_fusion: inputs have more then 1 client. Don't fuse it for now.!"
return
False
inputs
.
append
(
i
)
inputs
.
append
(
i
)
s
=
scalar
.
Scalar
(
i
.
dtype
)
.
make_variable
()
s
=
scalar
.
Scalar
(
i
.
dtype
)
.
make_variable
()
s_inputs
.
append
(
s
)
s_inputs
.
append
(
s
)
s_g
.
append
(
s
)
s_g
.
append
(
s
)
else
:
print
"local_elemwise_fusion: have an owner that is not an Elemwise."
return
False
#if no inputs have are an elemwise, their is nothing to fuse.
if
nb_elemwise
==
0
:
if
nb_elemwise
==
0
:
# print "local_elemwise_fusion: node have no elemwise in inputs. Nothing to fuse."
return
False
return
False
#if one of the inputs have more then 1 clients and it is an intermediate result. We don't fuse.
if
any
([
len
(
x
.
clients
)
!=
1
and
x
.
owner
for
x
in
node
.
inputs
]):
#len(node.inputs[0].clients)!=1:
print
"local_elemwise_fusion: node have more then 1 clients."
,
[
x
.
clients
for
x
in
node
.
inputs
]
return
False
otype
=
node
.
outputs
[
0
]
.
type
otype
=
node
.
outputs
[
0
]
.
type
# print "local_elemwise_fusion"
# print [type(x) for x in s_inputs]
# print "node",node
# print "node.inputs",node.inputs
# print "node.inputs[0].op",node.inputs[0].op
# print "node.inputs[1].op",node.inputs[1].op
# print "node.outputs",node.outputs
# print "s_g",s_g, [type(x) for x in s_g]
# print "s_inpust",s_inputs
s_new_out
=
node
.
op
.
scalar_op
(
*
s_g
)
s_new_out
=
node
.
op
.
scalar_op
(
*
s_g
)
# print "s_new_out",s_new_out
#create the composite op.
#create the composite op.
C
=
scalar
.
Composite
(
s_inputs
,[
s_new_out
])
C
=
scalar
.
Composite
(
s_inputs
,[
s_new_out
])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论