Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
631e5dc9
提交
631e5dc9
authored
8月 23, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Theano function overhead increase due to gh-6275. Shared variable was not…
Fix Theano function overhead increase due to gh-6275. Shared variable was not triggering the input alias check and that was right.
上级
f4ef0469
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
35 行增加
和
2 行删除
+35
-2
function_module.py
theano/compile/function_module.py
+6
-2
test_function_module.py
theano/compile/tests/test_function_module.py
+29
-0
没有找到文件。
theano/compile/function_module.py
浏览文件 @
631e5dc9
...
...
@@ -385,8 +385,12 @@ class Function(object):
# TODO: this only need to be set if there is more then 1 input
self
.
_check_for_aliased_inputs
=
False
for
i
in
maker
.
inputs
:
if
(
isinstance
(
i
,
In
)
and
((
hasattr
(
i
,
'borrow'
)
and
i
.
borrow
)
or
(
hasattr
(
i
,
'mutable'
)
and
i
.
mutable
))):
# If the input is a shared variable, the memory region is
# under Theano control and so we don't need to check if it
# is aliased as we never do that.
if
(
isinstance
(
i
,
In
)
and
not
i
.
shared
and
(
getattr
(
i
,
'borrow'
,
False
)
or
getattr
(
i
,
'mutable'
,
False
))):
self
.
_check_for_aliased_inputs
=
True
break
...
...
theano/compile/tests/test_function_module.py
浏览文件 @
631e5dc9
...
...
@@ -582,6 +582,35 @@ class T_function(unittest.TestCase):
except
TypeError
:
assert
(
func
(
first
=
1
)
==
x
)
def
test_check_for_aliased_inputs
(
self
):
b
=
np
.
random
.
rand
(
5
,
4
)
s1
=
theano
.
shared
(
b
)
s2
=
theano
.
shared
(
b
)
x1
=
theano
.
tensor
.
vector
()
# Assert cases we should not check for aliased inputs
for
d
in
[
dict
(
outputs
=
[
s1
+
1
]),
dict
(
outputs
=
[
s1
+
1
,
s2
+
3
]),
dict
(
outputs
=
[
s1
+
1
],
updates
=
[(
s2
,
s2
+
3
)]),
dict
(
inputs
=
[
x1
],
outputs
=
[
x1
+
1
],
updates
=
[(
s2
,
s2
+
3
)])]:
if
"inputs"
not
in
d
:
d
[
"inputs"
]
=
[]
f
=
theano
.
function
(
**
d
)
assert
not
f
.
_check_for_aliased_inputs
,
d
# Assert cases we should check for aliased inputs
for
d
in
[
dict
(
inputs
=
[
theano
.
In
(
x1
,
borrow
=
True
)],
outputs
=
[
x1
+
1
],
updates
=
[(
s2
,
s2
+
3
)]),
dict
(
inputs
=
[
theano
.
In
(
x1
,
borrow
=
True
,
mutable
=
True
)],
outputs
=
[
x1
+
1
],
updates
=
[(
s2
,
s2
+
3
)]),
dict
(
inputs
=
[
theano
.
In
(
x1
,
mutable
=
True
)],
outputs
=
[
x1
+
1
],
updates
=
[(
s2
,
s2
+
3
)])]:
if
"inputs"
not
in
d
:
d
[
"inputs"
]
=
[]
f
=
theano
.
function
(
**
d
)
assert
f
.
_check_for_aliased_inputs
,
d
class
T_picklefunction
(
unittest
.
TestCase
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论