Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
260fc9a7
提交
260fc9a7
authored
3月 18, 2016
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4258 from lamblin/fix_debugmode_dnn
Fixes for debugmode in dnn and gpuarray
上级
153b0dfb
32645f15
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
42 行增加
和
22 行删除
+42
-22
dnn.py
theano/sandbox/cuda/dnn.py
+8
-1
test_dnn.py
theano/sandbox/cuda/tests/test_dnn.py
+8
-8
basic_ops.py
theano/sandbox/gpuarray/basic_ops.py
+2
-0
blas.py
theano/sandbox/gpuarray/blas.py
+2
-1
dnn.py
theano/sandbox/gpuarray/dnn.py
+16
-2
neighbours.py
theano/sandbox/gpuarray/neighbours.py
+4
-0
test_basic.py
theano/tensor/tests/test_basic.py
+2
-10
没有找到文件。
theano/sandbox/cuda/dnn.py
浏览文件 @
260fc9a7
...
@@ -1322,9 +1322,16 @@ class GpuDnnPoolDesc(GpuOp):
...
@@ -1322,9 +1322,16 @@ class GpuDnnPoolDesc(GpuOp):
if
self
.
pad
!=
(
0
,
0
)
and
version
()
==
-
1
:
if
self
.
pad
!=
(
0
,
0
)
and
version
()
==
-
1
:
raise
RuntimeError
(
"CuDNN pooling with padding requires CuDNN v2"
)
raise
RuntimeError
(
"CuDNN pooling with padding requires CuDNN v2"
)
return
Apply
(
self
,
[],
node
=
Apply
(
self
,
[],
[
CDataType
(
"cudnnPoolingDescriptor_t"
,
[
CDataType
(
"cudnnPoolingDescriptor_t"
,
freefunc
=
"cudnnDestroyPoolingDescriptor"
)()])
freefunc
=
"cudnnDestroyPoolingDescriptor"
)()])
# DebugMode cannot compare the values of CDataType variables, so by
# default it returns False all the time. To prevent DebugMode from
# complaining because of the MergeOptimizer, we make this variable
# always compare to True.
out
=
node
.
outputs
[
0
]
out
.
tag
.
values_eq_approx
=
tensor
.
type
.
values_eq_approx_always_true
return
node
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
desc
,
=
outputs
desc
,
=
outputs
...
...
theano/sandbox/cuda/tests/test_dnn.py
浏览文件 @
260fc9a7
...
@@ -412,6 +412,13 @@ def test_pooling3d():
...
@@ -412,6 +412,13 @@ def test_pooling3d():
if
not
cuda
.
dnn
.
dnn_available
()
or
cuda
.
dnn
.
version
()
<
(
3000
,
3000
):
if
not
cuda
.
dnn
.
dnn_available
()
or
cuda
.
dnn
.
version
()
<
(
3000
,
3000
):
raise
SkipTest
(
cuda
.
dnn
.
dnn_available
.
msg
)
raise
SkipTest
(
cuda
.
dnn
.
dnn_available
.
msg
)
# For max pooling pool3d2d explicitly pads the input with
# -inf. Because of this, the compilation mode for the function
# that uses pool3d2d should not check for infinite values or
# it will falsely believe there is a error in the graph.
mode_without_gpu2
=
mode_without_gpu
.
including
()
mode_without_gpu2
.
check_isfinite
=
False
# 'average_exc_pad' is disabled for versions < 4004
# 'average_exc_pad' is disabled for versions < 4004
if
cuda
.
dnn
.
version
()
<
(
4004
,
4004
):
if
cuda
.
dnn
.
version
()
<
(
4004
,
4004
):
modes
=
(
'max'
,
'average_inc_pad'
)
modes
=
(
'max'
,
'average_inc_pad'
)
...
@@ -447,13 +454,6 @@ def test_pooling3d():
...
@@ -447,13 +454,6 @@ def test_pooling3d():
strides
=
(
stride
,
stride
,
stride
),
strides
=
(
stride
,
stride
,
stride
),
pad
=
pad
,
pool_func
=
func
)
pad
=
pad
,
pool_func
=
func
)
# For max pooling pool3d2d explicitly pads the input with
# -inf. Because of this, the compilation mode for the function
# that uses pool3d2d should not check for infinite values or
# it will falsely believe there is a error in the graph.
mode_without_gpu2
=
mode_without_gpu
.
including
()
mode_without_gpu2
.
check_isfinite
=
False
f1
=
theano
.
function
([
x
],
out1
,
mode
=
mode_with_gpu
)
f1
=
theano
.
function
([
x
],
out1
,
mode
=
mode_with_gpu
)
assert
any
([
isinstance
(
node
.
op
,
cuda
.
dnn
.
GpuDnnPool
)
assert
any
([
isinstance
(
node
.
op
,
cuda
.
dnn
.
GpuDnnPool
)
for
node
in
f1
.
maker
.
fgraph
.
apply_nodes
])
for
node
in
f1
.
maker
.
fgraph
.
apply_nodes
])
...
@@ -512,7 +512,7 @@ def test_pooling3d():
...
@@ -512,7 +512,7 @@ def test_pooling3d():
strides
=
(
stride
,
stride
,
stride
),
strides
=
(
stride
,
stride
,
stride
),
pad
=
pad
,
pool_func
=
func
)
pad
=
pad
,
pool_func
=
func
)
fc
=
theano
.
function
([
x
],
theano
.
grad
(
out
.
sum
(),
x
),
fc
=
theano
.
function
([
x
],
theano
.
grad
(
out
.
sum
(),
x
),
mode
=
mode_without_gpu
)
mode
=
mode_without_gpu
2
)
c_out
=
fc
(
data
)
c_out
=
fc
(
data
)
utt
.
assert_allclose
(
c_out
,
g_out
)
utt
.
assert_allclose
(
c_out
,
g_out
)
...
...
theano/sandbox/gpuarray/basic_ops.py
浏览文件 @
260fc9a7
...
@@ -996,6 +996,8 @@ class GpuJoin(HideC, Join):
...
@@ -996,6 +996,8 @@ class GpuJoin(HideC, Join):
def
perform
(
self
,
node
,
axis_and_tensors
,
out_
,
ctx
):
def
perform
(
self
,
node
,
axis_and_tensors
,
out_
,
ctx
):
out
,
=
out_
out
,
=
out_
axis
=
int
(
axis_and_tensors
[
0
])
axis
=
int
(
axis_and_tensors
[
0
])
if
axis
<
0
:
axis
+=
axis_and_tensors
[
1
]
.
ndim
tensors
=
axis_and_tensors
[
1
:]
tensors
=
axis_and_tensors
[
1
:]
out
[
0
]
=
pygpu
.
concatenate
(
tensors
,
axis
=
axis
,
context
=
ctx
)
.
astype
(
out
[
0
]
=
pygpu
.
concatenate
(
tensors
,
axis
=
axis
,
context
=
ctx
)
.
astype
(
node
.
outputs
[
0
]
.
dtype
)
node
.
outputs
[
0
]
.
dtype
)
...
...
theano/sandbox/gpuarray/blas.py
浏览文件 @
260fc9a7
...
@@ -287,7 +287,8 @@ class GpuDot22(BlasOp):
...
@@ -287,7 +287,8 @@ class GpuDot22(BlasOp):
def
perform
(
self
,
node
,
inputs
,
outputs
):
def
perform
(
self
,
node
,
inputs
,
outputs
):
x
,
y
=
inputs
x
,
y
=
inputs
out
=
pygpu
.
empty
((
x
.
shape
[
0
],
y
.
shape
[
1
]),
dtype
=
x
.
dtype
)
out
=
pygpu
.
empty
((
x
.
shape
[
0
],
y
.
shape
[
1
]),
dtype
=
x
.
dtype
,
context
=
x
.
context
)
outputs
[
0
][
0
]
=
blas
.
gemm
(
1.
,
x
,
y
,
0.
,
out
,
outputs
[
0
][
0
]
=
blas
.
gemm
(
1.
,
x
,
y
,
0.
,
out
,
overwrite_c
=
True
)
overwrite_c
=
True
)
...
...
theano/sandbox/gpuarray/dnn.py
浏览文件 @
260fc9a7
...
@@ -307,9 +307,16 @@ class GpuDnnConvDesc(COp):
...
@@ -307,9 +307,16 @@ class GpuDnnConvDesc(COp):
if
kern_shape
.
type
.
ndim
!=
1
or
kern_shape
.
type
.
dtype
!=
'int64'
:
if
kern_shape
.
type
.
ndim
!=
1
or
kern_shape
.
type
.
dtype
!=
'int64'
:
raise
TypeError
(
'kern must be 1D shape tensor'
)
raise
TypeError
(
'kern must be 1D shape tensor'
)
return
Apply
(
self
,
[
kern_shape
],
node
=
Apply
(
self
,
[
kern_shape
],
[
CDataType
(
"cudnnConvolutionDescriptor_t"
,
[
CDataType
(
"cudnnConvolutionDescriptor_t"
,
freefunc
=
"cudnnDestroyConvolutionDescriptor"
)()])
freefunc
=
"cudnnDestroyConvolutionDescriptor"
)()])
# DebugMode cannot compare the values of CDataType variables, so by
# default it returns False all the time. To prevent DebugMode from
# complaining because of the MergeOptimizer, we make this variable
# always compare to True.
out
=
node
.
outputs
[
0
]
out
.
tag
.
values_eq_approx
=
tensor
.
type
.
values_eq_approx_always_true
return
node
def
get_op_params
(
self
):
def
get_op_params
(
self
):
pad0
=
'0'
pad0
=
'0'
...
@@ -998,9 +1005,16 @@ class GpuDnnPoolDesc(Op):
...
@@ -998,9 +1005,16 @@ class GpuDnnPoolDesc(Op):
self
.
pad
=
(
0
,
0
)
self
.
pad
=
(
0
,
0
)
def
make_node
(
self
):
def
make_node
(
self
):
return
Apply
(
self
,
[],
node
=
Apply
(
self
,
[],
[
CDataType
(
"cudnnPoolingDescriptor_t"
,
[
CDataType
(
"cudnnPoolingDescriptor_t"
,
freefunc
=
"cudnnDestroyPoolingDescriptor"
)()])
freefunc
=
"cudnnDestroyPoolingDescriptor"
)()])
# DebugMode cannot compare the values of CDataType variables, so by
# default it returns False all the time. To prevent DebugMode from
# complaining because of the MergeOptimizer, we make this variable
# always compare to True.
out
=
node
.
outputs
[
0
]
out
.
tag
.
values_eq_approx
=
tensor
.
type
.
values_eq_approx_always_true
return
node
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
desc
,
=
outputs
desc
,
=
outputs
...
...
theano/sandbox/gpuarray/neighbours.py
浏览文件 @
260fc9a7
...
@@ -462,6 +462,10 @@ class GpuImages2Neibs(GpuKernelBase, Images2Neibs, Op):
...
@@ -462,6 +462,10 @@ class GpuImages2Neibs(GpuKernelBase, Images2Neibs, Op):
} // END NESTED SCOPE
} // END NESTED SCOPE
"""
%
locals
()
"""
%
locals
()
def
perform
(
self
,
node
,
inp
,
out
,
ctx
):
# Disable the perform method from the CPU version
Op
.
perform
(
self
,
node
,
inp
,
out
,
ctx
)
@op_lifter
([
Images2Neibs
])
@op_lifter
([
Images2Neibs
])
def
use_gpu_images2neibs
(
node
,
context_name
):
def
use_gpu_images2neibs
(
node
,
context_name
):
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
260fc9a7
...
@@ -3884,11 +3884,7 @@ class T_Join_and_Split(unittest.TestCase):
...
@@ -3884,11 +3884,7 @@ class T_Join_and_Split(unittest.TestCase):
got
=
f
(
-
2
)
got
=
f
(
-
2
)
assert
numpy
.
allclose
(
got
,
want
)
assert
numpy
.
allclose
(
got
,
want
)
try
:
self
.
assertRaises
((
IndexError
,
OverflowError
),
f
,
-
3
)
got
=
f
(
-
3
)
assert
False
except
IndexError
:
pass
def
test_join_matrixC_negative_axis
(
self
):
def
test_join_matrixC_negative_axis
(
self
):
"""constant join negative axis"""
"""constant join negative axis"""
...
@@ -3920,11 +3916,7 @@ class T_Join_and_Split(unittest.TestCase):
...
@@ -3920,11 +3916,7 @@ class T_Join_and_Split(unittest.TestCase):
got
=
f
()
got
=
f
()
assert
numpy
.
allclose
(
got
,
want
)
assert
numpy
.
allclose
(
got
,
want
)
try
:
self
.
assertRaises
((
IndexError
,
OverflowError
),
join
,
-
3
,
a
,
b
)
s
=
join
(
-
3
,
a
,
b
)
assert
False
except
IndexError
:
pass
utt
.
verify_grad
(
lambda
a
,
b
:
join
(
-
1
,
a
,
b
),
[
v
,
2
*
v
],
utt
.
verify_grad
(
lambda
a
,
b
:
join
(
-
1
,
a
,
b
),
[
v
,
2
*
v
],
mode
=
self
.
mode
)
mode
=
self
.
mode
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论