Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7014437a
提交
7014437a
authored
3月 12, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implemented GpuSum for pattern 01(sum or row in a matrix)
上级
78aa30fc
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
66 行增加
和
1 行删除
+66
-1
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+65
-0
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+1
-1
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
7014437a
...
@@ -769,6 +769,41 @@ class GpuSum(Op):
...
@@ -769,6 +769,41 @@ class GpuSum(Op):
}
}
"""
%
locals
()
"""
%
locals
()
def
c_code_reduce_01
(
self
,
sio
,
node
,
name
,
x
,
z
,
fail
):
print
>>
sio
,
"""
{
int verbose = 0;
dim3 n_threads(
std::min(CudaNdarray_HOST_DIMS(
%(x)
s)[1],
NUM_VECTOR_OP_THREADS_PER_BLOCK));
dim3 n_blocks(CudaNdarray_HOST_DIMS(
%(x)
s)[0]);
if (verbose) printf("running kernel_reduce_sum_01_
%(name)
s
\\
n");
int n_shared = sizeof(float) * n_threads.x;
kernel_reduce_sum_01_
%(name)
s<<<n_blocks, n_threads, n_shared>>>(
CudaNdarray_HOST_DIMS(
%(x)
s)[0],
CudaNdarray_HOST_DIMS(
%(x)
s)[1],
CudaNdarray_DEV_DATA(
%(x)
s),
CudaNdarray_HOST_STRIDES(
%(x)
s)[0],
CudaNdarray_HOST_STRIDES(
%(x)
s)[1],
CudaNdarray_DEV_DATA(
%(z)
s),
CudaNdarray_HOST_STRIDES(
%(z)
s)[0]
);
CNDA_THREAD_SYNC;
cudaError_t sts = cudaGetLastError();
if (cudaSuccess != sts)
{
PyErr_Format(PyExc_RuntimeError, "Cuda error:
%%
s:
%%
s. (grid:
%%
i x
%%
i; block:
%%
i x
%%
i x
%%
i)
\\
n",
"kernel_reduce_sum_01_
%(name)
s",
cudaGetErrorString(sts),
n_blocks.x,
n_blocks.y,
n_threads.x,
n_threads.y,
n_threads.z);
%(fail)
s;
}
}
"""
%
locals
()
def
c_code_reduce_10
(
self
,
sio
,
node
,
name
,
x
,
z
,
fail
):
def
c_code_reduce_10
(
self
,
sio
,
node
,
name
,
x
,
z
,
fail
):
print
>>
sio
,
"""
print
>>
sio
,
"""
...
@@ -1085,6 +1120,36 @@ class GpuSum(Op):
...
@@ -1085,6 +1120,36 @@ class GpuSum(Op):
%(reducebuf)
s
%(reducebuf)
s
}
}
"""
%
locals
()
"""
%
locals
()
if
self
.
reduce_mask
==
(
0
,
1
):
# this kernel uses one block for each row.
# threads per block for each element per row.
reducebuf
=
self
.
_k_reduce_buf
(
'Z[blockIdx.x * sZ0]'
)
print
>>
sio
,
"""
static __global__ void kernel_reduce_sum_01_
%(nodename)
s(
const int d0,
const int d1,
const float *A, const int sA0, const int sA1,
float * Z, const int sZ0)
{
const int threadCount = blockDim.x;
const int threadNum = threadIdx.x;
extern __shared__ float buf[];
float mysum = 0.0f;
if (warpSize != 32)
{
return; //TODO: set error code
}
for (int i1 = threadIdx.x; i1 < d1; i1 += blockDim.x)
{
float Ai = A[i1 * sA1 + blockIdx.x * sA0];
mysum += Ai;
}
%(reducebuf)
s
}
"""
%
locals
()
if
self
.
reduce_mask
==
(
1
,
0
):
if
self
.
reduce_mask
==
(
1
,
0
):
# this kernel uses one block for each column,
# this kernel uses one block for each column,
# threads per block for each element per column.
# threads per block for each element per column.
...
...
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
7014437a
...
@@ -36,7 +36,7 @@ def test_sum():
...
@@ -36,7 +36,7 @@ def test_sum():
"""
"""
for
shape
,
pattern
in
[((
5
,),[
0
]),
for
shape
,
pattern
in
[((
5
,),[
0
]),
((
5
,
4
),[
0
,
1
]),((
33
,
31
),[
0
,
1
]),((
5
,
4
),[
0
]),
#need something bigger then 32 for some opt test.
((
5
,
4
),[
0
,
1
]),((
33
,
31
),[
0
,
1
]),((
5
,
4
),[
1
]),((
5
,
4
),[
0
]),
#need something bigger then 32 for some opt test.
((
5
,
4
,
3
),[
0
]),((
5
,
4
,
3
),[
0
,
1
]),((
5
,
4
,
3
),[
2
]),((
5
,
4
,
3
),[
0
,
1
,
2
]),
((
5
,
4
,
3
),[
0
]),((
5
,
4
,
3
),[
0
,
1
]),((
5
,
4
,
3
),[
2
]),((
5
,
4
,
3
),[
0
,
1
,
2
]),
((
5
,
4
,
3
,
2
),[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
2
,
3
])]:
((
5
,
4
,
3
,
2
),[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
2
,
3
])]:
a
=
tensor
.
TensorType
(
'float32'
,(
False
,)
*
len
(
shape
))()
a
=
tensor
.
TensorType
(
'float32'
,(
False
,)
*
len
(
shape
))()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论