Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9fd0cb25
提交
9fd0cb25
authored
7月 12, 2017
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Let filter_variable fix broadcast between GPU vars
上级
73cf3066
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
18 行增加
和
4 行删除
+18
-4
test_type.py
theano/gpuarray/tests/test_type.py
+16
-0
type.py
theano/gpuarray/type.py
+2
-4
没有找到文件。
theano/gpuarray/tests/test_type.py
浏览文件 @
9fd0cb25
...
@@ -91,6 +91,22 @@ def test_filter_float():
...
@@ -91,6 +91,22 @@ def test_filter_float():
del
theano
.
compile
.
sharedvalue
.
shared
.
constructors
[
-
1
]
del
theano
.
compile
.
sharedvalue
.
shared
.
constructors
[
-
1
]
def
test_filter_variable
():
# Test that filter_variable accepts more restrictive broadcast
gpu_row
=
GpuArrayType
(
dtype
=
theano
.
config
.
floatX
,
broadcastable
=
(
True
,
False
))
gpu_matrix
=
GpuArrayType
(
dtype
=
theano
.
config
.
floatX
,
broadcastable
=
(
False
,
False
))
r
=
gpu_row
()
m
=
gpu_matrix
.
filter_variable
(
r
)
assert
m
.
type
==
gpu_matrix
# On CPU as well
r
=
theano
.
tensor
.
row
()
m
=
gpu_matrix
.
filter_variable
(
r
)
assert
m
.
type
==
gpu_matrix
def
test_gpuarray_shared_scalar
():
def
test_gpuarray_shared_scalar
():
# By default, we don't put scalar as shared variable on the GPU
# By default, we don't put scalar as shared variable on the GPU
nose
.
tools
.
assert_raises
(
nose
.
tools
.
assert_raises
(
...
...
theano/gpuarray/type.py
浏览文件 @
9fd0cb25
...
@@ -303,8 +303,6 @@ class GpuArrayType(Type):
...
@@ -303,8 +303,6 @@ class GpuArrayType(Type):
return
data
return
data
def
filter_variable
(
self
,
other
,
allow_convert
=
True
):
def
filter_variable
(
self
,
other
,
allow_convert
=
True
):
from
theano.gpuarray.basic_ops
import
GpuFromHost
if
hasattr
(
other
,
'_as_GpuArrayVariable'
):
if
hasattr
(
other
,
'_as_GpuArrayVariable'
):
other
=
other
.
_as_GpuArrayVariable
(
self
.
context_name
)
other
=
other
.
_as_GpuArrayVariable
(
self
.
context_name
)
...
@@ -314,7 +312,7 @@ class GpuArrayType(Type):
...
@@ -314,7 +312,7 @@ class GpuArrayType(Type):
if
other
.
type
==
self
:
if
other
.
type
==
self
:
return
other
return
other
if
not
isinstance
(
other
.
type
,
tensor
.
TensorType
):
if
not
isinstance
(
other
.
type
,
(
TensorType
,
GpuArrayType
)
):
raise
TypeError
(
'Incompatible type'
,
(
self
,
other
.
type
))
raise
TypeError
(
'Incompatible type'
,
(
self
,
other
.
type
))
if
(
other
.
type
.
dtype
!=
self
.
dtype
):
if
(
other
.
type
.
dtype
!=
self
.
dtype
):
raise
TypeError
(
'Incompatible dtype'
,
(
self
.
dtype
,
raise
TypeError
(
'Incompatible dtype'
,
(
self
.
dtype
,
...
@@ -335,7 +333,7 @@ class GpuArrayType(Type):
...
@@ -335,7 +333,7 @@ class GpuArrayType(Type):
str
(
self
.
broadcastable
)))
str
(
self
.
broadcastable
)))
other
=
other2
other
=
other2
return
GpuFromHost
(
self
.
context_name
)(
other
)
return
other
.
transfer
(
self
.
context_name
)
@staticmethod
@staticmethod
def
values_eq
(
a
,
b
,
force_same_dtype
=
True
):
def
values_eq
(
a
,
b
,
force_same_dtype
=
True
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论