Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5ecbbde2
提交
5ecbbde2
authored
9月 10, 2015
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3364 from seanprime7/drvapi
Use the libgpuarray APIs to manage GPU code compilation, execution, etc.
上级
752f1f73
16f37f44
全部展开
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
24 行增加
和
6 行删除
+24
-6
basic_ops.py
theano/sandbox/gpuarray/basic_ops.py
+9
-0
conv.cu
theano/sandbox/gpuarray/conv.cu
+0
-0
conv.py
theano/sandbox/gpuarray/conv.py
+0
-0
conv_full_kernel.cu
theano/sandbox/gpuarray/conv_full_kernel.cu
+0
-0
conv_kernel.cu
theano/sandbox/gpuarray/conv_kernel.cu
+0
-0
elemwise.py
theano/sandbox/gpuarray/elemwise.py
+0
-0
kernel_codegen.py
theano/sandbox/gpuarray/kernel_codegen.py
+15
-6
neighbours.py
theano/sandbox/gpuarray/neighbours.py
+0
-0
nnet.py
theano/sandbox/gpuarray/nnet.py
+0
-0
subtensor.py
theano/sandbox/gpuarray/subtensor.py
+0
-0
没有找到文件。
theano/sandbox/gpuarray/basic_ops.py
浏览文件 @
5ecbbde2
...
@@ -144,6 +144,15 @@ class GpuKernelBase(object):
...
@@ -144,6 +144,15 @@ class GpuKernelBase(object):
def
_generate_kernel_vars
(
self
,
k
):
def
_generate_kernel_vars
(
self
,
k
):
return
"""static GpuKernel
%(kname)
s;"""
%
dict
(
kname
=
k
.
objvar
)
return
"""static GpuKernel
%(kname)
s;"""
%
dict
(
kname
=
k
.
objvar
)
def
c_support_code
(
self
):
return
"""
template <typename T>
static T ceil_intdiv(T a, T b)
{
return (a/b) + ((a
%
b) ? 1: 0);
}
"""
def
c_support_code_apply
(
self
,
node
,
name
):
def
c_support_code_apply
(
self
,
node
,
name
):
kernels
=
self
.
gpu_kernels
(
node
,
name
)
kernels
=
self
.
gpu_kernels
(
node
,
name
)
bins
=
'
\n
'
.
join
(
self
.
_generate_kernel_bin
(
k
)
for
k
in
kernels
)
bins
=
'
\n
'
.
join
(
self
.
_generate_kernel_bin
(
k
)
for
k
in
kernels
)
...
...
theano/sandbox/gpuarray/conv.cu
浏览文件 @
5ecbbde2
差异被折叠。
点击展开。
theano/sandbox/gpuarray/conv.py
浏览文件 @
5ecbbde2
差异被折叠。
点击展开。
theano/sandbox/gpuarray/conv_full_kernel.cu
浏览文件 @
5ecbbde2
差异被折叠。
点击展开。
theano/sandbox/gpuarray/conv_kernel.cu
浏览文件 @
5ecbbde2
差异被折叠。
点击展开。
theano/sandbox/gpuarray/elemwise.py
浏览文件 @
5ecbbde2
差异被折叠。
点击展开。
theano/sandbox/gpuarray/kernel_codegen.py
浏览文件 @
5ecbbde2
...
@@ -3,6 +3,12 @@ Helper routines for generating gpu kernels for nvcc.
...
@@ -3,6 +3,12 @@ Helper routines for generating gpu kernels for nvcc.
"""
"""
try
:
import
pygpu
from
pygpu
import
gpuarray
except
ImportError
:
pass
def
nvcc_kernel
(
name
,
params
,
body
):
def
nvcc_kernel
(
name
,
params
,
body
):
"""
"""
Return the c code of a kernel function.
Return the c code of a kernel function.
...
@@ -26,7 +32,7 @@ def nvcc_kernel(name, params, body):
...
@@ -26,7 +32,7 @@ def nvcc_kernel(name, params, body):
else
:
else
:
yield
b
yield
b
bodystr
=
';
\n
'
.
join
(
flatbody
())
bodystr
=
';
\n
'
.
join
(
flatbody
())
return
"""
__global__
void
%(name)
s (
%(paramstr)
s)
return
"""
KERNEL
void
%(name)
s (
%(paramstr)
s)
{
{
%(bodystr)
s;
%(bodystr)
s;
}
}
...
@@ -167,11 +173,12 @@ def inline_softmax(N, buf, buf2, threadPos, threadCount, dtype="float32"):
...
@@ -167,11 +173,12 @@ def inline_softmax(N, buf, buf2, threadPos, threadCount, dtype="float32"):
We use __i as an int variable in a loop.
We use __i as an int variable in a loop.
"""
"""
ctype
=
gpuarray
.
dtype_to_ctype
(
dtype
)
return
[
return
[
# get max of buf (trashing all but buf[0])
# get max of buf (trashing all but buf[0])
inline_reduce_max
(
N
,
buf
,
threadPos
,
threadCount
),
inline_reduce_max
(
N
,
buf
,
threadPos
,
threadCount
),
'__syncthreads()'
,
'__syncthreads()'
,
(
'
npy_
%
s row_max = '
+
buf
+
'[0]'
)
%
d
type
,
(
'
%
s row_max = '
+
buf
+
'[0]'
)
%
c
type
,
'__syncthreads()'
,
'__syncthreads()'
,
'for(int __i='
+
threadPos
+
'; __i<'
+
N
+
'for(int __i='
+
threadPos
+
'; __i<'
+
N
+
'; __i+='
+
threadCount
+
'){'
,
'; __i+='
+
threadCount
+
'){'
,
...
@@ -181,7 +188,7 @@ def inline_softmax(N, buf, buf2, threadPos, threadCount, dtype="float32"):
...
@@ -181,7 +188,7 @@ def inline_softmax(N, buf, buf2, threadPos, threadCount, dtype="float32"):
'__syncthreads()'
,
'__syncthreads()'
,
inline_reduce_sum
(
N
,
buf
,
threadPos
,
threadCount
),
inline_reduce_sum
(
N
,
buf
,
threadPos
,
threadCount
),
'__syncthreads()'
,
'__syncthreads()'
,
(
'
npy_
%
s row_sum = '
+
buf
+
'[0]'
)
%
d
type
,
(
'
%
s row_sum = '
+
buf
+
'[0]'
)
%
c
type
,
'__syncthreads()'
,
'__syncthreads()'
,
# divide each exp() result by the sum to complete the job.
# divide each exp() result by the sum to complete the job.
'for(int __i='
+
threadPos
+
'; __i<'
+
N
+
'for(int __i='
+
threadPos
+
'; __i<'
+
N
+
...
@@ -259,11 +266,12 @@ def inline_reduce_fixed_shared(N, buf, x, stride_x, load_x, pos, count,
...
@@ -259,11 +266,12 @@ def inline_reduce_fixed_shared(N, buf, x, stride_x, load_x, pos, count,
r_2
=
manner_fn
(
"
%
s[
%
s]"
%
(
buf
,
pos
),
"
%
s[
%
s+2]"
%
(
buf
,
pos
))
r_2
=
manner_fn
(
"
%
s[
%
s]"
%
(
buf
,
pos
),
"
%
s[
%
s+2]"
%
(
buf
,
pos
))
r_1
=
manner_fn
(
"
%
s[
%
s]"
%
(
buf
,
pos
),
"
%
s[
%
s+1]"
%
(
buf
,
pos
))
r_1
=
manner_fn
(
"
%
s[
%
s]"
%
(
buf
,
pos
),
"
%
s[
%
s+1]"
%
(
buf
,
pos
))
ctype
=
gpuarray
.
dtype_to_ctype
(
dtype
)
return
"""
return
"""
{
{
// This function trashes buf[1..n_threads],
// This function trashes buf[1..n_threads],
// leaving the reduction result in buf[0].
// leaving the reduction result in buf[0].
npy_
%(d
type)
s red =
%(init)
s;
%(c
type)
s red =
%(init)
s;
#pragma unroll 16
#pragma unroll 16
for (int i =
%(pos)
s +
%(count)
s; i<
%(N)
s; i +=
%(count)
s){
for (int i =
%(pos)
s +
%(count)
s; i<
%(N)
s; i +=
%(count)
s){
red =
%(loop_line)
s;
red =
%(loop_line)
s;
...
@@ -356,6 +364,7 @@ def inline_softmax_fixed_shared(N, buf, x, stride_x, load_x,
...
@@ -356,6 +364,7 @@ def inline_softmax_fixed_shared(N, buf, x, stride_x, load_x,
We use tx as an int variable in a loop.
We use tx as an int variable in a loop.
"""
"""
ctype
=
gpuarray
.
dtype_to_ctype
(
dtype
)
ret
=
[
ret
=
[
# get max of buf (trashing all but buf[0])
# get max of buf (trashing all but buf[0])
inline_reduce_fixed_shared_max
(
N
,
buf
,
x
,
stride_x
,
load_x
,
inline_reduce_fixed_shared_max
(
N
,
buf
,
x
,
stride_x
,
load_x
,
...
@@ -363,7 +372,7 @@ def inline_softmax_fixed_shared(N, buf, x, stride_x, load_x,
...
@@ -363,7 +372,7 @@ def inline_softmax_fixed_shared(N, buf, x, stride_x, load_x,
b
,
stride_b
,
load_b
,
b
,
stride_b
,
load_b
,
dtype
),
dtype
),
'__syncthreads()'
,
'__syncthreads()'
,
(
'
npy_
%
s row_max = '
+
buf
+
'[0]'
)
%
d
type
,
(
'
%
s row_max = '
+
buf
+
'[0]'
)
%
c
type
,
'__syncthreads()'
,
'__syncthreads()'
,
inline_reduce_fixed_shared
(
N
,
buf
,
x
,
stride_x
,
load_x
,
inline_reduce_fixed_shared
(
N
,
buf
,
x
,
stride_x
,
load_x
,
threadPos
,
threadCount
,
threadPos
,
threadCount
,
...
@@ -371,7 +380,7 @@ def inline_softmax_fixed_shared(N, buf, x, stride_x, load_x,
...
@@ -371,7 +380,7 @@ def inline_softmax_fixed_shared(N, buf, x, stride_x, load_x,
lambda
a
:
"exp(
%
s - row_max)"
%
a
,
lambda
a
:
"exp(
%
s - row_max)"
%
a
,
b
,
stride_b
,
load_b
,
dtype
),
b
,
stride_b
,
load_b
,
dtype
),
'__syncthreads()'
,
'__syncthreads()'
,
(
'
npy_
%
s row_sum = '
+
buf
+
'[0]'
)
%
d
type
,
(
'
%
s row_sum = '
+
buf
+
'[0]'
)
%
c
type
,
'__syncthreads()'
,
'__syncthreads()'
,
"for (int tx = threadIdx.x; tx< N; tx += blockDim.x){"
,
"for (int tx = threadIdx.x; tx< N; tx += blockDim.x){"
,
]
]
...
...
theano/sandbox/gpuarray/neighbours.py
浏览文件 @
5ecbbde2
差异被折叠。
点击展开。
theano/sandbox/gpuarray/nnet.py
浏览文件 @
5ecbbde2
差异被折叠。
点击展开。
theano/sandbox/gpuarray/subtensor.py
浏览文件 @
5ecbbde2
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论