Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
dba4873c
提交
dba4873c
authored
6月 26, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stop using NVCC_compiler since it's not actually useful.
上级
ce264c0e
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
39 行增加
和
24 行删除
+39
-24
dnn.py
theano/sandbox/gpuarray/dnn.py
+39
-24
没有找到文件。
theano/sandbox/gpuarray/dnn.py
浏览文件 @
dba4873c
...
@@ -6,10 +6,11 @@ from theano import Op, Apply, tensor, config, Variable
...
@@ -6,10 +6,11 @@ from theano import Op, Apply, tensor, config, Variable
from
theano.scalar
import
as_scalar
,
constant
from
theano.scalar
import
as_scalar
,
constant
from
theano.gradient
import
DisconnectedType
,
grad_not_implemented
from
theano.gradient
import
DisconnectedType
,
grad_not_implemented
from
theano.gof
import
Optimizer
,
local_optimizer
,
COp
from
theano.gof
import
Optimizer
,
local_optimizer
,
COp
from
theano.gof.cmodule
import
GCC_compiler
from
theano.gof.type
import
CDataType
,
Generic
from
theano.gof.type
import
CDataType
,
Generic
from
theano.compile
import
optdb
from
theano.compile
import
optdb
from
theano.compile.ops
import
shape_i
from
theano.compile.ops
import
shape_i
from
theano.configparser
import
AddConfigVar
,
EnumStr
from
theano.configparser
import
AddConfigVar
,
EnumStr
,
StrParam
from
theano.tensor.nnet
import
SoftmaxGrad
from
theano.tensor.nnet
import
SoftmaxGrad
from
theano.tensor.signal.downsample
import
(
from
theano.tensor.signal.downsample
import
(
DownsampleFactorMax
,
DownsampleFactorMaxGrad
)
DownsampleFactorMax
,
DownsampleFactorMaxGrad
)
...
@@ -25,7 +26,22 @@ from .conv import GpuConv
...
@@ -25,7 +26,22 @@ from .conv import GpuConv
from
.nnet
import
GpuSoftmax
from
.nnet
import
GpuSoftmax
from
.opt
import
gpu_seqopt
,
register_opt
,
conv_groupopt
,
op_lifter
from
.opt
import
gpu_seqopt
,
register_opt
,
conv_groupopt
,
op_lifter
from
.opt_util
import
alpha_merge
,
output_merge
from
.opt_util
import
alpha_merge
,
output_merge
from
.comp
import
NVCC_compiler
# This is to avoid conflict with the one in cuda/dnn.py
if
not
hasattr
(
config
,
'dnn'
):
AddConfigVar
(
'dnn.conv.workmem'
,
"Default value for the workmem attribute of cudnn "
"convolutions."
,
EnumStr
(
'small'
,
'none'
,
'large'
),
in_c_key
=
False
)
AddConfigVar
(
'dnn.include_path'
,
"Location of the cudnn header (defaults to the cuda root)"
,
StrParam
(
lambda
:
os
.
path
.
join
(
config
.
cuda
.
root
,
'include'
)))
AddConfigVar
(
'dnn.library_path'
,
"Location of the cudnn header (defaults to the cuda root)"
,
StrParam
(
lambda
:
os
.
path
.
join
(
config
.
cuda
.
root
,
'lib64'
)))
def
dnn_available
():
def
dnn_available
():
...
@@ -64,17 +80,17 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
...
@@ -64,17 +80,17 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
# default gpu, not the one selected by the user. If mixed
# default gpu, not the one selected by the user. If mixed
# GPU are installed or if the GPUs are configured in
# GPU are installed or if the GPUs are configured in
# exclusive mode, this cause bad detection.
# exclusive mode, this cause bad detection.
comp
,
out
,
err
=
NV
CC_compiler
.
try_flags
(
comp
,
out
,
err
=
G
CC_compiler
.
try_flags
(
[
"-l"
,
"cudnn"
,
"-I"
+
os
.
path
.
dirname
(
__file__
),
[
"-l"
,
"cudnn"
,
"-I"
+
os
.
path
.
dirname
(
__file__
),
"-I"
+
os
.
path
.
join
(
theano
.
config
.
cuda
.
root
,
'include'
)
,
"-I"
+
config
.
dnn
.
include_path
,
"-L"
+
os
.
path
.
join
(
theano
.
config
.
cuda
.
root
,
'lib64'
)
],
"-L"
+
config
.
dnn
.
library_path
],
preambule
=
preambule
,
body
=
body
,
preambule
=
preambule
,
body
=
body
,
try_run
=
False
,
output
=
True
)
try_run
=
False
,
output
=
True
)
dnn_available
.
avail
=
comp
dnn_available
.
avail
=
comp
if
not
dnn_available
.
avail
:
if
not
dnn_available
.
avail
:
dnn_available
.
msg
=
(
dnn_available
.
msg
=
(
"Theano can
not compile with cuDNN. We got this error:
\n
"
+
"Theano cannot compile with cuDNN. We got this error:
\n
"
+
str
(
err
))
str
(
err
))
else
:
else
:
# If we can compile, check that we can import and run.
# If we can compile, check that we can import and run.
...
@@ -149,22 +165,29 @@ class DnnBase(COp):
...
@@ -149,22 +165,29 @@ class DnnBase(COp):
'gpuarray_api.h'
]
'gpuarray_api.h'
]
def
c_header_dirs
(
self
):
def
c_header_dirs
(
self
):
return
[
os
.
path
.
dirname
(
__file__
),
pygpu
.
get_include
()]
return
[
os
.
path
.
dirname
(
__file__
),
pygpu
.
get_include
(),
config
.
dnn
.
include_path
]
def
c_libraries
(
self
):
def
c_libraries
(
self
):
return
[
'cudnn'
,
'gpuarray'
]
return
[
'cudnn'
,
'gpuarray'
]
def
c_lib_dirs
(
self
):
return
[
config
.
dnn
.
library_path
]
class
DnnVersion
(
Op
):
def
c_compiler
(
self
):
return
NVCC_compiler
class
DnnVersion
(
Op
):
def
c_headers
(
self
):
def
c_headers
(
self
):
return
[
'cudnn.h'
]
return
[
'cudnn.h'
]
def
c_header_dirs
(
self
):
return
[
config
.
dnn
.
include_path
]
def
c_libraries
(
self
):
def
c_libraries
(
self
):
return
[
'cudnn'
]
return
[
'cudnn'
]
def
c_lib_dirs
(
self
):
return
[
config
.
dnn
.
library_path
]
def
c_support_code
(
self
):
def
c_support_code
(
self
):
return
"""
return
"""
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
...
@@ -229,13 +252,13 @@ class GpuDnnConvDesc(Op):
...
@@ -229,13 +252,13 @@ class GpuDnnConvDesc(Op):
return
[
'cudnn.h'
,
'cudnn_helper.h'
]
return
[
'cudnn.h'
,
'cudnn_helper.h'
]
def
c_header_dirs
(
self
):
def
c_header_dirs
(
self
):
return
[
os
.
path
.
dirname
(
__file__
)]
return
[
os
.
path
.
dirname
(
__file__
)
,
config
.
dnn
.
include_path
]
def
c_libraries
(
self
):
def
c_libraries
(
self
):
return
[
'cudnn'
]
return
[
'cudnn'
]
def
c_
compiler
(
self
):
def
c_
lib_dirs
(
self
):
return
NVCC_compiler
return
[
config
.
dnn
.
library_path
]
def
__init__
(
self
,
border_mode
,
subsample
=
(
1
,
1
),
conv_mode
=
'conv'
):
def
__init__
(
self
,
border_mode
,
subsample
=
(
1
,
1
),
conv_mode
=
'conv'
):
if
isinstance
(
border_mode
,
int
):
if
isinstance
(
border_mode
,
int
):
...
@@ -349,14 +372,6 @@ class GpuDnnConvDesc(Op):
...
@@ -349,14 +372,6 @@ class GpuDnnConvDesc(Op):
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
1
,
version
())
return
(
1
,
version
())
# This is to avoid conflict with the one in cuda/dnn.py
if
not
hasattr
(
config
,
'dnn'
):
AddConfigVar
(
'dnn.conv.workmem'
,
"Default value for the workmem attribute of cudnn "
"convolutions."
,
EnumStr
(
'small'
,
'none'
,
'large'
),
in_c_key
=
False
)
# scalar constants
# scalar constants
_zero
=
constant
(
numpy
.
asarray
(
0.0
,
dtype
=
'float64'
))
_zero
=
constant
(
numpy
.
asarray
(
0.0
,
dtype
=
'float64'
))
_one
=
constant
(
numpy
.
asarray
(
1.0
,
dtype
=
'float64'
))
_one
=
constant
(
numpy
.
asarray
(
1.0
,
dtype
=
'float64'
))
...
@@ -735,13 +750,13 @@ class GpuDnnPoolDesc(Op):
...
@@ -735,13 +750,13 @@ class GpuDnnPoolDesc(Op):
return
[
'cudnn.h'
,
'cudnn_helper.h'
]
return
[
'cudnn.h'
,
'cudnn_helper.h'
]
def
c_header_dirs
(
self
):
def
c_header_dirs
(
self
):
return
[
os
.
path
.
dirname
(
__file__
)]
return
[
os
.
path
.
dirname
(
__file__
)
,
config
.
dnn
.
include_path
]
def
c_libraries
(
self
):
def
c_libraries
(
self
):
return
[
'cudnn'
]
return
[
'cudnn'
]
def
c_
compiler
(
self
):
def
c_
lib_dirs
(
self
):
return
NVCC_compiler
return
[
config
.
dnn
.
library_path
]
def
do_constant_folding
(
self
,
node
):
def
do_constant_folding
(
self
,
node
):
return
False
return
False
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论