Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5b4a0d08
提交
5b4a0d08
authored
10月 21, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply pyupgrade to tests.gof
上级
30cfad4b
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
25 行增加
和
16 行删除
+25
-16
test_graph.py
tests/gof/test_graph.py
+1
-1
test_op.py
tests/gof/test_op.py
+3
-4
test_opt.py
tests/gof/test_opt.py
+1
-1
test_params_type.py
tests/gof/test_params_type.py
+1
-1
test_sched.py
tests/gof/test_sched.py
+5
-5
test_vm.py
tests/gof/test_vm.py
+14
-4
没有找到文件。
tests/gof/test_graph.py
浏览文件 @
5b4a0d08
...
@@ -78,7 +78,7 @@ class X:
...
@@ -78,7 +78,7 @@ class X:
return
str
(
leaf
.
type
)
return
str
(
leaf
.
type
)
def
node_formatter
(
self
,
node
,
argstrings
):
def
node_formatter
(
self
,
node
,
argstrings
):
return
"
%
s(
%
s)"
%
(
node
.
op
,
", "
.
join
(
argstrings
))
return
"
{}({})"
.
format
(
node
.
op
,
", "
.
join
(
argstrings
))
def
str
(
self
,
inputs
,
outputs
):
def
str
(
self
,
inputs
,
outputs
):
return
as_string
(
return
as_string
(
...
...
tests/gof/test_op.py
浏览文件 @
5b4a0d08
import
numpy
as
np
import
numpy
as
np
import
pytest
import
pytest
from
six
import
string_types
import
theano
import
theano
import
theano.gof.op
as
op
import
theano.gof.op
as
op
...
@@ -34,7 +33,7 @@ class MyType(Type):
...
@@ -34,7 +33,7 @@ class MyType(Type):
def
filter
(
self
,
x
,
strict
=
False
,
allow_downcast
=
None
):
def
filter
(
self
,
x
,
strict
=
False
,
allow_downcast
=
None
):
# Dummy filter: we want this type to represent strings that
# Dummy filter: we want this type to represent strings that
# start with `self.thingy`.
# start with `self.thingy`.
if
not
isinstance
(
x
,
str
ing_types
):
if
not
isinstance
(
x
,
str
):
raise
TypeError
(
"Invalid type"
)
raise
TypeError
(
"Invalid type"
)
if
not
x
.
startswith
(
self
.
thingy
):
if
not
x
.
startswith
(
self
.
thingy
):
raise
ValueError
(
"Invalid value"
)
raise
ValueError
(
"Invalid value"
)
...
@@ -89,10 +88,10 @@ class StructOp(Op):
...
@@ -89,10 +88,10 @@ class StructOp(Op):
return
Apply
(
self
,
[
i
],
[
scalar
.
uint64
()])
return
Apply
(
self
,
[
i
],
[
scalar
.
uint64
()])
def
c_support_code_struct
(
self
,
node
,
name
):
def
c_support_code_struct
(
self
,
node
,
name
):
return
"npy_uint64 counter
%
s;"
%
(
name
,
)
return
"npy_uint64 counter
{};"
.
format
(
name
)
def
c_init_code_struct
(
self
,
node
,
name
,
sub
):
def
c_init_code_struct
(
self
,
node
,
name
,
sub
):
return
"counter
%
s = 0;"
%
(
name
,
)
return
"counter
{} = 0;"
.
format
(
name
)
def
c_code
(
self
,
node
,
name
,
input_names
,
outputs_names
,
sub
):
def
c_code
(
self
,
node
,
name
,
input_names
,
outputs_names
,
sub
):
return
"""
return
"""
...
...
tests/gof/test_opt.py
浏览文件 @
5b4a0d08
...
@@ -548,7 +548,7 @@ class TestMergeOptimizer:
...
@@ -548,7 +548,7 @@ class TestMergeOptimizer:
assert
len
(
no_input_ops
)
==
2
,
fg
.
apply_nodes
assert
len
(
no_input_ops
)
==
2
,
fg
.
apply_nodes
class
TestEquilibrium
(
object
)
:
class
TestEquilibrium
:
def
test_1
(
self
):
def
test_1
(
self
):
x
,
y
,
z
=
map
(
MyVariable
,
"xyz"
)
x
,
y
,
z
=
map
(
MyVariable
,
"xyz"
)
e
=
op3
(
op4
(
x
,
y
))
e
=
op3
(
op4
(
x
,
y
))
...
...
tests/gof/test_params_type.py
浏览文件 @
5b4a0d08
...
@@ -102,7 +102,7 @@ class QuadraticCOpFunc(COp):
...
@@ -102,7 +102,7 @@ class QuadraticCOpFunc(COp):
params_type
=
ParamsType
(
a
=
tensor_type_0d
,
b
=
scalar_type
,
c
=
generic_type
)
params_type
=
ParamsType
(
a
=
tensor_type_0d
,
b
=
scalar_type
,
c
=
generic_type
)
def
__init__
(
self
,
a
,
b
,
c
):
def
__init__
(
self
,
a
,
b
,
c
):
super
(
QuadraticCOpFunc
,
self
)
.
__init__
(
super
()
.
__init__
(
"c_code/test_quadratic_function.c"
,
"APPLY_SPECIFIC(compute_quadratic)"
"c_code/test_quadratic_function.c"
,
"APPLY_SPECIFIC(compute_quadratic)"
)
)
self
.
a
=
a
self
.
a
=
a
...
...
tests/gof/test_sched.py
浏览文件 @
5b4a0d08
...
@@ -45,11 +45,11 @@ def test_reverse_dict():
...
@@ -45,11 +45,11 @@ def test_reverse_dict():
def
test__toposort
():
def
test__toposort
():
edges
=
{
edges
=
{
1
:
set
((
4
,
6
,
7
))
,
1
:
{
4
,
6
,
7
}
,
2
:
set
((
4
,
6
,
7
))
,
2
:
{
4
,
6
,
7
}
,
3
:
set
((
5
,
7
))
,
3
:
{
5
,
7
}
,
4
:
set
((
6
,
7
))
,
4
:
{
6
,
7
}
,
5
:
set
((
7
,))
,
5
:
{
7
}
,
}
}
order
=
_toposort
(
edges
)
order
=
_toposort
(
edges
)
assert
not
any
(
assert
not
any
(
...
...
tests/gof/test_vm.py
浏览文件 @
5b4a0d08
...
@@ -100,7 +100,9 @@ def test_speed():
...
@@ -100,7 +100,9 @@ def test_speed():
t_b
=
t3
-
t2
t_b
=
t3
-
t2
print
(
print
(
"
%
s takes
%
f s/Kop"
%
(
"numpy"
,
(
1000
*
(
t_b
-
t_a
)
/
(
steps_b
-
steps_a
)))
"{} takes {:f} s/Kop"
.
format
(
"numpy"
,
(
1000
*
(
t_b
-
t_a
)
/
(
steps_b
-
steps_a
))
)
)
)
def
time_linker
(
name
,
linker
):
def
time_linker
(
name
,
linker
):
...
@@ -127,7 +129,11 @@ def test_speed():
...
@@ -127,7 +129,11 @@ def test_speed():
t_a
=
t1
-
t0
t_a
=
t1
-
t0
t_b
=
t3
-
t2
t_b
=
t3
-
t2
print
(
"
%
s takes
%
f s/Kop"
%
(
name
,
(
1000
*
(
t_b
-
t_a
)
/
(
steps_b
-
steps_a
))))
print
(
"{} takes {:f} s/Kop"
.
format
(
name
,
(
1000
*
(
t_b
-
t_a
)
/
(
steps_b
-
steps_a
))
)
)
time_linker
(
"c|py"
,
OpWiseCLinker
)
time_linker
(
"c|py"
,
OpWiseCLinker
)
time_linker
(
"vmLinker"
,
vm
.
VM_Linker
)
time_linker
(
"vmLinker"
,
vm
.
VM_Linker
)
...
@@ -170,7 +176,11 @@ def test_speed_lazy():
...
@@ -170,7 +176,11 @@ def test_speed_lazy():
t_a
=
t1
-
t0
t_a
=
t1
-
t0
t_b
=
t3
-
t2
t_b
=
t3
-
t2
print
(
"
%
s takes
%
f s/Kop"
%
(
name
,
(
1000
*
(
t_b
-
t_a
)
/
(
steps_b
-
steps_a
))))
print
(
"{} takes {:f} s/Kop"
.
format
(
name
,
(
1000
*
(
t_b
-
t_a
)
/
(
steps_b
-
steps_a
))
)
)
time_linker
(
"vmLinker"
,
vm
.
VM_Linker
)
time_linker
(
"vmLinker"
,
vm
.
VM_Linker
)
time_linker
(
"vmLinker_nogc"
,
lambda
:
vm
.
VM_Linker
(
allow_gc
=
False
))
time_linker
(
"vmLinker_nogc"
,
lambda
:
vm
.
VM_Linker
(
allow_gc
=
False
))
...
@@ -425,7 +435,7 @@ def test_reallocation():
...
@@ -425,7 +435,7 @@ def test_reallocation():
return
[
False
,
None
]
return
[
False
,
None
]
assert
check_storage
(
storage_map
)[
0
]
assert
check_storage
(
storage_map
)[
0
]
assert
len
(
set
(
id
(
v
)
for
v
in
storage_map
.
values
())
)
<
len
(
storage_map
)
assert
len
(
{
id
(
v
)
for
v
in
storage_map
.
values
()}
)
<
len
(
storage_map
)
@pytest.mark.skipif
(
@pytest.mark.skipif
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论