Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cf1aa9bf
提交
cf1aa9bf
authored
8月 27, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Factor out the config flags for dnn to avoid errors.
上级
c20412f4
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
47 行增加
和
63 行删除
+47
-63
dnn.py
theano/sandbox/cuda/dnn.py
+4
-46
dnn_flags.py
theano/sandbox/dnn_flags.py
+42
-0
dnn.py
theano/sandbox/gpuarray/dnn.py
+1
-17
没有找到文件。
theano/sandbox/cuda/dnn.py
浏览文件 @
cf1aa9bf
...
...
@@ -10,7 +10,6 @@ from theano.gof import Optimizer, local_optimizer, COp
from
theano.gof.type
import
CDataType
,
Generic
from
theano.compile
import
optdb
from
theano.compile.ops
import
shape_i
from
theano.configparser
import
AddConfigVar
,
EnumStr
from
theano.tensor.nnet
import
SoftmaxGrad
from
theano.tensor.signal.downsample
import
(
DownsampleFactorMax
,
MaxPoolGrad
,
AveragePoolGrad
)
...
...
@@ -28,6 +27,8 @@ from theano.sandbox.cuda import gpu_seqopt, register_opt
from
theano.sandbox.cuda.nvcc_compiler
import
NVCC_compiler
import
theano.sandbox.dnn_flags
def
dnn_available
():
if
dnn_available
.
avail
is
None
:
...
...
@@ -62,8 +63,8 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
# exclusive mode, this cause bad detection.
comp
,
out
,
err
=
NVCC_compiler
.
try_flags
(
[
"-l"
,
"cudnn"
,
"-I"
+
os
.
path
.
dirname
(
__file__
),
"-I"
+
os
.
path
.
join
(
theano
.
config
.
cuda
.
root
,
'include'
)
,
"-L"
+
os
.
path
.
join
(
theano
.
config
.
cuda
.
root
,
'lib64'
)
],
"-I"
+
config
.
dnn
.
include_path
,
"-L"
+
config
.
dnn
.
library_path
],
preambule
=
preambule
,
body
=
body
,
try_run
=
False
,
output
=
True
)
...
...
@@ -141,7 +142,6 @@ if (%(err)s != CUDNN_STATUS_SUCCESS) {
%(fail)
s
}
}
"""
%
dict
(
var
=
var
,
err
=
err
,
desc
=
desc
,
fail
=
fail
)
...
...
@@ -359,37 +359,9 @@ class GpuDnnConvDesc(GpuOp):
def
c_code_cache_version
(
self
):
return
(
2
,
version
())
AddConfigVar
(
'dnn.conv.workmem'
,
"This flag is deprecated; use dnn.conv.algo_fwd."
,
EnumStr
(
''
),
in_c_key
=
False
)
AddConfigVar
(
'dnn.conv.workmem_bwd'
,
"This flag is deprecated; use dnn.conv.algo_bwd."
,
EnumStr
(
''
),
in_c_key
=
False
)
AddConfigVar
(
'dnn.conv.algo_fwd'
,
"Default implementation to use for CuDNN forward convolution."
,
EnumStr
(
'small'
,
'none'
,
'large'
,
'fft'
,
'guess_once'
,
'guess_on_shape_change'
,
'time_once'
,
'time_on_shape_change'
),
in_c_key
=
False
)
AddConfigVar
(
'dnn.conv.algo_bwd'
,
"Default implementation to use for CuDNN backward convolution."
,
EnumStr
(
'none'
,
'deterministic'
,
'fft'
,
'guess_once'
,
'guess_on_shape_change'
,
'time_once'
,
'time_on_shape_change'
),
in_c_key
=
False
)
# scalar constants
_zero
=
constant
(
numpy
.
asarray
(
0.0
,
dtype
=
'float32'
))
_one
=
constant
(
numpy
.
asarray
(
1.0
,
dtype
=
'float32'
))
_ifour
=
constant
(
numpy
.
asarray
(
4
,
dtype
=
'int32'
))
_ifive
=
constant
(
numpy
.
asarray
(
5
,
dtype
=
'int32'
))
def
ensure_float
(
val
,
default
,
name
):
...
...
@@ -406,20 +378,6 @@ def ensure_float(val, default, name):
return
val
def
ensure_int
(
val
,
default
,
name
):
if
val
is
None
:
return
default
.
clone
()
if
not
isinstance
(
val
,
Variable
):
val
=
constant
(
val
)
if
hasattr
(
val
,
'ndim'
)
and
val
.
ndim
==
0
:
val
=
as_scalar
(
val
)
if
not
isinstance
(
val
.
type
,
theano
.
scalar
.
Scalar
):
raise
TypeError
(
"
%
s: expected a scalar value"
%
(
name
,))
if
not
val
.
type
.
dtype
==
'int32'
:
raise
TypeError
(
"
%
s: type is not int32"
%
(
name
,))
return
val
class
GpuDnnConv
(
DnnBase
,
COp
):
"""
The forward convolution.
...
...
theano/sandbox/dnn_flags.py
0 → 100644
浏览文件 @
cf1aa9bf
"""
This module contains the configuration flags for cudnn support.
Those are shared between the cuda and gpuarray backend which is why
they are in this file.
"""
import
os.path
from
theano.configparser
import
AddConfigVar
,
EnumStr
,
StrParam
from
theano
import
config
AddConfigVar
(
'dnn.conv.workmem'
,
"This flag is deprecated; use dnn.conv.algo_fwd."
,
EnumStr
(
''
),
in_c_key
=
False
)
AddConfigVar
(
'dnn.conv.workmem_bwd'
,
"This flag is deprecated; use dnn.conv.algo_bwd."
,
EnumStr
(
''
),
in_c_key
=
False
)
AddConfigVar
(
'dnn.conv.algo_fwd'
,
"Default implementation to use for CuDNN forward convolution."
,
EnumStr
(
'small'
,
'none'
,
'large'
,
'fft'
,
'guess_once'
,
'guess_on_shape_change'
,
'time_once'
,
'time_on_shape_change'
),
in_c_key
=
False
)
AddConfigVar
(
'dnn.conv.algo_bwd'
,
"Default implementation to use for CuDNN backward convolution."
,
EnumStr
(
'none'
,
'deterministic'
,
'fft'
,
'guess_once'
,
'guess_on_shape_change'
,
'time_once'
,
'time_on_shape_change'
),
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'
)))
theano/sandbox/gpuarray/dnn.py
浏览文件 @
cf1aa9bf
...
...
@@ -10,7 +10,6 @@ from theano.gof.cmodule import GCC_compiler
from
theano.gof.type
import
CDataType
,
Generic
from
theano.compile
import
optdb
from
theano.compile.ops
import
shape_i
from
theano.configparser
import
AddConfigVar
,
EnumStr
,
StrParam
from
theano.tensor.nnet
import
SoftmaxGrad
from
theano.tensor.signal.downsample
import
(
DownsampleFactorMax
,
MaxPoolGrad
,
AveragePoolGrad
)
...
...
@@ -27,21 +26,7 @@ from .nnet import GpuSoftmax
from
.opt
import
gpu_seqopt
,
register_opt
,
conv_groupopt
,
op_lifter
from
.opt_util
import
alpha_merge
,
output_merge
# 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'
)))
from
theano.sandbox
import
dnn_flags
def
dnn_available
():
...
...
@@ -186,7 +171,6 @@ class DnnBase(COp):
class
DnnVersion
(
Op
):
__props__
=
()
def
c_headers
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论