Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1ec0d8b1
提交
1ec0d8b1
authored
4月 14, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
First try at making visibility=hidden the default.
上级
94e31183
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
51 行增加
和
34 行删除
+51
-34
cmodule.py
theano/gof/cmodule.py
+18
-5
cutils.py
theano/gof/cutils.py
+3
-2
lazylinker_c.c
theano/gof/lazylinker_c.c
+3
-18
theano_mod_helper.h
theano/gof/theano_mod_helper.h
+12
-0
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+3
-6
cuda_ndarray.cuh
theano/sandbox/cuda/cuda_ndarray.cuh
+3
-1
nvcc_compiler.py
theano/sandbox/cuda/nvcc_compiler.py
+7
-1
scan_perform_ext.py
theano/scan_module/scan_perform_ext.py
+2
-1
没有找到文件。
theano/gof/cmodule.py
浏览文件 @
1ec0d8b1
...
@@ -150,7 +150,7 @@ class DynamicModule(object):
...
@@ -150,7 +150,7 @@ class DynamicModule(object):
self
.
support_code
=
[]
self
.
support_code
=
[]
self
.
functions
=
[]
self
.
functions
=
[]
self
.
includes
=
[
"<Python.h>"
,
"<iostream>"
]
self
.
includes
=
[
"<Python.h>"
,
"<iostream>"
,
'"theano_mod_helper.h"'
]
self
.
init_blocks
=
[]
self
.
init_blocks
=
[]
def
print_methoddef
(
self
,
stream
):
def
print_methoddef
(
self
,
stream
):
...
@@ -171,14 +171,14 @@ static struct PyModuleDef moduledef = {{
...
@@ -171,14 +171,14 @@ static struct PyModuleDef moduledef = {{
MyMethods,
MyMethods,
}};
}};
"""
.
format
(
name
=
self
.
hash_placeholder
),
file
=
stream
)
"""
.
format
(
name
=
self
.
hash_placeholder
),
file
=
stream
)
print
((
"
PyMOD
INIT_FUNC PyInit_
%
s(void) {"
%
print
((
"
THEANO_
INIT_FUNC PyInit_
%
s(void) {"
%
self
.
hash_placeholder
),
file
=
stream
)
self
.
hash_placeholder
),
file
=
stream
)
for
block
in
self
.
init_blocks
:
for
block
in
self
.
init_blocks
:
print
(
' '
,
block
,
file
=
stream
)
print
(
' '
,
block
,
file
=
stream
)
print
(
" PyObject *m = PyModule_Create(&moduledef);"
,
file
=
stream
)
print
(
" PyObject *m = PyModule_Create(&moduledef);"
,
file
=
stream
)
print
(
" return m;"
,
file
=
stream
)
print
(
" return m;"
,
file
=
stream
)
else
:
else
:
print
((
"
PyMOD
INIT_FUNC init
%
s(void){"
%
print
((
"
THEANO_
INIT_FUNC init
%
s(void){"
%
self
.
hash_placeholder
),
file
=
stream
)
self
.
hash_placeholder
),
file
=
stream
)
for
block
in
self
.
init_blocks
:
for
block
in
self
.
init_blocks
:
print
(
' '
,
block
,
file
=
stream
)
print
(
' '
,
block
,
file
=
stream
)
...
@@ -1449,7 +1449,8 @@ def std_include_dirs():
...
@@ -1449,7 +1449,8 @@ def std_include_dirs():
py_plat_spec_inc
=
distutils
.
sysconfig
.
get_python_inc
(
plat_specific
=
True
)
py_plat_spec_inc
=
distutils
.
sysconfig
.
get_python_inc
(
plat_specific
=
True
)
python_inc_dirs
=
([
py_inc
]
if
py_inc
==
py_plat_spec_inc
python_inc_dirs
=
([
py_inc
]
if
py_inc
==
py_plat_spec_inc
else
[
py_inc
,
py_plat_spec_inc
])
else
[
py_inc
,
py_plat_spec_inc
])
return
numpy_inc_dirs
+
python_inc_dirs
gof_inc_dir
=
os
.
path
.
dirname
(
__file__
)
return
numpy_inc_dirs
+
python_inc_dirs
+
[
gof_inc_dir
]
def
std_lib_dirs_and_libs
():
def
std_lib_dirs_and_libs
():
...
@@ -1929,7 +1930,7 @@ class GCC_compiler(Compiler):
...
@@ -1929,7 +1930,7 @@ class GCC_compiler(Compiler):
@staticmethod
@staticmethod
def
compile_str
(
module_name
,
src_code
,
location
=
None
,
def
compile_str
(
module_name
,
src_code
,
location
=
None
,
include_dirs
=
None
,
lib_dirs
=
None
,
libs
=
None
,
include_dirs
=
None
,
lib_dirs
=
None
,
libs
=
None
,
preargs
=
None
,
py_module
=
True
):
preargs
=
None
,
py_module
=
True
,
hide_symbols
=
True
):
"""
"""
:param module_name: string (this has been embedded in the src_code
:param module_name: string (this has been embedded in the src_code
...
@@ -1952,6 +1953,10 @@ class GCC_compiler(Compiler):
...
@@ -1952,6 +1953,10 @@ class GCC_compiler(Compiler):
:param py_module: if False, compile to a shared library, but do not
:param py_module: if False, compile to a shared library, but do not
import it as a Python module.
import it as a Python module.
:param hide_symbols: if True (the default) all symbols will be
hidden from the library symbol table (which means that other
objects can't use them.
:returns: dynamically-imported python module of the compiled code.
:returns: dynamically-imported python module of the compiled code.
(unless py_module is False, in that case returns None.)
(unless py_module is False, in that case returns None.)
"""
"""
...
@@ -2006,6 +2011,14 @@ class GCC_compiler(Compiler):
...
@@ -2006,6 +2011,14 @@ class GCC_compiler(Compiler):
else
:
else
:
cmd
.
extend
(
preargs
)
cmd
.
extend
(
preargs
)
cmd
.
extend
(
'-I
%
s'
%
idir
for
idir
in
include_dirs
)
cmd
.
extend
(
'-I
%
s'
%
idir
for
idir
in
include_dirs
)
if
hide_symbols
and
sys
.
platform
!=
'win32'
:
# This has been available since gcc 4.0 so we suppose it
# is always available. We pass it here since it
# significantly reduces the size of the symbol table for
# the objects we want to share. This in turns leads to
# improved loading times on most platforms (win32 is
# different, as usual).
cmd
.
append
(
'-fvisibility=hidden'
)
cmd
.
extend
([
'-o'
,
lib_filename
])
cmd
.
extend
([
'-o'
,
lib_filename
])
cmd
.
append
(
cppfilename
)
cmd
.
append
(
cppfilename
)
cmd
.
extend
([
'-L
%
s'
%
ldir
for
ldir
in
lib_dirs
])
cmd
.
extend
([
'-L
%
s'
%
ldir
for
ldir
in
lib_dirs
])
...
...
theano/gof/cutils.py
浏览文件 @
1ec0d8b1
...
@@ -188,6 +188,7 @@ def compile_cutils():
...
@@ -188,6 +188,7 @@ def compile_cutils():
code
=
(
"""
code
=
(
"""
#include <Python.h>
#include <Python.h>
#include "numpy/arrayobject.h"
#include "numpy/arrayobject.h"
#include "theano_mod_helper.h"
extern "C"{
extern "C"{
static PyObject *
static PyObject *
...
@@ -236,7 +237,7 @@ def compile_cutils():
...
@@ -236,7 +237,7 @@ def compile_cutils():
CutilsExtMethods,
CutilsExtMethods,
};
};
PyMOD
INIT_FUNC
THEANO_
INIT_FUNC
PyInit_cutils_ext(void) {
PyInit_cutils_ext(void) {
import_array();
import_array();
return PyModule_Create(&moduledef);
return PyModule_Create(&moduledef);
...
@@ -245,7 +246,7 @@ def compile_cutils():
...
@@ -245,7 +246,7 @@ def compile_cutils():
"""
"""
else
:
else
:
code
+=
"""
code
+=
"""
PyMOD
INIT_FUNC
THEANO_
INIT_FUNC
initcutils_ext(void)
initcutils_ext(void)
{
{
import_array();
import_array();
...
...
theano/gof/lazylinker_c.c
浏览文件 @
1ec0d8b1
#include <Python.h>
#include <Python.h>
#include "theano_mod_helper.h"
#include "structmember.h"
#include "structmember.h"
#include <sys/time.h>
#include <sys/time.h>
// Old Python compatibility from here:
// http://www.python.org/dev/peps/pep-0353/
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
typedef
int
Py_ssize_t
;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
// This one was taken from:
// http://svn.python.org/projects/python/trunk/Modules/_ctypes/ctypes.h
#define PyNumber_AsSsize_t(ob, exc) PyInt_AsLong(ob)
#endif
#if PY_VERSION_HEX >= 0x03000000
#if PY_VERSION_HEX >= 0x03000000
#include "numpy/npy_3kcompat.h"
#include "numpy/npy_3kcompat.h"
#define PyCObject_AsVoidPtr NpyCapsule_AsVoidPtr
#define PyCObject_AsVoidPtr NpyCapsule_AsVoidPtr
...
@@ -1033,10 +1023,6 @@ static PyMethodDef lazylinker_ext_methods[] = {
...
@@ -1033,10 +1023,6 @@ static PyMethodDef lazylinker_ext_methods[] = {
{
NULL
,
NULL
,
0
,
NULL
}
/* Sentinel */
{
NULL
,
NULL
,
0
,
NULL
}
/* Sentinel */
};
};
#ifndef PyMODINIT_FUNC
/* declarations for DLL import/export */
#define PyMODINIT_FUNC void
#endif
#if defined(NPY_PY3K)
#if defined(NPY_PY3K)
static
struct
PyModuleDef
moduledef
=
{
static
struct
PyModuleDef
moduledef
=
{
PyModuleDef_HEAD_INIT
,
PyModuleDef_HEAD_INIT
,
...
@@ -1052,11 +1038,11 @@ static struct PyModuleDef moduledef = {
...
@@ -1052,11 +1038,11 @@ static struct PyModuleDef moduledef = {
#endif
#endif
#if defined(NPY_PY3K)
#if defined(NPY_PY3K)
#define RETVAL m
#define RETVAL m
PyMOD
INIT_FUNC
THEANO_
INIT_FUNC
PyInit_lazylinker_ext
(
void
)
{
PyInit_lazylinker_ext
(
void
)
{
#else
#else
#define RETVAL
#define RETVAL
PyMOD
INIT_FUNC
THEANO_
INIT_FUNC
initlazylinker_ext
(
void
)
initlazylinker_ext
(
void
)
{
{
#endif
#endif
...
@@ -1076,4 +1062,3 @@ initlazylinker_ext(void)
...
@@ -1076,4 +1062,3 @@ initlazylinker_ext(void)
return
RETVAL
;
return
RETVAL
;
}
}
theano/gof/theano_mod_helper.h
0 → 100644
浏览文件 @
1ec0d8b1
#ifndef THEANO_MOD_HELPER
#define THEANO_MOD_HELPER
#ifndef _WIN32
#define MOD_PUBLIC __attribute__((visibility ("default")))
#else
#define MOD_PUBLIC
#endif
#define THEANO_INIT_FUNC MOD_PUBLIC PyMODINIT_FUNC
#endif
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
1ec0d8b1
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include <Python.h>
#include <Python.h>
#include <structmember.h>
#include <structmember.h>
#include "theano_mod_helper.h"
#include <numpy/arrayobject.h>
#include <numpy/arrayobject.h>
#include <iostream>
#include <iostream>
...
@@ -3475,10 +3476,6 @@ static PyMethodDef module_methods[] = {
...
@@ -3475,10 +3476,6 @@ static PyMethodDef module_methods[] = {
{
NULL
,
NULL
,
NULL
,
NULL
}
/* Sentinel */
{
NULL
,
NULL
,
NULL
,
NULL
}
/* Sentinel */
};
};
#ifndef PyMODINIT_FUNC
/* declarations for DLL import/export */
#define PyMODINIT_FUNC void
#endif
#define CNDA_MOD_NAME "cuda_ndarray"
#define CNDA_MOD_NAME "cuda_ndarray"
#define CNDA_DOCSTRING "CUDA implementation of a numpy ndarray-like object."
#define CNDA_DOCSTRING "CUDA implementation of a numpy ndarray-like object."
...
@@ -3493,10 +3490,10 @@ static struct PyModuleDef cuda_ndarray_moduledef =
...
@@ -3493,10 +3490,10 @@ static struct PyModuleDef cuda_ndarray_moduledef =
module_methods
module_methods
};
};
PyMOD
INIT_FUNC
THEANO_
INIT_FUNC
PyInit_cuda_ndarray
(
void
)
PyInit_cuda_ndarray
(
void
)
#else
#else
PyMOD
INIT_FUNC
THEANO_
INIT_FUNC
initcuda_ndarray
(
void
)
initcuda_ndarray
(
void
)
#endif
#endif
{
{
...
...
theano/sandbox/cuda/cuda_ndarray.cuh
浏览文件 @
1ec0d8b1
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
#include "numpy/npy_3kcompat.h"
#include "numpy/npy_3kcompat.h"
#include "theano_mod_helper.h"
// Py3k strings are unicode, these mimic old functionality.
// Py3k strings are unicode, these mimic old functionality.
//
//
// NOTE: npy_3kcompat.h replaces PyString_X with PyBytes_X, which breaks
// NOTE: npy_3kcompat.h replaces PyString_X with PyBytes_X, which breaks
...
@@ -53,7 +55,7 @@
...
@@ -53,7 +55,7 @@
#endif
#endif
#define ALWAYS_INLINE
#define ALWAYS_INLINE
#else //else _WIN32
#else //else _WIN32
#define DllExport
#define DllExport
MOD_PUBLIC
#define ALWAYS_INLINE __attribute__((always_inline))
#define ALWAYS_INLINE __attribute__((always_inline))
#endif
#endif
...
...
theano/sandbox/cuda/nvcc_compiler.py
浏览文件 @
1ec0d8b1
...
@@ -208,7 +208,7 @@ class NVCC_compiler(Compiler):
...
@@ -208,7 +208,7 @@ class NVCC_compiler(Compiler):
def
compile_str
(
def
compile_str
(
module_name
,
src_code
,
module_name
,
src_code
,
location
=
None
,
include_dirs
=
[],
lib_dirs
=
[],
libs
=
[],
preargs
=
[],
location
=
None
,
include_dirs
=
[],
lib_dirs
=
[],
libs
=
[],
preargs
=
[],
rpaths
=
rpath_defaults
,
py_module
=
True
):
rpaths
=
rpath_defaults
,
py_module
=
True
,
hide_symbols
=
True
):
""":param module_name: string (this has been embedded in the src_code
""":param module_name: string (this has been embedded in the src_code
:param src_code: a complete c or c++ source listing for the module
:param src_code: a complete c or c++ source listing for the module
:param location: a pre-existing filesystem directory where the
:param location: a pre-existing filesystem directory where the
...
@@ -225,6 +225,9 @@ class NVCC_compiler(Compiler):
...
@@ -225,6 +225,9 @@ class NVCC_compiler(Compiler):
:param py_module: if False, compile to a shared library, but
:param py_module: if False, compile to a shared library, but
do not import as a Python module.
do not import as a Python module.
:param hide_symbols: if True (the default), hide all symbols
from the library symbol table unless explicitely exported.
:returns: dynamically-imported python module of the compiled code.
:returns: dynamically-imported python module of the compiled code.
(unless py_module is False, in that case returns None.)
(unless py_module is False, in that case returns None.)
...
@@ -320,6 +323,9 @@ class NVCC_compiler(Compiler):
...
@@ -320,6 +323,9 @@ class NVCC_compiler(Compiler):
# in both math_functions.h and pymath.h,
# in both math_functions.h and pymath.h,
# by not including the one in pymath.h
# by not including the one in pymath.h
cmd
.
extend
([
'-D HAVE_ROUND'
])
cmd
.
extend
([
'-D HAVE_ROUND'
])
else
:
if
hide_symbols
:
preargs2
.
append
(
'-fvisibility=hidden'
)
if
local_bitwidth
()
==
64
:
if
local_bitwidth
()
==
64
:
cmd
.
append
(
'-m64'
)
cmd
.
append
(
'-m64'
)
...
...
theano/scan_module/scan_perform_ext.py
浏览文件 @
1ec0d8b1
...
@@ -109,7 +109,8 @@ except ImportError:
...
@@ -109,7 +109,8 @@ except ImportError:
preargs
.
append
(
"-D NPY_F_CONTIGUOUS=NPY_ARRAY_F_CONTIGUOUS"
)
preargs
.
append
(
"-D NPY_F_CONTIGUOUS=NPY_ARRAY_F_CONTIGUOUS"
)
cmodule
.
GCC_compiler
.
compile_str
(
dirname
,
code
,
location
=
loc
,
cmodule
.
GCC_compiler
.
compile_str
(
dirname
,
code
,
location
=
loc
,
preargs
=
preargs
)
preargs
=
preargs
,
hide_symbols
=
False
)
# Save version into the __init__.py file.
# Save version into the __init__.py file.
init_py
=
os
.
path
.
join
(
loc
,
'__init__.py'
)
init_py
=
os
.
path
.
join
(
loc
,
'__init__.py'
)
open
(
init_py
,
'w'
)
.
write
(
'_version =
%
s
\n
'
%
version
)
open
(
init_py
,
'w'
)
.
write
(
'_version =
%
s
\n
'
%
version
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论