Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
77daa7eb
Unverified
提交
77daa7eb
authored
5月 11, 2018
作者:
abergeron
提交者:
GitHub
5月 11, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6574 from GSam/pypy-hack
Make Theano work under pypy (WIP)
上级
516c609f
e75319f5
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
50 行增加
和
8 行删除
+50
-8
cmodule.py
theano/gof/cmodule.py
+33
-6
type.py
theano/gof/type.py
+10
-2
vm.py
theano/gof/vm.py
+7
-0
没有找到文件。
theano/gof/cmodule.py
浏览文件 @
77daa7eb
...
@@ -269,6 +269,14 @@ def dlimport(fullpath, suffix=None):
...
@@ -269,6 +269,14 @@ def dlimport(fullpath, suffix=None):
if
not
os
.
path
.
isabs
(
fullpath
):
if
not
os
.
path
.
isabs
(
fullpath
):
raise
ValueError
(
'`fullpath` must be an absolute path'
,
fullpath
)
raise
ValueError
(
'`fullpath` must be an absolute path'
,
fullpath
)
if
suffix
is
None
:
if
suffix
is
None
:
suffix
=
''
dist_suffix
=
distutils
.
sysconfig
.
get_config_var
(
"SO"
)
if
dist_suffix
is
not
None
and
dist_suffix
!=
''
:
if
fullpath
.
endswith
(
dist_suffix
):
suffix
=
dist_suffix
if
suffix
==
''
:
if
fullpath
.
endswith
(
'.so'
):
if
fullpath
.
endswith
(
'.so'
):
suffix
=
'.so'
suffix
=
'.so'
elif
fullpath
.
endswith
(
'.pyd'
):
elif
fullpath
.
endswith
(
'.pyd'
):
...
@@ -277,8 +285,7 @@ def dlimport(fullpath, suffix=None):
...
@@ -277,8 +285,7 @@ def dlimport(fullpath, suffix=None):
suffix
=
'.dll'
suffix
=
'.dll'
elif
fullpath
.
endswith
(
'.py'
):
elif
fullpath
.
endswith
(
'.py'
):
suffix
=
'.py'
suffix
=
'.py'
else
:
suffix
=
''
rval
=
None
rval
=
None
if
fullpath
.
endswith
(
suffix
):
if
fullpath
.
endswith
(
suffix
):
module_name
=
'.'
.
join
(
fullpath
.
split
(
os
.
path
.
sep
)[
-
2
:])[:
-
len
(
suffix
)]
module_name
=
'.'
.
join
(
fullpath
.
split
(
os
.
path
.
sep
)[
-
2
:])[:
-
len
(
suffix
)]
...
@@ -1675,10 +1682,21 @@ def std_lib_dirs_and_libs():
...
@@ -1675,10 +1682,21 @@ def std_lib_dirs_and_libs():
elif
sys
.
platform
==
'darwin'
:
elif
sys
.
platform
==
'darwin'
:
std_lib_dirs_and_libs
.
data
=
[],
[]
std_lib_dirs_and_libs
.
data
=
[],
[]
else
:
else
:
# assume Linux
if
platform
.
python_implementation
()
==
'PyPy'
:
# Assume Linux (note: Ubuntu doesn't ship this .so)
if
sys
.
version_info
<
(
3
,):
libname
=
"pypy-c"
else
:
libname
=
"pypy3-c"
# Unfortunately the only convention of this .so is that it appears
# next to the location of the interpreter binary.
libdir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
sys
.
executable
))
else
:
# Assume Linux
# Typical include directory: /usr/include/python2.6
# Typical include directory: /usr/include/python2.6
# get the name of the python library (shared object)
# get the name of the python library (shared object)
libname
=
distutils
.
sysconfig
.
get_config_var
(
"LDLIBRARY"
)
libname
=
distutils
.
sysconfig
.
get_config_var
(
"LDLIBRARY"
)
if
libname
.
startswith
(
"lib"
):
if
libname
.
startswith
(
"lib"
):
...
@@ -2277,9 +2295,18 @@ class GCC_compiler(Compiler):
...
@@ -2277,9 +2295,18 @@ class GCC_compiler(Compiler):
if
not
src_code
.
endswith
(
'
\n
'
):
if
not
src_code
.
endswith
(
'
\n
'
):
cppfile
.
write
(
'
\n
'
)
cppfile
.
write
(
'
\n
'
)
lib_filename
=
os
.
path
.
join
(
if
platform
.
python_implementation
()
==
'PyPy'
:
location
,
suffix
=
'.'
+
get_lib_extension
()
'
%
s.
%
s'
%
(
module_name
,
get_lib_extension
()))
dist_suffix
=
distutils
.
sysconfig
.
get_config_var
(
"SO"
)
if
dist_suffix
is
not
None
and
dist_suffix
!=
''
:
suffix
=
dist_suffix
filepath
=
'
%
s
%
s'
%
(
module_name
,
suffix
)
else
:
filepath
=
'
%
s.
%
s'
%
(
module_name
,
get_lib_extension
())
lib_filename
=
os
.
path
.
join
(
location
,
filepath
)
_logger
.
debug
(
'Generating shared lib
%
s'
,
lib_filename
)
_logger
.
debug
(
'Generating shared lib
%
s'
,
lib_filename
)
cmd
=
[
theano
.
config
.
cxx
,
get_gcc_shared_library_arg
(),
'-g'
]
cmd
=
[
theano
.
config
.
cxx
,
get_gcc_shared_library_arg
(),
'-g'
]
...
...
theano/gof/type.py
浏览文件 @
77daa7eb
...
@@ -7,6 +7,7 @@ Defines the `Type` class.
...
@@ -7,6 +7,7 @@ Defines the `Type` class.
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
import
ctypes
import
ctypes
import
platform
from
six
import
string_types
from
six
import
string_types
...
@@ -606,7 +607,10 @@ class Generic(SingletonType):
...
@@ -606,7 +607,10 @@ class Generic(SingletonType):
generic
=
Generic
()
generic
=
Generic
()
_cdata_type
=
ctypes
.
py_object
.
from_address
(
_cdata_type
=
None
if
platform
.
python_implementation
()
!=
'PyPy'
:
_cdata_type
=
ctypes
.
py_object
.
from_address
(
ctypes
.
addressof
(
ctypes
.
pythonapi
.
PyCapsule_Type
))
.
value
ctypes
.
addressof
(
ctypes
.
pythonapi
.
PyCapsule_Type
))
.
value
...
@@ -679,8 +683,12 @@ class CDataType(Type):
...
@@ -679,8 +683,12 @@ class CDataType(Type):
self
.
version
=
version
self
.
version
=
version
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
if
data
is
not
None
and
not
isinstance
(
data
,
_cdata_type
):
# We ignore this type-check (_cdata_type is None) in PyPy
# because this type is not exposed to us.
if
data
is
not
None
and
_cdata_type
is
not
None
:
if
not
isinstance
(
data
,
_cdata_type
):
raise
TypeError
(
"expected None or a PyCapsule"
)
raise
TypeError
(
"expected None or a PyCapsule"
)
return
data
return
data
def
_get_func
(
self
):
def
_get_func
(
self
):
...
...
theano/gof/vm.py
浏览文件 @
77daa7eb
...
@@ -13,6 +13,7 @@ import logging
...
@@ -13,6 +13,7 @@ import logging
import
sys
import
sys
import
time
import
time
import
warnings
import
warnings
import
platform
from
theano.configparser
import
(
config
,
_config_var_list
)
from
theano.configparser
import
(
config
,
_config_var_list
)
...
@@ -983,7 +984,11 @@ class VM_Linker(link.LocalLinker):
...
@@ -983,7 +984,11 @@ class VM_Linker(link.LocalLinker):
if
oidx
in
update_in_from_out
:
if
oidx
in
update_in_from_out
:
update_storage
.
append
(
update_in_from_out
[
oidx
])
update_storage
.
append
(
update_in_from_out
[
oidx
])
# PyPy has no sys.getrefcount, so ignore this check if not running
# under CPython.
if
platform
.
python_implementation
()
==
'CPython'
:
c0
=
sys
.
getrefcount
(
node_n_inputs
)
c0
=
sys
.
getrefcount
(
node_n_inputs
)
vm
=
CVM
(
vm
=
CVM
(
nodes
,
nodes
,
thunks
,
thunks
,
...
@@ -1006,6 +1011,8 @@ class VM_Linker(link.LocalLinker):
...
@@ -1006,6 +1011,8 @@ class VM_Linker(link.LocalLinker):
update_storage
=
update_storage
,
update_storage
=
update_storage
,
dependencies
=
dependency_map_list
,
dependencies
=
dependency_map_list
,
)
)
if
platform
.
python_implementation
()
==
'CPython'
:
assert
c0
==
sys
.
getrefcount
(
node_n_inputs
)
assert
c0
==
sys
.
getrefcount
(
node_n_inputs
)
else
:
else
:
lazy
=
self
.
lazy
lazy
=
self
.
lazy
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论