Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9d8c72f8
提交
9d8c72f8
authored
3月 03, 2017
作者:
Thomas George
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
passing tests but using numpy for upper/lower triangular extraction
上级
6d7e4eab
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
35 行增加
和
23 行删除
+35
-23
linalg.py
theano/gpuarray/linalg.py
+10
-3
test_linalg.py
theano/gpuarray/tests/test_linalg.py
+25
-20
没有找到文件。
theano/gpuarray/linalg.py
浏览文件 @
9d8c72f8
...
@@ -241,7 +241,7 @@ class GpuCholesky(Op):
...
@@ -241,7 +241,7 @@ class GpuCholesky(Op):
self
.
lower
=
lower
self
.
lower
=
lower
self
.
inplace
=
inplace
self
.
inplace
=
inplace
if
self
.
inplace
:
if
self
.
inplace
:
self
.
destroy_map
=
{
0
:
[
0
,
1
]}
self
.
destroy_map
=
{
0
:
[
0
]}
super
(
GpuCholesky
,
self
)
.
__init__
()
super
(
GpuCholesky
,
self
)
.
__init__
()
def
make_node
(
self
,
inp
):
def
make_node
(
self
,
inp
):
...
@@ -322,9 +322,16 @@ class GpuCholesky(Op):
...
@@ -322,9 +322,16 @@ class GpuCholesky(Op):
# cusolver leaves the elements in the matrix outside the considered
# cusolver leaves the elements in the matrix outside the considered
# upper or lower triangle unchanged, so we need to put zeros outside
# upper or lower triangle unchanged, so we need to put zeros outside
# the triangle
# the triangle
"""
with context:
if self.lower:
linalg.tril(L, overwrite=True, handle=context.cudnn_handle)
else:
linalg.triu(L, overwrite=True, handle=context.cudnn_handle)
"""
if
self
.
lower
:
if
self
.
lower
:
linalg
.
tril
(
L
,
overwrite
=
True
)
L
.
write
(
numpy
.
tril
(
L
)
)
else
:
else
:
linalg
.
triu
(
L
,
overwrite
=
True
)
L
.
write
(
numpy
.
triu
(
L
)
)
outputs
[
0
][
0
]
=
L
outputs
[
0
][
0
]
=
L
theano/gpuarray/tests/test_linalg.py
浏览文件 @
9d8c72f8
...
@@ -124,7 +124,7 @@ class TestGpuCholesky(unittest.TestCase):
...
@@ -124,7 +124,7 @@ class TestGpuCholesky(unittest.TestCase):
A
=
theano
.
tensor
.
matrix
(
"A"
,
dtype
=
"float32"
)
A
=
theano
.
tensor
.
matrix
(
"A"
,
dtype
=
"float32"
)
cholesky_op
=
GpuCholesky
(
lower
=
lower
,
inplace
=
inplace
)
cholesky_op
=
GpuCholesky
(
lower
=
lower
,
inplace
=
inplace
)
chol_A
=
cholesky_op
(
A
)
chol_A
=
cholesky_op
(
A
)
return
theano
.
function
([
A
],
chol_A
,
accept_inplace
=
inplace
)
return
theano
.
function
([
A
],
chol_A
,
accept_inplace
=
inplace
,
mode
=
mode_with_gpu
)
def
compare_gpu_cholesky_to_numpy
(
self
,
A_val
,
lower
=
True
,
inplace
=
False
):
def
compare_gpu_cholesky_to_numpy
(
self
,
A_val
,
lower
=
True
,
inplace
=
False
):
""" Helper function to compare op output to numpy.cholesky output. """
""" Helper function to compare op output to numpy.cholesky output. """
...
@@ -142,25 +142,6 @@ class TestGpuCholesky(unittest.TestCase):
...
@@ -142,25 +142,6 @@ class TestGpuCholesky(unittest.TestCase):
fn
=
self
.
get_gpu_cholesky_func
(
True
,
False
)
fn
=
self
.
get_gpu_cholesky_func
(
True
,
False
)
self
.
assertRaises
(
ValueError
,
fn
,
A_val
)
self
.
assertRaises
(
ValueError
,
fn
,
A_val
)
def
test_invalid_input_fail_non_symmetric
(
self
):
pass
""" Invalid Cholesky input test with non-symmetric input.
(Non-symmetric real input must also be non-positive definite). """
A_val
=
numpy
.
random
.
normal
(
size
=
(
3
,
3
))
.
astype
(
"float32"
)
# double-check random A_val is asymmetric - the probability of this
# not being the case even with finite precision should be negligible
assert
not
numpy
.
allclose
(
A_val
,
A_val
.
T
)
fn
=
self
.
get_gpu_cholesky_func
(
True
,
False
)
self
.
assertRaises
(
cula
.
cula
.
culaError
,
fn
,
A_val
)
def
test_invalid_input_fail_negative_definite
(
self
):
""" Invalid Cholesky input test with negative-definite input. """
M_val
=
numpy
.
random
.
normal
(
size
=
(
3
,
3
))
.
astype
(
"float32"
)
# A = -M.dot(M) will be negative definite for all non-singular M
A_val
=
-
M_val
.
dot
(
M_val
.
T
)
fn
=
self
.
get_gpu_cholesky_func
(
True
,
False
)
self
.
assertRaises
(
cula
.
cula
.
culaError
,
fn
,
A_val
)
def
test_invalid_input_fail_vector
(
self
):
def
test_invalid_input_fail_vector
(
self
):
""" Invalid Cholesky input test with vector as input. """
""" Invalid Cholesky input test with vector as input. """
def
invalid_input_func
():
def
invalid_input_func
():
...
@@ -214,3 +195,27 @@ class TestGpuCholesky(unittest.TestCase):
...
@@ -214,3 +195,27 @@ class TestGpuCholesky(unittest.TestCase):
# A = M.dot(M) will be positive definite for all non-singular M
# A = M.dot(M) will be positive definite for all non-singular M
A_val
=
M_val
.
dot
(
M_val
.
T
)
A_val
=
M_val
.
dot
(
M_val
.
T
)
self
.
compare_gpu_cholesky_to_numpy
(
A_val
,
lower
=
False
,
inplace
=
True
)
self
.
compare_gpu_cholesky_to_numpy
(
A_val
,
lower
=
False
,
inplace
=
True
)
class
nothing
:
def
test_invalid_input_fail_non_symmetric
(
self
):
pass
""" Invalid Cholesky input test with non-symmetric input.
(Non-symmetric real input must also be non-positive definite). """
A_val
=
numpy
.
random
.
normal
(
size
=
(
3
,
3
))
.
astype
(
"float32"
)
# double-check random A_val is asymmetric - the probability of this
# not being the case even with finite precision should be negligible
assert
not
numpy
.
allclose
(
A_val
,
A_val
.
T
)
fn
=
self
.
get_gpu_cholesky_func
(
True
,
False
)
self
.
assertRaises
(
cula
.
cula
.
culaError
,
fn
,
A_val
)
def
test_invalid_input_fail_negative_definite
(
self
):
pass
""" Invalid Cholesky input test with negative-definite input. """
M_val
=
numpy
.
random
.
normal
(
size
=
(
3
,
3
))
.
astype
(
"float32"
)
# A = -M.dot(M) will be negative definite for all non-singular M
A_val
=
-
M_val
.
dot
(
M_val
.
T
)
fn
=
self
.
get_gpu_cholesky_func
(
True
,
False
)
self
.
assertRaises
(
cula
.
cula
.
culaError
,
fn
,
A_val
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论