Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
eac844fc
提交
eac844fc
authored
3月 13, 2013
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PEP8
上级
0684ff58
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
10 行删除
+11
-10
function_module.py
theano/compile/function_module.py
+11
-10
没有找到文件。
theano/compile/function_module.py
浏览文件 @
eac844fc
...
@@ -781,7 +781,6 @@ class SanityCheckFunction(Function):
...
@@ -781,7 +781,6 @@ class SanityCheckFunction(Function):
return
variables
return
variables
###
###
### FunctionMaker
### FunctionMaker
###
###
...
@@ -813,12 +812,12 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
...
@@ -813,12 +812,12 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
view_tree_set
(
alias_root
(
fgraph
.
outputs
[
i
]),
views_of_output_i
)
view_tree_set
(
alias_root
(
fgraph
.
outputs
[
i
]),
views_of_output_i
)
copied
=
False
copied
=
False
# do not allow outputs to be aliased
# do not allow outputs to be aliased
for
j
in
xrange
(
i
+
1
,
len
(
fgraph
.
outputs
)):
for
j
in
xrange
(
i
+
1
,
len
(
fgraph
.
outputs
)):
# We could don't put deep copy if both outputs have borrow==True
# We could don't put deep copy if both outputs have borrow==True
# and not(wrapped_outputs[i].borrow and wrapped_outputs[j].borrow):
# and not(wrapped_outputs[i].borrow and wrapped_outputs[j].borrow):
if
fgraph
.
outputs
[
j
]
in
views_of_output_i
:
if
fgraph
.
outputs
[
j
]
in
views_of_output_i
:
if
wrapped_outputs
[
i
]
.
borrow
and
wrapped_outputs
[
j
]
.
borrow
:
if
wrapped_outputs
[
i
]
.
borrow
and
wrapped_outputs
[
j
]
.
borrow
:
fgraph
.
change_input
(
'output'
,
i
,
view_op
(
fgraph
.
outputs
[
i
]),
fgraph
.
change_input
(
'output'
,
i
,
view_op
(
fgraph
.
outputs
[
i
]),
reason
=
reason
)
reason
=
reason
)
else
:
else
:
fgraph
.
change_input
(
'output'
,
i
,
deep_copy_op
(
fgraph
.
outputs
[
i
]),
fgraph
.
change_input
(
'output'
,
i
,
deep_copy_op
(
fgraph
.
outputs
[
i
]),
...
@@ -831,7 +830,8 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
...
@@ -831,7 +830,8 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
# do not allow outputs to be aliased to an inputs (j), unless
# do not allow outputs to be aliased to an inputs (j), unless
# a) that j'th input has been 'destroyed' by e.g. in-place computations
# a) that j'th input has been 'destroyed' by e.g. in-place computations
# b) that j'th input is a shared variable that is also being updated
# b) that j'th input is a shared variable that is also being updated
if
hasattr
(
fgraph
,
'get_destroyers_of'
)
and
fgraph
.
get_destroyers_of
(
input_j
):
if
(
hasattr
(
fgraph
,
'get_destroyers_of'
)
and
fgraph
.
get_destroyers_of
(
input_j
)):
continue
continue
if
input_j
in
updated_fgraph_inputs
:
if
input_j
in
updated_fgraph_inputs
:
continue
continue
...
@@ -840,7 +840,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
...
@@ -840,7 +840,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
if
input_j
in
fgraph
.
inputs
:
if
input_j
in
fgraph
.
inputs
:
j
=
fgraph
.
inputs
.
index
(
input_j
)
j
=
fgraph
.
inputs
.
index
(
input_j
)
if
wrapped_outputs
[
i
]
.
borrow
and
wrapped_inputs
[
j
]
.
borrow
:
if
wrapped_outputs
[
i
]
.
borrow
and
wrapped_inputs
[
j
]
.
borrow
:
fgraph
.
change_input
(
'output'
,
i
,
view_op
(
fgraph
.
outputs
[
i
]),
fgraph
.
change_input
(
'output'
,
i
,
view_op
(
fgraph
.
outputs
[
i
]),
reason
=
"insert_deepcopy"
)
reason
=
"insert_deepcopy"
)
break
break
else
:
else
:
...
@@ -848,7 +848,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
...
@@ -848,7 +848,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
reason
=
"insert_deepcopy"
)
reason
=
"insert_deepcopy"
)
break
break
elif
wrapped_outputs
[
i
]
.
borrow
:
elif
wrapped_outputs
[
i
]
.
borrow
:
fgraph
.
change_input
(
'output'
,
i
,
view_op
(
fgraph
.
outputs
[
i
]),
fgraph
.
change_input
(
'output'
,
i
,
view_op
(
fgraph
.
outputs
[
i
]),
reason
=
"insert_deepcopy"
)
reason
=
"insert_deepcopy"
)
break
break
else
:
else
:
...
@@ -857,6 +857,8 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
...
@@ -857,6 +857,8 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
break
break
NODEFAULT
=
[
'NODEFAULT'
]
NODEFAULT
=
[
'NODEFAULT'
]
class
FunctionMaker
(
object
):
class
FunctionMaker
(
object
):
"""`FunctionMaker` is the class to `create` `Function` instances.
"""`FunctionMaker` is the class to `create` `Function` instances.
...
@@ -876,7 +878,7 @@ class FunctionMaker(object):
...
@@ -876,7 +878,7 @@ class FunctionMaker(object):
elif
isinstance
(
input
,
(
list
,
tuple
)):
elif
isinstance
(
input
,
(
list
,
tuple
)):
# (r, u) -> SymbolicInput(variable=r, update=u)
# (r, u) -> SymbolicInput(variable=r, update=u)
if
len
(
input
)
==
2
:
if
len
(
input
)
==
2
:
return
SymbolicInput
(
input
[
0
],
update
=
input
[
1
])
return
SymbolicInput
(
input
[
0
],
update
=
input
[
1
])
else
:
else
:
raise
TypeError
(
"Expected two elements in the list or tuple."
,
input
)
raise
TypeError
(
"Expected two elements in the list or tuple."
,
input
)
else
:
else
:
...
@@ -899,7 +901,7 @@ class FunctionMaker(object):
...
@@ -899,7 +901,7 @@ class FunctionMaker(object):
stacklevel
=
2
)
stacklevel
=
2
)
return
self
.
fgraph
return
self
.
fgraph
def
env_setter
(
self
,
value
):
def
env_setter
(
self
,
value
):
warnings
.
warn
(
"FunctionMaker.env is deprecated, it has been renamed 'fgraph'"
,
warnings
.
warn
(
"FunctionMaker.env is deprecated, it has been renamed 'fgraph'"
,
stacklevel
=
2
)
stacklevel
=
2
)
self
.
fgraph
=
value
self
.
fgraph
=
value
...
@@ -911,7 +913,6 @@ class FunctionMaker(object):
...
@@ -911,7 +913,6 @@ class FunctionMaker(object):
env
=
property
(
env_getter
,
env_setter
,
env_deleter
)
env
=
property
(
env_getter
,
env_setter
,
env_deleter
)
@staticmethod
@staticmethod
def
wrap_out
(
output
):
def
wrap_out
(
output
):
if
isinstance
(
output
,
SymbolicOutput
):
if
isinstance
(
output
,
SymbolicOutput
):
...
@@ -922,7 +923,7 @@ class FunctionMaker(object):
...
@@ -922,7 +923,7 @@ class FunctionMaker(object):
raise
TypeError
(
"Unknown output type:
%
s (
%
s)"
,
type
(
output
),
output
)
raise
TypeError
(
"Unknown output type:
%
s (
%
s)"
,
type
(
output
),
output
)
def
__init__
(
self
,
inputs
,
outputs
,
def
__init__
(
self
,
inputs
,
outputs
,
mode
=
None
,
accept_inplace
=
False
,
function_builder
=
Function
,
mode
=
None
,
accept_inplace
=
False
,
function_builder
=
Function
,
profile
=
None
,
on_unused_input
=
None
):
profile
=
None
,
on_unused_input
=
None
):
"""
"""
:type inputs: a list of SymbolicInput instances
:type inputs: a list of SymbolicInput instances
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论