Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ede0a42b
提交
ede0a42b
authored
11月 16, 2010
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refractored the aliasing test by adding a method like `may_share_memory` to
the Theano type
上级
ae9825c5
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
24 行增加
和
8 行删除
+24
-8
function_module.py
theano/compile/function_module.py
+14
-8
basic.py
theano/sparse/basic.py
+6
-0
basic.py
theano/tensor/basic.py
+4
-0
没有找到文件。
theano/compile/function_module.py
浏览文件 @
ede0a42b
...
@@ -5,6 +5,7 @@ __docformat__ = "restructuredtext en"
...
@@ -5,6 +5,7 @@ __docformat__ = "restructuredtext en"
import
copy_reg
import
copy_reg
import
cPickle
import
cPickle
import
itertools
import
sys
,
time
,
copy
import
sys
,
time
,
copy
...
@@ -537,19 +538,24 @@ class Function(object):
...
@@ -537,19 +538,24 @@ class Function(object):
## Collect aliased inputs among the storage space
## Collect aliased inputs among the storage space
args_share_memory
=
[]
args_share_memory
=
[]
for
i
in
xrange
(
len
(
self
.
input_storage
)):
for
i
in
xrange
(
len
(
self
.
input_storage
)):
if
isinstance
(
self
.
input_storage
[
i
]
.
storage
[
0
],
i_var
=
self
.
maker
.
inputs
[
i
]
.
variable
numpy
.
ndarray
):
i_val
=
self
.
input_storage
[
i
]
.
storage
[
0
]
if
hasattr
(
i_var
.
type
,
'may_share_memory'
):
is_aliased
=
False
is_aliased
=
False
for
j
in
xrange
(
len
(
args_share_memory
)):
for
j
in
xrange
(
len
(
args_share_memory
)):
for
k
in
args_share_memory
[
j
]:
if
numpy
.
may_share_memory
(
group_j
=
itertools
.
izip
(
self
.
input_storage
[
i
]
.
storage
[
0
]
,
[
self
.
maker
.
inputs
[
k
]
.
variable
for
k
self
.
input_storage
[
k
]
.
storage
[
0
]):
in
args_share_memory
[
j
]],
[
self
.
input_storage
[
k
]
.
storage
[
0
]
for
k
in
args_share_memory
[
j
]])
if
numpy
.
any
([
(
var
.
type
is
i_var
.
type
and
var
.
type
.
may_share_memory
(
val
,
i_val
)
)
for
(
var
,
val
)
in
group_j
]):
is_aliased
=
True
is_aliased
=
True
args_share_memory
[
j
]
.
append
(
i
)
args_share_memory
[
j
]
.
append
(
i
)
break
break
if
is_aliased
:
break
if
not
is_aliased
:
if
not
is_aliased
:
args_share_memory
.
append
([
i
])
args_share_memory
.
append
([
i
])
...
...
theano/sparse/basic.py
浏览文件 @
ede0a42b
...
@@ -174,6 +174,12 @@ class SparseType(gof.Type):
...
@@ -174,6 +174,12 @@ class SparseType(gof.Type):
raise
NotImplementedError
()
raise
NotImplementedError
()
return
sp
return
sp
@staticmethod
def
may_share_memory
(
a
,
b
):
# This is Fred suggestion for a quick and dirty way of checking
# aliasing .. this can potentially be further refined (ticket #374)
return
a
is
b
def
make_variable
(
self
,
name
=
None
):
def
make_variable
(
self
,
name
=
None
):
return
SparseVariable
(
self
,
name
=
name
)
return
SparseVariable
(
self
,
name
=
name
)
...
...
theano/tensor/basic.py
浏览文件 @
ede0a42b
...
@@ -472,6 +472,10 @@ class TensorType(Type):
...
@@ -472,6 +472,10 @@ class TensorType(Type):
return
type
(
self
)
==
type
(
other
)
and
other
.
dtype
==
self
.
dtype
\
return
type
(
self
)
==
type
(
other
)
and
other
.
dtype
==
self
.
dtype
\
and
other
.
broadcastable
==
self
.
broadcastable
and
other
.
broadcastable
==
self
.
broadcastable
@staticmethod
def
may_share_memory
(
a
,
b
):
return
numpy
.
may_share_memory
(
a
,
b
)
@staticmethod
@staticmethod
def
values_eq
(
a
,
b
):
def
values_eq
(
a
,
b
):
#TODO: check to see if the dtype and shapes must match
#TODO: check to see if the dtype and shapes must match
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论