Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f90f78ae
提交
f90f78ae
authored
9月 02, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Flake8 fixes.
上级
383670fd
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
13 行增加
和
20 行删除
+13
-20
dnn.py
theano/sandbox/gpuarray/dnn.py
+13
-20
没有找到文件。
theano/sandbox/gpuarray/dnn.py
浏览文件 @
f90f78ae
...
@@ -27,7 +27,8 @@ from .nnet import GpuSoftmax
...
@@ -27,7 +27,8 @@ 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
theano.sandbox
import
dnn_flags
# We need to import this to define the flags.
from
theano.sandbox
import
dnn_flags
# noqa
def
dnn_available
():
def
dnn_available
():
...
@@ -80,7 +81,6 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
...
@@ -80,7 +81,6 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
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.
v
=
version
()
if
version
()
==
20
:
if
version
()
==
20
:
dnn_available
.
avail
=
False
dnn_available
.
avail
=
False
dnn_available
.
msg
=
(
dnn_available
.
msg
=
(
...
@@ -1316,7 +1316,7 @@ class GpuDnnSoftmaxBase(DnnBase):
...
@@ -1316,7 +1316,7 @@ class GpuDnnSoftmaxBase(DnnBase):
Parameters
Parameters
----------
----------
tensor_format
tensor_format
Whether the data format is 'bc01' or 'b01c'
.
*deprecated* Ignored, will look at the strides of the input(s)
.
algo
algo
'fast' or 'accurate' indicating whether computations should be
'fast' or 'accurate' indicating whether computations should be
optimized for speed or accuracy respectively.
optimized for speed or accuracy respectively.
...
@@ -1327,12 +1327,10 @@ class GpuDnnSoftmaxBase(DnnBase):
...
@@ -1327,12 +1327,10 @@ class GpuDnnSoftmaxBase(DnnBase):
"""
"""
__props__
=
(
'
tensor_format'
,
'
mode'
,
'algo'
)
__props__
=
(
'mode'
,
'algo'
)
def
__init__
(
self
,
tensor_format
,
algo
,
mode
):
def
__init__
(
self
,
_
,
algo
,
mode
):
assert
(
tensor_format
in
(
'bc01'
,
'b01c'
))
DnnBase
.
__init__
(
self
)
DnnBase
.
__init__
(
self
)
self
.
tensor_format
=
tensor_format
assert
(
algo
in
(
'fast'
,
'accurate'
,
'log'
))
assert
(
algo
in
(
'fast'
,
'accurate'
,
'log'
))
if
algo
==
'log'
and
version
()
<
3000
:
if
algo
==
'log'
and
version
()
<
3000
:
...
@@ -1398,11 +1396,6 @@ cudnnStatus_t err%(name)s;
...
@@ -1398,11 +1396,6 @@ cudnnStatus_t err%(name)s;
ins
=
inputs
ins
=
inputs
outs
,
=
outputs
outs
,
=
outputs
if
self
.
tensor_format
==
'b01c'
:
tensor_format
=
"CUDNN_TENSOR_NHWC"
else
:
tensor_format
=
"CUDNN_TENSOR_NCHW"
if
self
.
mode
==
'instance'
:
if
self
.
mode
==
'instance'
:
mode
=
"CUDNN_SOFTMAX_MODE_INSTANCE"
mode
=
"CUDNN_SOFTMAX_MODE_INSTANCE"
else
:
else
:
...
@@ -1465,7 +1458,7 @@ class GpuDnnSoftmax(GpuDnnSoftmaxBase):
...
@@ -1465,7 +1458,7 @@ class GpuDnnSoftmax(GpuDnnSoftmaxBase):
Op for the cuDNN Softmax.
Op for the cuDNN Softmax.
tensor_format
tensor_format
Whether the data format is 'bc01' or 'b01c'
.
*deprecated* Ignored, will look at input strides
.
algo
algo
'fast' or 'accurate' indicating whether computations should be
'fast' or 'accurate' indicating whether computations should be
optimized for speed or accuracy respectively.
optimized for speed or accuracy respectively.
...
@@ -1508,10 +1501,10 @@ err%(name)s = cudnnSoftmaxForward(
...
@@ -1508,10 +1501,10 @@ err%(name)s = cudnnSoftmaxForward(
g_sm
,
=
grads
g_sm
,
=
grads
sm
=
self
.
make_node
(
x
)
.
outputs
[
0
]
sm
=
self
.
make_node
(
x
)
.
outputs
[
0
]
return
[
GpuDnnSoftmaxGrad
(
return
[
GpuDnnSoftmaxGrad
(
self
.
tensor_format
,
None
,
self
.
algo
,
self
.
algo
,
self
.
mode
self
.
mode
)(
g_sm
,
sm
)]
)(
g_sm
,
sm
)]
class
GpuDnnSoftmaxGrad
(
GpuDnnSoftmaxBase
):
class
GpuDnnSoftmaxGrad
(
GpuDnnSoftmaxBase
):
...
@@ -1521,7 +1514,7 @@ class GpuDnnSoftmaxGrad(GpuDnnSoftmaxBase):
...
@@ -1521,7 +1514,7 @@ class GpuDnnSoftmaxGrad(GpuDnnSoftmaxBase):
Parameters
Parameters
----------
----------
tensor_format
tensor_format
Whether the data format is 'bc01' or 'b01c'
.
*deprecated* Ignored, will look at the input strides
.
algo
algo
'fast' or 'accurate' indicating whether computations should be
'fast' or 'accurate' indicating whether computations should be
optimized for speed or accuracy respectively.
optimized for speed or accuracy respectively.
...
@@ -1770,6 +1763,7 @@ def local_softmax_dnn(node):
...
@@ -1770,6 +1763,7 @@ def local_softmax_dnn(node):
out
=
as_gpuarray_variable
(
out
.
dimshuffle
(
0
,
1
))
out
=
as_gpuarray_variable
(
out
.
dimshuffle
(
0
,
1
))
return
[
out
]
return
[
out
]
@register_opt
(
'cudnn'
)
@register_opt
(
'cudnn'
)
@local_optimizer
([
GpuElemwise
])
@local_optimizer
([
GpuElemwise
])
def
local_log_softmax_dnn
(
node
):
def
local_log_softmax_dnn
(
node
):
...
@@ -1782,8 +1776,7 @@ def local_log_softmax_dnn(node):
...
@@ -1782,8 +1776,7 @@ def local_log_softmax_dnn(node):
isinstance
(
node
.
inputs
[
0
]
.
owner
.
op
,
GpuDnnSoftmax
)
and
isinstance
(
node
.
inputs
[
0
]
.
owner
.
op
,
GpuDnnSoftmax
)
and
len
(
node
.
inputs
[
0
]
.
clients
)
==
1
):
len
(
node
.
inputs
[
0
]
.
clients
)
==
1
):
softmax_node
=
node
.
inputs
[
0
]
.
owner
softmax_node
=
node
.
inputs
[
0
]
.
owner
new_softmax
=
GpuDnnSoftmax
(
softmax_node
.
op
.
tensor_format
,
'log'
,
new_softmax
=
GpuDnnSoftmax
(
None
,
'log'
,
softmax_node
.
op
.
mode
)
softmax_node
.
op
.
mode
)
return
[
new_softmax
(
softmax_node
.
inputs
[
0
])]
return
[
new_softmax
(
softmax_node
.
inputs
[
0
])]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论