Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f2a2181c
提交
f2a2181c
authored
1月 22, 2016
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3907 from laurent-dinh/conv_test
Optimization test for convolution
上级
2dc471fc
97fe07f0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
73 行增加
和
23 行删除
+73
-23
test_abstractconv.py
theano/sandbox/cuda/tests/test_abstractconv.py
+36
-10
test_abstractconv.py
theano/sandbox/gpuarray/tests/test_abstractconv.py
+37
-13
没有找到文件。
theano/sandbox/cuda/tests/test_abstractconv.py
浏览文件 @
f2a2181c
...
@@ -7,7 +7,11 @@ from theano.tests import unittest_tools as utt
...
@@ -7,7 +7,11 @@ from theano.tests import unittest_tools as utt
import
theano.tensor.nnet.abstract_conv
as
conv
import
theano.tensor.nnet.abstract_conv
as
conv
from
theano.sandbox.cuda
import
float32_shared_constructor
as
gpu_shared
from
theano.sandbox.cuda
import
float32_shared_constructor
as
gpu_shared
from
theano.compile
import
shared
as
cpu_shared
from
theano.compile
import
shared
as
cpu_shared
from
theano.sandbox.cuda.dnn
import
dnn_available
,
dnn_conv
,
dnn_gradweight
,
dnn_gradinput
from
theano.sandbox.cuda.dnn
import
(
dnn_available
,
dnn_conv
,
dnn_gradweight
,
dnn_gradinput
,
GpuDnnConv
,
GpuDnnConvGradW
,
GpuDnnConvGradI
)
from
theano.sandbox.cuda.blas
import
(
GpuCorrMM
,
GpuCorrMM_gradWeights
,
GpuCorrMM_gradInputs
)
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
import
theano.sandbox.cuda
as
cuda
import
theano.sandbox.cuda
as
cuda
...
@@ -51,7 +55,8 @@ class TestConv2d(unittest.TestCase):
...
@@ -51,7 +55,8 @@ class TestConv2d(unittest.TestCase):
def
run_fwd
(
self
,
inputs_shape
,
filters_shape
,
ref
=
dnn_conv
,
def
run_fwd
(
self
,
inputs_shape
,
filters_shape
,
ref
=
dnn_conv
,
subsample
=
(
1
,
1
),
verify_grad
=
True
,
mode
=
mode_without_gpu
,
subsample
=
(
1
,
1
),
verify_grad
=
True
,
mode
=
mode_without_gpu
,
border_mode
=
'valid'
,
filter_flip
=
True
,
device
=
'cpu'
,
provide_shape
=
False
):
border_mode
=
'valid'
,
filter_flip
=
True
,
device
=
'cpu'
,
provide_shape
=
False
,
target_op
=
None
):
inputs_val
=
numpy
.
random
.
random
(
inputs_shape
)
.
astype
(
'float32'
)
inputs_val
=
numpy
.
random
.
random
(
inputs_shape
)
.
astype
(
'float32'
)
filters_val
=
numpy
.
random
.
random
(
filters_shape
)
.
astype
(
'float32'
)
filters_val
=
numpy
.
random
.
random
(
filters_shape
)
.
astype
(
'float32'
)
...
@@ -84,6 +89,11 @@ class TestConv2d(unittest.TestCase):
...
@@ -84,6 +89,11 @@ class TestConv2d(unittest.TestCase):
filter_shape
=
kshp
)
filter_shape
=
kshp
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
=
mode
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
=
mode
)
f
=
theano
.
function
([],
c
,
mode
)
f
=
theano
.
function
([],
c
,
mode
)
if
target_op
is
not
None
:
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
in
f
.
maker
.
fgraph
.
toposort
()])
res_ref
=
numpy
.
array
(
f_ref
())
res_ref
=
numpy
.
array
(
f_ref
())
res
=
numpy
.
array
(
f
())
res
=
numpy
.
array
(
f
())
utt
.
assert_allclose
(
res_ref
,
res
)
utt
.
assert_allclose
(
res_ref
,
res
)
...
@@ -96,7 +106,7 @@ class TestConv2d(unittest.TestCase):
...
@@ -96,7 +106,7 @@ class TestConv2d(unittest.TestCase):
def
run_gradweight
(
self
,
inputs_shape
,
filters_shape
,
output_shape
,
def
run_gradweight
(
self
,
inputs_shape
,
filters_shape
,
output_shape
,
ref
=
dnn_gradweight
,
subsample
=
(
1
,
1
),
filter_flip
=
True
,
ref
=
dnn_gradweight
,
subsample
=
(
1
,
1
),
filter_flip
=
True
,
verify_grad
=
True
,
mode
=
mode_without_gpu
,
border_mode
=
'valid'
,
verify_grad
=
True
,
mode
=
mode_without_gpu
,
border_mode
=
'valid'
,
device
=
'cpu'
,
provide_shape
=
False
):
device
=
'cpu'
,
provide_shape
=
False
,
target_op
=
None
):
inputs_val
=
numpy
.
random
.
random
(
inputs_shape
)
.
astype
(
'float32'
)
inputs_val
=
numpy
.
random
.
random
(
inputs_shape
)
.
astype
(
'float32'
)
output_val
=
numpy
.
random
.
random
(
output_shape
)
.
astype
(
'float32'
)
output_val
=
numpy
.
random
.
random
(
output_shape
)
.
astype
(
'float32'
)
...
@@ -128,6 +138,11 @@ class TestConv2d(unittest.TestCase):
...
@@ -128,6 +138,11 @@ class TestConv2d(unittest.TestCase):
conv_mode
=
conv_mode
)
conv_mode
=
conv_mode
)
f
=
theano
.
function
([],
c
,
mode
)
f
=
theano
.
function
([],
c
,
mode
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
)
if
target_op
is
not
None
:
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
in
f
.
maker
.
fgraph
.
toposort
()])
res_ref
=
numpy
.
array
(
f_ref
())
res_ref
=
numpy
.
array
(
f_ref
())
res
=
numpy
.
array
(
f
())
res
=
numpy
.
array
(
f
())
utt
.
assert_allclose
(
res_ref
,
res
)
utt
.
assert_allclose
(
res_ref
,
res
)
...
@@ -144,7 +159,8 @@ class TestConv2d(unittest.TestCase):
...
@@ -144,7 +159,8 @@ class TestConv2d(unittest.TestCase):
output_shape
,
ref
=
dnn_gradinput
,
output_shape
,
ref
=
dnn_gradinput
,
subsample
=
(
1
,
1
),
filter_flip
=
True
,
subsample
=
(
1
,
1
),
filter_flip
=
True
,
verify_grad
=
True
,
mode
=
mode_without_gpu
,
verify_grad
=
True
,
mode
=
mode_without_gpu
,
border_mode
=
'valid'
,
device
=
'cpu'
,
provide_shape
=
False
):
border_mode
=
'valid'
,
device
=
'cpu'
,
provide_shape
=
False
,
target_op
=
None
):
output_val
=
numpy
.
random
.
random
(
output_shape
)
.
astype
(
'float32'
)
output_val
=
numpy
.
random
.
random
(
output_shape
)
.
astype
(
'float32'
)
filters_val
=
numpy
.
random
.
random
(
filters_shape
)
.
astype
(
'float32'
)
filters_val
=
numpy
.
random
.
random
(
filters_shape
)
.
astype
(
'float32'
)
...
@@ -174,6 +190,11 @@ class TestConv2d(unittest.TestCase):
...
@@ -174,6 +190,11 @@ class TestConv2d(unittest.TestCase):
conv_mode
=
conv_mode
)
conv_mode
=
conv_mode
)
f
=
theano
.
function
([],
c
,
mode
)
f
=
theano
.
function
([],
c
,
mode
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
)
if
target_op
is
not
None
:
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
in
f
.
maker
.
fgraph
.
toposort
()])
res_ref
=
numpy
.
array
(
f_ref
())
res_ref
=
numpy
.
array
(
f_ref
())
res
=
numpy
.
array
(
f
())
res
=
numpy
.
array
(
f
())
utt
.
assert_allclose
(
res_ref
,
res
)
utt
.
assert_allclose
(
res_ref
,
res
)
...
@@ -200,17 +221,17 @@ class TestConv2d(unittest.TestCase):
...
@@ -200,17 +221,17 @@ class TestConv2d(unittest.TestCase):
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
GpuDnnConv
)
self
.
run_gradweight
(
inputs_shape
=
i
,
filters_shape
=
f
,
self
.
run_gradweight
(
inputs_shape
=
i
,
filters_shape
=
f
,
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
GpuDnnConvGradW
)
self
.
run_gradinput
(
inputs_shape
=
i
,
filters_shape
=
f
,
self
.
run_gradinput
(
inputs_shape
=
i
,
filters_shape
=
f
,
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
GpuDnnConvGradI
)
def
test_gpucorrmm_conv
(
self
):
def
test_gpucorrmm_conv
(
self
):
if
not
dnn_available
():
if
not
dnn_available
():
...
@@ -228,14 +249,19 @@ class TestConv2d(unittest.TestCase):
...
@@ -228,14 +249,19 @@ class TestConv2d(unittest.TestCase):
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
(
GpuCorrMM
,
GpuCorrMM_gradWeights
,
GpuCorrMM_gradInputs
))
self
.
run_gradweight
(
inputs_shape
=
i
,
filters_shape
=
f
,
self
.
run_gradweight
(
inputs_shape
=
i
,
filters_shape
=
f
,
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
GpuCorrMM_gradWeights
)
self
.
run_gradinput
(
inputs_shape
=
i
,
filters_shape
=
f
,
self
.
run_gradinput
(
inputs_shape
=
i
,
filters_shape
=
f
,
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
GpuCorrMM_gradInputs
)
theano/sandbox/gpuarray/tests/test_abstractconv.py
浏览文件 @
f2a2181c
...
@@ -9,7 +9,13 @@ from theano.tests import unittest_tools as utt
...
@@ -9,7 +9,13 @@ from theano.tests import unittest_tools as utt
import
theano.tensor.nnet.abstract_conv
as
conv
import
theano.tensor.nnet.abstract_conv
as
conv
from
theano.compile
import
shared
as
cpu_shared
from
theano.compile
import
shared
as
cpu_shared
from
..type
import
gpuarray_shared_constructor
as
gpu_shared
from
..type
import
gpuarray_shared_constructor
as
gpu_shared
from
..dnn
import
dnn_available
,
dnn_conv
,
dnn_gradweight
,
dnn_gradinput
from
..dnn
import
(
dnn_available
,
dnn_conv
,
dnn_gradweight
,
dnn_gradinput
,
GpuDnnConv
,
GpuDnnConvGradW
,
GpuDnnConvGradI
)
from
theano.tensor.nnet.corr
import
(
CorrMM
,
CorrMM_gradWeights
,
CorrMM_gradInputs
)
from
theano.tensor.nnet.conv
import
ConvOp
from
theano.tensor.nnet
import
ConvGrad3D
,
ConvTransp3D
from
.config
import
mode_with_gpu
,
mode_without_gpu
,
test_ctx_name
from
.config
import
mode_with_gpu
,
mode_without_gpu
,
test_ctx_name
...
@@ -44,7 +50,7 @@ class TestConv2d(unittest.TestCase):
...
@@ -44,7 +50,7 @@ class TestConv2d(unittest.TestCase):
def
run_fwd
(
self
,
inputs_shape
,
filters_shape
,
ref
=
dnn_conv
,
def
run_fwd
(
self
,
inputs_shape
,
filters_shape
,
ref
=
dnn_conv
,
subsample
=
(
1
,
1
),
verify_grad
=
True
,
mode
=
mode_without_gpu
,
subsample
=
(
1
,
1
),
verify_grad
=
True
,
mode
=
mode_without_gpu
,
border_mode
=
'valid'
,
filter_flip
=
True
,
device
=
'cpu'
,
border_mode
=
'valid'
,
filter_flip
=
True
,
device
=
'cpu'
,
provide_shape
=
False
):
provide_shape
=
False
,
target_op
=
None
):
inputs_val
=
numpy
.
random
.
random
(
inputs_shape
)
.
astype
(
'float32'
)
inputs_val
=
numpy
.
random
.
random
(
inputs_shape
)
.
astype
(
'float32'
)
filters_val
=
numpy
.
random
.
random
(
filters_shape
)
.
astype
(
'float32'
)
filters_val
=
numpy
.
random
.
random
(
filters_shape
)
.
astype
(
'float32'
)
...
@@ -77,6 +83,11 @@ class TestConv2d(unittest.TestCase):
...
@@ -77,6 +83,11 @@ class TestConv2d(unittest.TestCase):
filter_shape
=
kshp
)
filter_shape
=
kshp
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
=
mode
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
=
mode
)
f
=
theano
.
function
([],
c
,
mode
)
f
=
theano
.
function
([],
c
,
mode
)
if
target_op
is
not
None
:
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
in
f
.
maker
.
fgraph
.
toposort
()])
res_ref
=
numpy
.
array
(
f_ref
())
res_ref
=
numpy
.
array
(
f_ref
())
res
=
numpy
.
array
(
f
())
res
=
numpy
.
array
(
f
())
utt
.
assert_allclose
(
res_ref
,
res
)
utt
.
assert_allclose
(
res_ref
,
res
)
...
@@ -89,7 +100,7 @@ class TestConv2d(unittest.TestCase):
...
@@ -89,7 +100,7 @@ class TestConv2d(unittest.TestCase):
def
run_gradweight
(
self
,
inputs_shape
,
filters_shape
,
output_shape
,
def
run_gradweight
(
self
,
inputs_shape
,
filters_shape
,
output_shape
,
ref
=
dnn_gradweight
,
subsample
=
(
1
,
1
),
filter_flip
=
True
,
ref
=
dnn_gradweight
,
subsample
=
(
1
,
1
),
filter_flip
=
True
,
verify_grad
=
True
,
mode
=
mode_without_gpu
,
border_mode
=
'valid'
,
verify_grad
=
True
,
mode
=
mode_without_gpu
,
border_mode
=
'valid'
,
device
=
'cpu'
,
provide_shape
=
False
):
device
=
'cpu'
,
provide_shape
=
False
,
target_op
=
None
):
inputs_val
=
numpy
.
random
.
random
(
inputs_shape
)
.
astype
(
'float32'
)
inputs_val
=
numpy
.
random
.
random
(
inputs_shape
)
.
astype
(
'float32'
)
output_val
=
numpy
.
random
.
random
(
output_shape
)
.
astype
(
'float32'
)
output_val
=
numpy
.
random
.
random
(
output_shape
)
.
astype
(
'float32'
)
...
@@ -121,6 +132,11 @@ class TestConv2d(unittest.TestCase):
...
@@ -121,6 +132,11 @@ class TestConv2d(unittest.TestCase):
conv_mode
=
conv_mode
)
conv_mode
=
conv_mode
)
f
=
theano
.
function
([],
c
,
mode
)
f
=
theano
.
function
([],
c
,
mode
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
)
if
target_op
is
not
None
:
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
in
f
.
maker
.
fgraph
.
toposort
()])
res_ref
=
numpy
.
array
(
f_ref
())
res_ref
=
numpy
.
array
(
f_ref
())
res
=
numpy
.
array
(
f
())
res
=
numpy
.
array
(
f
())
utt
.
assert_allclose
(
res_ref
,
res
)
utt
.
assert_allclose
(
res_ref
,
res
)
...
@@ -135,7 +151,8 @@ class TestConv2d(unittest.TestCase):
...
@@ -135,7 +151,8 @@ class TestConv2d(unittest.TestCase):
def
run_gradinput
(
self
,
inputs_shape
,
filters_shape
,
output_shape
,
ref
=
dnn_gradinput
,
def
run_gradinput
(
self
,
inputs_shape
,
filters_shape
,
output_shape
,
ref
=
dnn_gradinput
,
subsample
=
(
1
,
1
),
filter_flip
=
True
,
verify_grad
=
True
,
mode
=
mode_without_gpu
,
subsample
=
(
1
,
1
),
filter_flip
=
True
,
verify_grad
=
True
,
mode
=
mode_without_gpu
,
border_mode
=
'valid'
,
device
=
'cpu'
,
provide_shape
=
False
):
border_mode
=
'valid'
,
device
=
'cpu'
,
provide_shape
=
False
,
target_op
=
None
):
output_val
=
numpy
.
random
.
random
(
output_shape
)
.
astype
(
'float32'
)
output_val
=
numpy
.
random
.
random
(
output_shape
)
.
astype
(
'float32'
)
filters_val
=
numpy
.
random
.
random
(
filters_shape
)
.
astype
(
'float32'
)
filters_val
=
numpy
.
random
.
random
(
filters_shape
)
.
astype
(
'float32'
)
...
@@ -165,6 +182,11 @@ class TestConv2d(unittest.TestCase):
...
@@ -165,6 +182,11 @@ class TestConv2d(unittest.TestCase):
conv_mode
=
conv_mode
)
conv_mode
=
conv_mode
)
f
=
theano
.
function
([],
c
,
mode
)
f
=
theano
.
function
([],
c
,
mode
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
)
f_ref
=
theano
.
function
([],
c_ref
,
mode
)
if
target_op
is
not
None
:
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
in
f
.
maker
.
fgraph
.
toposort
()])
res_ref
=
numpy
.
array
(
f_ref
())
res_ref
=
numpy
.
array
(
f_ref
())
res
=
numpy
.
array
(
f
())
res
=
numpy
.
array
(
f
())
utt
.
assert_allclose
(
res_ref
,
res
)
utt
.
assert_allclose
(
res_ref
,
res
)
...
@@ -192,17 +214,17 @@ class TestConv2d(unittest.TestCase):
...
@@ -192,17 +214,17 @@ class TestConv2d(unittest.TestCase):
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
GpuDnnConv
)
self
.
run_gradweight
(
inputs_shape
=
i
,
filters_shape
=
f
,
self
.
run_gradweight
(
inputs_shape
=
i
,
filters_shape
=
f
,
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
GpuDnnConvGradW
)
self
.
run_gradinput
(
inputs_shape
=
i
,
filters_shape
=
f
,
self
.
run_gradinput
(
inputs_shape
=
i
,
filters_shape
=
f
,
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'gpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
GpuDnnConvGradI
)
def
test_cormm_conv
(
self
):
def
test_cormm_conv
(
self
):
if
not
dnn_available
(
test_ctx_name
):
if
not
dnn_available
(
test_ctx_name
):
...
@@ -220,17 +242,17 @@ class TestConv2d(unittest.TestCase):
...
@@ -220,17 +242,17 @@ class TestConv2d(unittest.TestCase):
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
CorrMM
)
self
.
run_gradweight
(
inputs_shape
=
i
,
filters_shape
=
f
,
self
.
run_gradweight
(
inputs_shape
=
i
,
filters_shape
=
f
,
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
CorrMM_gradWeights
)
self
.
run_gradinput
(
inputs_shape
=
i
,
filters_shape
=
f
,
self
.
run_gradinput
(
inputs_shape
=
i
,
filters_shape
=
f
,
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
CorrMM_gradInputs
)
def
test_cpu_conv
(
self
):
def
test_cpu_conv
(
self
):
if
not
dnn_available
(
test_ctx_name
):
if
not
dnn_available
(
test_ctx_name
):
...
@@ -271,7 +293,7 @@ class TestConv2d(unittest.TestCase):
...
@@ -271,7 +293,7 @@ class TestConv2d(unittest.TestCase):
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
self
.
run_fwd
(
inputs_shape
=
i
,
filters_shape
=
f
,
subsample
=
s
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
verify_grad
=
True
,
mode
=
mode
,
device
=
'cpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
ConvOp
)
else
:
else
:
self
.
assertRaises
(
NotImplementedError
,
self
.
assertRaises
(
NotImplementedError
,
self
.
run_fwd
,
self
.
run_fwd
,
...
@@ -290,7 +312,8 @@ class TestConv2d(unittest.TestCase):
...
@@ -290,7 +312,8 @@ class TestConv2d(unittest.TestCase):
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
False
,
mode
=
mode
,
device
=
'cpu'
,
verify_grad
=
False
,
mode
=
mode
,
device
=
'cpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
(
ConvOp
,
ConvGrad3D
))
else
:
else
:
self
.
assertRaises
(
NotImplementedError
,
self
.
assertRaises
(
NotImplementedError
,
self
.
run_gradweight
,
self
.
run_gradweight
,
...
@@ -310,7 +333,8 @@ class TestConv2d(unittest.TestCase):
...
@@ -310,7 +333,8 @@ class TestConv2d(unittest.TestCase):
output_shape
=
o
,
subsample
=
s
,
output_shape
=
o
,
subsample
=
s
,
verify_grad
=
False
,
mode
=
mode
,
device
=
'cpu'
,
verify_grad
=
False
,
mode
=
mode
,
device
=
'cpu'
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
provide_shape
=
provide_shape
,
border_mode
=
b
,
filter_flip
=
flip
)
filter_flip
=
flip
,
target_op
=
(
ConvOp
,
ConvTransp3D
))
else
:
else
:
self
.
assertRaises
(
NotImplementedError
,
self
.
assertRaises
(
NotImplementedError
,
self
.
run_gradinput
,
self
.
run_gradinput
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论