Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6faf896e
提交
6faf896e
authored
1月 01, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
1月 01, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move hash_from_code to theano.utils and remove theano.gof.utils.hash_from_file
上级
5a180b58
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
23 行增加
和
39 行删除
+23
-39
configparser.py
theano/configparser.py
+2
-14
utils.py
theano/gof/utils.py
+0
-21
cmodule.py
theano/link/c/cmodule.py
+7
-2
utils.py
theano/sparse/utils.py
+1
-1
utils.py
theano/tensor/utils.py
+1
-1
utils.py
theano/utils.py
+12
-0
没有找到文件。
theano/configparser.py
浏览文件 @
6faf896e
import
hashlib
import
logging
import
logging
import
os
import
os
import
shlex
import
shlex
...
@@ -15,7 +14,7 @@ from configparser import (
...
@@ -15,7 +14,7 @@ from configparser import (
from
functools
import
wraps
from
functools
import
wraps
from
io
import
StringIO
from
io
import
StringIO
from
theano.utils
import
deprecated
from
theano.utils
import
deprecated
,
hash_from_code
_logger
=
logging
.
getLogger
(
"theano.configparser"
)
_logger
=
logging
.
getLogger
(
"theano.configparser"
)
...
@@ -67,17 +66,6 @@ class _ChangeFlagsDecorator:
...
@@ -67,17 +66,6 @@ class _ChangeFlagsDecorator:
v
.
__set__
(
self
.
_root
,
self
.
old_vals
[
k
])
v
.
__set__
(
self
.
_root
,
self
.
old_vals
[
k
])
def
_hash_from_code
(
msg
):
"""This function was copied from theano.gof.utils to get rid of that import."""
# hashlib.sha256() requires an object that supports buffer interface,
# but Python 3 (unicode) strings don't.
if
isinstance
(
msg
,
str
):
msg
=
msg
.
encode
()
# Python 3 does not like module names that start with
# a digit.
return
"m"
+
hashlib
.
sha256
(
msg
)
.
hexdigest
()
class
_SectionRedirect
:
class
_SectionRedirect
:
"""Functions as a mock property on the TheanoConfigParser.
"""Functions as a mock property on the TheanoConfigParser.
...
@@ -136,7 +124,7 @@ class TheanoConfigParser:
...
@@ -136,7 +124,7 @@ class TheanoConfigParser:
[
c
for
c
in
self
.
_config_var_dict
.
values
()
if
c
.
in_c_key
],
[
c
for
c
in
self
.
_config_var_dict
.
values
()
if
c
.
in_c_key
],
key
=
lambda
cv
:
cv
.
name
,
key
=
lambda
cv
:
cv
.
name
,
)
)
return
_
hash_from_code
(
return
hash_from_code
(
"
\n
"
.
join
(
"
\n
"
.
join
(
[
[
"{} = {}"
.
format
(
cv
.
name
,
cv
.
__get__
(
self
,
self
.
__class__
))
"{} = {}"
.
format
(
cv
.
name
,
cv
.
__get__
(
self
,
self
.
__class__
))
...
...
theano/gof/utils.py
浏览文件 @
6faf896e
import
hashlib
import
linecache
import
linecache
import
sys
import
sys
import
traceback
import
traceback
...
@@ -462,23 +461,3 @@ def flatten(a):
...
@@ -462,23 +461,3 @@ def flatten(a):
return
l
return
l
else
:
else
:
return
[
a
]
return
[
a
]
def
hash_from_code
(
msg
):
# hashlib.sha256() requires an object that supports buffer interface,
# but Python 3 (unicode) strings don't.
if
isinstance
(
msg
,
str
):
msg
=
msg
.
encode
()
# Python 3 does not like module names that start with
# a digit.
return
"m"
+
hashlib
.
sha256
(
msg
)
.
hexdigest
()
def
hash_from_file
(
file_path
):
"""
Return the SHA256 hash of a file.
"""
with
open
(
file_path
,
"rb"
)
as
f
:
file_content
=
f
.
read
()
return
hash_from_code
(
file_content
)
theano/link/c/cmodule.py
浏览文件 @
6faf896e
...
@@ -26,9 +26,14 @@ from theano.configdefaults import config, gcc_version_str
...
@@ -26,9 +26,14 @@ from theano.configdefaults import config, gcc_version_str
# we will abuse the lockfile mechanism when reading and writing the registry
# we will abuse the lockfile mechanism when reading and writing the registry
from
theano.gof
import
compilelock
from
theano.gof
import
compilelock
from
theano.gof.utils
import
flatten
,
hash_from_code
from
theano.gof.utils
import
flatten
from
theano.link.c.exceptions
import
MissingGXX
from
theano.link.c.exceptions
import
MissingGXX
from
theano.utils
import
LOCAL_BITWIDTH
,
output_subprocess_Popen
,
subprocess_Popen
from
theano.utils
import
(
LOCAL_BITWIDTH
,
hash_from_code
,
output_subprocess_Popen
,
subprocess_Popen
,
)
importlib
=
None
importlib
=
None
...
...
theano/sparse/utils.py
浏览文件 @
6faf896e
from
theano.
gof.
utils
import
hash_from_code
from
theano.utils
import
hash_from_code
def
hash_from_sparse
(
data
):
def
hash_from_sparse
(
data
):
...
...
theano/tensor/utils.py
浏览文件 @
6faf896e
import
numpy
as
np
import
numpy
as
np
import
theano
import
theano
from
theano.
gof.
utils
import
hash_from_code
from
theano.utils
import
hash_from_code
def
hash_from_ndarray
(
data
):
def
hash_from_ndarray
(
data
):
...
...
theano/utils.py
浏览文件 @
6faf896e
"""Utility functions that only depend on the standard library."""
"""Utility functions that only depend on the standard library."""
import
hashlib
import
inspect
import
inspect
import
os
import
os
import
struct
import
struct
...
@@ -284,3 +285,14 @@ def output_subprocess_Popen(command, **params):
...
@@ -284,3 +285,14 @@ def output_subprocess_Popen(command, **params):
# the stdout/stderr pipe.
# the stdout/stderr pipe.
out
=
p
.
communicate
()
out
=
p
.
communicate
()
return
out
+
(
p
.
returncode
,)
return
out
+
(
p
.
returncode
,)
def
hash_from_code
(
msg
):
"""Return the SHA256 hash of a string or bytes."""
# hashlib.sha256() requires an object that supports buffer interface,
# but Python 3 (unicode) strings don't.
if
isinstance
(
msg
,
str
):
msg
=
msg
.
encode
()
# Python 3 does not like module names that start with
# a digit.
return
"m"
+
hashlib
.
sha256
(
msg
)
.
hexdigest
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论