Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
47be7bd3
提交
47be7bd3
authored
6月 08, 2015
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Better error message
上级
18fb4acc
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
39 行增加
和
10 行删除
+39
-10
dnn_fwd.c
theano/sandbox/cuda/dnn_fwd.c
+5
-0
dnn_gi.c
theano/sandbox/cuda/dnn_gi.c
+6
-0
dnn_gw.c
theano/sandbox/cuda/dnn_gw.c
+6
-0
test_conv_cuda_ndarray.py
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
+21
-9
test_dnn.py
theano/sandbox/cuda/tests/test_dnn.py
+1
-1
没有找到文件。
theano/sandbox/cuda/dnn_fwd.c
浏览文件 @
47be7bd3
...
@@ -5,6 +5,11 @@ APPLY_SPECIFIC(conv_fwd)(CudaNdarray *input, CudaNdarray *kerns,
...
@@ -5,6 +5,11 @@ APPLY_SPECIFIC(conv_fwd)(CudaNdarray *input, CudaNdarray *kerns,
CudaNdarray
*
om
,
cudnnConvolutionDescriptor_t
desc
,
CudaNdarray
*
om
,
cudnnConvolutionDescriptor_t
desc
,
float
alpha
,
float
beta
,
CudaNdarray
**
output
)
{
float
alpha
,
float
beta
,
CudaNdarray
**
output
)
{
cudnnStatus_t
err
=
CUDNN_STATUS_SUCCESS
;
cudnnStatus_t
err
=
CUDNN_STATUS_SUCCESS
;
if
(
CudaNdarray_HOST_DIMS
(
input
)[
1
]
!=
CudaNdarray_HOST_DIMS
(
kerns
)[
1
])
{
PyErr_SetString
(
PyExc_ValueError
,
"GpuDnnConv images and kernel must have the same stack size
\n
"
);
return
1
;
}
if
(
c_set_tensor4d
(
input
,
APPLY_SPECIFIC
(
input
))
==
-
1
)
if
(
c_set_tensor4d
(
input
,
APPLY_SPECIFIC
(
input
))
==
-
1
)
return
1
;
return
1
;
...
...
theano/sandbox/cuda/dnn_gi.c
浏览文件 @
47be7bd3
...
@@ -6,6 +6,12 @@ APPLY_SPECIFIC(conv_gi)(CudaNdarray *kerns, CudaNdarray *output,
...
@@ -6,6 +6,12 @@ APPLY_SPECIFIC(conv_gi)(CudaNdarray *kerns, CudaNdarray *output,
float
alpha
,
float
beta
,
CudaNdarray
**
input
)
{
float
alpha
,
float
beta
,
CudaNdarray
**
input
)
{
cudnnStatus_t
err
=
CUDNN_STATUS_SUCCESS
;
cudnnStatus_t
err
=
CUDNN_STATUS_SUCCESS
;
if
(
CudaNdarray_HOST_DIMS
(
im
)[
1
]
!=
CudaNdarray_HOST_DIMS
(
kerns
)[
1
])
{
PyErr_SetString
(
PyExc_ValueError
,
"GpuDnnConv images and kernel must have the same stack size
\n
"
);
return
1
;
}
if
(
c_set_tensor4d
(
output
,
APPLY_SPECIFIC
(
output
))
==
-
1
)
if
(
c_set_tensor4d
(
output
,
APPLY_SPECIFIC
(
output
))
==
-
1
)
return
1
;
return
1
;
if
(
c_set_filter
(
kerns
,
APPLY_SPECIFIC
(
kerns
))
==
-
1
)
if
(
c_set_filter
(
kerns
,
APPLY_SPECIFIC
(
kerns
))
==
-
1
)
...
...
theano/sandbox/cuda/dnn_gw.c
浏览文件 @
47be7bd3
...
@@ -6,6 +6,12 @@ APPLY_SPECIFIC(conv_gw)(CudaNdarray *input, CudaNdarray *output,
...
@@ -6,6 +6,12 @@ APPLY_SPECIFIC(conv_gw)(CudaNdarray *input, CudaNdarray *output,
float
alpha
,
float
beta
,
CudaNdarray
**
kerns
)
{
float
alpha
,
float
beta
,
CudaNdarray
**
kerns
)
{
cudnnStatus_t
err
=
CUDNN_STATUS_SUCCESS
;
cudnnStatus_t
err
=
CUDNN_STATUS_SUCCESS
;
if
(
CudaNdarray_HOST_DIMS
(
input
)[
1
]
!=
CudaNdarray_HOST_DIMS
(
km
)[
1
])
{
PyErr_SetString
(
PyExc_ValueError
,
"GpuDnnConv images and kernel must have the same stack size
\n
"
);
return
1
;
}
if
(
c_set_tensor4d
(
input
,
APPLY_SPECIFIC
(
input
))
==
-
1
)
if
(
c_set_tensor4d
(
input
,
APPLY_SPECIFIC
(
input
))
==
-
1
)
return
1
;
return
1
;
if
(
c_set_tensor4d
(
output
,
APPLY_SPECIFIC
(
output
))
==
-
1
)
if
(
c_set_tensor4d
(
output
,
APPLY_SPECIFIC
(
output
))
==
-
1
)
...
...
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
浏览文件 @
47be7bd3
...
@@ -184,11 +184,6 @@ def _params_allgood(ishape, kshape, mode, subsample=(1, 1), img_stride=(1, 1),
...
@@ -184,11 +184,6 @@ def _params_allgood(ishape, kshape, mode, subsample=(1, 1), img_stride=(1, 1),
kern
=
kern
[:,
:,
::
kern_stride
[
0
],
::
kern_stride
[
1
]]
kern
=
kern
[:,
:,
::
kern_stride
[
0
],
::
kern_stride
[
1
]]
npy_kern
=
npy_kern
[:,
:,
::
kern_stride
[
0
],
::
kern_stride
[
1
]]
npy_kern
=
npy_kern
[:,
:,
::
kern_stride
[
0
],
::
kern_stride
[
1
]]
t2
=
None
t0
=
time
.
time
()
cpuval
=
py_conv
(
npy_img
,
npy_kern
,
mode
,
subsample
)
t1
=
time
.
time
()
i
=
cuda
.
CudaNdarrayType
(
i
=
cuda
.
CudaNdarrayType
(
broadcastable
=
[
sh
==
1
for
sh
in
npy_img
.
shape
])()
broadcastable
=
[
sh
==
1
for
sh
in
npy_img
.
shape
])()
k
=
cuda
.
CudaNdarrayType
(
k
=
cuda
.
CudaNdarrayType
(
...
@@ -198,21 +193,28 @@ def _params_allgood(ishape, kshape, mode, subsample=(1, 1), img_stride=(1, 1),
...
@@ -198,21 +193,28 @@ def _params_allgood(ishape, kshape, mode, subsample=(1, 1), img_stride=(1, 1),
version
=
version
,
version
=
version
,
verbose
=
verbose
,
verbose
=
verbose
,
kshp
=
compile_kshp
)(
i
,
k
)
kshp
=
compile_kshp
)(
i
,
k
)
assert
[(
sh
==
1
)
is
br
for
sh
,
br
in
zip
(
cpuval
.
shape
[:
2
],
op
.
type
.
broadcastable
[:
2
])]
f
=
theano
.
function
([
i
,
k
],
op
,
mode
=
theano_mode
)
f
=
theano
.
function
([
i
,
k
],
op
,
mode
=
theano_mode
)
if
cls
is
not
None
:
if
cls
is
not
None
:
assert
any
([
isinstance
(
node
.
op
,
cls
)
assert
any
([
isinstance
(
node
.
op
,
cls
)
for
node
in
f
.
maker
.
fgraph
.
toposort
()]),
"Cannot find class
%
r in
%
r"
%
(
cls
,
f
.
maker
.
fgraph
.
toposort
())
for
node
in
f
.
maker
.
fgraph
.
toposort
()]),
"Cannot find class
%
r in
%
r"
%
(
cls
,
f
.
maker
.
fgraph
.
toposort
())
gpuval
=
f
(
img
,
kern
)
t2
=
time
.
time
()
t2
=
time
.
time
()
gpuval
=
f
(
img
,
kern
)
t3
=
time
.
time
()
for
i
in
range
(
nb_iter
):
for
i
in
range
(
nb_iter
):
gpuval2
=
f
(
img
,
kern
)
gpuval2
=
f
(
img
,
kern
)
assert
(
numpy
.
asarray
(
gpuval
)
==
numpy
.
asarray
(
gpuval2
))
.
all
()
assert
(
numpy
.
asarray
(
gpuval
)
==
numpy
.
asarray
(
gpuval2
))
.
all
()
gpuval
=
numpy
.
asarray
(
gpuval
)
gpuval
=
numpy
.
asarray
(
gpuval
)
# CPU val computed after GPU val to get the GPU errors.
t0
=
time
.
time
()
cpuval
=
py_conv
(
npy_img
,
npy_kern
,
mode
,
subsample
)
t1
=
time
.
time
()
assert
gpuval
.
shape
==
cpuval
.
shape
,
(
"shape mismatch"
,
gpuval
.
shape
,
cpuval
.
shape
)
assert
gpuval
.
shape
==
cpuval
.
shape
,
(
"shape mismatch"
,
gpuval
.
shape
,
cpuval
.
shape
)
assert_allclose
(
cpuval
,
gpuval
,
rtol
=
rtol
,
atol
=
atol
)
assert_allclose
(
cpuval
,
gpuval
,
rtol
=
rtol
,
atol
=
atol
)
assert
numpy
.
all
(
numpy
.
isfinite
(
gpuval
)),
gpuval
assert
numpy
.
all
(
numpy
.
isfinite
(
gpuval
)),
gpuval
assert
[(
sh
==
1
)
is
br
for
sh
,
br
in
zip
(
cpuval
.
shape
[:
2
],
op
.
type
.
broadcastable
[:
2
])]
if
(
t2
is
not
None
):
if
(
t2
is
not
None
):
if
mode
==
'valid'
:
if
mode
==
'valid'
:
...
@@ -222,7 +224,7 @@ def _params_allgood(ishape, kshape, mode, subsample=(1, 1), img_stride=(1, 1),
...
@@ -222,7 +224,7 @@ def _params_allgood(ishape, kshape, mode, subsample=(1, 1), img_stride=(1, 1),
kshape
[
3
]
*
ishape
[
2
]
*
ishape
[
3
]
*
2
)
kshape
[
3
]
*
ishape
[
2
]
*
ishape
[
3
]
*
2
)
approx_fp
/=
1e6
approx_fp
/=
1e6
cpu_mflops
=
approx_fp
/
(
t1
-
t0
)
cpu_mflops
=
approx_fp
/
(
t1
-
t0
)
gpu_mflops
=
approx_fp
/
(
t
2
-
t1
)
gpu_mflops
=
approx_fp
/
(
t
3
-
t2
)
if
verbose
>
0
:
if
verbose
>
0
:
print
(
'
%15
s'
%
str
(
ishape
),
'
%15
s'
%
str
(
kshape
),
end
=
' '
,
file
=
sys
.
stdout
)
print
(
'
%15
s'
%
str
(
ishape
),
'
%15
s'
%
str
(
kshape
),
end
=
' '
,
file
=
sys
.
stdout
)
print
(
'
%12.5
f
%7.2
f
%7.2
f
%7.1
f'
%
(
approx_fp
,
print
(
'
%12.5
f
%7.2
f
%7.2
f
%7.1
f'
%
(
approx_fp
,
...
@@ -410,6 +412,16 @@ def test_dnn_valid():
...
@@ -410,6 +412,16 @@ def test_dnn_valid():
yield
t
yield
t
def
test_dnn_valid_err
():
try
:
_params_allgood
((
1
,
2
,
4
,
4
),
(
1
,
1
,
2
,
2
),
'valid'
,
theano_mode
=
theano_mode
.
including
(
"cudnn"
),
cls
=
DnnBase
)
assert
"Shape error not raised"
except
ValueError
:
pass
def
test_default_conv
():
def
test_default_conv
():
"""Just test that we introduce the right GPU convolution
"""Just test that we introduce the right GPU convolution
version.
version.
...
...
theano/sandbox/cuda/tests/test_dnn.py
浏览文件 @
47be7bd3
...
@@ -475,7 +475,7 @@ class TestDnnInferShapes(utt.InferShapeTester):
...
@@ -475,7 +475,7 @@ class TestDnnInferShapes(utt.InferShapeTester):
dtype
=
'float32'
dtype
=
'float32'
)
)
kern_vals
=
numpy
.
asarray
(
kern_vals
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
3
,
4
,
5
,
6
),
numpy
.
random
.
rand
(
13
,
14
,
15
,
1
6
),
dtype
=
'float32'
dtype
=
'float32'
)
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论