Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e5bb665a
提交
e5bb665a
authored
7月 08, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make GpuCrossentropySoftmaxArgmax1HotWithBias and…
Make GpuCrossentropySoftmaxArgmax1HotWithBias and GpuCrossentropySoftmax1HotWithBiasDx work for bigger inputs.
上级
83897d76
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
14 行删除
+24
-14
nnet.py
theano/sandbox/cuda/nnet.py
+20
-12
test_nnet.py
theano/sandbox/cuda/tests/test_nnet.py
+4
-2
没有找到文件。
theano/sandbox/cuda/nnet.py
浏览文件 @
e5bb665a
...
@@ -41,7 +41,7 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
...
@@ -41,7 +41,7 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
float * sm_data, int sms0, int sms1,
float * sm_data, int sms0, int sms1,
float * am_data, int ams0)
float * am_data, int ams0)
{
{
const int row = blockIdx.x;
for (int row = blockIdx.x; row < M; row += gridDim.x){
const float * x = x_data + xs0 * row;
const float * x = x_data + xs0 * row;
const int y_idx = (int)y_idx_data[row * y_idxs0];
const int y_idx = (int)y_idx_data[row * y_idxs0];
...
@@ -84,6 +84,7 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
...
@@ -84,6 +84,7 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
}
}
am_data[row*ams0] = row_max_j;
am_data[row*ams0] = row_max_j;
}
}
}
"""
"""
...
@@ -168,7 +169,8 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
...
@@ -168,7 +169,8 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
}
}
}
}
{
{
int n_blocks = CudaNdarray_HOST_DIMS(
%(sm)
s)[0];
int n_blocks = std::min(CudaNdarray_HOST_DIMS(
%(x)
s)[0],
NUM_VECTOR_OP_BLOCKS);
//TODO: launch more threads per row and do parallel sum and max reductions
//TODO: launch more threads per row and do parallel sum and max reductions
int n_threads = 1;
int n_threads = 1;
int n_shared_bytes = 0; //n_threads * sizeof(float);
int n_shared_bytes = 0; //n_threads * sizeof(float);
...
@@ -195,8 +197,11 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
...
@@ -195,8 +197,11 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
if (cudaSuccess != err)
if (cudaSuccess != err)
{
{
PyErr_Format(PyExc_RuntimeError,
PyErr_Format(PyExc_RuntimeError,
"Cuda error:
%(classname)
s
%(nodename)
s:
%%
s.
\\
n",
"Cuda error:
%(classname)
s
%(nodename)
s:
%%
s.
\\
n"
cudaGetErrorString(err));
"The kernel was launched with
%%
d threads,"
"
%%
d blocks and
%%
d shared memory
\\
n",
cudaGetErrorString(err),
n_threads, n_blocks, n_shared_bytes);
// no need to decref output vars the cleanup code will do it
// no need to decref output vars the cleanup code will do it
%(fail)
s;
%(fail)
s;
}
}
...
@@ -206,7 +211,7 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
...
@@ -206,7 +211,7 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias (GpuOp):
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
#return ()
#return ()
return
(
3
,)
return
(
4
,)
gpu_crossentropy_softmax_argmax_1hot_with_bias
=
GpuCrossentropySoftmaxArgmax1HotWithBias
()
gpu_crossentropy_softmax_argmax_1hot_with_bias
=
GpuCrossentropySoftmaxArgmax1HotWithBias
()
...
@@ -235,7 +240,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx (GpuOp):
...
@@ -235,7 +240,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx (GpuOp):
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
#return ()
#return ()
return
(
5
,)
return
(
6
,)
def
c_code
(
self
,
node
,
nodename
,
inp
,
out
,
sub
):
def
c_code
(
self
,
node
,
nodename
,
inp
,
out
,
sub
):
dnll
,
sm
,
y_idx
=
inp
dnll
,
sm
,
y_idx
=
inp
...
@@ -283,11 +288,12 @@ class GpuCrossentropySoftmax1HotWithBiasDx (GpuOp):
...
@@ -283,11 +288,12 @@ class GpuCrossentropySoftmax1HotWithBiasDx (GpuOp):
}
}
}
}
{
{
int n_blocks = std::min(CudaNdarray_HOST_DIMS(
%(dx)
s)[0],
NUM_VECTOR_OP_BLOCKS);
int n_threads = std::min(CudaNdarray_HOST_DIMS(
%(dx)
s)[1],256);
kCrossEntropySoftmax1HotWithBiasDx_
%(nodename)
s
kCrossEntropySoftmax1HotWithBiasDx_
%(nodename)
s
<<<
<<<n_blocks, n_threads>>>(
CudaNdarray_HOST_DIMS(
%(dx)
s)[0],
std::min(CudaNdarray_HOST_DIMS(
%(dx)
s)[1],256)
>>>(
CudaNdarray_HOST_DIMS(
%(dx)
s)[0],
CudaNdarray_HOST_DIMS(
%(dx)
s)[0],
CudaNdarray_HOST_DIMS(
%(dx)
s)[1],
CudaNdarray_HOST_DIMS(
%(dx)
s)[1],
...
@@ -310,9 +316,11 @@ class GpuCrossentropySoftmax1HotWithBiasDx (GpuOp):
...
@@ -310,9 +316,11 @@ class GpuCrossentropySoftmax1HotWithBiasDx (GpuOp):
if( cudaSuccess != err)
if( cudaSuccess != err)
{
{
PyErr_Format(PyExc_RuntimeError,
PyErr_Format(PyExc_RuntimeError,
"Cuda error:
%%
s:
%%
s.
\\
n",
"Cuda error:
%%
s:
%%
s.
\\
n"
"The kernel was launched with
%%
d threads and"
"
%%
d blocks
\\
n",
"kCrossEntropySoftmax1HotWithBiasDx_
%(nodename)
s",
"kCrossEntropySoftmax1HotWithBiasDx_
%(nodename)
s",
cudaGetErrorString(err));
cudaGetErrorString(err)
, n_threads, n_blocks
);
%(fail)
s;
%(fail)
s;
}
}
}
}
...
...
theano/sandbox/cuda/tests/test_nnet.py
浏览文件 @
e5bb665a
...
@@ -25,7 +25,6 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
...
@@ -25,7 +25,6 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
This is basic test for GpuCrossentropySoftmaxArgmax1HotWithBias
This is basic test for GpuCrossentropySoftmaxArgmax1HotWithBias
We check that we loop when their is too much threads
We check that we loop when their is too much threads
TODO: check that we loop when their is too much block(>32*1024)
"""
"""
...
@@ -100,13 +99,16 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
...
@@ -100,13 +99,16 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
This is basic test for GpuCrossentropySoftmax1HotWithBiasDx
This is basic test for GpuCrossentropySoftmax1HotWithBiasDx
We check that we loop when their is too much threads
We check that we loop when their is too much threads
TODO: check that we loop when their is too much block(>32*1024)
"""
"""
n_in
=
1000
n_in
=
1000
batch_size
=
4097
batch_size
=
4097
n_out
=
1250
n_out
=
1250
if
not
isinstance
(
mode_with_gpu
,
theano
.
compile
.
DebugMode
):
n_in
=
4098
n_out
=
4099
# Seed numpy.random with config.unittests.rseed
# Seed numpy.random with config.unittests.rseed
utt
.
seed_rng
()
utt
.
seed_rng
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论