Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
021ed662
提交
021ed662
authored
10月 21, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply pyupgrade to tests.gpuarray
上级
5b4a0d08
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
22 行增加
和
28 行删除
+22
-28
check_dnn_conv.py
tests/gpuarray/check_dnn_conv.py
+9
-13
rnn_support.py
tests/gpuarray/rnn_support.py
+2
-2
run_dnn_conv.py
tests/gpuarray/run_dnn_conv.py
+2
-2
test_blas.py
tests/gpuarray/test_blas.py
+4
-6
test_dnn.py
tests/gpuarray/test_dnn.py
+3
-3
test_multinomial.py
tests/gpuarray/test_multinomial.py
+2
-2
没有找到文件。
tests/gpuarray/check_dnn_conv.py
浏览文件 @
021ed662
...
@@ -319,7 +319,7 @@ class ConvCaseGeneratorChain:
...
@@ -319,7 +319,7 @@ class ConvCaseGeneratorChain:
return
chain
(
*
[
generator
.
get_cases
(
filter
)
for
generator
in
self
.
generators
])
return
chain
(
*
[
generator
.
get_cases
(
filter
)
for
generator
in
self
.
generators
])
class
CuDNNV51ConvCaseGenerator
(
object
)
:
class
CuDNNV51ConvCaseGenerator
:
"""
"""
Helper class to generate specific test cases for every algorithm supported by cuDNN V5.1.
Helper class to generate specific test cases for every algorithm supported by cuDNN V5.1.
Same class exists for cuDNN V6.0 (see below).
Same class exists for cuDNN V6.0 (see below).
...
@@ -486,9 +486,7 @@ class CuDNNV6ConvCaseGenerator(CuDNNV51ConvCaseGenerator):
...
@@ -486,9 +486,7 @@ class CuDNNV6ConvCaseGenerator(CuDNNV51ConvCaseGenerator):
]
]
return
ConvCaseGeneratorChain
(
*
generators
)
return
ConvCaseGeneratorChain
(
*
generators
)
if
ndim
==
3
:
if
ndim
==
3
:
return
super
(
CuDNNV6ConvCaseGenerator
,
self
)
.
_fwd_fft_tiling
(
return
super
()
.
_fwd_fft_tiling
(
ndim
,
dtype
,
precision
)
ndim
,
dtype
,
precision
)
def
_gw_none
(
self
,
ndim
):
def
_gw_none
(
self
,
ndim
):
return
self
.
_fwd_none
(
ndim
)
return
self
.
_fwd_none
(
ndim
)
...
@@ -513,36 +511,34 @@ class CuDNNV6ConvCaseGenerator(CuDNNV51ConvCaseGenerator):
...
@@ -513,36 +511,34 @@ class CuDNNV6ConvCaseGenerator(CuDNNV51ConvCaseGenerator):
def
_fwd_runtime
(
self
,
ndim
,
dtype
,
precision
):
def
_fwd_runtime
(
self
,
ndim
,
dtype
,
precision
):
if
ndim
==
2
and
dtype
==
precision
==
"float16"
:
if
ndim
==
2
and
dtype
==
precision
==
"float16"
:
return
ConvCaseGenerator
(
ndim
=
ndim
,
dilations
=
self
.
_dilations
(
ndim
))
return
ConvCaseGenerator
(
ndim
=
ndim
,
dilations
=
self
.
_dilations
(
ndim
))
return
super
(
CuDNNV6ConvCaseGenerator
,
self
)
.
_fwd_runtime
(
return
super
()
.
_fwd_runtime
(
ndim
,
dtype
,
precision
)
ndim
,
dtype
,
precision
)
def
_gw_runtime
(
self
,
ndim
,
dtype
,
precision
):
def
_gw_runtime
(
self
,
ndim
,
dtype
,
precision
):
if
ndim
==
2
and
dtype
==
precision
==
"float16"
:
if
ndim
==
2
and
dtype
==
precision
==
"float16"
:
return
ConvCaseGenerator
(
ndim
=
ndim
,
dilations
=
self
.
_dilations
(
ndim
))
return
ConvCaseGenerator
(
ndim
=
ndim
,
dilations
=
self
.
_dilations
(
ndim
))
return
super
(
CuDNNV6ConvCaseGenerator
,
self
)
.
_gw_runtime
(
ndim
,
dtype
,
precision
)
return
super
()
.
_gw_runtime
(
ndim
,
dtype
,
precision
)
def
_gi_runtime
(
self
,
ndim
,
dtype
,
precision
):
def
_gi_runtime
(
self
,
ndim
,
dtype
,
precision
):
if
ndim
==
2
and
dtype
==
precision
==
"float16"
:
if
ndim
==
2
and
dtype
==
precision
==
"float16"
:
return
ConvCaseGenerator
(
ndim
=
ndim
,
dilations
=
self
.
_dilations
(
ndim
))
return
ConvCaseGenerator
(
ndim
=
ndim
,
dilations
=
self
.
_dilations
(
ndim
))
return
super
(
CuDNNV6ConvCaseGenerator
,
self
)
.
_gi_runtime
(
ndim
,
dtype
,
precision
)
return
super
()
.
_gi_runtime
(
ndim
,
dtype
,
precision
)
def
fwd
(
self
,
algo
,
ndim
,
dtype
,
precision
):
def
fwd
(
self
,
algo
,
ndim
,
dtype
,
precision
):
if
algo
==
self
.
NONE
:
if
algo
==
self
.
NONE
:
return
self
.
_fwd_none
(
ndim
)
return
self
.
_fwd_none
(
ndim
)
return
super
(
CuDNNV6ConvCaseGenerator
,
self
)
.
fwd
(
algo
,
ndim
,
dtype
,
precision
)
return
super
()
.
fwd
(
algo
,
ndim
,
dtype
,
precision
)
def
gw
(
self
,
algo
,
ndim
,
dtype
,
precision
):
def
gw
(
self
,
algo
,
ndim
,
dtype
,
precision
):
if
algo
==
self
.
NONE
:
if
algo
==
self
.
NONE
:
return
self
.
_gw_none
(
ndim
)
return
self
.
_gw_none
(
ndim
)
if
algo
==
self
.
FFT_TILING
:
if
algo
==
self
.
FFT_TILING
:
return
self
.
_gw_fft_tiling
(
ndim
)
return
self
.
_gw_fft_tiling
(
ndim
)
return
super
(
CuDNNV6ConvCaseGenerator
,
self
)
.
gw
(
algo
,
ndim
,
dtype
,
precision
)
return
super
()
.
gw
(
algo
,
ndim
,
dtype
,
precision
)
def
gi
(
self
,
algo
,
ndim
,
dtype
,
precision
):
def
gi
(
self
,
algo
,
ndim
,
dtype
,
precision
):
if
algo
==
self
.
NONE
:
if
algo
==
self
.
NONE
:
return
self
.
_gi_none
(
ndim
)
return
self
.
_gi_none
(
ndim
)
return
super
(
CuDNNV6ConvCaseGenerator
,
self
)
.
gi
(
algo
,
ndim
,
dtype
,
precision
)
return
super
()
.
gi
(
algo
,
ndim
,
dtype
,
precision
)
cudnn_conv_case_generator
=
(
cudnn_conv_case_generator
=
(
...
@@ -550,7 +546,7 @@ cudnn_conv_case_generator = (
...
@@ -550,7 +546,7 @@ cudnn_conv_case_generator = (
)
)
class
BaseTestDnnConv
(
object
)
:
class
BaseTestDnnConv
:
"""
"""
Base class for exhaustive tests. Use its subclasses
Base class for exhaustive tests. Use its subclasses
to run actual tests.
to run actual tests.
...
...
tests/gpuarray/rnn_support.py
浏览文件 @
021ed662
...
@@ -4,7 +4,7 @@ import theano
...
@@ -4,7 +4,7 @@ import theano
import
theano.tensor
as
tt
import
theano.tensor
as
tt
class
Model
(
object
)
:
class
Model
:
def
__init__
(
self
,
name
=
""
):
def
__init__
(
self
,
name
=
""
):
self
.
name
=
name
self
.
name
=
name
self
.
layers
=
[]
self
.
layers
=
[]
...
@@ -54,7 +54,7 @@ def bias_weights(length, param_list=None, name=""):
...
@@ -54,7 +54,7 @@ def bias_weights(length, param_list=None, name=""):
return
bias
return
bias
class
Layer
(
object
)
:
class
Layer
:
"""Generic Layer Template which all layers should inherit"""
"""Generic Layer Template which all layers should inherit"""
def
__init__
(
self
,
name
=
""
):
def
__init__
(
self
,
name
=
""
):
...
...
tests/gpuarray/run_dnn_conv.py
浏览文件 @
021ed662
...
@@ -35,7 +35,7 @@ class BorderAction(TupleAction):
...
@@ -35,7 +35,7 @@ class BorderAction(TupleAction):
# Border extractor for command line args parser.
# Border extractor for command line args parser.
def
__call__
(
self
,
parser
,
namespace
,
values
,
option_string
=
None
):
def
__call__
(
self
,
parser
,
namespace
,
values
,
option_string
=
None
):
if
values
not
in
(
"valid"
,
"full"
,
"half"
):
if
values
not
in
(
"valid"
,
"full"
,
"half"
):
super
(
BorderAction
,
self
)
.
__call__
(
parser
,
namespace
,
values
,
option_string
)
super
()
.
__call__
(
parser
,
namespace
,
values
,
option_string
)
else
:
else
:
setattr
(
namespace
,
self
.
dest
,
values
)
setattr
(
namespace
,
self
.
dest
,
values
)
...
@@ -201,7 +201,7 @@ else:
...
@@ -201,7 +201,7 @@ else:
args
.
dtype
,
args
.
precision
=
data_type_configurations
[
args
.
dtype_config
]
args
.
dtype
,
args
.
precision
=
data_type_configurations
[
args
.
dtype_config
]
if
(
args
.
dtype
,
args
.
precision
)
not
in
cudnn
.
get_supported_dtype_configs
():
if
(
args
.
dtype
,
args
.
precision
)
not
in
cudnn
.
get_supported_dtype_configs
():
raise
ValueError
(
raise
ValueError
(
"Unsupported data type configuration
%
s
%
s."
%
(
args
.
dtype
,
args
.
precision
)
"Unsupported data type configuration
{} {}."
.
format
(
args
.
dtype
,
args
.
precision
)
)
)
if
args
.
algo
not
in
SUPPORTED_DNN_CONV_ALGO_RUNTIME
:
if
args
.
algo
not
in
SUPPORTED_DNN_CONV_ALGO_RUNTIME
:
...
...
tests/gpuarray/test_blas.py
浏览文件 @
021ed662
...
@@ -153,13 +153,11 @@ TestGpuGemm = makeTester(
...
@@ -153,13 +153,11 @@ TestGpuGemm = makeTester(
)
)
gemm_batched_tests
=
dict
(
gemm_batched_tests
=
{
(
"test_b
%
im
%
ik
%
in
%
i"
"test_b
%
im
%
ik
%
in
%
i"
%
(
b
,
m
,
k
,
n
),
%
(
b
,
m
,
k
,
n
):
[
rand
(
b
,
m
,
n
),
rand
(),
rand
(
b
,
m
,
k
),
rand
(
b
,
k
,
n
),
rand
()]
[
rand
(
b
,
m
,
n
),
rand
(),
rand
(
b
,
m
,
k
),
rand
(
b
,
k
,
n
),
rand
()],
)
for
b
,
m
,
k
,
n
in
itertools
.
combinations
([
2
,
3
,
5
,
7
,
11
,
13
],
4
)
for
b
,
m
,
k
,
n
in
itertools
.
combinations
([
2
,
3
,
5
,
7
,
11
,
13
],
4
)
)
}
gemm_batched_tests
[
"float16"
]
=
[
gemm_batched_tests
[
"float16"
]
=
[
rand
(
3
,
4
,
7
)
.
astype
(
"float16"
),
rand
(
3
,
4
,
7
)
.
astype
(
"float16"
),
...
...
tests/gpuarray/test_dnn.py
浏览文件 @
021ed662
...
@@ -2768,7 +2768,7 @@ class Cudnn_grouped_conv(TestGroupedConvNoOptim):
...
@@ -2768,7 +2768,7 @@ class Cudnn_grouped_conv(TestGroupedConvNoOptim):
conv_gradi_op
=
dnn
.
GpuDnnConvGradI
conv_gradi_op
=
dnn
.
GpuDnnConvGradI
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Cudnn_grouped_conv
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
()
.
__init__
(
*
args
,
**
kwargs
)
class
Cudnn_grouped_conv3d
(
TestGroupedConv3dNoOptim
):
class
Cudnn_grouped_conv3d
(
TestGroupedConv3dNoOptim
):
...
@@ -2778,7 +2778,7 @@ class Cudnn_grouped_conv3d(TestGroupedConv3dNoOptim):
...
@@ -2778,7 +2778,7 @@ class Cudnn_grouped_conv3d(TestGroupedConv3dNoOptim):
conv_gradi_op
=
dnn
.
GpuDnnConvGradI
conv_gradi_op
=
dnn
.
GpuDnnConvGradI
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Cudnn_grouped_conv3d
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
()
.
__init__
(
*
args
,
**
kwargs
)
def
test_dnn_spatialtf
():
def
test_dnn_spatialtf
():
...
@@ -3049,7 +3049,7 @@ def test_dnn_spatialtf_grad():
...
@@ -3049,7 +3049,7 @@ def test_dnn_spatialtf_grad():
)
)
class
TestDnnConv2DRuntimeAlgorithms
(
object
)
:
class
TestDnnConv2DRuntimeAlgorithms
:
ndim
=
2
ndim
=
2
cpu_conv_class
=
CorrMM
cpu_conv_class
=
CorrMM
runtime_shapes
=
[
runtime_shapes
=
[
...
...
tests/gpuarray/test_multinomial.py
浏览文件 @
021ed662
...
@@ -147,7 +147,7 @@ def test_gpu_opt_dtypes():
...
@@ -147,7 +147,7 @@ def test_gpu_opt_dtypes():
pval
=
pval
/
pval
.
sum
(
axis
=
1
)[:,
None
]
pval
=
pval
/
pval
.
sum
(
axis
=
1
)[:,
None
]
uval
=
np
.
ones_like
(
pval
[:,
0
])
*
0.5
uval
=
np
.
ones_like
(
pval
[:,
0
])
*
0.5
samples
=
f
(
pval
,
uval
)
samples
=
f
(
pval
,
uval
)
assert
samples
.
dtype
==
dtype
,
"
%
s !=
%
s"
%
(
samples
.
dtype
,
dtype
)
assert
samples
.
dtype
==
dtype
,
"
{} != {}"
.
format
(
samples
.
dtype
,
dtype
)
def
test_gpu_opt
():
def
test_gpu_opt
():
...
@@ -380,7 +380,7 @@ def test_unpickle_legacy_op():
...
@@ -380,7 +380,7 @@ def test_unpickle_legacy_op():
fname
=
"test_gpuarray_multinomial_wo_replacement.pkl"
fname
=
"test_gpuarray_multinomial_wo_replacement.pkl"
if
not
PY3
:
if
not
PY3
:
with
open
(
os
.
path
.
join
(
testfile_dir
,
fname
)
,
"r"
)
as
fp
:
with
open
(
os
.
path
.
join
(
testfile_dir
,
fname
))
as
fp
:
u
=
Unpickler
(
fp
)
u
=
Unpickler
(
fp
)
m
=
u
.
load
()
m
=
u
.
load
()
assert
isinstance
(
m
,
GPUAChoiceFromUniform
)
assert
isinstance
(
m
,
GPUAChoiceFromUniform
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论