Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e350433d
提交
e350433d
authored
6月 27, 2017
作者:
João Victor Tozatti Risso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more checks and fix data layout in spatialtf grid generator
Signed-off-by:
João Victor Tozatti Risso
<
joaovictor.risso@gmail.com
>
上级
e2bc4954
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
8 行删除
+24
-8
spatialtf_grid.c
theano/gpuarray/c_code/spatialtf_grid.c
+24
-8
没有找到文件。
theano/gpuarray/c_code/spatialtf_grid.c
浏览文件 @
e350433d
...
...
@@ -18,33 +18,49 @@ spatialtf_grid(PyGpuArrayObject * theta,
return
-
1
;
}
if
(
Py
Array_DIM
(
grid_dimensions
,
0
)
<
4
)
if
(
Py
GpuArray_NDIM
(
theta
)
!=
3
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"Grid dimensions array must have at least 4 dimensions!"
);
"theta must have three dimensions!"
);
return
-
1
;
}
if
(
PyGpuArray_DIM
(
theta
,
1
)
!=
2
&&
PyGpuArray_DIM
(
theta
,
2
)
!=
3
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"Incorrect dimensions for theta, should be (%d, %d, %d), got (%d, %d, %d)"
,
PyGpuArray_DIMS
(
theta
)[
0
],
2
,
3
,
PyGpuArray_DIMS
(
theta
)[
0
],
PyGpuArray_DIMS
(
theta
)[
1
],
PyGpuArray_DIMS
(
theta
)[
2
]
);
return
-
1
;
}
if
(
PyArray_DIM
(
grid_dimensions
,
0
)
<
3
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"Grid dimensions array must have at least 3 dimensions!"
);
return
-
1
;
}
// Obtain grid dimensions
npy_int
*
dimensions_data
=
(
npy_int
*
)
PyArray_DATA
(
grid_dimensions
);
const
size_t
width
=
dimensions_data
[
0
];
const
size_t
num_images
=
dimensions_data
[
0
];
const
size_t
height
=
dimensions_data
[
1
];
const
size_t
num_images
=
dimensions_data
[
3
];
const
size_t
width
=
dimensions_data
[
2
];
// Grid of coordinates is of size num_images * height * width * 2 for a 2D transformation
const
size_t
grid_dims
[
4
]
=
{
width
,
height
,
2
,
num_images
};
const
size_t
grid_dims
[
4
]
=
{
num_images
,
height
,
width
,
2
};
if
(
width
==
0
||
height
==
0
||
num_images
==
0
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"
Invalid grid dimensions!
"
);
"
One of the grid dimensions is zero
"
);
return
-
1
;
}
if
(
NULL
==
*
grid
)
{
*
grid
=
pygpu_zeros
(
4
,
&
(
grid_dims
[
0
]),
theta
->
ga
.
typecode
,
GA_C_ORDER
,
gpu_ctx
,
Py_None
);
*
grid
=
pygpu_zeros
(
4
,
&
(
grid_dims
[
0
]),
theta
->
ga
.
typecode
,
GA_C_ORDER
,
gpu_ctx
,
Py_None
);
if
(
NULL
==
*
grid
)
{
PyErr_SetString
(
PyExc_MemoryError
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论