Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
15b8c753
提交
15b8c753
authored
4月 24, 2016
作者:
Chinnadhurai Sankar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix pep-8 errors in gof
上级
ad6a0499
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
67 行增加
和
80 行删除
+67
-80
callcache.py
theano/gof/callcache.py
+12
-12
cc.py
theano/gof/cc.py
+7
-13
cmodule.py
theano/gof/cmodule.py
+5
-6
graph.py
theano/gof/graph.py
+3
-3
link.py
theano/gof/link.py
+4
-6
op.py
theano/gof/op.py
+15
-17
toolbox.py
theano/gof/toolbox.py
+18
-18
unify.py
theano/gof/unify.py
+1
-3
vm.py
theano/gof/vm.py
+2
-2
没有找到文件。
theano/gof/callcache.py
浏览文件 @
15b8c753
...
...
@@ -18,8 +18,8 @@ class CallCache(object):
def
persist
(
self
,
filename
=
None
):
"""
Cache "filename" as a pickle file
"""
Cache "filename" as a pickle file
"""
if
filename
is
None
:
filename
=
self
.
filename
with
open
(
filename
,
'w'
)
as
f
:
...
...
@@ -27,16 +27,16 @@ class CallCache(object):
def
call
(
self
,
fn
,
args
=
(),
key
=
None
):
"""
Retrieve item from the cache(if available)
based on a key
Parameters
------------
key
parameter to retrieve cache item
fn,args
key to retrieve if "key" is None
"""
Retrieve item from the cache(if available)
based on a key
Parameters
------------
key
parameter to retrieve cache item
fn,args
key to retrieve if "key" is None
"""
if
key
is
None
:
key
=
(
fn
,
tuple
(
args
))
if
key
not
in
self
.
cache
:
...
...
theano/gof/cc.py
浏览文件 @
15b8c753
...
...
@@ -115,14 +115,12 @@ def failure_code(sub):
def
failure_code_init
(
sub
):
"""
Code for failure in the struct init.
Parameters:
--------------
sub
Dictionary used to template the struct.
* failure_var -> must contain a variable name to use for
the failure code.
"""
return
'''{
if (!PyErr_Occurred()) {
...
...
@@ -137,8 +135,8 @@ def failure_code_init(sub):
def
code_gen
(
blocks
):
"""
From a list of L{CodeBlock} instances, returns a string
that executes them all in sequence.
that executes them all in sequence.
Eg for C{(decl1, task1,
cleanup1)} and C{(decl2, task2, cleanup2)} the returned string
will be of the form:
...
...
@@ -156,7 +154,7 @@ def code_gen(blocks):
Parameters:
----------------
blocks
blocks
List of CodeBlock instances such that
* declarations, behavior and cleanup are in the run()
method of the struct
...
...
@@ -895,7 +893,6 @@ class CLinker(link.Linker):
"""
Returns a list of support code strings that are needed by
one or more Variables or Ops.
The support code from Variables is added before the support code from Ops.This might contain duplicates.
"""
ret
=
[]
...
...
@@ -1172,10 +1169,8 @@ class CLinker(link.Linker):
be allocated.
storage_map: dict that map variables to storages.
This is used when you need to customize the storage of
this thunk.
keep_lock
WRITEME
this thunk.keep_lock
WRITEME
Returns: thunk, input_storage, output_storage
The return values can be used as follows:
...
...
@@ -1845,11 +1840,10 @@ def _default_checker(x, y):
"""
Default checker for DualLinker. This checks that the
variables contain the same data using ==.
Parameters
-------------
x,y
the variables to compare data
x,y
the variables to compare data
"""
if
x
[
0
]
!=
y
[
0
]:
raise
Exception
(
"Output mismatch."
,
...
...
theano/gof/cmodule.py
浏览文件 @
15b8c753
...
...
@@ -1474,10 +1474,9 @@ class ModuleCache(object):
def
_rmtree
(
parent
,
ignore_nocleanup
=
False
,
msg
=
''
,
level
=
logging
.
DEBUG
,
ignore_if_missing
=
False
):
"""
On NFS filesystems, it is impossible to delete a directory with open
files in it.
files in it.
So instead, some commands in this file will respond to a
failed rmtree() by touching a 'delete.me' file. This file is a message
...
...
@@ -1485,13 +1484,13 @@ def _rmtree(parent, ignore_nocleanup=False, msg='', level=logging.DEBUG,
Paramters
----------
parent
Root node to start deleting from
Root node to start deleting from
ignore_nocleanup
Delete the tree if flag is TRUE
Delete the tree if flag is TRUE
level
Python Logging level. Set to "DEBUG" by default
Python Logging level. Set to "DEBUG" by default
ignore_if_missing
If set to True, just return without any issue if parent is NULL
If set to True, just return without any issue if parent is NULL
"""
if
ignore_if_missing
and
not
os
.
path
.
exists
(
parent
):
return
...
...
theano/gof/graph.py
浏览文件 @
15b8c753
...
...
@@ -708,7 +708,7 @@ def variables_and_orphans(i, o):
i : list
Input L{Variable}s.
o : list
Output L{Variable}s.
Output L{Variable}s.
"""
def
expand
(
r
):
...
...
@@ -775,7 +775,7 @@ def variables(i, o):
def
orphans
(
i
,
o
):
"""
Extracts list of variables within input and output nodes ( via dfs t ravesal) and returns the "orphans" among them
Parameters
----------
i : list
...
...
@@ -1225,7 +1225,7 @@ def op_as_string(i, op,
leaf_formatter
=
default_leaf_formatter
,
node_formatter
=
default_node_formatter
):
"""
Op to return a string representation of the subgraph
Op to return a string representation of the subgraph
between i and o
"""
strs
=
as_string
(
i
,
op
.
inputs
,
leaf_formatter
,
node_formatter
)
...
...
theano/gof/link.py
浏览文件 @
15b8c753
...
...
@@ -54,8 +54,7 @@ def thunk_hook(type, value, trace):
"""
This function is meant to replace excepthook and do some
special work if the exception value has a __thunk_trace__
field.
field.
In that case, it retrieves the field, which should
contain a trace as returned by L{traceback.extract_stack},
and prints it out on L{stderr}.
...
...
@@ -64,7 +63,7 @@ def thunk_hook(type, value, trace):
Parameters
------------
type
Exception class
Exception class
value
Exception instance
trace
...
...
@@ -617,7 +616,7 @@ def map_storage(fgraph, order, input_storage, output_storage, storage_map=None):
def
streamline
(
fgraph
,
thunks
,
order
,
post_thunk_old_storage
=
None
,
no_recycling
=
None
,
nice_errors
=
True
):
"""
WRITEME
WRITEME
Parameters
----------
...
...
@@ -714,7 +713,6 @@ class LocalLinker(Linker):
def
gc_helper
(
node_list
):
"""
Return the set of Variable instances which are computed by node_list.
Parameters
----------
node_list
...
...
@@ -790,7 +788,7 @@ class PerformLinker(LocalLinker):
def
make_all
(
self
,
input_storage
=
None
,
output_storage
=
None
,
storage_map
=
None
):
"""
Returns Function to run all nodes, list of input containers, list of outputs
Returns Function to run all nodes, list of input containers, list of outputs
Parameters
----------
...
...
theano/gof/op.py
浏览文件 @
15b8c753
...
...
@@ -792,8 +792,8 @@ class Op(utils.object2, PureOp, CLinkerOp):
def
_props
(
self
):
"""
Tuple of properties of all attributes
"""
Tuple of properties of all attributes
"""
return
tuple
(
getattr
(
self
,
a
)
for
a
in
self
.
__props__
)
def
_props_dict
(
self
):
...
...
@@ -927,7 +927,7 @@ class Op(utils.object2, PureOp, CLinkerOp):
def
make_thunk
(
self
,
node
,
storage_map
,
compute_map
,
no_recycling
):
"""
This function must return a thunk, that is a zero-arguments
This function must return a thunk, that is a zero-arguments
function that encapsulates the computation to be performed
by this op on the arguments of the node.
...
...
@@ -981,9 +981,8 @@ class Op(utils.object2, PureOp, CLinkerOp):
def
make_node
(
self
,
*
inputs
):
"""
Create a "apply" nodes for the inputs in that order.
"""
Create a "apply" nodes for the inputs in that order.
"""
if
not
hasattr
(
self
,
'itypes'
):
raise
NotImplementedError
(
"You can either define itypes and otypes,
\
or implement make_node"
)
...
...
@@ -1068,7 +1067,7 @@ def debug_error_message(msg):
def
debug_assert
(
condition
,
msg
=
None
):
"""
Customized assert with options to ignore the assert
Customized assert with options to ignore the assert
with just a warning
"""
if
msg
is
None
:
...
...
@@ -1179,8 +1178,8 @@ class OpenMPOp(Op):
def
c_compile_args
(
self
):
"""
Return the compilation arg "fopenmp" if openMP is supported
"""
Return the compilation arg "fopenmp" if openMP is supported
"""
self
.
update_self_openmp
()
if
self
.
openmp
:
return
[
'-fopenmp'
]
...
...
@@ -1188,9 +1187,8 @@ class OpenMPOp(Op):
def
c_headers
(
self
):
"""
Return the header file name "omp.h" if openMP is supported
"""
Return the header file name "omp.h" if openMP is supported
"""
self
.
update_self_openmp
()
if
self
.
openmp
:
return
[
"omp.h"
]
...
...
@@ -1199,8 +1197,8 @@ class OpenMPOp(Op):
@staticmethod
def
test_gxx_support
():
"""
Check if openMP is supported
"""
Check if openMP is supported
"""
code
=
"""
#include <omp.h>
int main( int argc, const char* argv[] )
...
...
@@ -1418,7 +1416,7 @@ class COp(Op):
def
c_init_code
(
self
):
"""
Get the code section for init_code
Get the code section for init_code
"""
if
'init_code'
in
self
.
code_sections
:
return
[
self
.
code_sections
[
'init_code'
]]
...
...
@@ -1588,8 +1586,8 @@ class COp(Op):
def
c_code_cleanup
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
"""
Stitches all the macros and "code_cleanup" together
"""
Stitches all the macros and "code_cleanup" together
"""
if
'code_cleanup'
in
self
.
code_sections
:
op_code
=
self
.
code_sections
[
'code_cleanup'
]
...
...
theano/gof/toolbox.py
浏览文件 @
15b8c753
...
...
@@ -115,19 +115,19 @@ class Bookkeeper(Feature):
def
on_attach
(
self
,
fgraph
):
"""
Called by FunctionGraph.attach_feature, the method that attaches
Called by FunctionGraph.attach_feature, the method that attaches
the feature to the FunctionGraph. Since this is called after the
FunctionGraph is initially populated, this is where you should
run checks on the initial contents of the FunctionGraph.
"""
"""
for
node
in
graph
.
io_toposort
(
fgraph
.
inputs
,
fgraph
.
outputs
):
self
.
on_import
(
fgraph
,
node
,
"on_attach"
)
def
on_detach
(
self
,
fgraph
):
"""
Should remove any dynamically added functionality
Should remove any dynamically added functionality
that it installed into the function_graph
"""
"""
for
node
in
graph
.
io_toposort
(
fgraph
.
inputs
,
fgraph
.
outputs
):
self
.
on_prune
(
fgraph
,
node
,
'Bookkeeper.detach'
)
...
...
@@ -189,9 +189,9 @@ class History(Feature):
def
on_detach
(
self
,
fgraph
):
"""
Should remove any dynamically added functionality
Should remove any dynamically added functionality
that it installed into the function_graph
"""
"""
del
fgraph
.
checkpoint
del
fgraph
.
revert
del
self
.
history
[
fgraph
]
...
...
@@ -238,18 +238,18 @@ class Validator(Feature):
def
on_detach
(
self
,
fgraph
):
"""
Should remove any dynamically added functionality
Should remove any dynamically added functionality
that it installed into the function_graph
"""
del
fgraph
.
validate
"""
del
fgraph
.
validate
del
fgraph
.
consistent
def
validate_
(
self
,
fgraph
):
"""
If the caller is replace_all_validate, just raise the
If the caller is replace_all_validate, just raise the
exception. replace_all_validate will print out the
verbose output. Or it has to be done here before raise.
"""
"""
t0
=
time
.
time
()
try
:
ret
=
fgraph
.
execute_callbacks
(
'validate'
)
...
...
@@ -313,9 +313,9 @@ class ReplaceValidate(History, Validator):
def
on_detach
(
self
,
fgraph
):
"""
Should remove any dynamically added functionality
Should remove any dynamically added functionality
that it installed into the function_graph
"""
"""
History
.
on_detach
(
self
,
fgraph
)
Validator
.
on_detach
(
self
,
fgraph
)
del
self
.
_nodes_removed
...
...
@@ -440,9 +440,9 @@ class NodeFinder(Bookkeeper):
def
on_detach
(
self
,
fgraph
):
"""
Should remove any dynamically added functionality
Should remove any dynamically added functionality
that it installed into the function_graph
"""
"""
if
self
.
fgraph
is
not
fgraph
:
raise
Exception
(
"This NodeFinder instance was not attached to the"
" provided fgraph."
)
...
...
@@ -493,9 +493,9 @@ class PrintListener(Feature):
def
on_detach
(
self
,
fgraph
):
"""
Should remove any dynamically added functionality
that it installed into the function_graph
"""
Should remove any dynamically added functionality
that it installed into the function_graph
"""
if
self
.
active
:
print
(
"-- detaching from: "
,
fgraph
)
...
...
theano/gof/unify.py
浏览文件 @
15b8c753
...
...
@@ -4,7 +4,7 @@ can be "unified" if there exists an assignment to all unification variables
such that the two expressions are equal.
For instance, [5, A, B] and [A, C, 9] can be unified if A=C=5 and B=9,
yielding [5, 5, 9].
yielding [5, 5, 9].
[5, [A, B]] and [A, [1, 2]] cannot be unified because there is no value for A
that satisfies the constraints. That's useful for pattern matching.
...
...
@@ -135,8 +135,6 @@ class Unification:
"""
This class represents a possible unification of a group of variables
with each other or with tangible values.
Parameters
----------
inplace : bool
...
...
theano/gof/vm.py
浏览文件 @
15b8c753
...
...
@@ -728,8 +728,8 @@ class VM_Linker(link.LocalLinker):
def
accept
(
self
,
fgraph
,
no_recycling
=
None
):
"""
Check if fgraph is the first FunctionGraph that has ever been
associated to self, else, create a new VM_Linker
Check if fgraph is the first FunctionGraph that has ever been
associated to self, else, create a new VM_Linker
associated to fgraph
Parameters
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论