Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d826e4da
提交
d826e4da
authored
2月 10, 2014
作者:
Marc-Alexandre Cote
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a dummy kernel for testing.
上级
5fa2fc57
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
9 行删除
+24
-9
extra_ops.py
theano/sandbox/cuda/extra_ops.py
+22
-7
test_extra_ops.py
theano/sandbox/cuda/tests/test_extra_ops.py
+2
-2
没有找到文件。
theano/sandbox/cuda/extra_ops.py
浏览文件 @
d826e4da
...
...
@@ -15,6 +15,7 @@ if cuda_available:
class
GpuCumsum
(
CumsumOp
,
GpuOp
):
def
__init__
(
self
,
axis
=
None
):
self
.
axis
=
axis
self
.
max_threads_dim0
=
None
def
make_node
(
self
,
x
):
assert
x
.
dtype
==
'float32'
...
...
@@ -53,7 +54,7 @@ class GpuCumsum(CumsumOp, GpuOp):
return
()
def
c_support_code_apply
(
self
,
node
,
nodename
):
mode
=
self
.
mode
axis
=
self
.
axis
return
"""
static __global__ void k_cumsum_1D_
%(nodename)
s(float* g_idata,
float* g_odata,
...
...
@@ -68,7 +69,7 @@ class GpuCumsum(CumsumOp, GpuOp):
for (int d = n/2; d > 0; d /= 2)
{
CNDA_THREAD_SYNC
;
__syncthreads()
;
if (threadIdx.x < d)
{
...
...
@@ -84,7 +85,7 @@ class GpuCumsum(CumsumOp, GpuOp):
for (int d = 1; d < n; d *= 2)
{
CNDA_THREAD_SYNC
;
__syncthreads()
;
if (threadIdx.x < d)
{
...
...
@@ -97,7 +98,7 @@ class GpuCumsum(CumsumOp, GpuOp):
}
}
CNDA_THREAD_SYNC
;
__syncthreads()
;
g_odata[2*threadIdx.x] = temp[2*threadIdx.x];
g_odata[2*threadIdx.x+1] = temp[2*threadIdx.x+1];
}
...
...
@@ -131,11 +132,11 @@ class GpuCumsum(CumsumOp, GpuOp):
if (!
%(z)
s)
%(fail)
s;
{
dim3 dim_block( min(shape[0],
%(max_threads_dim0)
s) );
dim3 dim_block( min(
(int)
shape[0],
%(max_threads_dim0)
s) );
dim3 dim_grid(1);
if (dim_block.x < shape[0])
dim_grid.x = (shape[0]-1 / dim_block.x) + 1;
#
Ceil
dim_grid.x = (shape[0]-1 / dim_block.x) + 1;
//
Ceil
void (*f)(float*, float*, int);
...
...
@@ -144,7 +145,7 @@ class GpuCumsum(CumsumOp, GpuOp):
f<<<dim_grid,dim_block>>>(CudaNdarray_DEV_DATA(
%(x)
s),
CudaNdarray_DEV_DATA(
%(z)
s),
shape[0]);
CNDA_THREAD_SYNC;
cudaError_t sts = cudaGetLastError();
if (cudaSuccess != sts)
...
...
@@ -166,3 +167,17 @@ class GpuCumsum(CumsumOp, GpuOp):
"""
%
locals
()
return
code
def
gpu_cumsum
(
x
,
axis
=
None
):
return
GpuCumsum
(
axis
)(
x
)
@local_optimizer
([
CumsumOp
])
def
use_gpu_cumsum
(
node
):
if
type
(
node
.
op
)
is
CumsumOp
and
node
.
inputs
[
0
]
.
dtype
==
'float32'
:
return
[
host_from_gpu
(
gpu_cumsum
(
gpu_from_host
(
node
.
inputs
[
0
]),
axis
=
node
.
op
.
axis
))]
if
cuda_available
:
register_gpu_opt
()(
use_gpu_cumsum
)
theano/sandbox/cuda/tests/test_extra_ops.py
浏览文件 @
d826e4da
...
...
@@ -5,7 +5,7 @@ import theano.sandbox.cuda as cuda_ndarray
if
cuda_ndarray
.
cuda_available
==
False
:
raise
SkipTest
(
'Optional package cuda disabled'
)
import
theano.
sandbox.test_neighbour
s
import
theano.
tensor.tests.test_extra_op
s
from
theano.sandbox.cuda.extra_ops
import
GpuCumsum
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
...
...
@@ -14,7 +14,7 @@ else:
mode_with_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'gpu'
)
class
TestGpuCumsum
(
theano
.
tensor
.
test
.
test_extra_ops
.
TestCumsumOp
):
class
TestGpuCumsum
(
theano
.
tensor
.
test
s
.
test_extra_ops
.
TestCumsumOp
):
mode
=
mode_with_gpu
op
=
GpuCumsum
dtypes
=
[
'float32'
]
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论