Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
554ba22f
提交
554ba22f
authored
8月 20, 2012
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #871 from delallea/minor
Minor stuff
上级
c6875ba4
bdcec1ab
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
47 行增加
和
47 行删除
+47
-47
using_gpu.txt
doc/tutorial/using_gpu.txt
+1
-1
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+3
-3
test_blas.py
theano/sandbox/cuda/tests/test_blas.py
+1
-1
test_nnet.py
theano/sandbox/cuda/tests/test_nnet.py
+1
-1
conv.py
theano/tensor/nnet/conv.py
+41
-41
没有找到文件。
doc/tutorial/using_gpu.txt
浏览文件 @
554ba22f
...
@@ -232,7 +232,7 @@ Tips for improving performance on GPU
...
@@ -232,7 +232,7 @@ Tips for improving performance on GPU
taking more time than its share, then if you know something about GPU
taking more time than its share, then if you know something about GPU
programming have a look at how it's implemented in theano.sandbox.cuda.
programming have a look at how it's implemented in theano.sandbox.cuda.
Check the line like 'Spent Xs(X%) in cpu Op, Xs(X%) in gpu Op and Xs(X%) transfert Op'
Check the line like 'Spent Xs(X%) in cpu Op, Xs(X%) in gpu Op and Xs(X%) transfert Op'
that can tell you if not enough
t
of your graph is on the gpu or if their
that can tell you if not enough of your graph is on the gpu or if their
is too much memory transfert.
is too much memory transfert.
...
...
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
554ba22f
...
@@ -64,7 +64,7 @@ def test_sum():
...
@@ -64,7 +64,7 @@ def test_sum():
((
5
,
4
,
3
,
10
,
11
),[
1
,
2
]),
((
5
,
4
,
3
,
10
,
11
),[
1
,
2
]),
((
5
,
4
,
3
,
20
),[
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
2
,
3
]),((
5
,
4
,
3
,
2
),[
1
,
2
,
3
]),
((
5
,
4
,
3
,
20
),[
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
2
,
3
]),((
5
,
4
,
3
,
2
),[
1
,
2
,
3
]),
#test shape bigger then 4096 on each dimension to make sure that we work correctly when we don't have enough
t
thread/block in each dimensions
#test shape bigger then 4096 on each dimension to make sure that we work correctly when we don't have enough thread/block in each dimensions
((
4100
,
3
),[
0
]),((
3
,
4101
),[
0
]),
#10
((
4100
,
3
),[
0
]),((
3
,
4101
),[
0
]),
#10
((
1024
,
33
),[
0
]),((
33
,
1024
),[
0
]),
#10
((
1024
,
33
),[
0
]),((
33
,
1024
),[
0
]),
#10
((
1025
,
33
),[
0
]),((
33
,
1025
),[
0
]),
#10
((
1025
,
33
),[
0
]),((
33
,
1025
),[
0
]),
#10
...
@@ -880,7 +880,7 @@ class T_subtensor(theano.tensor.tests.test_basic.T_subtensor):
...
@@ -880,7 +880,7 @@ class T_subtensor(theano.tensor.tests.test_basic.T_subtensor):
((
4
,
4
,
2
,
3
),
[
3
,
3
,
1
,
1
,
2
,
2
,
0
,
0
,
((
4
,
4
,
2
,
3
),
[
3
,
3
,
1
,
1
,
2
,
2
,
0
,
0
,
-
1
,
-
2
,
-
3
,
-
4
],
False
),
-
1
,
-
2
,
-
3
,
-
4
],
False
),
]:
]:
# If there is not enough
t
memory on the GPU, skip the test
# If there is not enough memory on the GPU, skip the test
size_needed
=
numpy
.
prod
(
shape
)
*
(
4
+
1
)
size_needed
=
numpy
.
prod
(
shape
)
*
(
4
+
1
)
if
isinstance
(
theano
.
compile
.
get_default_mode
(),
if
isinstance
(
theano
.
compile
.
get_default_mode
(),
theano
.
compile
.
DebugMode
):
theano
.
compile
.
DebugMode
):
...
@@ -905,7 +905,7 @@ class T_subtensor(theano.tensor.tests.test_basic.T_subtensor):
...
@@ -905,7 +905,7 @@ class T_subtensor(theano.tensor.tests.test_basic.T_subtensor):
# Test with input strided
# Test with input strided
t
=
self
.
adv_sub1
()(
n
[::
-
1
],
idx
)
t
=
self
.
adv_sub1
()(
n
[::
-
1
],
idx
)
#DebugMode do
a copy of the input, so we lo
ose the strides.
#DebugMode do
es a copy of the input, so we l
ose the strides.
if
not
isinstance
(
theano
.
compile
.
get_default_mode
(),
if
not
isinstance
(
theano
.
compile
.
get_default_mode
(),
theano
.
compile
.
DebugMode
):
theano
.
compile
.
DebugMode
):
t
.
owner
.
op
.
perform_using_take
=
fast
t
.
owner
.
op
.
perform_using_take
=
fast
...
...
theano/sandbox/cuda/tests/test_blas.py
浏览文件 @
554ba22f
...
@@ -310,7 +310,7 @@ def test_downsample():
...
@@ -310,7 +310,7 @@ def test_downsample():
# The grad is too slow on GT220 GPU
# The grad is too slow on GT220 GPU
# This cause the computer to freeze...
# This cause the computer to freeze...
# Remove this when it get
optimized enought
# Remove this when it get
s optimized enough
# This only bypass the last 2 checks
# This only bypass the last 2 checks
# Those tests where passing in all Mode on a GTX470
# Those tests where passing in all Mode on a GTX470
if
shp
[
0
]
>
30000
or
shp
[
1
]
>
30000
:
if
shp
[
0
]
>
30000
or
shp
[
1
]
>
30000
:
...
...
theano/sandbox/cuda/tests/test_nnet.py
浏览文件 @
554ba22f
...
@@ -46,7 +46,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
...
@@ -46,7 +46,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
#we precompute the dot with big shape before to allow the test of
#we precompute the dot with big shape before to allow the test of
#GpuCrossentropySoftmax1HotWithBiasDx to don't fail with the error
#GpuCrossentropySoftmax1HotWithBiasDx to don't fail with the error
#(the launch timed out and was terminated) on GPU card not
#(the launch timed out and was terminated) on GPU card not
#powerful
l enought
. We need the big shape to check for corner
#powerful
enough
. We need the big shape to check for corner
#case.
#case.
dot_result
=
T
.
fmatrix
(
'dot_result'
)
dot_result
=
T
.
fmatrix
(
'dot_result'
)
...
...
theano/tensor/nnet/conv.py
浏览文件 @
554ba22f
...
@@ -55,10 +55,10 @@ def conv2d(input, filters, image_shape=None, filter_shape=None,
...
@@ -55,10 +55,10 @@ def conv2d(input, filters, image_shape=None, filter_shape=None,
:type subsample: tuple of len 2
:type subsample: tuple of len 2
:param subsample: factor by which to subsample the output
:param subsample: factor by which to subsample the output
:type image_shape: tuple of len 4 of int or Contant variable
:type image_shape: tuple of len 4 of int or Con
s
tant variable
:param image_shape: (batch size, stack size, nb row, nb col)
:param image_shape: (batch size, stack size, nb row, nb col)
Optional, used for optimization.
Optional, used for optimization.
:type filter_shape: tuple of len 4 of int or Contant variable
:type filter_shape: tuple of len 4 of int or Con
s
tant variable
:param filter_shape: (nb filters, stack size, nb row, nb col)
:param filter_shape: (nb filters, stack size, nb row, nb col)
Optional, used for optimization.
Optional, used for optimization.
...
@@ -1744,15 +1744,15 @@ if (%(z)s->strides[3] != (npy_intp)sizeof(%(type)s)) %(fail)s;
...
@@ -1744,15 +1744,15 @@ if (%(z)s->strides[3] != (npy_intp)sizeof(%(type)s)) %(fail)s;
for(int b=0;b<
%(self_bsize)
s ;b+=
%(unroll_bsize)
s){
for(int b=0;b<
%(self_bsize)
s ;b+=
%(unroll_bsize)
s){
for(int n_kern=0;n_kern<
%(self_nkern)
s;n_kern+=
%(unroll_ksize)
s){
for(int n_kern=0;n_kern<
%(self_nkern)
s;n_kern+=
%(unroll_ksize)
s){
"""
%
d
"""
%
d
ret
+=
my_dup2
(
"
%(type)
s * __restrict__ out
%(unroll_iter)
s=(
%(type)
s *)(PyArray_GETPTR2(
%(z)
s,b+
%(unroll_biter)
s,n_kern+
%(unroll_kiter)
s));"
)
ret
+=
my_dup2
(
"
%(type)
s * __restrict__ out
%(unroll_iter)
s=(
%(type)
s *)(PyArray_GETPTR2(
%(z)
s,b+
%(unroll_biter)
s,n_kern+
%(unroll_kiter)
s));"
)
ret
+=
my_dup
(
"for (int i = 0; i < dim_zz[0]*dim_zz[1]; ++i) out
%(unroll_iter)
s[i] = 0;"
,
unroll_bsize
*
unroll_ksize
)
ret
+=
my_dup
(
"for (int i = 0; i < dim_zz[0]*dim_zz[1]; ++i) out
%(unroll_iter)
s[i] = 0;"
,
unroll_bsize
*
unroll_ksize
)
ret
+=
"""
ret
+=
"""
for(int stack_size=0;stack_size<
%(self_imshp0)
s;stack_size++){
for(int stack_size=0;stack_size<
%(self_imshp0)
s;stack_size++){
"""
%
d
"""
%
d
ret
+=
my_dup
(
"const
%(type)
s * __restrict__ in
%(unroll_iter)
d=(
%(type)
s *)(PyArray_GETPTR2(img2d,b+
%(unroll_iter)
s,stack_size));"
,
unroll_bsize
)
ret
+=
my_dup
(
"const
%(type)
s * __restrict__ in
%(unroll_iter)
d=(
%(type)
s *)(PyArray_GETPTR2(img2d,b+
%(unroll_iter)
s,stack_size));"
,
unroll_bsize
)
ret
+=
my_dup
(
"const
%(type)
s * __restrict__ hvals
%(unroll_iter)
s=(
%(type)
s *)(PyArray_GETPTR2(filtersflipped,n_kern+
%(unroll_iter)
s,stack_size));"
,
unroll_ksize
)
ret
+=
my_dup
(
"const
%(type)
s * __restrict__ hvals
%(unroll_iter)
s=(
%(type)
s *)(PyArray_GETPTR2(filtersflipped,n_kern+
%(unroll_iter)
s,stack_size));"
,
unroll_ksize
)
ret
+=
"""
ret
+=
"""
int new_m;
int new_m;
...
@@ -1764,9 +1764,9 @@ for(int b=0;b< %(self_bsize)s ;b+=%(unroll_bsize)s){
...
@@ -1764,9 +1764,9 @@ for(int b=0;b< %(self_bsize)s ;b+=%(unroll_bsize)s){
for (int iter_n=0; iter_n < Os[1]; iter_n++) { // loop over columns
for (int iter_n=0; iter_n < Os[1]; iter_n++) { // loop over columns
int pos_n=iter_n*
%(self_dy)
s;
int pos_n=iter_n*
%(self_dy)
s;
"""
%
d
"""
%
d
ret
+=
my_dup
(
"
%(type)
s sum
%(unroll_iter)
s=0;"
,
unroll_bsize
*
unroll_ksize
)
ret
+=
my_dup
(
"
%(type)
s sum
%(unroll_iter)
s=0;"
,
unroll_bsize
*
unroll_ksize
)
ret
+=
"""
ret
+=
"""
// Sum over kernel, if index into image is out of bounds
// Sum over kernel, if index into image is out of bounds
// fill with the value
// fill with the value
...
@@ -1774,15 +1774,15 @@ for(int b=0;b< %(self_bsize)s ;b+=%(unroll_bsize)s){
...
@@ -1774,15 +1774,15 @@ for(int b=0;b< %(self_bsize)s ;b+=%(unroll_bsize)s){
int ind0 = (new_m-j);
int ind0 = (new_m-j);
if(mode==FULL){
if(mode==FULL){
"""
%
d
"""
%
d
ret
+=
my_dup
(
"const
%(type)
s * idx_hvals
%(unroll_iter)
s=&hvals
%(unroll_iter)
s[j*dim_ker1];"
,
unroll_ksize
)
ret
+=
my_dup
(
"const
%(type)
s * idx_hvals
%(unroll_iter)
s=&hvals
%(unroll_iter)
s[j*dim_ker1];"
,
unroll_ksize
)
ret
+=
"""
ret
+=
"""
if(ind0 < 0 || ind0 >= dim_im[0]){
if(ind0 < 0 || ind0 >= dim_im[0]){
if(fill_value!=0)
if(fill_value!=0)
for (int k=0; k < dim_ker1; k++) {
for (int k=0; k < dim_ker1; k++) {
"""
%
d
"""
%
d
ret
+=
my_dup2
(
"sum
%(unroll_iter)
s += idx_hvals
%(unroll_kiter)
s[k] * fill_value;"
)
ret
+=
my_dup2
(
"sum
%(unroll_iter)
s += idx_hvals
%(unroll_kiter)
s[k] * fill_value;"
)
ret
+=
"""
ret
+=
"""
}
}
}else{
}else{
//do the part where kernel is to the right of the img
//do the part where kernel is to the right of the img
...
@@ -1791,49 +1791,49 @@ for(int b=0;b< %(self_bsize)s ;b+=%(unroll_bsize)s){
...
@@ -1791,49 +1791,49 @@ for(int b=0;b< %(self_bsize)s ;b+=%(unroll_bsize)s){
if(fill_value!=0){
if(fill_value!=0){
for(k=0;k<max_k;k++){
for(k=0;k<max_k;k++){
"""
%
d
"""
%
d
ret
+=
my_dup2
(
"sum
%(unroll_iter)
s += idx_hvals
%(unroll_kiter)
s[k] * fill_value;"
)
ret
+=
my_dup2
(
"sum
%(unroll_iter)
s += idx_hvals
%(unroll_kiter)
s[k] * fill_value;"
)
ret
+=
"""
ret
+=
"""
}
}
}else {k=max_k;}
}else {k=max_k;}
//do the part where the kernel is on the img
//do the part where the kernel is on the img
max_k=min(pos_n+1,(int)dim_ker1);
max_k=min(pos_n+1,(int)dim_ker1);
"""
%
d
"""
%
d
ret
+=
my_dup
(
"const
%(type)
s * idx_in
%(unroll_iter)
s=&in
%(unroll_iter)
s[ind0*dim_im[1]];"
,
unroll_bsize
)
ret
+=
my_dup
(
"const
%(type)
s * idx_in
%(unroll_iter)
s=&in
%(unroll_iter)
s[ind0*dim_im[1]];"
,
unroll_bsize
)
ret
+=
"""
ret
+=
"""
for (int ind1=pos_n-k; k<max_k; k++,ind1--) {
for (int ind1=pos_n-k; k<max_k; k++,ind1--) {
"""
%
d
"""
%
d
ret
+=
my_dup2
(
"sum
%(unroll_iter)
s+= idx_hvals
%(unroll_kiter)
s[k] * idx_in
%(unroll_biter)
s[ind1];"
)
ret
+=
my_dup2
(
"sum
%(unroll_iter)
s+= idx_hvals
%(unroll_kiter)
s[k] * idx_in
%(unroll_biter)
s[ind1];"
)
ret
+=
"""
ret
+=
"""
}
}
//do the part to the left of the img
//do the part to the left of the img
if(fill_value!=0)
if(fill_value!=0)
for(;k<dim_ker1;k++){
for(;k<dim_ker1;k++){
"""
%
d
"""
%
d
ret
+=
my_dup2
(
"sum
%(unroll_iter)
s += idx_hvals
%(unroll_kiter)
s[k] * fill_value;"
)
ret
+=
my_dup2
(
"sum
%(unroll_iter)
s += idx_hvals
%(unroll_kiter)
s[k] * fill_value;"
)
ret
+=
"""
ret
+=
"""
}
}
}
}
}else{//valid mode
}else{//valid mode
"""
%
d
"""
%
d
ret
+=
my_dup
(
"const
%(type)
s* idx_in
%(unroll_iter)
s=&in
%(unroll_iter)
s[ind0*dim_im[1]];"
,
unroll_bsize
)
ret
+=
my_dup
(
"const
%(type)
s* idx_in
%(unroll_iter)
s=&in
%(unroll_iter)
s[ind0*dim_im[1]];"
,
unroll_bsize
)
ret
+=
my_dup
(
"const
%(type)
s* idx_hvals
%(unroll_iter)
s=&hvals
%(unroll_iter)
s[j*dim_ker1];"
,
unroll_ksize
)
ret
+=
my_dup
(
"const
%(type)
s* idx_hvals
%(unroll_iter)
s=&hvals
%(unroll_iter)
s[j*dim_ker1];"
,
unroll_ksize
)
ret
+=
"""
ret
+=
"""
int new_n = (pos_n+dim_ker1-1);
int new_n = (pos_n+dim_ker1-1);
for (int k=0,last=new_n; k < dim_ker1; k++,last--) {
for (int k=0,last=new_n; k < dim_ker1; k++,last--) {
"""
%
d
"""
%
d
ret
+=
my_dup2
(
"sum
%(unroll_iter)
s+=idx_hvals
%(unroll_kiter)
s[k]*idx_in
%(unroll_biter)
s[last];"
)
ret
+=
my_dup2
(
"sum
%(unroll_iter)
s+=idx_hvals
%(unroll_kiter)
s[k]*idx_in
%(unroll_biter)
s[last];"
)
ret
+=
"""
ret
+=
"""
}
}
}
}
}//for j
}//for j
"""
%
d
"""
%
d
ret
+=
my_dup
(
"out
%(unroll_iter)
s[iter_m*dim_zz[1]+iter_n]
%(affectation)
s sum
%(unroll_iter)
s;"
,
unroll_bsize
*
unroll_ksize
)
ret
+=
my_dup
(
"out
%(unroll_iter)
s[iter_m*dim_zz[1]+iter_n]
%(affectation)
s sum
%(unroll_iter)
s;"
,
unroll_bsize
*
unroll_ksize
)
ret
+=
"""
ret
+=
"""
}//for n
}//for n
}//for m
}//for m
}//for stack_size
}//for stack_size
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论