Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
eeb32bd2
提交
eeb32bd2
authored
10月 21, 2014
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow None as a valid context.
The NoContext object in graph will serve a "absent context" marker.
上级
df669cc6
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
9 行增加
和
8 行删除
+9
-8
cc.py
theano/gof/cc.py
+5
-5
graph.py
theano/gof/graph.py
+2
-1
op.py
theano/gof/op.py
+2
-2
没有找到文件。
theano/gof/cc.py
浏览文件 @
eeb32bd2
...
@@ -516,7 +516,7 @@ class CLinker(link.Linker):
...
@@ -516,7 +516,7 @@ class CLinker(link.Linker):
self
.
contexts
=
dict
()
self
.
contexts
=
dict
()
for
node
in
self
.
node_order
:
for
node
in
self
.
node_order
:
ctx
=
node
.
run_context
()
ctx
=
node
.
run_context
()
if
ctx
is
not
None
:
if
ctx
is
not
graph
.
NoContext
:
# try to avoid creating more than one variable for the
# try to avoid creating more than one variable for the
# same context.
# same context.
if
ctx
in
self
.
contexts
:
if
ctx
in
self
.
contexts
:
...
@@ -665,7 +665,7 @@ class CLinker(link.Linker):
...
@@ -665,7 +665,7 @@ class CLinker(link.Linker):
sub
=
dict
(
failure_var
=
failure_var
)
sub
=
dict
(
failure_var
=
failure_var
)
ctx
=
node
.
run_context
()
ctx
=
node
.
run_context
()
if
ctx
is
not
None
:
if
ctx
is
not
graph
.
NoContext
:
context_var
=
symbol
[
self
.
contexts
[
ctx
]]
context_var
=
symbol
[
self
.
contexts
[
ctx
]]
# The placeholder will be replaced by a hash of the entire
# The placeholder will be replaced by a hash of the entire
...
@@ -682,15 +682,15 @@ class CLinker(link.Linker):
...
@@ -682,15 +682,15 @@ class CLinker(link.Linker):
# Make the CodeBlock for c_code
# Make the CodeBlock for c_code
sub
[
'id'
]
=
id
sub
[
'id'
]
=
id
sub
[
'fail'
]
=
failure_code
(
sub
)
sub
[
'fail'
]
=
failure_code
(
sub
)
if
ctx
is
not
None
:
if
ctx
is
not
graph
.
NoContext
:
sub
[
'context'
]
=
context_var
sub
[
'context'
]
=
context_var
sub_struct
=
dict
()
sub_struct
=
dict
()
sub_struct
[
'id'
]
=
id
+
1
sub_struct
[
'id'
]
=
id
+
1
sub_struct
[
'fail'
]
=
failure_code_init
(
sub
)
sub_struct
[
'fail'
]
=
failure_code_init
(
sub
)
if
ctx
is
not
None
:
if
ctx
is
not
graph
.
NoContext
:
# Since context inputs are always constants they are
# Since context inputs are always constants they are
# guar
e
nteed to be available in the struct init code.
# guar
a
nteed to be available in the struct init code.
sub_struct
[
'context'
]
=
context_var
sub_struct
[
'context'
]
=
context_var
struct_support
=
""
struct_support
=
""
...
...
theano/gof/graph.py
浏览文件 @
eeb32bd2
...
@@ -21,6 +21,7 @@ from theano.misc.ordered_set import OrderedSet
...
@@ -21,6 +21,7 @@ from theano.misc.ordered_set import OrderedSet
is_same_graph_with_merge
=
None
is_same_graph_with_merge
=
None
equal_computations
=
None
equal_computations
=
None
NoContext
=
object
()
class
Node
(
utils
.
object2
):
class
Node
(
utils
.
object2
):
"""A Node in a theano graph.
"""A Node in a theano graph.
...
@@ -120,7 +121,7 @@ class Apply(Node):
...
@@ -120,7 +121,7 @@ class Apply(Node):
"""
"""
if
hasattr
(
self
.
op
,
'get_context'
):
if
hasattr
(
self
.
op
,
'get_context'
):
return
self
.
op
.
get_context
(
self
)
return
self
.
op
.
get_context
(
self
)
return
No
ne
return
No
Context
def
default_output
(
self
):
def
default_output
(
self
):
"""Returns the default output for this node.
"""Returns the default output for this node.
...
...
theano/gof/op.py
浏览文件 @
eeb32bd2
...
@@ -742,9 +742,9 @@ class Op(utils.object2, PureOp, CLinkerOp):
...
@@ -742,9 +742,9 @@ class Op(utils.object2, PureOp, CLinkerOp):
p
=
node
.
op
.
perform
p
=
node
.
op
.
perform
ctx
=
node
.
get
_context
()
ctx
=
node
.
run
_context
()
if
ctx
is
None
:
if
ctx
is
graph
.
NoContext
:
# 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
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论