Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a5b08f9a
提交
a5b08f9a
authored
10月 05, 2017
作者:
notoraptor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rebase and update with latest master branch.
上级
fb6da2d1
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
22 行增加
和
10 行删除
+22
-10
cudnn_defs.py
theano/gpuarray/cudnn_defs.py
+6
-0
check_dnn_conv.py
theano/gpuarray/tests/check_dnn_conv.py
+2
-2
run_dnn_conv.py
theano/gpuarray/tests/run_dnn_conv.py
+14
-8
没有找到文件。
theano/gpuarray/cudnn_defs.py
浏览文件 @
a5b08f9a
...
...
@@ -176,6 +176,9 @@ class CuDNNV51(object):
return
False
def
bwd_filter_algo_supports_dtype_config
(
self
,
algo
,
dtype
,
precision
,
ndim
):
# NB: Theano does not support float16 precision anymore for backward cuDNN convolutions.
if
is_true_half_config
(
dtype
,
precision
):
return
False
algorithms
=
self
.
cudnnConvolutionBwdFilterAlgo_t
algo
=
algorithms
.
fromalias
(
algo
)
if
algo
==
algorithms
.
CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0
:
...
...
@@ -193,6 +196,9 @@ class CuDNNV51(object):
return
False
def
bwd_data_algo_supports_dtype_config
(
self
,
algo
,
dtype
,
precision
,
ndim
):
# NB: Theano does not support float16 precision anymore for backward cuDNN convolutions.
if
is_true_half_config
(
dtype
,
precision
):
return
False
algorithms
=
self
.
cudnnConvolutionBwdDataAlgo_t
algo
=
algorithms
.
fromalias
(
algo
)
if
algo
==
algorithms
.
CUDNN_CONVOLUTION_BWD_DATA_ALGO_0
:
...
...
theano/gpuarray/tests/check_dnn_conv.py
浏览文件 @
a5b08f9a
...
...
@@ -76,7 +76,7 @@ def dnn_gradweight(img, topgrad, kerns_shp, alpha=1, beta=0, out=None, border_mo
topgrad
=
gpu_contiguous
(
as_gpuarray_variable
(
topgrad
,
ctx_name
))
kerns_shp
=
theano
.
tensor
.
as_tensor_variable
(
kerns_shp
)
precision
=
get_precision
(
precision
,
[
img
,
topgrad
])
precision
=
get_precision
(
precision
,
[
img
,
topgrad
]
,
for_grad
=
True
)
desc
=
GpuDnnConvDesc
(
border_mode
=
border_mode
,
subsample
=
subsample
,
dilation
=
dilation
,
conv_mode
=
conv_mode
,
precision
=
precision
)(
kerns_shp
)
if
beta
==
0
:
...
...
@@ -97,7 +97,7 @@ def dnn_gradinput(kerns, topgrad, img_shp, alpha=1, beta=0, out=None, border_mod
topgrad
=
gpu_contiguous
(
as_gpuarray_variable
(
topgrad
,
ctx_name
))
img_shp
=
theano
.
tensor
.
as_tensor_variable
(
img_shp
)
precision
=
get_precision
(
precision
,
[
kerns
,
topgrad
])
precision
=
get_precision
(
precision
,
[
kerns
,
topgrad
]
,
for_grad
=
True
)
desc
=
GpuDnnConvDesc
(
border_mode
=
border_mode
,
subsample
=
subsample
,
dilation
=
dilation
,
conv_mode
=
conv_mode
,
precision
=
precision
)(
kerns
.
shape
)
if
beta
==
0
:
...
...
theano/gpuarray/tests/run_dnn_conv.py
浏览文件 @
a5b08f9a
# This script allows to run one specific cuDNN convolution test case.
# This script should not be imported, but only used as a program.
# python run_dnn_conv.py --help # Print help.
# python run_dnn_conv.py {fwd|bwd-filter|bwd-data} {2d|3d} -a <algo> -i <inputShape> -f <filterShape> ...
...
...
@@ -14,6 +15,9 @@ from theano.gpuarray.cudnn_defs import (HALF, FLOAT, DOUBLE,
from
theano.gpuarray.tests.check_dnn_conv
import
(
cudnn
,
TestDnnConv2D
,
TestDnnConv3D
,
CheckDnn
)
from
theano.tensor.nnet.abstract_conv
import
get_conv_output_shape
if
__name__
!=
'__main__'
:
raise
ImportError
(
'This script must not be imported.'
)
class
TupleAction
(
argparse
.
Action
):
# Tuple extractor for command line args parser.
...
...
@@ -31,9 +35,6 @@ class BorderAction(TupleAction):
setattr
(
namespace
,
self
.
dest
,
values
)
if
__name__
!=
'__main__'
:
raise
ImportError
(
'This script must not be imported.'
)
args
=
sys
.
argv
[
1
:]
computations
=
FWD
,
BWD_FILTER
,
BWD_DATA
=
(
'fwd'
,
'gradweight'
,
'gradinput'
)
algorithms
=
(
tuple
(
sorted
(
list
(
set
(
cudnn
.
cudnnConvolutionFwdAlgo_t
.
get_aliases
()
+
...
...
@@ -93,16 +94,19 @@ if len(args.input_shape) not in (4, 5):
ndim
=
len
(
args
.
input_shape
)
-
2
if
ndim
==
2
:
tests
=
TestDnnConv2D
()
if
ndim
==
3
:
el
if
ndim
==
3
:
tests
=
TestDnnConv3D
()
if
args
.
subsample
is
None
:
args
.
subsample
=
(
1
,)
*
ndim
if
args
.
dilation
is
None
:
args
.
dilation
=
(
1
,)
*
ndim
if
not
(
ndim
==
len
(
args
.
subsample
)
==
len
(
args
.
dilation
)):
raise
ValueError
(
'Expected parameters sized for
%
d dimensions.'
%
ndim
)
if
isinstance
(
args
.
border_mode
,
tuple
)
and
ndim
!=
len
(
args
.
border_mode
):
raise
ValueError
(
'Expected borders sized for
%
d dimensions.'
%
ndim
)
if
args
.
alpha
==
0
:
raise
ValueError
(
'Nothing could be computed if alpha is 0.'
)
...
...
@@ -118,17 +122,19 @@ else:
args
.
dtype
,
args
.
precision
=
data_type_configurations
[
args
.
dtype_config
]
if
(
args
.
dtype
,
args
.
precision
)
not
in
cudnn
.
get_supported_dtype_configs
():
raise
ValueError
(
'Unsupported data type configuration
%
s
%
s.'
%
(
args
.
dtype
,
args
.
precision
))
if
args
.
algo
not
in
SUPPORTED_DNN_CONV_ALGO_RUNTIME
:
check_config
=
False
if
test
==
FWD
:
check_config
=
cudnn
.
fwd_algo_supports_dtype_config
(
args
.
algo
,
args
.
dtype
,
args
.
precision
,
ndim
)
if
test
==
BWD_FILTER
:
el
if
test
==
BWD_FILTER
:
check_config
=
cudnn
.
bwd_filter_algo_supports_dtype_config
(
args
.
algo
,
args
.
dtype
,
args
.
precision
,
ndim
)
if
test
==
BWD_DATA
:
el
if
test
==
BWD_DATA
:
check_config
=
cudnn
.
bwd_data_algo_supports_dtype_config
(
args
.
algo
,
args
.
dtype
,
args
.
precision
,
ndim
)
if
not
check_config
:
print
(
'Warning:
%
s computation does not normally support configuration (
%
s,
%
s) for algo
%
s.'
%
(
test
,
args
.
dtype
,
args
.
precision
,
args
.
algo
),
file
=
sys
.
stderr
)
algo
=
args
.
algo
dtype
=
args
.
dtype
precision
=
args
.
precision
...
...
@@ -143,10 +149,10 @@ if test == FWD:
tests
.
run_conv_fwd
(
algo
,
dtype
,
precision
,
parameters
)
expected_output_shape
=
get_conv_output_shape
(
args
.
input_shape
,
args
.
filter_shape
,
args
.
border_mode
,
args
.
subsample
,
args
.
dilation
)
if
test
==
BWD_FILTER
:
el
if
test
==
BWD_FILTER
:
tests
.
run_conv_gradweight
(
algo
,
dtype
,
precision
,
parameters
)
expected_output_shape
=
args
.
filter_shape
if
test
==
BWD_DATA
:
el
if
test
==
BWD_DATA
:
tests
.
run_conv_gradinput
(
algo
,
dtype
,
precision
,
parameters
)
expected_output_shape
=
args
.
input_shape
print
(
'Computed shape:'
,
expected_output_shape
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论