Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
278d5e8d
提交
278d5e8d
authored
6月 28, 2017
作者:
João Victor Tozatti Risso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change spatialtf implementation to use NCHW tensors
Signed-off-by:
João Victor Tozatti Risso
<
joaovictor.risso@gmail.com
>
上级
0c5b9306
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
28 行增加
和
21 行删除
+28
-21
spatialtf_desc.c
theano/gpuarray/c_code/spatialtf_desc.c
+9
-2
spatialtf_grid.c
theano/gpuarray/c_code/spatialtf_grid.c
+3
-2
spatialtf_sampler.c
theano/gpuarray/c_code/spatialtf_sampler.c
+9
-10
dnn.py
theano/gpuarray/dnn.py
+7
-7
没有找到文件。
theano/gpuarray/c_code/spatialtf_desc.c
浏览文件 @
278d5e8d
...
@@ -5,8 +5,15 @@ int APPLY_SPECIFIC(spatialtf_desc)(cudnnSpatialTransformerDescriptor_t * desc,
...
@@ -5,8 +5,15 @@ int APPLY_SPECIFIC(spatialtf_desc)(cudnnSpatialTransformerDescriptor_t * desc,
{
{
cudnnStatus_t
err
;
cudnnStatus_t
err
;
// num_channels, width, height, num_images
if
(
params
->
nimages
==
0
||
params
->
nchannels
==
0
||
const
int
out_tensor_dims
[
4
]
=
{
params
->
nimages
,
params
->
height
,
params
->
width
,
params
->
nchannels
};
params
->
height
==
0
||
params
->
width
==
0
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"Invalid grid dimensions"
);
return
-
1
;
}
// num_images, num_channels, height, width
const
int
out_tensor_dims
[
4
]
=
{
params
->
nimages
,
params
->
nchannels
,
params
->
height
,
params
->
width
};
err
=
cudnnCreateSpatialTransformerDescriptor
(
desc
);
err
=
cudnnCreateSpatialTransformerDescriptor
(
desc
);
if
(
CUDNN_STATUS_SUCCESS
!=
err
)
if
(
CUDNN_STATUS_SUCCESS
!=
err
)
...
...
theano/gpuarray/c_code/spatialtf_grid.c
浏览文件 @
278d5e8d
...
@@ -43,8 +43,9 @@ spatialtf_grid(PyArrayObject * grid_dimensions,
...
@@ -43,8 +43,9 @@ spatialtf_grid(PyArrayObject * grid_dimensions,
// Obtain grid dimensions
// Obtain grid dimensions
const
size_t
num_images
=
(
size_t
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
0
)
);
const
size_t
num_images
=
(
size_t
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
0
)
);
const
size_t
height
=
(
size_t
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
1
)
);
// Dimension 1 is the number of image channels
const
size_t
width
=
(
size_t
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
2
)
);
const
size_t
height
=
(
size_t
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
2
)
);
const
size_t
width
=
(
size_t
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
3
)
);
// Grid of coordinates is of size num_images * height * width * 2 for a 2D transformation
// Grid of coordinates is of size num_images * height * width * 2 for a 2D transformation
const
size_t
grid_dims
[
4
]
=
{
num_images
,
height
,
width
,
2
};
const
size_t
grid_dims
[
4
]
=
{
num_images
,
height
,
width
,
2
};
...
...
theano/gpuarray/c_code/spatialtf_sampler.c
浏览文件 @
278d5e8d
...
@@ -38,7 +38,7 @@ spatialtf_sampler(PyGpuArrayObject * input,
...
@@ -38,7 +38,7 @@ spatialtf_sampler(PyGpuArrayObject * input,
spatialtf_context_t
spatialtf_ctx
;
spatialtf_context_t
spatialtf_ctx
;
cudnnDataType_t
dt
;
cudnnDataType_t
dt
;
// Number of color channels (feature maps) is the innermost dimension
// Number of color channels (feature maps) is the innermost dimension
cudnnTensorFormat_t
tf
=
CUDNN_TENSOR_N
HWC
;
cudnnTensorFormat_t
tf
=
CUDNN_TENSOR_N
CHW
;
cudnnStatus_t
err
=
CUDNN_STATUS_SUCCESS
;
cudnnStatus_t
err
=
CUDNN_STATUS_SUCCESS
;
if
(
PyArray_DIM
(
grid_dimensions
,
0
)
!=
4
)
if
(
PyArray_DIM
(
grid_dimensions
,
0
)
!=
4
)
...
@@ -50,11 +50,11 @@ spatialtf_sampler(PyGpuArrayObject * input,
...
@@ -50,11 +50,11 @@ spatialtf_sampler(PyGpuArrayObject * input,
// Obtain grid dimensions
// Obtain grid dimensions
const
int
num_images
=
(
int
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
0
)
);
const
int
num_images
=
(
int
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
0
)
);
const
int
height
=
(
int
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
1
)
);
const
int
num_channels
=
(
int
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
1
)
);
const
int
width
=
(
int
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
2
)
);
const
int
height
=
(
int
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
2
)
);
const
int
num_channels
=
(
int
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
3
)
);
const
int
width
=
(
int
)
*
(
(
npy_int
*
)
PyArray_GETPTR1
(
grid_dimensions
,
3
)
);
switch
(
grid
->
ga
.
typecode
)
switch
(
input
->
ga
.
typecode
)
{
{
case
GA_DOUBLE
:
case
GA_DOUBLE
:
alpha_p
=
(
void
*
)
&
alpha
;
alpha_p
=
(
void
*
)
&
alpha
;
...
@@ -98,9 +98,9 @@ spatialtf_sampler(PyGpuArrayObject * input,
...
@@ -98,9 +98,9 @@ spatialtf_sampler(PyGpuArrayObject * input,
// of the grid's width and height. The number of images and channels
// of the grid's width and height. The number of images and channels
// should be the same as the grid dimensions
// should be the same as the grid dimensions
const
int
input_num_images
=
(
int
)
PyGpuArray_DIM
(
input
,
0
);
const
int
input_num_images
=
(
int
)
PyGpuArray_DIM
(
input
,
0
);
const
int
input_
height
=
(
int
)
PyGpuArray_DIM
(
input
,
1
);
const
int
input_
num_channels
=
(
int
)
PyGpuArray_DIM
(
input
,
1
);
const
int
input_
width
=
(
int
)
PyGpuArray_DIM
(
input
,
2
);
const
int
input_
height
=
(
int
)
PyGpuArray_DIM
(
input
,
2
);
const
int
input_
num_channels
=
(
int
)
PyGpuArray_DIM
(
input
,
3
);
const
int
input_
width
=
(
int
)
PyGpuArray_DIM
(
input
,
3
);
if
(
input_num_images
!=
num_images
||
if
(
input_num_images
!=
num_images
||
input_num_channels
!=
num_channels
)
input_num_channels
!=
num_channels
)
...
@@ -154,8 +154,7 @@ spatialtf_sampler(PyGpuArrayObject * input,
...
@@ -154,8 +154,7 @@ spatialtf_sampler(PyGpuArrayObject * input,
if
(
NULL
==
*
output
)
if
(
NULL
==
*
output
)
{
{
// (num_images, height, width, num_channels )
const
size_t
out_dims
[
4
]
=
{
num_images
,
num_channels
,
height
,
width
};
const
size_t
out_dims
[
4
]
=
{
num_images
,
height
,
width
,
num_channels
};
*
output
=
pygpu_zeros
(
4
,
&
(
out_dims
[
0
]),
input
->
ga
.
typecode
,
GA_C_ORDER
,
*
output
=
pygpu_zeros
(
4
,
&
(
out_dims
[
0
]),
input
->
ga
.
typecode
,
GA_C_ORDER
,
gpu_ctx
,
Py_None
);
gpu_ctx
,
Py_None
);
...
...
theano/gpuarray/dnn.py
浏览文件 @
278d5e8d
...
@@ -2841,7 +2841,7 @@ class GpuDnnSpatialTfDesc(COp):
...
@@ -2841,7 +2841,7 @@ class GpuDnnSpatialTfDesc(COp):
"""
"""
__props__
=
(
'dimensions'
,
'precision'
)
__props__
=
(
'dimensions'
,
'precision'
)
params_type
=
ParamsType
(
nimages
=
int_t
,
height
=
int_t
,
width
=
int_t
,
nchannels
=
int_t
,
params_type
=
ParamsType
(
nimages
=
int_t
,
nchannels
=
int_t
,
height
=
int_t
,
width
=
int_t
,
nb_dims
=
int_t
,
precision
=
cudnn
.
cudnnDataType_t
)
nb_dims
=
int_t
,
precision
=
cudnn
.
cudnnDataType_t
)
def
c_headers
(
self
):
def
c_headers
(
self
):
...
@@ -2886,14 +2886,14 @@ class GpuDnnSpatialTfDesc(COp):
...
@@ -2886,14 +2886,14 @@ class GpuDnnSpatialTfDesc(COp):
out
.
tag
.
values_eq_approx
=
tensor
.
type
.
values_eq_approx_always_true
out
.
tag
.
values_eq_approx
=
tensor
.
type
.
values_eq_approx_always_true
return
node
return
node
#
Grid width
#
Number of images
nimages
=
property
(
lambda
self
:
self
.
dimensions
[
0
])
nimages
=
property
(
lambda
self
:
self
.
dimensions
[
0
])
# Number of channels
nchannels
=
property
(
lambda
self
:
self
.
dimensions
[
1
])
# Grid height
# Grid height
height
=
property
(
lambda
self
:
self
.
dimensions
[
1
])
height
=
property
(
lambda
self
:
self
.
dimensions
[
2
])
# Number of feature maps
# Grid width
width
=
property
(
lambda
self
:
self
.
dimensions
[
2
])
width
=
property
(
lambda
self
:
self
.
dimensions
[
3
])
# Number of images
nchannels
=
property
(
lambda
self
:
self
.
dimensions
[
3
])
# Number of dimensions in the output tensor
# Number of dimensions in the output tensor
nb_dims
=
property
(
lambda
self
:
len
(
self
.
dimensions
))
nb_dims
=
property
(
lambda
self
:
len
(
self
.
dimensions
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论