Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
559bd4f9
提交
559bd4f9
authored
6月 13, 2016
作者:
Frédéric Bastien
提交者:
GitHub
6月 13, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4617 from nouiz/fix_cycle_opt
[FIX TRAVIS] Make the new node on a graph not depend on the old node.
上级
420a9b83
cf0c1bf0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
5 行删除
+23
-5
basic.py
theano/tensor/basic.py
+9
-3
opt.py
theano/tensor/opt.py
+14
-2
没有找到文件。
theano/tensor/basic.py
浏览文件 @
559bd4f9
...
@@ -590,6 +590,8 @@ def get_scalar_constant_value(orig_v, elemwise=True,
...
@@ -590,6 +590,8 @@ def get_scalar_constant_value(orig_v, elemwise=True,
----------
----------
elemwise : bool
elemwise : bool
If False, we won't try to go into elemwise. So this call is faster.
If False, we won't try to go into elemwise. So this call is faster.
But we still investigate in Second Elemwise (as this is a substitute
for Alloc)
only_process_constants : bool
only_process_constants : bool
If True, we only attempt to obtain the value of `orig_v` if it's
If True, we only attempt to obtain the value of `orig_v` if it's
directly constant and don't try to dig through dimshuffles, fills,
directly constant and don't try to dig through dimshuffles, fills,
...
@@ -650,14 +652,18 @@ def get_scalar_constant_value(orig_v, elemwise=True,
...
@@ -650,14 +652,18 @@ def get_scalar_constant_value(orig_v, elemwise=True,
ret
=
[[
None
]]
ret
=
[[
None
]]
v
.
owner
.
op
.
perform
(
v
.
owner
,
const
,
ret
)
v
.
owner
.
op
.
perform
(
v
.
owner
,
const
,
ret
)
return
ret
[
0
][
0
]
.
copy
()
return
ret
[
0
][
0
]
.
copy
()
elif
elemwise
and
isinstance
(
v
.
owner
.
op
,
Elemwise
):
# In fast_compile, we don't enable local_fill_to_alloc, so
# we need to investigate Second as Alloc. So elemwise
# don't disable the check for Second.
elif
isinstance
(
v
.
owner
.
op
,
Elemwise
):
if
isinstance
(
v
.
owner
.
op
.
scalar_op
,
scal
.
Second
):
if
isinstance
(
v
.
owner
.
op
.
scalar_op
,
scal
.
Second
):
# We don't need both input to be constant for second
# We don't need both input to be constant for second
shp
,
val
=
v
.
owner
.
inputs
shp
,
val
=
v
.
owner
.
inputs
v
=
val
v
=
val
continue
continue
elif
isinstance
(
v
.
owner
.
op
.
scalar_op
,
elif
elemwise
and
isinstance
(
get_scalar_constant_value_elemwises
):
v
.
owner
.
op
.
scalar_op
,
get_scalar_constant_value_elemwises
):
const
=
[
get_scalar_constant_value
(
i
)
const
=
[
get_scalar_constant_value
(
i
)
for
i
in
v
.
owner
.
inputs
]
for
i
in
v
.
owner
.
inputs
]
ret
=
[[
None
]]
ret
=
[[
None
]]
...
...
theano/tensor/opt.py
浏览文件 @
559bd4f9
...
@@ -3753,8 +3753,20 @@ def local_useless_switch(node):
...
@@ -3753,8 +3753,20 @@ def local_useless_switch(node):
if
out
.
type
.
broadcastable
!=
node
.
outputs
[
0
]
.
type
.
broadcastable
:
if
out
.
type
.
broadcastable
!=
node
.
outputs
[
0
]
.
type
.
broadcastable
:
# We need to copy data to the new dimensions during execution
# We need to copy data to the new dimensions during execution
out
=
T
.
alloc
(
out
,
*
[
node
.
outputs
[
0
]
.
shape
[
i
]
for
i
in
xrange
(
out
.
ndim
)])
# We should not depend on node.outputs as this would
# make the new node depend on the old one that will
# get optimized again. So this create a cycle.
shps
=
[]
for
idx
,
(
b1
,
b2
),
in
enumerate
(
zip
(
out
.
type
.
broadcastable
,
node
.
outputs
[
0
]
.
type
.
broadcastable
)):
if
b1
==
b2
:
shps
.
append
(
out
.
shape
[
idx
])
elif
not
node
.
inputs
[
1
]
.
type
.
broadcastable
[
idx
]:
shps
.
append
(
node
.
inputs
[
1
]
.
shape
[
idx
])
else
:
shps
.
append
(
node
.
inputs
[
2
]
.
shape
[
idx
])
out
=
T
.
alloc
(
out
,
*
shps
)
else
:
else
:
out
=
out
out
=
out
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论