Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8f92ab47
提交
8f92ab47
authored
10月 02, 2011
作者:
David Warde-Farley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
STY: fixed pep8 warnings in op.py
上级
e24cbb76
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
21 行删除
+23
-21
op.py
theano/gof/op.py
+23
-21
没有找到文件。
theano/gof/op.py
浏览文件 @
8f92ab47
...
@@ -140,7 +140,6 @@ class CLinkerObject(object):
...
@@ -140,7 +140,6 @@ class CLinkerObject(object):
"""
"""
return
self
.
c_code_cache_version
()
return
self
.
c_code_cache_version
()
def
c_compile_args
(
self
):
def
c_compile_args
(
self
):
"""Optional: Return a list of compile args recommended to compile the
"""Optional: Return a list of compile args recommended to compile the
code returned by other methods in this class.
code returned by other methods in this class.
...
@@ -174,6 +173,7 @@ class CLinkerObject(object):
...
@@ -174,6 +173,7 @@ class CLinkerObject(object):
"""
"""
raise
utils
.
MethodNotDefined
(
"c_no_compile_args"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
utils
.
MethodNotDefined
(
"c_no_compile_args"
,
type
(
self
),
self
.
__class__
.
__name__
)
class
CLinkerOp
(
CLinkerObject
):
class
CLinkerOp
(
CLinkerObject
):
"""
"""
Interface definition for `Op` subclasses compiled by `CLinker`.
Interface definition for `Op` subclasses compiled by `CLinker`.
...
@@ -413,7 +413,7 @@ class PureOp(object):
...
@@ -413,7 +413,7 @@ class PureOp(object):
no_recycling
=
[])
no_recycling
=
[])
required
=
thunk
()
required
=
thunk
()
assert
not
required
# We provided all inputs
assert
not
required
# We provided all inputs
for
output
in
node
.
outputs
:
for
output
in
node
.
outputs
:
# Check that the output has been computed
# Check that the output has been computed
...
@@ -467,6 +467,7 @@ class PureOp(object):
...
@@ -467,6 +467,7 @@ class PureOp(object):
"""
"""
raise
utils
.
MethodNotDefined
(
"perform"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
utils
.
MethodNotDefined
(
"perform"
,
type
(
self
),
self
.
__class__
.
__name__
)
class
Op
(
utils
.
object2
,
PureOp
,
CLinkerOp
):
class
Op
(
utils
.
object2
,
PureOp
,
CLinkerOp
):
"""Convenience class to bundle `PureOp` and `CLinkerOp`"""
"""Convenience class to bundle `PureOp` and `CLinkerOp`"""
def
__new__
(
cls
,
*
args
,
**
kwargs
):
def
__new__
(
cls
,
*
args
,
**
kwargs
):
...
@@ -519,13 +520,15 @@ class Op(utils.object2, PureOp, CLinkerOp):
...
@@ -519,13 +520,15 @@ class Op(utils.object2, PureOp, CLinkerOp):
no_recycling
=
e_no_recycling
)
no_recycling
=
e_no_recycling
)
logger
.
debug
(
'Trying CLinker.make_thunk'
)
logger
.
debug
(
'Trying CLinker.make_thunk'
)
fill_storage
,
node_input_filters
,
node_output_filters
=
cl
.
make_thunk
(
outputs
=
cl
.
make_thunk
(
input_storage
=
node_input_storage
,
input_storage
=
node_input_storage
,
output_storage
=
node_output_storage
)
output_storage
=
node_output_storage
)
fill_storage
,
node_input_filters
,
node_output_filters
=
outputs
def
rval
():
def
rval
():
fill_storage
()
fill_storage
()
for
o
in
node
.
outputs
:
for
o
in
node
.
outputs
:
compute_map
[
o
][
0
]
=
True
compute_map
[
o
][
0
]
=
True
rval
.
cthunk
=
fill_storage
.
cthunk
rval
.
cthunk
=
fill_storage
.
cthunk
rval
.
inputs
=
node_input_storage
rval
.
inputs
=
node_input_storage
rval
.
outputs
=
node_output_storage
rval
.
outputs
=
node_output_storage
...
@@ -538,11 +541,13 @@ class Op(utils.object2, PureOp, CLinkerOp):
...
@@ -538,11 +541,13 @@ class Op(utils.object2, PureOp, CLinkerOp):
p
=
node
.
op
.
perform
p
=
node
.
op
.
perform
# default arguments are stored in the closure of `rval`
# default arguments are stored in the closure of `rval`
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
):
r
=
p
(
n
,
[
x
[
0
]
for
x
in
i
],
o
)
r
=
p
(
n
,
[
x
[
0
]
for
x
in
i
],
o
)
for
o
in
node
.
outputs
:
for
o
in
node
.
outputs
:
compute_map
[
o
][
0
]
=
True
compute_map
[
o
][
0
]
=
True
return
r
return
r
rval
.
inputs
=
node_input_storage
rval
.
inputs
=
node_input_storage
rval
.
outputs
=
node_output_storage
rval
.
outputs
=
node_output_storage
rval
.
perform
=
p
rval
.
perform
=
p
...
@@ -565,6 +570,7 @@ def get_test_value(v):
...
@@ -565,6 +570,7 @@ def get_test_value(v):
v_tensor
=
theano
.
tensor
.
as_tensor_variable
(
v
)
v_tensor
=
theano
.
tensor
.
as_tensor_variable
(
v
)
return
PureOp
.
_get_test_value
(
v_tensor
)
return
PureOp
.
_get_test_value
(
v_tensor
)
def
missing_test_message
(
msg
):
def
missing_test_message
(
msg
):
""" Displays msg, a message saying that some test_value is missing,
""" Displays msg, a message saying that some test_value is missing,
in the appropriate form based on config.compute_test_value:
in the appropriate form based on config.compute_test_value:
...
@@ -575,16 +581,14 @@ def missing_test_message(msg):
...
@@ -575,16 +581,14 @@ def missing_test_message(msg):
warn: display msg as a warning
warn: display msg as a warning
raise: raise an AttributeError with msg as the exception text
raise: raise an AttributeError with msg as the exception text
"""
"""
action
=
config
.
compute_test_value
action
=
config
.
compute_test_value
if
action
==
'raise'
:
if
action
==
'raise'
:
raise
AttributeError
(
msg
)
raise
AttributeError
(
msg
)
elif
action
==
'warn'
:
elif
action
==
'warn'
:
warnings
.
warn
(
msg
,
stacklevel
=
2
)
warnings
.
warn
(
msg
,
stacklevel
=
2
)
else
:
else
:
assert
action
in
[
'ignore'
,
'off'
]
assert
action
in
[
'ignore'
,
'off'
]
def
debug_error_message
(
msg
):
def
debug_error_message
(
msg
):
""" Displays a message saying that an error was found in some
""" Displays a message saying that an error was found in some
...
@@ -596,28 +600,24 @@ def debug_error_message(msg):
...
@@ -596,28 +600,24 @@ def debug_error_message(msg):
#this message should never be called when the debugger is off
#this message should never be called when the debugger is off
assert
action
!=
'off'
assert
action
!=
'off'
if
action
in
[
'raise'
,
'ignore'
]:
if
action
in
[
'raise'
,
'ignore'
]:
raise
ValueError
(
msg
)
raise
ValueError
(
msg
)
else
:
else
:
assert
action
==
'warn'
assert
action
==
'warn'
warnings
.
warn
(
msg
,
stacklevel
=
2
)
warnings
.
warn
(
msg
,
stacklevel
=
2
)
def
debug_assert
(
condition
,
msg
):
def
debug_assert
(
condition
,
msg
):
if
not
condition
:
if
not
condition
:
action
=
config
.
compute_test_value
action
=
config
.
compute_test_value
if
action
in
[
'raise'
,
'ignore'
]:
if
action
in
[
'raise'
,
'ignore'
]:
raise
AssertionError
(
msg
)
raise
AssertionError
(
msg
)
else
:
else
:
assert
action
==
'warn'
assert
action
==
'warn'
warnings
.
warn
(
msg
,
stacklevel
=
2
)
warnings
.
warn
(
msg
,
stacklevel
=
2
)
def
get_debug_values
(
*
args
):
def
get_debug_values
(
*
args
):
""" Given a list of variables, does one of three things:
""" Given a list of variables, does one of three things:
1. If the interactive debugger is off, returns an empty list
1. If the interactive debugger is off, returns an empty list
...
@@ -647,9 +647,11 @@ def get_debug_values(*args):
...
@@ -647,9 +647,11 @@ def get_debug_values(*args):
rval
.
append
(
get_test_value
(
arg
))
rval
.
append
(
get_test_value
(
arg
))
except
AttributeError
:
except
AttributeError
:
if
hasattr
(
arg
,
'name'
)
and
arg
.
name
is
not
None
:
if
hasattr
(
arg
,
'name'
)
and
arg
.
name
is
not
None
:
missing_test_message
(
"Argument "
+
str
(
i
)
+
"('"
+
arg
.
name
+
"') has no test value"
)
missing_test_message
(
"Argument "
+
str
(
i
)
+
"('"
+
arg
.
name
+
"') has no test value"
)
else
:
else
:
missing_test_message
(
"Argument "
+
str
(
i
)
+
" has no test value"
)
missing_test_message
(
"Argument "
+
str
(
i
)
+
" has no test value"
)
return
[]
return
[]
return
[
tuple
(
rval
)
]
return
[
tuple
(
rval
)
]
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论