Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ce1d5d01
提交
ce1d5d01
authored
1月 27, 2017
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add inplace filtering for GpuArrayType so that shared value replacement
can be done without additional memory usage.
上级
e8daf149
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
19 行增加
和
6 行删除
+19
-6
type.py
theano/gpuarray/type.py
+19
-6
没有找到文件。
theano/gpuarray/type.py
浏览文件 @
ce1d5d01
...
@@ -197,6 +197,11 @@ class GpuArrayType(Type):
...
@@ -197,6 +197,11 @@ class GpuArrayType(Type):
self
.
broadcastable
)
self
.
broadcastable
)
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
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
(
isinstance
(
data
,
gpuarray
.
GpuArray
)
and
if
(
isinstance
(
data
,
gpuarray
.
GpuArray
)
and
data
.
typecode
==
self
.
typecode
):
data
.
typecode
==
self
.
typecode
):
# This is just to make this condition not enter the
# This is just to make this condition not enter the
...
@@ -218,9 +223,13 @@ class GpuArrayType(Type):
...
@@ -218,9 +223,13 @@ class GpuArrayType(Type):
(
allow_downcast
is
None
and
(
allow_downcast
is
None
and
type
(
data
)
==
float
and
type
(
data
)
==
float
and
self
.
dtype
==
config
.
floatX
)):
self
.
dtype
==
config
.
floatX
)):
data
=
gpuarray
.
array
(
data
,
dtype
=
self
.
typecode
,
copy
=
False
,
if
not
isinstance
(
data
,
gpuarray
.
GpuArray
):
ndmin
=
len
(
self
.
broadcastable
),
data
=
numpy
.
array
(
data
,
dtype
=
self
.
dtype
,
copy
=
False
,
context
=
self
.
context
)
ndmin
=
len
(
self
.
broadcastable
))
else
:
data
=
gpuarray
.
array
(
data
,
dtype
=
self
.
typecode
,
copy
=
False
,
ndmin
=
len
(
self
.
broadcastable
),
context
=
self
.
context
)
else
:
else
:
if
not
hasattr
(
data
,
'dtype'
):
if
not
hasattr
(
data
,
'dtype'
):
converted_data
=
theano
.
_asarray
(
data
,
self
.
dtype
)
converted_data
=
theano
.
_asarray
(
data
,
self
.
dtype
)
...
@@ -230,12 +239,10 @@ class GpuArrayType(Type):
...
@@ -230,12 +239,10 @@ class GpuArrayType(Type):
converted_data
,
converted_data
,
force_same_dtype
=
False
):
force_same_dtype
=
False
):
data
=
converted_data
data
=
converted_data
data
=
gpuarray
.
array
(
data
,
context
=
self
.
context
)
up_dtype
=
scalar
.
upcast
(
self
.
dtype
,
data
.
dtype
)
up_dtype
=
scalar
.
upcast
(
self
.
dtype
,
data
.
dtype
)
if
up_dtype
==
self
.
dtype
:
if
up_dtype
==
self
.
dtype
:
data
=
gpuarray
.
array
(
data
,
dtype
=
self
.
dtype
,
copy
=
False
,
data
=
numpy
.
array
(
data
,
dtype
=
self
.
dtype
,
copy
=
False
)
context
=
self
.
context
)
else
:
else
:
raise
TypeError
(
"
%
s cannot store a value of dtype
%
s "
raise
TypeError
(
"
%
s cannot store a value of dtype
%
s "
"without risking loss of precision."
%
"without risking loss of precision."
%
...
@@ -250,6 +257,12 @@ class GpuArrayType(Type):
...
@@ -250,6 +257,12 @@ class GpuArrayType(Type):
if
b
and
shp
[
i
]
!=
1
:
if
b
and
shp
[
i
]
!=
1
:
raise
TypeError
(
"Non-unit value on shape on a broadcastable"
raise
TypeError
(
"Non-unit value on shape on a broadcastable"
" dimension."
,
shp
,
self
.
broadcastable
)
" dimension."
,
shp
,
self
.
broadcastable
)
if
not
isinstance
(
data
,
gpuarray
.
GpuArray
):
if
old_data
and
old_data
.
shape
==
data
.
shape
:
old_data
.
write
(
data
)
data
=
old_data
else
:
data
=
pygpu
.
array
(
data
,
context
=
self
.
context
)
return
data
return
data
def
filter_variable
(
self
,
other
,
allow_convert
=
True
):
def
filter_variable
(
self
,
other
,
allow_convert
=
True
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论