Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f8d20d3e
提交
f8d20d3e
authored
7月 03, 2017
作者:
João Victor Tozatti Risso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename precision to dtype in spatialtf
Signed-off-by:
João Victor Tozatti Risso
<
joaovictor.risso@gmail.com
>
上级
105b33b2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
19 行删除
+19
-19
spatialtf_desc.c
theano/gpuarray/c_code/spatialtf_desc.c
+1
-1
dnn.py
theano/gpuarray/dnn.py
+18
-18
没有找到文件。
theano/gpuarray/c_code/spatialtf_desc.c
浏览文件 @
f8d20d3e
...
@@ -27,7 +27,7 @@ int APPLY_SPECIFIC(spatialtf_desc)(cudnnSpatialTransformerDescriptor_t * desc,
...
@@ -27,7 +27,7 @@ int APPLY_SPECIFIC(spatialtf_desc)(cudnnSpatialTransformerDescriptor_t * desc,
// Currently, only the bilinear sampler is supported by cuDNN,
// Currently, only the bilinear sampler is supported by cuDNN,
// so it is not available as a parameter
// so it is not available as a parameter
err
=
cudnnSetSpatialTransformerNdDescriptor
(
*
desc
,
CUDNN_SAMPLER_BILINEAR
,
err
=
cudnnSetSpatialTransformerNdDescriptor
(
*
desc
,
CUDNN_SAMPLER_BILINEAR
,
params
->
precision
,
params
->
nb_dims
,
out_tensor_dims
);
params
->
dtype
,
params
->
nb_dims
,
out_tensor_dims
);
if
(
CUDNN_STATUS_SUCCESS
!=
err
)
if
(
CUDNN_STATUS_SUCCESS
!=
err
)
{
{
PyErr_Format
(
PyExc_MemoryError
,
PyErr_Format
(
PyExc_MemoryError
,
...
...
theano/gpuarray/dnn.py
浏览文件 @
f8d20d3e
...
@@ -2840,9 +2840,9 @@ class GpuDnnSpatialTfDesc(COp):
...
@@ -2840,9 +2840,9 @@ class GpuDnnSpatialTfDesc(COp):
operations.
operations.
"""
"""
__props__
=
(
'dimensions'
,
'
precision
'
)
__props__
=
(
'dimensions'
,
'
dtype
'
)
params_type
=
ParamsType
(
nimages
=
int_t
,
nchannels
=
int_t
,
height
=
int_t
,
width
=
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
,
dtype
=
cudnn
.
cudnnDataType_t
)
def
c_headers
(
self
):
def
c_headers
(
self
):
return
[
'cudnn.h'
,
'cudnn_helper.h'
]
return
[
'cudnn.h'
,
'cudnn_helper.h'
]
...
@@ -2859,7 +2859,7 @@ class GpuDnnSpatialTfDesc(COp):
...
@@ -2859,7 +2859,7 @@ class GpuDnnSpatialTfDesc(COp):
def
do_constant_folding
(
self
,
node
):
def
do_constant_folding
(
self
,
node
):
return
False
return
False
def
__init__
(
self
,
dimensions
,
precision
=
"float32"
):
def
__init__
(
self
,
dimensions
,
dtype
=
"float32"
):
COp
.
__init__
(
self
,
[
"c_code/spatialtf_desc.c"
],
"APPLY_SPECIFIC(spatialtf_desc)"
)
COp
.
__init__
(
self
,
[
"c_code/spatialtf_desc.c"
],
"APPLY_SPECIFIC(spatialtf_desc)"
)
# dimensions must have at least width and height
# dimensions must have at least width and height
...
@@ -2871,8 +2871,8 @@ class GpuDnnSpatialTfDesc(COp):
...
@@ -2871,8 +2871,8 @@ class GpuDnnSpatialTfDesc(COp):
# not exceed 4 dimensions (width, height, num_feature_maps, num_images)
# not exceed 4 dimensions (width, height, num_feature_maps, num_images)
assert
len
(
self
.
dimensions
)
<=
4
assert
len
(
self
.
dimensions
)
<=
4
assert
cudnn
.
cudnnDataType_t
.
has_alias
(
precision
)
assert
cudnn
.
cudnnDataType_t
.
has_alias
(
dtype
)
self
.
precision
=
precision
self
.
dtype
=
dtype
def
make_node
(
self
):
def
make_node
(
self
):
node
=
Apply
(
self
,
[],
node
=
Apply
(
self
,
[],
...
@@ -2908,14 +2908,14 @@ class GpuDnnGridGenerator(DnnBase):
...
@@ -2908,14 +2908,14 @@ class GpuDnnGridGenerator(DnnBase):
operations.
operations.
"""
"""
__props__
=
(
'
precision
'
,)
__props__
=
(
'
dtype
'
,)
_cop_num_inputs
=
3
_cop_num_inputs
=
3
_cop_num_outputs
=
1
_cop_num_outputs
=
1
def
__init__
(
self
,
precision
):
def
__init__
(
self
,
dtype
):
DnnBase
.
__init__
(
self
,
[
"c_code/spatialtf_grid.c"
],
"spatialtf_grid"
)
DnnBase
.
__init__
(
self
,
[
"c_code/spatialtf_grid.c"
],
"spatialtf_grid"
)
self
.
precision
=
precision
self
.
dtype
=
dtype
def
dnn_context
(
self
,
node
):
def
dnn_context
(
self
,
node
):
return
node
.
outputs
[
0
]
.
type
.
context_name
return
node
.
outputs
[
0
]
.
type
.
context_name
...
@@ -2930,7 +2930,7 @@ class GpuDnnGridGenerator(DnnBase):
...
@@ -2930,7 +2930,7 @@ class GpuDnnGridGenerator(DnnBase):
assert
theta
.
ndim
==
3
assert
theta
.
ndim
==
3
# Allocate GPU memory for grid of coordinates
# Allocate GPU memory for grid of coordinates
grid
=
GpuArrayType
(
dtype
=
self
.
precision
,
grid
=
GpuArrayType
(
dtype
=
self
.
dtype
,
broadcastable
=
(
False
,
False
,
False
,
False
,),
broadcastable
=
(
False
,
False
,
False
,
False
,),
context_name
=
context_name
)()
context_name
=
context_name
)()
...
@@ -2947,14 +2947,14 @@ class GpuDnnGridSampler(DnnBase):
...
@@ -2947,14 +2947,14 @@ class GpuDnnGridSampler(DnnBase):
operations.
operations.
"""
"""
__props__
=
(
'
precision
'
,)
__props__
=
(
'
dtype
'
,)
_cop_num_inputs
=
6
_cop_num_inputs
=
6
_cop_num_outputs
=
1
_cop_num_outputs
=
1
def
__init__
(
self
,
precision
):
def
__init__
(
self
,
dtype
):
DnnBase
.
__init__
(
self
,
[
"c_code/spatialtf_sampler.c"
],
"spatialtf_sampler"
)
DnnBase
.
__init__
(
self
,
[
"c_code/spatialtf_sampler.c"
],
"spatialtf_sampler"
)
self
.
precision
=
precision
self
.
dtype
=
dtype
def
dnn_context
(
self
,
node
):
def
dnn_context
(
self
,
node
):
return
node
.
outputs
[
0
]
.
type
.
context_name
return
node
.
outputs
[
0
]
.
type
.
context_name
...
@@ -2967,7 +2967,7 @@ class GpuDnnGridSampler(DnnBase):
...
@@ -2967,7 +2967,7 @@ class GpuDnnGridSampler(DnnBase):
grid
=
as_gpuarray_variable
(
grid
,
context_name
)
grid
=
as_gpuarray_variable
(
grid
,
context_name
)
grid_dimensions
=
as_tensor_variable
(
grid_dimensions
)
grid_dimensions
=
as_tensor_variable
(
grid_dimensions
)
output
=
GpuArrayType
(
dtype
=
self
.
precision
,
output
=
GpuArrayType
(
dtype
=
self
.
dtype
,
broadcastable
=
img
.
type
.
ndim
*
(
False
,),
broadcastable
=
img
.
type
.
ndim
*
(
False
,),
context_name
=
context_name
)()
context_name
=
context_name
)()
...
@@ -2993,7 +2993,7 @@ class GpuDnnGridSampler(DnnBase):
...
@@ -2993,7 +2993,7 @@ class GpuDnnGridSampler(DnnBase):
pass
pass
def
dnn_spatialtf
(
img
,
theta
,
grid_dims
,
alpha
=
None
,
beta
=
None
,
precision
=
None
):
def
dnn_spatialtf
(
img
,
theta
,
grid_dims
,
alpha
=
None
,
beta
=
None
,
dtype
=
None
):
"""
"""
GPU spatial transformer using cuDNN from NVIDIA.
GPU spatial transformer using cuDNN from NVIDIA.
"""
"""
...
@@ -3001,18 +3001,18 @@ def dnn_spatialtf(img, theta, grid_dims, alpha=None, beta=None, precision=None):
...
@@ -3001,18 +3001,18 @@ def dnn_spatialtf(img, theta, grid_dims, alpha=None, beta=None, precision=None):
img
=
gpu_contiguous
(
img
)
img
=
gpu_contiguous
(
img
)
theta
=
gpu_contiguous
(
theta
)
theta
=
gpu_contiguous
(
theta
)
precision
=
get_precision
(
precision
,
[
img
,
theta
])
dtype
=
get_precision
(
dtype
,
[
img
,
theta
])
# Create spatial transformer descriptor
# Create spatial transformer descriptor
desc
=
GpuDnnSpatialTfDesc
(
grid_dims
,
precision
)()
desc
=
GpuDnnSpatialTfDesc
(
grid_dims
,
dtype
)()
# Create grid dimensions variable
# Create grid dimensions variable
grid_dims_var
=
as_tensor_variable
(
grid_dims
)
grid_dims_var
=
as_tensor_variable
(
grid_dims
)
# Setup grid of coordinates
# Setup grid of coordinates
grid_coord
=
GpuDnnGridGenerator
(
precision
)(
grid_dims_var
,
theta
,
desc
)
grid_coord
=
GpuDnnGridGenerator
(
dtype
)(
grid_dims_var
,
theta
,
desc
)
grid_sampler
=
GpuDnnGridSampler
(
precision
)(
img
,
grid_coord
,
grid_dims_var
,
desc
,
grid_sampler
=
GpuDnnGridSampler
(
dtype
)(
img
,
grid_coord
,
grid_dims_var
,
desc
,
alpha
,
beta
)
alpha
,
beta
)
return
grid_sampler
return
grid_sampler
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论