Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a7f94e0d
提交
a7f94e0d
authored
8月 06, 2012
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #829 from lamblin/fix_profile_py24
Fix test failure involving ProfileMode with python 2.4 NEWS.txt: fix python 2.4 problem with 1 tests (PL)
上级
fe0ad63e
ae9e4693
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
48 行增加
和
17 行删除
+48
-17
debugmode.py
theano/compile/debugmode.py
+1
-1
mode.py
theano/compile/mode.py
+1
-1
test_modes.py
theano/compile/tests/test_modes.py
+23
-1
cc.py
theano/gof/cc.py
+5
-2
link.py
theano/gof/link.py
+17
-1
unify.py
theano/gof/unify.py
+1
-0
utils.py
theano/gof/utils.py
+0
-11
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
a7f94e0d
...
...
@@ -1560,7 +1560,7 @@ class _Linker(gof.link.LocalLinker):
no_recycling
=
[]
if
self
.
fgraph
is
not
None
and
self
.
fgraph
is
not
fgraph
:
assert
type
(
self
)
is
_Linker
return
type
(
self
)(
self
.
fgraph
,
self
.
maker
)
.
accept
(
fgraph
,
no_recycling
)
return
type
(
self
)(
maker
=
self
.
maker
)
.
accept
(
fgraph
,
no_recycling
)
self
.
fgraph
=
fgraph
self
.
no_recycling
=
no_recycling
return
self
...
...
theano/compile/mode.py
浏览文件 @
a7f94e0d
...
...
@@ -328,7 +328,7 @@ class Mode(object):
self
.
linker_time
=
0
def
__str__
(
self
):
return
"
Mode(linker =
%
s, optimizer =
%
s)"
%
(
return
"
%
s(linker =
%
s, optimizer =
%
s)"
%
(
self
.
__class__
.
__name__
,
self
.
provided_linker
,
self
.
provided_optimizer
)
def
__get_optimizer
(
self
):
...
...
theano/compile/tests/test_modes.py
浏览文件 @
a7f94e0d
"""
Test compilation modes
"""
import
copy
import
unittest
import
theano
...
...
@@ -25,7 +26,6 @@ class T_bunch_of_modes(unittest.TestCase):
modes
=
predef_modes
+
[
Mode
(
linker
,
'fast_run'
)
for
linker
in
linkers
]
for
mode
in
modes
:
x
=
T
.
matrix
()
y
=
T
.
vector
()
f
=
theano
.
function
([
x
,
y
],
x
+
y
,
mode
=
mode
)
...
...
@@ -33,6 +33,7 @@ class T_bunch_of_modes(unittest.TestCase):
f
([[
1
,
2
],
[
3
,
4
]],
[
5
,
6
])
linker_classes_involved
.
append
(
f
.
maker
.
mode
.
linker
.
__class__
)
#print 'MODE:', mode, f.maker.mode.linker, 'stop'
# regression check:
# there should be
# - VM_Linker
...
...
@@ -42,5 +43,26 @@ class T_bunch_of_modes(unittest.TestCase):
# - DebugMode's Linker (DEBUG_MODE)
assert
5
==
len
(
set
(
linker_classes_involved
))
class
T_ProfileMode_WrapLinker
(
unittest
.
TestCase
):
def
test_1
(
self
):
# First, compile a function with a new ProfileMode() object
# No need to call that function
x
=
T
.
matrix
()
mode
=
ProfileMode
()
theano
.
function
([
x
],
x
*
2
,
mode
=
mode
)
# Then, build a mode with the same linker, and a modified optimizer
default_mode
=
theano
.
compile
.
mode
.
get_default_mode
()
modified_mode
=
default_mode
.
including
(
'specialize'
)
# The following line used to fail, with Python 2.4, in July 2012,
# because an fgraph was associated to the default linker
copy
.
deepcopy
(
modified_mode
)
# More straightforward test
assert
theano
.
compile
.
mode
.
get_default_mode
()
.
linker
.
fgraph
is
None
if
__name__
==
'__main__'
:
unittest
.
main
()
theano/gof/cc.py
浏览文件 @
a7f94e0d
...
...
@@ -1408,8 +1408,11 @@ class OpWiseCLinker(link.LocalLinker):
if
no_recycling
is
None
:
no_recycling
=
[]
if
self
.
fgraph
is
not
None
and
self
.
fgraph
is
not
fgraph
:
return
type
(
self
)(
self
.
fallback_on_perform
)
.
accept
(
fgraph
,
no_recycling
)
return
type
(
self
)(
fallback_on_perform
=
self
.
fallback_on_perform
,
allow_gc
=
self
.
allow_gc
,
nice_errors
=
self
.
nice_errors
)
.
accept
(
fgraph
,
no_recycling
)
#raise Exception("Cannot accept from a Linker that is
#already tied to another FunctionGraph.")
self
.
fgraph
=
fgraph
...
...
theano/gof/link.py
浏览文件 @
a7f94e0d
...
...
@@ -433,7 +433,7 @@ class PerformLinker(LocalLinker):
if
no_recycling
is
None
:
no_recycling
=
[]
if
self
.
fgraph
is
not
None
and
self
.
fgraph
is
not
fgraph
:
return
type
(
self
)()
.
accept
(
fgraph
,
no_recycling
)
return
type
(
self
)(
allow_gc
=
self
.
allow_gc
)
.
accept
(
fgraph
,
no_recycling
)
#raise Exception("Cannot accept from a Linker that is already tied to another FunctionGraph.")
self
.
fgraph
=
fgraph
self
.
no_recycling
=
no_recycling
...
...
@@ -553,6 +553,22 @@ class WrapLinker(Linker):
self
.
linkers
=
linkers
self
.
wrapper
=
wrapper
def
__copy__
(
self
):
"""
Shallow copy of a WrapLinker.
@returns: A copy of self, where each of the linkers in self.linkers
have been shallow-copied.
It is useful because in FunctionMaker, copy.copy is called on the
Mode's linker, so that it is not modified inplace when linker.accept()
is called. In this case, we want the wrapped linkers to be copied too.
"""
other
=
self
.
__class__
(
linkers
=
[
copy
(
l
)
for
l
in
self
.
linkers
],
wrapper
=
self
.
wrapper
)
return
other
def
accept
(
self
,
fgraph
,
no_recycling
=
None
):
"""
@type fgraph: gof.FunctionGraph
...
...
theano/gof/unify.py
浏览文件 @
a7f94e0d
...
...
@@ -9,6 +9,7 @@ if there exists an assignment to all unification variables such that
"""
from
copy
import
copy
from
python25
import
partial
from
utils
import
*
...
...
theano/gof/utils.py
浏览文件 @
a7f94e0d
...
...
@@ -179,17 +179,6 @@ def from_return_values(values):
return
[
values
]
def
partial
(
func
,
*
args
,
**
keywords
):
def
newfunc
(
*
fargs
,
**
fkeywords
):
newkeywords
=
keywords
.
copy
()
newkeywords
.
update
(
fkeywords
)
return
func
(
*
(
args
+
fargs
),
**
newkeywords
)
newfunc
.
func
=
func
newfunc
.
args
=
args
newfunc
.
keywords
=
keywords
return
newfunc
class
ClsInit
(
type
):
"""Class initializer for L{Op} subclasses"""
def
__init__
(
cls
,
name
,
bases
,
dct
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论