Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2b658090
提交
2b658090
authored
10月 21, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply pyupgrade to theano.misc
上级
bcccce7a
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
33 行增加
和
35 行删除
+33
-35
check_blas.py
theano/misc/check_blas.py
+1
-1
check_duplicate_key.py
theano/misc/check_duplicate_key.py
+2
-3
check_multi_gpu.py
theano/misc/check_multi_gpu.py
+6
-6
elemwise_time_test.py
theano/misc/elemwise_time_test.py
+1
-1
frozendict.py
theano/misc/frozendict.py
+1
-1
check_whitespace.py
theano/misc/hooks/check_whitespace.py
+4
-3
reindent.py
theano/misc/hooks/reindent.py
+2
-2
ordered_set.py
theano/misc/ordered_set.py
+4
-6
pkl_utils.py
theano/misc/pkl_utils.py
+12
-12
没有找到文件。
theano/misc/check_blas.py
浏览文件 @
2b658090
...
...
@@ -293,7 +293,7 @@ if __name__ == "__main__":
print
(
"(
%
d,
%
d) and (
%
d,
%
d)."
%
(
M
,
N
,
N
,
K
))
print
()
print
(
"Total execution time:
%.2
fs on
%
s."
%
(
t
,
impl
))
print
(
"Total execution time:
{:.2f}s on {}."
.
format
(
t
,
impl
))
print
()
print
(
"Try to run this script a few times. Experience shows that"
...
...
theano/misc/check_duplicate_key.py
浏览文件 @
2b658090
...
...
@@ -27,7 +27,7 @@ for dir in dirs:
keys
.
setdefault
(
key
,
0
)
keys
[
key
]
+=
1
del
f
except
IO
Error
:
except
OS
Error
:
# print dir, "don't have a key.pkl file"
pass
try
:
...
...
@@ -41,9 +41,8 @@ for dir in dirs:
del
mod
del
f
del
path
except
IO
Error
:
except
OS
Error
:
print
(
dir
,
"don't have a mod.{cpp,cu} file"
)
pass
if
DISPLAY_DUPLICATE_KEYS
:
for
k
,
v
in
keys
.
items
():
...
...
theano/misc/check_multi_gpu.py
浏览文件 @
2b658090
...
...
@@ -56,7 +56,7 @@ def main(dev1, dev2):
t2
=
time
.
time
()
r
=
None
print
(
"one ctx async
%
f"
%
(
t2
-
t
,
))
print
(
"one ctx async
{:f}"
.
format
(
t2
-
t
))
t
=
time
.
time
()
r
=
f2
.
fn
()
...
...
@@ -64,7 +64,7 @@ def main(dev1, dev2):
t2
=
time
.
time
()
r
=
None
print
(
"two ctx async
%
f"
%
(
t2
-
t
,
))
print
(
"two ctx async
{:f}"
.
format
(
t2
-
t
))
t
=
time
.
time
()
r
=
f3
.
fn
()
...
...
@@ -74,14 +74,14 @@ def main(dev1, dev2):
t2
=
time
.
time
()
r
=
None
print
(
"two ctx, 2 fct async
%
f"
%
(
t2
-
t
,
))
print
(
"two ctx, 2 fct async
{:f}"
.
format
(
t2
-
t
))
t
=
time
.
time
()
r
=
f5
.
fn
()
r2
=
f6
.
fn
()
t2
=
time
.
time
()
r
=
None
print
(
"two ctx, 2 fct with transfer
%
f"
%
(
t2
-
t
,
))
print
(
"two ctx, 2 fct with transfer
{:f}"
.
format
(
t2
-
t
))
# Multi-thread version
class
myThread
(
threading
.
Thread
):
...
...
@@ -110,7 +110,7 @@ def main(dev1, dev2):
thread2
.
join
()
t2
=
time
.
time
()
print
(
"two ctx, 2 fct async, 2 threads
%
f"
%
(
t2
-
t
,
))
print
(
"two ctx, 2 fct async, 2 threads
{:f}"
.
format
(
t2
-
t
))
thread1
=
myThread
(
"Thread-5"
,
f5
,
False
)
thread2
=
myThread
(
"Thread-6"
,
f6
,
False
)
...
...
@@ -121,7 +121,7 @@ def main(dev1, dev2):
thread2
.
join
()
t2
=
time
.
time
()
print
(
"two ctx, 2 fct with transfer, 2 threads
%
f"
%
(
t2
-
t
,
))
print
(
"two ctx, 2 fct with transfer, 2 threads
{:f}"
.
format
(
t2
-
t
))
if
__name__
==
"__main__"
:
...
...
theano/misc/elemwise_time_test.py
浏览文件 @
2b658090
...
...
@@ -67,5 +67,5 @@ if __name__ == "__main__":
(
cheapTime
,
costlyTime
)
=
ElemwiseOpTime
(
N
=
options
.
N
,
script
=
options
.
script
)
if
options
.
script
:
sys
.
stdout
.
write
(
"
%2.9
f
%2.9
f
\n
"
%
(
cheapTime
,
costlyTime
))
sys
.
stdout
.
write
(
"
{:2.9f} {:2.9f}
\n
"
.
format
(
cheapTime
,
costlyTime
))
sys
.
stdout
.
flush
()
theano/misc/frozendict.py
浏览文件 @
2b658090
...
...
@@ -36,7 +36,7 @@ class frozendict(Mapping):
return
len
(
self
.
_dict
)
def
__repr__
(
self
):
return
"<
%
s
%
r>"
%
(
self
.
__class__
.
__name__
,
self
.
_dict
)
return
"<
{} {!r}>"
.
format
(
self
.
__class__
.
__name__
,
self
.
_dict
)
def
__hash__
(
self
):
if
self
.
_hash
is
None
:
...
...
theano/misc/hooks/check_whitespace.py
浏览文件 @
2b658090
...
...
@@ -150,7 +150,7 @@ def is_python_file(filename):
def
get_file_contents
(
filename
,
revision
=
"tip"
):
hg_out
=
run_mercurial_command
(
"cat -r
%
s
%
s"
%
(
revision
,
filename
))
hg_out
=
run_mercurial_command
(
"cat -r
{} {}"
.
format
(
revision
,
filename
))
return
hg_out
...
...
@@ -169,7 +169,7 @@ def save_diffs(diffs, filename):
def
should_skip_commit
():
if
not
os
.
path
.
exists
(
SKIP_WHITESPACE_CHECK_FILENAME
):
return
False
with
open
(
SKIP_WHITESPACE_CHECK_FILENAME
,
"r"
)
as
whitespace_check_file
:
with
open
(
SKIP_WHITESPACE_CHECK_FILENAME
)
as
whitespace_check_file
:
whitespace_check_changeset
=
whitespace_check_file
.
read
()
return
whitespace_check_changeset
==
parent_commit
()
...
...
@@ -253,7 +253,8 @@ def main(argv=None):
parse_error
=
get_parse_error
(
code
)
if
parse_error
is
not
None
:
print
(
"***
%
s has parse error:
%
s"
%
(
filename
,
parse_error
),
file
=
sys
.
stderr
"*** {} has parse error: {}"
.
format
(
filename
,
parse_error
),
file
=
sys
.
stderr
,
)
block_commit
=
True
else
:
...
...
theano/misc/hooks/reindent.py
浏览文件 @
2b658090
...
...
@@ -120,8 +120,8 @@ def check(file):
print
(
"checking"
,
file
,
"..."
,
end
=
" "
)
try
:
f
=
open
(
file
)
except
IO
Error
as
msg
:
errprint
(
"
%
s: I/O Error:
%
s"
%
(
file
,
str
(
msg
)))
except
OS
Error
as
msg
:
errprint
(
"
{}: I/O Error: {}"
.
format
(
file
,
str
(
msg
)))
return
r
=
Reindenter
(
f
)
...
...
theano/misc/ordered_set.py
浏览文件 @
2b658090
...
...
@@ -2,8 +2,6 @@ import types
import
weakref
from
collections.abc
import
MutableSet
from
six
import
string_types
def
check_deterministic
(
iterable
):
# Most places where OrderedSet is used, theano interprets any exception
...
...
@@ -14,7 +12,7 @@ def check_deterministic(iterable):
# theano to use exceptions correctly, so that this can be a TypeError.
if
iterable
is
not
None
:
if
not
isinstance
(
iterable
,
(
list
,
tuple
,
OrderedSet
,
types
.
GeneratorType
,
str
ing_types
)
iterable
,
(
list
,
tuple
,
OrderedSet
,
types
.
GeneratorType
,
str
)
):
if
len
(
iterable
)
>
1
:
# We need to accept length 1 size to allow unpickle in tests.
...
...
@@ -45,7 +43,7 @@ def check_deterministic(iterable):
# {{{ http://code.activestate.com/recipes/576696/ (r5)
class
Link
(
object
)
:
class
Link
:
# This make that we need to use a different pickle protocol
# then the default. Othewise, there is pickling errors
__slots__
=
"prev"
,
"next"
,
"key"
,
"__weakref__"
...
...
@@ -173,8 +171,8 @@ class OrderedSet(MutableSet):
def
__repr__
(
self
):
if
not
self
:
return
"
%
s()"
%
(
self
.
__class__
.
__name__
,
)
return
"
%
s(
%
r)"
%
(
self
.
__class__
.
__name__
,
list
(
self
))
return
"
{}()"
.
format
(
self
.
__class__
.
__name__
)
return
"
{}({!r})"
.
format
(
self
.
__class__
.
__name__
,
list
(
self
))
def
__eq__
(
self
,
other
):
# Note that we implement only the comparison to another
...
...
theano/misc/pkl_utils.py
浏览文件 @
2b658090
...
...
@@ -82,7 +82,7 @@ class StripPickler(Pickler):
return
Pickler
.
save
(
self
,
obj
)
class
PersistentNdarrayID
(
object
)
:
class
PersistentNdarrayID
:
"""Persist ndarrays in an object by saving them to a zip file.
:param zip_file: A zip file handle that the NumPy arrays will be saved to.
...
...
@@ -104,7 +104,7 @@ class PersistentNdarrayID(object):
def
_resolve_name
(
self
,
obj
):
"""Determine the name the object should be saved under."""
name
=
"array_{
0
}"
.
format
(
self
.
count
)
name
=
"array_{}"
.
format
(
self
.
count
)
self
.
count
+=
1
return
name
...
...
@@ -117,7 +117,7 @@ class PersistentNdarrayID(object):
name
=
self
.
_resolve_name
(
obj
)
zipadd
(
write_array
,
self
.
zip_file
,
name
)
self
.
seen
[
id
(
obj
)]
=
"ndarray.{
0
}"
.
format
(
name
)
self
.
seen
[
id
(
obj
)]
=
"ndarray.{}"
.
format
(
name
)
return
self
.
seen
[
id
(
obj
)]
...
...
@@ -139,9 +139,9 @@ class PersistentGpuArrayID(PersistentNdarrayID):
name
=
self
.
_resolve_name
(
obj
)
zipadd
(
write_array
,
self
.
zip_file
,
name
)
self
.
seen
[
id
(
obj
)]
=
"gpuarray.{
0
}"
.
format
(
name
)
self
.
seen
[
id
(
obj
)]
=
"gpuarray.{}"
.
format
(
name
)
return
self
.
seen
[
id
(
obj
)]
return
super
(
PersistentGpuArrayID
,
self
)
.
__call__
(
obj
)
return
super
()
.
__call__
(
obj
)
class
PersistentSharedVariableID
(
PersistentGpuArrayID
):
...
...
@@ -169,7 +169,7 @@ class PersistentSharedVariableID(PersistentGpuArrayID):
"""
def
__init__
(
self
,
zip_file
,
allow_unnamed
=
True
,
allow_duplicates
=
True
):
super
(
PersistentSharedVariableID
,
self
)
.
__init__
(
zip_file
)
super
()
.
__init__
(
zip_file
)
self
.
name_counter
=
defaultdict
(
int
)
self
.
ndarray_names
=
{}
self
.
allow_unnamed
=
allow_unnamed
...
...
@@ -184,11 +184,11 @@ class PersistentSharedVariableID(PersistentGpuArrayID):
if
not
self
.
allow_duplicates
:
raise
ValueError
(
"multiple shared variables with the name "
"`{
0
}` found"
.
format
(
name
)
"`{}` found"
.
format
(
name
)
)
name
=
"{
0}_{1
}"
.
format
(
name
,
count
+
1
)
name
=
"{
}_{
}"
.
format
(
name
,
count
+
1
)
return
name
return
super
(
PersistentSharedVariableID
,
self
)
.
_resolve_name
(
obj
)
return
super
()
.
_resolve_name
(
obj
)
def
__call__
(
self
,
obj
):
if
isinstance
(
obj
,
SharedVariable
):
...
...
@@ -197,11 +197,11 @@ class PersistentSharedVariableID(PersistentGpuArrayID):
ValueError
(
"can't pickle shared variable with name `pkl`"
)
self
.
ndarray_names
[
id
(
obj
.
container
.
storage
[
0
])]
=
obj
.
name
elif
not
self
.
allow_unnamed
:
raise
ValueError
(
"unnamed shared variable, {
0
}"
.
format
(
obj
))
return
super
(
PersistentSharedVariableID
,
self
)
.
__call__
(
obj
)
raise
ValueError
(
"unnamed shared variable, {}"
.
format
(
obj
))
return
super
()
.
__call__
(
obj
)
class
PersistentNdarrayLoad
(
object
)
:
class
PersistentNdarrayLoad
:
"""Load NumPy arrays that were persisted to a zip file when pickling.
:param zip_file: The zip file handle in which the NumPy arrays are saved.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论