Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
46ef1c33
提交
46ef1c33
authored
5月 23, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Flake8 for gof/cutils.py
上级
9d7c48d9
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
45 行增加
和
36 行删除
+45
-36
cutils.py
theano/gof/cutils.py
+45
-35
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/gof/cutils.py
浏览文件 @
46ef1c33
...
...
@@ -14,18 +14,21 @@ if os.path.exists(os.path.join(config.compiledir, 'cutils_ext.so')):
def
compile_cutils_code
():
types
=
[
'npy_'
+
t
for
t
in
[
'int8'
,
'int16'
,
'int32'
,
'int64'
,
'int128'
,
'int256'
,
'uint8'
,
'uint16'
,
'uint32'
,
'uint64'
,
'uint128'
,
'uint256'
,
'float16'
,
'float32'
,
'float64'
,
'float80'
,
'float96'
,
'float128'
,
'float256'
]]
'int256'
,
'uint8'
,
'uint16'
,
'uint32'
,
'uint64'
,
'uint128'
,
'uint256'
,
'float16'
,
'float32'
,
'float64'
,
'float80'
,
'float96'
,
'float128'
,
'float256'
]]
complex_types
=
[
'npy_'
+
t
for
t
in
[
'complex32'
,
'complex64'
,
'complex128'
,
'complex160'
,
'complex192'
,
'complex512'
]]
'complex128'
,
'complex160'
,
'complex192'
,
'complex512'
]]
inplace_map_template
=
"""
#if defined(
%(typen)
s)
static void
%(type)
s_inplace_add(PyArrayMapIterObject *mit, PyArrayIterObject *it, int inc_or_set)
static void
%(type)
s_inplace_add(PyArrayMapIterObject *mit,
PyArrayIterObject *it, int inc_or_set)
{
int index = mit->size;
while (index--) {
...
...
@@ -38,46 +41,52 @@ def compile_cutils_code():
#endif
"""
floatadd
=
"((
%(type)
s*)mit->dataptr)[0] = inc_or_set * ((
%(type)
s*)mit->dataptr)[0] + ((
%(type)
s*)it->dataptr)[0];"
floatadd
=
(
"((
%(type)
s*)mit->dataptr)[0] = inc_or_set * "
"((
%(type)
s*)mit->dataptr)[0] + ((
%(type)
s*)it->dataptr)[0];"
)
complexadd
=
"""
((
%(type)
s*)mit->dataptr)[0].real = inc_or_set * ((
%(type)
s*)mit->dataptr)[0].real + ((
%(type)
s*)it->dataptr)[0].real;
((
%(type)
s*)mit->dataptr)[0].imag = inc_or_set * ((
%(type)
s*)mit->dataptr)[0].imag + ((
%(type)
s*)it->dataptr)[0].imag;
((
%(type)
s*)mit->dataptr)[0].real = inc_or_set *
((
%(type)
s*)mit->dataptr)[0].real + ((
%(type)
s*)it->dataptr)[0].real;
((
%(type)
s*)mit->dataptr)[0].imag = inc_or_set *
((
%(type)
s*)mit->dataptr)[0].imag + ((
%(type)
s*)it->dataptr)[0].imag;
"""
fns
=
''
.
join
([
inplace_map_template
%
{
'type'
:
t
,
'typen'
:
t
.
upper
(),
'op'
:
floatadd
%
{
'type'
:
t
}}
for
t
in
types
]
+
for
t
in
types
]
+
[
inplace_map_template
%
{
'type'
:
t
,
'typen'
:
t
.
upper
(),
'op'
:
complexadd
%
{
'type'
:
t
}}
for
t
in
complex_types
])
for
t
in
complex_types
])
def
gen_binop
(
type
,
typen
):
return
"""
#if defined(
%(typen)
s)
%(type)
s_inplace_add,
#endif
"""
%
dict
(
type
=
type
,
typen
=
typen
)
fn_array
=
(
"static inplace_map_binop addition_funcs[] = {"
+
''
.
join
([
"""
#if defined(
%(typen)
s)
%(type)
s_inplace_add,
#endif
"""
%
{
'type'
:
t
,
'typen'
:
t
.
upper
()}
for
t
in
types
+
complex_types
])
+
"""NULL};
"""
)
''
.
join
([
gen_binop
(
type
=
t
,
typen
=
t
.
upper
())
for
t
in
types
+
complex_types
])
+
"NULL};
\n
"
)
def
gen_num
(
typen
):
return
"""
#if defined(
%(typen)
s)
%(typen)
s,
#endif
"""
%
dict
(
type
=
type
,
typen
=
typen
)
type_number_array
=
(
"static int type_numbers[] = {"
+
''
.
join
([
"""
#if defined(
%(typen)
s)
%(typen)
s,
#endif
"""
%
{
'type'
:
t
,
'typen'
:
t
.
upper
()}
for
t
in
types
+
complex_types
])
+
"-1000};"
)
''
.
join
([
gen_num
(
typen
=
t
.
upper
())
for
t
in
types
+
complex_types
])
+
"-1000};"
)
code
=
(
"""
#if NPY_API_VERSION >= 0x00000008
typedef void (*inplace_map_binop)(PyArrayMapIterObject *, PyArrayIterObject *, int inc_or_set);
"""
+
fns
+
fn_array
+
type_number_array
+
"""
typedef void (*inplace_map_binop)(PyArrayMapIterObject *,
PyArrayIterObject *, int inc_or_set);
"""
+
fns
+
fn_array
+
type_number_array
+
"""
static int
map_increment(PyArrayMapIterObject *mit, PyObject *op, inplace_map_binop add_inplace, int inc_or_set)
map_increment(PyArrayMapIterObject *mit, PyObject *op,
inplace_map_binop add_inplace, int inc_or_set)
{
PyArrayObject *arr = NULL;
PyArrayIterObject *it;
...
...
@@ -129,7 +138,8 @@ inplace_increment(PyObject *dummy, PyObject *args)
return NULL;
}
if (!PyArray_Check(arg_a)) {
PyErr_SetString(PyExc_ValueError, "needs an ndarray as first argument");
PyErr_SetString(PyExc_ValueError,
"needs an ndarray as first argument");
return NULL;
}
...
...
@@ -285,7 +295,7 @@ try:
open
(
os
.
path
.
join
(
location
,
'__init__.py'
),
'w'
)
.
close
()
try
:
from
cutils_ext.cutils_ext
import
*
from
cutils_ext.cutils_ext
import
*
# noqa
except
ImportError
:
get_lock
()
# Ensure no-one else is currently modifying the content of the compilation
...
...
@@ -296,11 +306,11 @@ try:
# We must retry to import it as some other process could
# have been compiling it between the first failed import
# and when we receive the lock
from
cutils_ext.cutils_ext
import
*
from
cutils_ext.cutils_ext
import
*
# noqa
except
ImportError
:
compile_cutils
()
from
cutils_ext.cutils_ext
import
*
from
cutils_ext.cutils_ext
import
*
# noqa
finally
:
# Release lock on compilation directory.
...
...
theano/tests/test_flake8.py
浏览文件 @
46ef1c33
...
...
@@ -268,7 +268,6 @@ whitelist_flake8 = [
"sparse/sandbox/truedot.py"
,
"sparse/sandbox/sp.py"
,
"gof/destroyhandler.py"
,
"gof/cutils.py"
,
"gof/compiledir.py"
,
"gof/unify.py"
,
"gof/lazylinker_c.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论