Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9a17df56
提交
9a17df56
authored
5月 10, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
factored adding traceback tag out of op and type. Added cls.Variable and cls.Constant to type
上级
98f7218c
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
32 行增加
和
17 行删除
+32
-17
op.py
theano/gof/op.py
+6
-4
type.py
theano/gof/type.py
+14
-12
utils.py
theano/gof/utils.py
+12
-1
没有找到文件。
theano/gof/op.py
浏览文件 @
9a17df56
...
@@ -9,9 +9,10 @@ compatible with `gof`'s :doc:`graph` routines.
...
@@ -9,9 +9,10 @@ compatible with `gof`'s :doc:`graph` routines.
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
import
utils
import
utils
import
traceback
from
theano
import
config
from
theano
import
config
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
"""
"""
...
@@ -320,9 +321,7 @@ class PureOp(object):
...
@@ -320,9 +321,7 @@ class PureOp(object):
"""
"""
node
=
self
.
make_node
(
*
inputs
,
**
kwargs
)
node
=
self
.
make_node
(
*
inputs
,
**
kwargs
)
limit
=
config
.
traceback
.
limit
self
.
add_tag_trace
(
node
)
if
limit
==
-
1
:
limit
=
None
node
.
tag
.
trace
=
traceback
.
extract_stack
(
limit
=
limit
)[:
-
1
]
if
self
.
default_output
is
not
None
:
if
self
.
default_output
is
not
None
:
return
node
.
outputs
[
self
.
default_output
]
return
node
.
outputs
[
self
.
default_output
]
else
:
else
:
...
@@ -331,6 +330,9 @@ class PureOp(object):
...
@@ -331,6 +330,9 @@ class PureOp(object):
else
:
else
:
return
node
.
outputs
return
node
.
outputs
# Convenience so that subclass implementers don't have to import utils
# just to self.add_tag_trace
add_tag_trace
=
staticmethod
(
utils
.
add_tag_trace
)
#########################
#########################
# Python implementation #
# Python implementation #
...
...
theano/gof/type.py
浏览文件 @
9a17df56
...
@@ -5,8 +5,7 @@ __docformat__ = "restructuredtext en"
...
@@ -5,8 +5,7 @@ __docformat__ = "restructuredtext en"
import
copy
import
copy
import
utils
import
utils
from
utils
import
MethodNotDefined
,
object2
from
utils
import
MethodNotDefined
,
object2
from
graph
import
Variable
import
graph
import
traceback
from
theano
import
config
from
theano
import
config
########
########
...
@@ -202,6 +201,9 @@ class PureType(object):
...
@@ -202,6 +201,9 @@ class PureType(object):
"""
"""
Variable
=
graph
.
Variable
#the type that will be created by call to make_variable.
Constant
=
graph
.
Constant
#the type that will be created by call to make_constant
def
filter
(
self
,
data
,
strict
=
False
):
def
filter
(
self
,
data
,
strict
=
False
):
"""Required: Return data or an appropriately wrapped/converted data.
"""Required: Return data or an appropriately wrapped/converted data.
...
@@ -233,8 +235,11 @@ class PureType(object):
...
@@ -233,8 +235,11 @@ class PureType(object):
A pretty string for printing and debugging.
A pretty string for printing and debugging.
"""
"""
r
=
Variable
(
self
,
name
=
name
)
return
self
.
Variable
(
self
,
name
=
name
)
return
r
def
make_constant
(
self
,
value
,
name
=
None
):
return
self
.
Constant
(
type
=
self
,
data
=
value
,
name
=
name
)
def
__call__
(
self
,
name
=
None
):
def
__call__
(
self
,
name
=
None
):
"""Return a new `Variable` instance of Type `self`.
"""Return a new `Variable` instance of Type `self`.
...
@@ -244,11 +249,7 @@ class PureType(object):
...
@@ -244,11 +249,7 @@ class PureType(object):
A pretty string for printing and debugging.
A pretty string for printing and debugging.
"""
"""
r
=
self
.
make_variable
(
name
)
return
utils
.
add_tag_trace
(
self
.
make_variable
(
name
))
limit
=
config
.
traceback
.
limit
if
limit
==
-
1
:
limit
=
None
r
.
tag
.
trace
=
traceback
.
extract_stack
(
limit
=
limit
)[:
-
1
]
return
r
def
values_eq
(
self
,
a
,
b
):
def
values_eq
(
self
,
a
,
b
):
"""
"""
...
@@ -319,9 +320,11 @@ class Type(object2, PureType, CLinkerType):
...
@@ -319,9 +320,11 @@ class Type(object2, PureType, CLinkerType):
"""
"""
## DELETEME ##
class
SingletonType
(
Type
):
class
SingletonType
(
Type
):
"""WRITEME"""
"""Convenient Base class for a Type subclass with no attributes
It saves having to implement __eq__ and __hash__
"""
__instance
=
None
__instance
=
None
def
__new__
(
cls
):
def
__new__
(
cls
):
if
cls
.
__instance
is
None
:
if
cls
.
__instance
is
None
:
...
@@ -378,6 +381,5 @@ class Generic(SingletonType):
...
@@ -378,6 +381,5 @@ class Generic(SingletonType):
Py_INCREF(py_
%(name)
s);
Py_INCREF(py_
%(name)
s);
"""
%
locals
()
"""
%
locals
()
generic
=
Generic
()
generic
=
Generic
()
theano/gof/utils.py
浏览文件 @
9a17df56
...
@@ -2,7 +2,18 @@
...
@@ -2,7 +2,18 @@
# import op
# import op
# import variable
# import variable
import
re
,
os
from
theano
import
config
import
re
,
os
,
traceback
def
add_tag_trace
(
thing
):
"""Add tag.trace to an node or variable.
The argument is returned after being affected (inplace).
"""
limit
=
config
.
traceback
.
limit
if
limit
==
-
1
:
limit
=
None
thing
.
tag
.
trace
=
traceback
.
extract_stack
(
limit
=
limit
)[:
-
1
]
return
thing
def
hashgen
():
def
hashgen
():
hashgen
.
next
+=
1
hashgen
.
next
+=
1
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论