Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d1d0f164
提交
d1d0f164
authored
2月 08, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fuse elemwise event when a variable is used for many into to the elemwise.
上级
9bec6b50
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
2 行删除
+14
-2
opt.py
theano/tensor/opt.py
+3
-1
test_opt.py
theano/tensor/tests/test_opt.py
+11
-1
没有找到文件。
theano/tensor/opt.py
浏览文件 @
d1d0f164
...
...
@@ -3119,7 +3119,9 @@ def local_elemwise_fusion_op(OP, max_input_fct=lambda node: 1024):
s_inputs
.
extend
(
tmp_scalar
)
s_g
.
append
(
s_op
)
else
:
if
i
in
inputs
:
# We must support the case where the same variable appear many
# time in the inputs
if
inputs
.
count
(
i
)
==
node
.
inputs
.
count
(
i
):
s
=
s_inputs
[
inputs
.
index
(
i
)]
else
:
s
=
scalar
.
Scalar
(
i
.
dtype
)
.
make_variable
()
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
d1d0f164
...
...
@@ -798,7 +798,9 @@ class test_fusion(unittest.TestCase):
(
theano
.
tensor
.
mul
(
fx
,
fx
,
fx
,
fx
),(
fx
,),(
fxv
,),
1
,
fxv
*
fxv
*
fxv
*
fxv
,
'float32'
),
(
theano
.
tensor
.
mul
(
fx
,
ftanx
,
ftanx
),(
fx
,),(
fxv
,),
2
,
fxv
*
numpy
.
tan
(
fxv
)
*
numpy
.
tan
(
fxv
),
'float32'
),
# TODO: This case is not fused!
(
theano
.
tensor
.
mul
(
fx
,
ftanx
,
ftanx
,
fx
),(
fx
,),(
fxv
,),
2
,
fxv
*
numpy
.
tan
(
fxv
)
*
numpy
.
tan
(
fxv
)
*
fxv
,
'float32'
),
# TODO: This case is not fused!
(
theano
.
tensor
.
mul
(
ftanx
,
ftanx
,
fx
+
fy
),(
fx
,
fy
),(
fxv
,
fyv
),
3
,
numpy
.
tan
(
fxv
)
*
numpy
.
tan
(
fxv
)
*
(
fxv
+
fyv
),
'float32'
),
# TODO: This case is not fused!
# The next case test when one variable appear as many inputs to an op.
# In the past, this was not fused.
(
theano
.
tensor
.
mul
(
ftanx
,
ftanx
,
fx
+
fy
),(
fx
,
fy
),(
fxv
,
fyv
),
2
,
numpy
.
tan
(
fxv
)
*
numpy
.
tan
(
fxv
)
*
(
fxv
+
fyv
),
'float32'
),
# TODO: This case is not fused!
]
if
slice
:
cases
=
cases
[
slice
]
...
...
@@ -844,6 +846,14 @@ class test_fusion(unittest.TestCase):
if
assert_len_topo
:
if
not
len
(
topo_
)
==
nb_elemwise
:
fail3
.
append
((
id
,
topo_
,
nb_elemwise
))
if
nb_elemwise
==
1
:
# check that the number of input to the Composite Elemwise is ok
# when there is not variable that appear multiple time the in input
# of g
assert
((
numpy
.
sum
([
not
isinstance
(
x
,
theano
.
gof
.
Constant
)
for
x
in
topo_
[
0
]
.
inputs
])
==
len
(
sym_inputs
))
or
len
(
set
(
g
.
owner
.
inputs
))
!=
len
(
g
.
owner
.
inputs
))
if
not
out_dtype
==
out
.
dtype
:
fail4
.
append
((
id
,
out_dtype
,
out
.
dtype
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论