Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a91c0116
提交
a91c0116
authored
3月 26, 2014
作者:
Pierre Luc Carrier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert CudaNdarray_HOST_DIMS(x) to PyGpuArray_DIMS(x) in op GpuImages2Neibs
上级
6c806974
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
28 行增加
和
28 行删除
+28
-28
neighbours.py
theano/sandbox/gpuarray/neighbours.py
+28
-28
没有找到文件。
theano/sandbox/gpuarray/neighbours.py
浏览文件 @
a91c0116
...
@@ -243,54 +243,54 @@ class GpuImages2Neibs(Images2Neibs, Op):
...
@@ -243,54 +243,54 @@ class GpuImages2Neibs(Images2Neibs, Op):
"Images2Neibs: in mode wrap_centered need patch with odd shapes");
"Images2Neibs: in mode wrap_centered need patch with odd shapes");
%(fail)
s;
%(fail)
s;
}
}
if (
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[2] < c ||
if (
PyGpuArray
_DIMS(
%(ten4)
s)[2] < c ||
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[3] < d)
PyGpuArray
_DIMS(
%(ten4)
s)[3] < d)
{
{
PyErr_Format(PyExc_TypeError,
PyErr_Format(PyExc_TypeError,
"Images2Neibs: in wrap_centered mode, don't"
"Images2Neibs: in wrap_centered mode, don't"
" support image shapes smaller then the patch"
" support image shapes smaller then the patch"
" shapes: neib_shape=(
%%
d,
%%
d),"
" shapes: neib_shape=(
%%
d,
%%
d),"
" ten4[2:]=[
%%
d,
%%
d]",
" ten4[2:]=[
%%
d,
%%
d]",
c, d,
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[2],
c, d,
PyGpuArray
_DIMS(
%(ten4)
s)[2],
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[3]);
PyGpuArray
_DIMS(
%(ten4)
s)[3]);
%(fail)
s;
%(fail)
s;
}
}
grid_c = CEIL_INTDIV(((
CudaNdarray_HOST
_DIMS(
%(ten4)
s))[2]),
grid_c = CEIL_INTDIV(((
PyGpuArray
_DIMS(
%(ten4)
s))[2]),
step_x);
step_x);
grid_d = CEIL_INTDIV(((
CudaNdarray_HOST
_DIMS(
%(ten4)
s))[3]),
grid_d = CEIL_INTDIV(((
PyGpuArray
_DIMS(
%(ten4)
s))[3]),
step_y);
step_y);
}else if ( "
%(mode)
s" == "valid") {
}else if ( "
%(mode)
s" == "valid") {
if ( ((
CudaNdarray_HOST
_DIMS(
%(ten4)
s))[2] < c) ||
if ( ((
PyGpuArray
_DIMS(
%(ten4)
s))[2] < c) ||
((((
CudaNdarray_HOST
_DIMS(
%(ten4)
s))[2]-c)
%%
step_x)!=0))
((((
PyGpuArray
_DIMS(
%(ten4)
s))[2]-c)
%%
step_x)!=0))
{
{
PyErr_Format(PyExc_TypeError,
PyErr_Format(PyExc_TypeError,
"neib_shape[0]=
%%
d, neib_step[0]=
%%
d and"
"neib_shape[0]=
%%
d, neib_step[0]=
%%
d and"
" ten4.shape[2]=
%%
d not consistent",
" ten4.shape[2]=
%%
d not consistent",
c, step_x,
c, step_x,
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[2]);
PyGpuArray
_DIMS(
%(ten4)
s)[2]);
%(fail)
s;
%(fail)
s;
}
}
if ( ((
CudaNdarray_HOST
_DIMS(
%(ten4)
s))[3] < d) ||
if ( ((
PyGpuArray
_DIMS(
%(ten4)
s))[3] < d) ||
((((
CudaNdarray_HOST
_DIMS(
%(ten4)
s))[3]-d)
%%
step_y)!=0))
((((
PyGpuArray
_DIMS(
%(ten4)
s))[3]-d)
%%
step_y)!=0))
{
{
PyErr_Format(PyExc_TypeError,
PyErr_Format(PyExc_TypeError,
"neib_shape[1]=
%%
d, neib_step[1]=
%%
d and"
"neib_shape[1]=
%%
d, neib_step[1]=
%%
d and"
" ten4.shape[3]=
%%
d not consistent",
" ten4.shape[3]=
%%
d not consistent",
d, step_y,
d, step_y,
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[3]);
PyGpuArray
_DIMS(
%(ten4)
s)[3]);
%(fail)
s;
%(fail)
s;
}
}
//number of patch in height
//number of patch in height
grid_c = 1+(((
CudaNdarray_HOST
_DIMS(
%(ten4)
s))[2]-c)/step_x);
grid_c = 1+(((
PyGpuArray
_DIMS(
%(ten4)
s))[2]-c)/step_x);
//number of patch in width
//number of patch in width
grid_d = 1+(((
CudaNdarray_HOST
_DIMS(
%(ten4)
s))[3]-d)/step_y);
grid_d = 1+(((
PyGpuArray
_DIMS(
%(ten4)
s))[3]-d)/step_y);
}else if ( "
%(mode)
s" == "ignore_borders") {
}else if ( "
%(mode)
s" == "ignore_borders") {
//number of patch in height
//number of patch in height
grid_c = 1+(((
CudaNdarray_HOST
_DIMS(
%(ten4)
s))[2]-c)/step_x);
grid_c = 1+(((
PyGpuArray
_DIMS(
%(ten4)
s))[2]-c)/step_x);
//number of patch in width
//number of patch in width
grid_d = 1+(((
CudaNdarray_HOST
_DIMS(
%(ten4)
s))[3]-d)/step_y);
grid_d = 1+(((
PyGpuArray
_DIMS(
%(ten4)
s))[3]-d)/step_y);
}else{
}else{
PyErr_Format(PyExc_TypeError,
PyErr_Format(PyExc_TypeError,
"Images2Neibs: unknow mode '
%(mode)
s'");
"Images2Neibs: unknow mode '
%(mode)
s'");
...
@@ -301,12 +301,12 @@ class GpuImages2Neibs(Images2Neibs, Op):
...
@@ -301,12 +301,12 @@ class GpuImages2Neibs(Images2Neibs, Op):
const int z_dim1 = c * d;
const int z_dim1 = c * d;
const int z_dim0 = grid_c
const int z_dim0 = grid_c
* grid_d
* grid_d
*
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[1]
*
PyGpuArray
_DIMS(
%(ten4)
s)[1]
*
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[0];
*
PyGpuArray
_DIMS(
%(ten4)
s)[0];
if ((NULL ==
%(z)
s)
if ((NULL ==
%(z)
s)
|| (
CudaNdarray_HOST
_DIMS(
%(z)
s)[0] != z_dim0)
|| (
PyGpuArray
_DIMS(
%(z)
s)[0] != z_dim0)
|| (
CudaNdarray_HOST
_DIMS(
%(z)
s)[1] != z_dim1))
|| (
PyGpuArray
_DIMS(
%(z)
s)[1] != z_dim1))
{
{
Py_XDECREF(
%(z)
s);
Py_XDECREF(
%(z)
s);
npy_intp dims[2];
npy_intp dims[2];
...
@@ -325,10 +325,10 @@ class GpuImages2Neibs(Images2Neibs, Op):
...
@@ -325,10 +325,10 @@ class GpuImages2Neibs(Images2Neibs, Op):
{ // NESTED SCOPE
{ // NESTED SCOPE
const int nb_batch =
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[0];
const int nb_batch =
PyGpuArray
_DIMS(
%(ten4)
s)[0];
const int nb_stack =
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[1];
const int nb_stack =
PyGpuArray
_DIMS(
%(ten4)
s)[1];
const int height =
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[2];
const int height =
PyGpuArray
_DIMS(
%(ten4)
s)[2];
const int width =
CudaNdarray_HOST
_DIMS(
%(ten4)
s)[3];
const int width =
PyGpuArray
_DIMS(
%(ten4)
s)[3];
const int c = *(dtype_
%(neib_shape)
s*) PyArray_GETPTR1(
const int c = *(dtype_
%(neib_shape)
s*) PyArray_GETPTR1(
%(neib_shape)
s, 0);
%(neib_shape)
s, 0);
...
@@ -348,14 +348,14 @@ class GpuImages2Neibs(Images2Neibs, Op):
...
@@ -348,14 +348,14 @@ class GpuImages2Neibs(Images2Neibs, Op):
//a higher core utilisation. for smaller patch size
//a higher core utilisation. for smaller patch size
while(c*d*(n_threads.z+1) < 128 && n_threads.z<64 &&
while(c*d*(n_threads.z+1) < 128 && n_threads.z<64 &&
n_threads.z<
CudaNdarray_HOST
_DIMS(
%(z)
s)[0]){
n_threads.z<
PyGpuArray
_DIMS(
%(z)
s)[0]){
n_threads.z++;
n_threads.z++;
}
}
int nb_block;
int nb_block;
if (
CudaNdarray_HOST
_DIMS(
%(z)
s)[0]
%%
n_threads.z == 0)
if (
PyGpuArray
_DIMS(
%(z)
s)[0]
%%
n_threads.z == 0)
nb_block =
CudaNdarray_HOST
_DIMS(
%(z)
s)[0] / n_threads.z;
nb_block =
PyGpuArray
_DIMS(
%(z)
s)[0] / n_threads.z;
else
else
nb_block = (
CudaNdarray_HOST
_DIMS(
%(z)
s)[0] / n_threads.z) + 1;
nb_block = (
PyGpuArray
_DIMS(
%(z)
s)[0] / n_threads.z) + 1;
dim3 n_blocks(std::min(32*1024,nb_block));
dim3 n_blocks(std::min(32*1024,nb_block));
int n_shared = 0;
int n_shared = 0;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论