Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fd83d922
提交
fd83d922
authored
7月 26, 2017
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a CUDNNDataType wrapper to handle all the libraries and other such stuff.
上级
38bd170b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
34 行增加
和
18 行删除
+34
-18
dnn.py
theano/gpuarray/dnn.py
+34
-18
没有找到文件。
theano/gpuarray/dnn.py
浏览文件 @
fd83d922
...
@@ -224,6 +224,31 @@ def dnn_available(context_name):
...
@@ -224,6 +224,31 @@ def dnn_available(context_name):
dnn_available
.
msg
=
None
dnn_available
.
msg
=
None
def
CUDNNDataType
(
name
,
freefunc
=
None
):
hdirs
=
[]
if
config
.
dnn
.
include_path
:
hdirs
.
append
(
config
.
dnn
.
include_path
)
if
config
.
cuda
.
include_path
:
hdirs
.
append
(
config
.
cuda
.
include_path
)
ldirs
=
[]
if
config
.
dnn
.
library_path
:
ldirs
.
append
(
config
.
dnn
.
library_path
)
cargs
=
[]
if
config
.
dnn
.
bin_path
:
if
sys
.
platform
==
'darwin'
:
cargs
.
append
(
'-Wl,-rpath,'
+
config
.
dnn
.
bin_path
)
else
:
cargs
.
append
(
'-Wl,-rpath,"'
+
config
.
dnn
.
bin_path
+
'"'
)
return
CDataType
(
name
,
freefunc
,
headers
=
[
'cudnn.h'
],
header_dirs
=
hdirs
,
libraries
=
[
'cudnn'
],
lib_dirs
=
ldirs
,
compile_args
=
cargs
,
version
=
version
(
raises
=
False
))
class
DnnVersion
(
Op
):
class
DnnVersion
(
Op
):
__props__
=
()
__props__
=
()
...
@@ -311,12 +336,7 @@ def version(raises=True):
...
@@ -311,12 +336,7 @@ def version(raises=True):
return
version
.
v
return
version
.
v
version
.
v
=
None
version
.
v
=
None
handle_type
=
CDataType
(
'cudnnHandle_t'
,
'cudnnDestroy'
,
handle_type
=
CUDNNDataType
(
'cudnnHandle_t'
,
'cudnnDestroy'
)
headers
=
[
'cudnn.h'
],
header_dirs
=
[
config
.
dnn
.
include_path
],
libraries
=
[
'cudnn'
],
lib_dirs
=
[
config
.
dnn
.
library_path
],
version
=
version
(
raises
=
False
))
# Get cuDNN definitions to be used.
# Get cuDNN definitions to be used.
cudnn
=
cudnn_defs
.
get_definitions
(
version
(
raises
=
False
))
cudnn
=
cudnn_defs
.
get_definitions
(
version
(
raises
=
False
))
...
@@ -489,9 +509,8 @@ class GpuDnnConvDesc(COp):
...
@@ -489,9 +509,8 @@ class GpuDnnConvDesc(COp):
kern_shape
=
theano
.
tensor
.
basic
.
cast
(
kern_shape
,
'int64'
)
kern_shape
=
theano
.
tensor
.
basic
.
cast
(
kern_shape
,
'int64'
)
node
=
Apply
(
self
,
[
kern_shape
],
node
=
Apply
(
self
,
[
kern_shape
],
[
CDataType
(
"cudnnConvolutionDescriptor_t"
,
[
CUDNNDataType
(
"cudnnConvolutionDescriptor_t"
,
freefunc
=
"cudnnDestroyConvolutionDescriptor"
,
freefunc
=
"cudnnDestroyConvolutionDescriptor"
)()])
version
=
version
(
raises
=
False
))()])
# DebugMode cannot compare the values of CDataType variables, so by
# DebugMode cannot compare the values of CDataType variables, so by
# default it returns False all the time. To prevent DebugMode from
# default it returns False all the time. To prevent DebugMode from
# complaining because of the MergeOptimizer, we make this variable
# complaining because of the MergeOptimizer, we make this variable
...
@@ -1301,9 +1320,8 @@ class GpuDnnPoolDesc(Op):
...
@@ -1301,9 +1320,8 @@ class GpuDnnPoolDesc(Op):
def
make_node
(
self
):
def
make_node
(
self
):
node
=
Apply
(
self
,
[],
node
=
Apply
(
self
,
[],
[
CDataType
(
"cudnnPoolingDescriptor_t"
,
[
CUDNNDataType
(
"cudnnPoolingDescriptor_t"
,
freefunc
=
"cudnnDestroyPoolingDescriptor"
,
freefunc
=
"cudnnDestroyPoolingDescriptor"
)()])
version
=
version
(
raises
=
False
))()])
# DebugMode cannot compare the values of CDataType variables, so by
# DebugMode cannot compare the values of CDataType variables, so by
# default it returns False all the time. To prevent DebugMode from
# default it returns False all the time. To prevent DebugMode from
# complaining because of the MergeOptimizer, we make this variable
# complaining because of the MergeOptimizer, we make this variable
...
@@ -1961,9 +1979,8 @@ class GpuDnnBatchNormGrad(DnnBase):
...
@@ -1961,9 +1979,8 @@ class GpuDnnBatchNormGrad(DnnBase):
return
[
shape
[
0
],
shape
[
2
],
shape
[
2
]]
return
[
shape
[
0
],
shape
[
2
],
shape
[
2
]]
gpudata_type
=
CDataType
(
'gpudata *'
,
'gpudata_release'
)
gpudata_type
=
CDataType
(
'gpudata *'
,
'gpudata_release'
)
dropoutdesc_type
=
CDataType
(
'cudnnDropoutDescriptor_t'
,
dropoutdesc_type
=
CUDNNDataType
(
'cudnnDropoutDescriptor_t'
,
'cudnnDestroyDropoutDescriptor'
,
'cudnnDestroyDropoutDescriptor'
)
version
=
version
(
raises
=
False
))
class
GpuDnnDropoutOp
(
DnnBase
):
class
GpuDnnDropoutOp
(
DnnBase
):
...
@@ -2031,9 +2048,8 @@ def dropout(x, dropout=0.0, seed=4242):
...
@@ -2031,9 +2048,8 @@ def dropout(x, dropout=0.0, seed=4242):
y
,
odesc
=
GpuDnnDropoutOp
()(
x
,
desc
)
y
,
odesc
=
GpuDnnDropoutOp
()(
x
,
desc
)
return
y
,
desc
,
odesc
,
states
return
y
,
desc
,
odesc
,
states
rnndesc_type
=
CDataType
(
'cudnnRNNDescriptor_t'
,
rnndesc_type
=
CUDNNDataType
(
'cudnnRNNDescriptor_t'
,
'cudnnDestroyRNNDescriptor'
,
'cudnnDestroyRNNDescriptor'
)
version
=
version
(
raises
=
False
))
def
as_i32
(
v
):
def
as_i32
(
v
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论