Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
02d11f7d
提交
02d11f7d
authored
3月 02, 2017
作者:
Frédéric Bastien
提交者:
GitHub
3月 02, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5635 from nouiz/comp_opt
[ENH] for rc3, Graph clean up, faster compilation, conv.assert_shape Theano flags, add unsafe in useless opt
上级
19540d4e
ad374dfc
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
53 行增加
和
20 行删除
+53
-20
config.txt
doc/library/config.txt
+7
-0
configdefaults.py
theano/configdefaults.py
+7
-0
opt.py
theano/gof/opt.py
+13
-4
basic_ops.py
theano/gpuarray/basic_ops.py
+3
-2
scan_utils.py
theano/scan_module/scan_utils.py
+2
-0
abstract_conv.py
theano/tensor/nnet/abstract_conv.py
+17
-14
opt.py
theano/tensor/opt.py
+4
-0
没有找到文件。
doc/library/config.txt
浏览文件 @
02d11f7d
...
...
@@ -693,6 +693,13 @@ import theano and print the config variable, as in:
If ``'False'``, do not use cuDNN or check if it is available.
.. attribute:: config.conv.assert_shape
If False, AbstractConv* ops won't add assert that verify that
the user provided shapes are also the one at run time.
This can speed up compilation time and/or execution time.
.. attribute:: config.dnn.conv.workmem
Deprecated, use :attr:`config.dnn.conv.algo_fwd`.
...
...
theano/configdefaults.py
浏览文件 @
02d11f7d
...
...
@@ -126,6 +126,13 @@ AddConfigVar(
BoolParam
(
False
,
allow_override
=
False
),
in_c_key
=
False
)
AddConfigVar
(
'conv.assert_shape'
,
"If False, AbstractConv* ops won't add assert that verify that"
" the user provided shapes are also the one at run time"
,
BoolParam
(
True
),
in_c_key
=
False
)
AddConfigVar
(
'print_global_stats'
,
"Print some global statistics (time spent) at the end"
,
...
...
theano/gof/opt.py
浏览文件 @
02d11f7d
...
...
@@ -607,11 +607,20 @@ class MergeFeature(object):
# properly.
# The clients should at least contain `node` itself!
if
node
.
inputs
:
assert
len
(
node
.
inputs
[
0
]
.
clients
)
>
0
assert
(
node
,
0
)
in
node
.
inputs
[
0
]
.
clients
# Take the smallest clients list. Some ops like elemwise
# have optimization that put constant as the first inputs.
# As constant have in general more clients than other type of nodes
# using always inputs[0] make us look at more nodes.
# Always pick the smallest clints list between inputs 0
# and -1 speed up optimization.
if
len
(
node
.
inputs
[
0
]
.
clients
)
<
len
(
node
.
inputs
[
-
1
]
.
clients
):
clients
=
node
.
inputs
[
0
]
.
clients
else
:
clients
=
node
.
inputs
[
-
1
]
.
clients
assert
len
(
clients
)
>
0
merge_candidates
=
[
c
for
(
c
,
i
)
in
node
.
inputs
[
0
]
.
clients
if
c
in
self
.
nodes_seen
]
merge_candidates
=
[
c
for
c
,
i
in
clients
if
c
in
self
.
nodes_seen
]
# Put all clients of Assert inputs (if exist) into merge_candidates
# TODO: Deactivated for now as this cause cycle in the graph.
...
...
theano/gpuarray/basic_ops.py
浏览文件 @
02d11f7d
...
...
@@ -270,13 +270,14 @@ class Kernel(object):
def
get_ctype
(
dtype
):
if
dtype
is
gpuarray
.
GpuArray
:
return
"gpudata *"
elif
isinstance
(
dtype
,
np
.
dtype
):
return
'npy_'
+
dtype
.
name
elif
dtype
==
gpuarray
.
SIZE
:
return
"size_t"
elif
dtype
==
gpuarray
.
SSIZE
:
return
"ssize_t"
else
:
if
not
isinstance
(
dtype
,
np
.
dtype
):
dtype
=
np
.
dtype
(
dtype
)
dtype
=
np
.
dtype
(
dtype
)
return
'npy_'
+
dtype
.
name
...
...
theano/scan_module/scan_utils.py
浏览文件 @
02d11f7d
...
...
@@ -1353,4 +1353,6 @@ def forced_replace(out, x, y):
elif
graph
.
owner
:
q
.
extendleft
(
graph
.
owner
.
inputs
)
if
len
(
to_replace
)
==
0
:
return
out
return
clone
(
out
,
replace
=
to_replace
)
theano/tensor/nnet/abstract_conv.py
浏览文件 @
02d11f7d
...
...
@@ -493,7 +493,7 @@ def assert_shape(x, expected_shape, msg='Unexpected shape.'):
will return `x` directly.
"""
if
expected_shape
is
None
:
if
expected_shape
is
None
or
not
theano
.
config
.
conv
.
assert_shape
:
return
x
shape
=
x
.
shape
tests
=
[]
...
...
@@ -1680,19 +1680,20 @@ class AbstractConv2d(AbstractConv):
def
grad
(
self
,
inp
,
grads
):
bottom
,
weights
=
inp
top
,
=
grads
# Don't add the assert again, as it was already added in the forward.
d_bottom
=
AbstractConv2d_gradInputs
(
self
.
imshp
,
self
.
kshp
,
self
.
border_mode
,
self
.
subsample
,
self
.
filter_flip
,
self
.
filter_dilation
)(
weights
,
top
,
bottom
.
shape
[
-
2
:])
weights
,
top
,
bottom
.
shape
[
-
2
:]
,
add_assert_shape
=
False
)
d_weights
=
AbstractConv2d_gradWeights
(
self
.
imshp
,
self
.
kshp
,
self
.
border_mode
,
self
.
subsample
,
self
.
filter_flip
,
self
.
filter_dilation
)(
bottom
,
top
,
weights
.
shape
[
-
2
:])
bottom
,
top
,
weights
.
shape
[
-
2
:]
,
add_assert_shape
=
False
)
# Make sure that the broadcastable pattern of the inputs is used
# for the gradients, even if the grad opts are not able to infer
...
...
@@ -1781,7 +1782,7 @@ class AbstractConv_gradWeights(BaseAbstractConv):
filter_dilation
=
filter_dilation
)
# Update shape/height_width
def
make_node
(
self
,
img
,
topgrad
,
shape
):
def
make_node
(
self
,
img
,
topgrad
,
shape
,
add_assert_shape
=
True
):
# Make sure both inputs are Variables with the same Type
if
not
isinstance
(
img
,
theano
.
Variable
):
img
=
as_tensor_variable
(
img
)
...
...
@@ -1795,10 +1796,10 @@ class AbstractConv_gradWeights(BaseAbstractConv):
raise
TypeError
(
'img must be
%
dD tensor'
%
(
2
+
self
.
convdim
))
if
topgrad
.
type
.
ndim
!=
2
+
self
.
convdim
:
raise
TypeError
(
'topgrad must be
%
dD tensor'
%
(
2
+
self
.
convdim
))
img
=
assert_shape
(
img
,
self
.
imshp
,
'AbstractConv_gradWeights shape mismatch: shape of '
'image does not match given imshp.'
)
if
add_assert_shape
:
img
=
assert_shape
(
img
,
self
.
imshp
,
'AbstractConv_gradWeights shape mismatch: shape of '
'image does not match given imshp.'
)
shape
=
as_tensor_variable
(
shape
)
broadcastable
=
[
topgrad
.
broadcastable
[
1
],
...
...
@@ -2020,7 +2021,7 @@ class AbstractConv_gradInputs(BaseAbstractConv):
filter_dilation
=
filter_dilation
)
# Update shape/height_width
def
make_node
(
self
,
kern
,
topgrad
,
shape
):
def
make_node
(
self
,
kern
,
topgrad
,
shape
,
add_assert_shape
=
True
):
# Make sure both inputs are Variables with the same Type
if
not
isinstance
(
kern
,
theano
.
Variable
):
kern
=
as_tensor_variable
(
kern
)
...
...
@@ -2035,9 +2036,10 @@ class AbstractConv_gradInputs(BaseAbstractConv):
if
topgrad
.
type
.
ndim
!=
2
+
self
.
convdim
:
raise
TypeError
(
'topgrad must be
%
dD tensor'
%
(
2
+
self
.
convdim
))
kern
=
assert_shape
(
kern
,
self
.
kshp
,
'AbstractConv_gradInputs shape mismatch: shape of '
'filters does not match given kshp.'
)
if
add_assert_shape
:
kern
=
assert_shape
(
kern
,
self
.
kshp
,
'AbstractConv_gradInputs shape mismatch: shape of '
'filters does not match given kshp.'
)
shape
=
as_tensor_variable
(
shape
)
broadcastable
=
[
topgrad
.
type
.
broadcastable
[
0
],
...
...
@@ -2158,8 +2160,9 @@ class AbstractConv2d_gradInputs(AbstractConv_gradInputs):
self
.
border_mode
,
self
.
subsample
,
self
.
filter_flip
,
self
.
filter_dilation
)(
bottom
,
top
,
weights
.
shape
[
-
2
:])
self
.
filter_dilation
)(
bottom
,
top
,
weights
.
shape
[
-
2
:])
d_top
=
AbstractConv2d
(
self
.
imshp
,
self
.
kshp
,
self
.
border_mode
,
self
.
subsample
,
...
...
theano/tensor/opt.py
浏览文件 @
02d11f7d
...
...
@@ -2418,6 +2418,10 @@ compile.optdb['specialize'].register('local_remove_all_assert',
local_remove_all_assert
,
'unsafe'
,
use_db_name_as_tag
=
False
)
compile
.
optdb
[
'useless'
]
.
register
(
'local_remove_all_assert'
,
local_remove_all_assert
,
'unsafe'
,
use_db_name_as_tag
=
False
)
#######################
# Constant Canonicalization
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论