Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a2941943
提交
a2941943
authored
7月 13, 2015
作者:
Iban Harlouchet
提交者:
Frederic
7月 22, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flake8 of theano/gof/op.py; 3 E left
上级
d9166080
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
27 行删除
+24
-27
op.py
theano/gof/op.py
+24
-26
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/gof/op.py
浏览文件 @
a2941943
...
@@ -4,14 +4,6 @@ The `Op` class is the base interface for all operations
...
@@ -4,14 +4,6 @@ The `Op` class is the base interface for all operations
compatible with `gof`'s :doc:`graph` routines.
compatible with `gof`'s :doc:`graph` routines.
"""
"""
__authors__
=
"theano-dev"
__copyright__
=
"(c) 2010, Universite de Montreal"
__license__
=
"3-clause BSD License"
__contact__
=
"theano-dev <theano-dev@googlegroups.com>"
__docformat__
=
"restructuredtext en"
import
inspect
import
inspect
import
logging
import
logging
import
numpy
import
numpy
...
@@ -32,6 +24,13 @@ from theano.gof import utils
...
@@ -32,6 +24,13 @@ from theano.gof import utils
from
theano.gof.cmodule
import
GCC_compiler
from
theano.gof.cmodule
import
GCC_compiler
from
theano.gof.fg
import
FunctionGraph
from
theano.gof.fg
import
FunctionGraph
__authors__
=
"theano-dev"
__copyright__
=
"(c) 2010, Universite de Montreal"
__license__
=
"3-clause BSD License"
__contact__
=
"theano-dev <theano-dev@googlegroups.com>"
__docformat__
=
"restructuredtext en"
class
CLinkerObject
(
object
):
class
CLinkerObject
(
object
):
"""Standard elements of an Op or Type used with the CLinker
"""Standard elements of an Op or Type used with the CLinker
...
@@ -224,8 +223,7 @@ class CLinkerOp(CLinkerObject):
...
@@ -224,8 +223,7 @@ class CLinkerOp(CLinkerObject):
- `MethodNotDefined`: the subclass does not override this method
- `MethodNotDefined`: the subclass does not override this method
"""
"""
raise
utils
.
MethodNotDefined
(
'
%
s.c_code'
\
raise
utils
.
MethodNotDefined
(
'
%
s.c_code'
%
self
.
__class__
.
__name__
)
%
self
.
__class__
.
__name__
)
def
c_code_cache_version_apply
(
self
,
node
):
def
c_code_cache_version_apply
(
self
,
node
):
"""Return a tuple of integers indicating the version of this Op.
"""Return a tuple of integers indicating the version of this Op.
...
@@ -278,8 +276,8 @@ class CLinkerOp(CLinkerObject):
...
@@ -278,8 +276,8 @@ class CLinkerOp(CLinkerObject):
:Exceptions:
:Exceptions:
- `MethodNotDefined`: the subclass does not override this method
- `MethodNotDefined`: the subclass does not override this method
"""
"""
raise
utils
.
MethodNotDefined
(
'
%
s.c_code_cleanup'
\
raise
utils
.
MethodNotDefined
(
'
%
s.c_code_cleanup'
%
%
self
.
__class__
.
__name__
)
self
.
__class__
.
__name__
)
def
c_support_code_apply
(
self
,
node
,
name
):
def
c_support_code_apply
(
self
,
node
,
name
):
"""Optional: Return utility code for use by an `Op` that will be
"""Optional: Return utility code for use by an `Op` that will be
...
@@ -763,6 +761,7 @@ class Op(utils.object2, PureOp, CLinkerOp):
...
@@ -763,6 +761,7 @@ class Op(utils.object2, PureOp, CLinkerOp):
return
r
return
r
else
:
else
:
ctx_val
=
node
.
context_type
.
filter
(
ctx
)
ctx_val
=
node
.
context_type
.
filter
(
ctx
)
def
rval
(
p
=
p
,
i
=
node_input_storage
,
o
=
node_output_storage
,
n
=
node
,
def
rval
(
p
=
p
,
i
=
node_input_storage
,
o
=
node_output_storage
,
n
=
node
,
ctx
=
ctx_val
):
ctx
=
ctx_val
):
r
=
p
(
n
,
[
x
[
0
]
for
x
in
i
],
o
,
ctx
)
r
=
p
(
n
,
[
x
[
0
]
for
x
in
i
],
o
,
ctx
)
...
@@ -1141,9 +1140,9 @@ class COp(Op):
...
@@ -1141,9 +1140,9 @@ class COp(Op):
n
=
1
n
=
1
while
n
<
len
(
split
):
while
n
<
len
(
split
):
if
split
[
n
]
==
'APPLY'
:
if
split
[
n
]
==
'APPLY'
:
self
.
code_sections
[
'support_code_apply'
]
=
split
[
n
+
1
]
self
.
code_sections
[
'support_code_apply'
]
=
split
[
n
+
1
]
elif
split
[
n
]
==
'SUPPORT'
:
elif
split
[
n
]
==
'SUPPORT'
:
self
.
code_sections
[
'support_code'
]
=
split
[
n
+
1
]
self
.
code_sections
[
'support_code'
]
=
split
[
n
+
1
]
n
+=
2
n
+=
2
continue
continue
...
@@ -1164,7 +1163,7 @@ class COp(Op):
...
@@ -1164,7 +1163,7 @@ class COp(Op):
(
self
.
func_files
[
i
],
split
[
n
]))
(
self
.
func_files
[
i
],
split
[
n
]))
if
split
[
n
]
not
in
self
.
code_sections
:
if
split
[
n
]
not
in
self
.
code_sections
:
self
.
code_sections
[
split
[
n
]]
=
""
self
.
code_sections
[
split
[
n
]]
=
""
self
.
code_sections
[
split
[
n
]]
+=
split
[
n
+
1
]
self
.
code_sections
[
split
[
n
]]
+=
split
[
n
+
1
]
n
+=
2
n
+=
2
else
:
else
:
...
@@ -1267,8 +1266,8 @@ class COp(Op):
...
@@ -1267,8 +1266,8 @@ class COp(Op):
def
get_sub_macros
(
self
,
sub
):
def
get_sub_macros
(
self
,
sub
):
define_macros
=
[]
define_macros
=
[]
undef_macros
=
[]
undef_macros
=
[]
define_macros
.
append
(
"#define FAIL
%
s"
%
define_macros
.
append
(
"#define FAIL
%
s"
%
(
(
self
.
_lquote_macro
(
sub
[
'fail'
]),))
self
.
_lquote_macro
(
sub
[
'fail'
]),))
undef_macros
.
append
(
"#undef FAIL"
)
undef_macros
.
append
(
"#undef FAIL"
)
if
'context'
in
sub
:
if
'context'
in
sub
:
define_macros
.
append
(
"#define CONTEXT
%
s"
%
(
sub
[
'context'
],))
define_macros
.
append
(
"#define CONTEXT
%
s"
%
(
sub
[
'context'
],))
...
@@ -1305,25 +1304,24 @@ class COp(Op):
...
@@ -1305,25 +1304,24 @@ class COp(Op):
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
if
self
.
func_name
is
not
None
:
if
self
.
func_name
is
not
None
:
assert
'code'
not
in
self
.
code_sections
assert
'code'
not
in
self
.
code_sections
func_name
=
self
.
func_name
func_args
=
self
.
format_c_function_args
(
inp
,
out
)
fail
=
sub
[
'fail'
]
define_macros
,
undef_macros
=
self
.
get_c_macros
(
node
,
name
,
define_macros
,
undef_macros
=
self
.
get_c_macros
(
node
,
name
,
check_input
=
False
)
check_input
=
False
)
# Generate the C code
# Generate the C code
return
"""
return
"""
%(define_macros)
s
%(define_macros)
s
{
{
if (
%(func_name)
s(
%(func_args)
s) != 0) {
if (
%(func_name)
s(
%(func_args)
s) != 0) {
%(fail)
s
%(fail)
s
}
}
}
}
%(undef_macros)
s
%(undef_macros)
s
"""
%
dict
(
func_name
=
self
.
func_name
,
fail
=
sub
[
'fail'
],
"""
%
dict
(
func_name
=
self
.
func_name
,
fail
=
sub
[
'fail'
],
func_args
=
self
.
format_c_function_args
(
inp
,
out
),
func_args
=
self
.
format_c_function_args
(
inp
,
out
),
define_macros
=
define_macros
,
undef_macros
=
undef_macros
)
define_macros
=
define_macros
,
undef_macros
=
undef_macros
)
else
:
else
:
if
'code'
in
self
.
code_sections
:
if
'code'
in
self
.
code_sections
:
op_code
=
self
.
code_sections
[
'code'
]
op_code
=
self
.
code_sections
[
'code'
]
...
...
theano/tests/test_flake8.py
浏览文件 @
a2941943
...
@@ -225,7 +225,6 @@ whitelist_flake8 = [
...
@@ -225,7 +225,6 @@ whitelist_flake8 = [
"sparse/sandbox/sp.py"
,
"sparse/sandbox/sp.py"
,
"gof/unify.py"
,
"gof/unify.py"
,
"gof/__init__.py"
,
"gof/__init__.py"
,
"gof/op.py"
,
"gof/tests/test_cmodule.py"
,
"gof/tests/test_cmodule.py"
,
"gof/tests/test_destroyhandler.py"
,
"gof/tests/test_destroyhandler.py"
,
"gof/tests/test_opt.py"
,
"gof/tests/test_opt.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论