Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
23aa7ddc
提交
23aa7ddc
authored
12月 21, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unhacking the filter code by adding a new filter_inplace method to Type API - NEEDS TESTING
上级
b5986c84
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
13 行增加
和
11 行删除
+13
-11
link.py
theano/gof/link.py
+4
-7
type.py
theano/sandbox/cuda/type.py
+9
-4
没有找到文件。
theano/gof/link.py
浏览文件 @
23aa7ddc
...
...
@@ -163,19 +163,16 @@ class Container(object):
if
value
is
None
:
self
.
storage
[
0
]
=
None
return
if
self
.
type
.
__class__
.
__name__
==
"CudaNdarrayType"
and
isinstance
(
value
,
numpy
.
ndarray
):
#The filter method of CudaNdarray alloc a new memory region on the gpu.
#The ref count will be decremented after that.
#That cause 2 region allocated at the same time!
#We decrement the memory reference conter now to try to lower the memory usage.
self
.
storage
[
0
]
=
None
kwargs
=
{}
if
self
.
strict
:
kwargs
[
'strict'
]
=
True
if
self
.
allow_downcast
is
not
None
:
kwargs
[
'allow_downcast'
]
=
self
.
allow_downcast
self
.
storage
[
0
]
=
self
.
type
.
filter
(
value
,
**
kwargs
)
if
hasattr
(
self
.
type
,
'filter_inplace'
):
self
.
storage
[
0
]
=
self
.
type
.
filter_inplace
(
value
,
self
.
storage
[
0
],
**
kwargs
)
else
:
self
.
storage
[
0
]
=
self
.
type
.
filter
(
value
,
**
kwargs
)
except
Exception
,
e
:
e
.
args
=
e
.
args
+
((
'Container name "
%
s"'
%
self
.
name
),)
...
...
theano/sandbox/cuda/type.py
浏览文件 @
23aa7ddc
...
...
@@ -53,14 +53,18 @@ class CudaNdarrayType(Type):
self
.
dtype_specs
()
# error checking is done there
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
return
self
.
filter_inplace
(
data
,
None
,
strict
=
strict
,
allow_downcast
=
allow_downcast
)
def
filter_inplace
(
self
,
data
,
old_data
,
strict
=
False
,
allow_downcast
=
None
):
if
strict
or
allow_downcast
or
isinstance
(
data
,
cuda
.
CudaNdarray
):
return
cuda
.
filter
(
data
,
self
.
broadcastable
,
strict
,
None
)
return
cuda
.
filter
(
data
,
self
.
broadcastable
,
strict
,
old_data
)
else
:
# (not strict) and (not allow_downcast)
# Check if data.dtype can be accurately casted to self.dtype
if
isinstance
(
data
,
numpy
.
ndarray
):
up_dtype
=
scal
.
upcast
(
self
.
dtype
,
data
.
dtype
)
if
up_dtype
==
self
.
dtype
:
return
cuda
.
filter
(
data
,
self
.
broadcastable
,
strict
,
None
)
return
cuda
.
filter
(
data
,
self
.
broadcastable
,
strict
,
old_data
)
else
:
raise
TypeError
(
'
%
s, with dtype
%
s, cannot store a value of '
...
...
@@ -75,10 +79,10 @@ class CudaNdarrayType(Type):
type
(
data
)
is
float
and
self
.
dtype
==
theano
.
config
.
floatX
):
return
cuda
.
filter
(
converted_data
,
self
.
broadcastable
,
strict
,
None
)
strict
,
old_data
)
elif
numpy
.
all
(
data
==
converted_data
):
return
cuda
.
filter
(
converted_data
,
self
.
broadcastable
,
strict
,
None
)
strict
,
old_data
)
else
:
raise
TypeError
(
'
%
s, with dtype
%
s, cannot store accurately value
%
s, '
...
...
@@ -87,6 +91,7 @@ class CudaNdarrayType(Type):
%
(
self
,
self
.
dtype
,
data
,
converted_data
,
self
.
dtype
),
data
)
@staticmethod
def
bound
(
a
):
high
=
a
.
gpudata
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论