Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ace491ba
提交
ace491ba
authored
4月 10, 2017
作者:
Thomas George
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
op lifter for cholesky
上级
bc6ceb89
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
34 行增加
和
3 行删除
+34
-3
linalg.py
theano/gpuarray/linalg.py
+4
-0
opt.py
theano/gpuarray/opt.py
+11
-1
test_linalg.py
theano/gpuarray/tests/test_linalg.py
+1
-1
test_opt.py
theano/gpuarray/tests/test_opt.py
+18
-1
没有找到文件。
theano/gpuarray/linalg.py
浏览文件 @
ace491ba
...
@@ -337,3 +337,7 @@ class GpuCholesky(Op):
...
@@ -337,3 +337,7 @@ class GpuCholesky(Op):
triu
(
L
)
triu
(
L
)
outputs
[
0
][
0
]
=
L
outputs
[
0
][
0
]
=
L
def
gpu_cholesky
(
A
,
lower
=
True
):
return
GpuCholesky
(
lower
)(
A
)
theano/gpuarray/opt.py
浏览文件 @
ace491ba
...
@@ -70,7 +70,7 @@ from .subtensor import (GpuIncSubtensor, GpuSubtensor,
...
@@ -70,7 +70,7 @@ from .subtensor import (GpuIncSubtensor, GpuSubtensor,
GpuAdvancedIncSubtensor1_dev20
)
GpuAdvancedIncSubtensor1_dev20
)
from
.opt_util
import
alpha_merge
,
output_merge
,
pad_dims
,
unpad_dims
from
.opt_util
import
alpha_merge
,
output_merge
,
pad_dims
,
unpad_dims
from
.reduction
import
GpuMaxAndArgmax
from
.reduction
import
GpuMaxAndArgmax
from
.linalg
import
(
GpuCusolverSolve
,
cusolver_available
)
from
.linalg
import
(
GpuCusolverSolve
,
GpuCholesky
,
cusolver_available
)
_logger
=
logging
.
getLogger
(
"theano.gpuarray.opt"
)
_logger
=
logging
.
getLogger
(
"theano.gpuarray.opt"
)
...
@@ -1967,6 +1967,16 @@ def local_gpu_solve(op, context_name, inputs, outputs):
...
@@ -1967,6 +1967,16 @@ def local_gpu_solve(op, context_name, inputs, outputs):
return
return
return
GpuCusolverSolve
()
return
GpuCusolverSolve
()
# Cholesky decomposition
@register_opt
(
'fast_compile'
)
@op_lifter
([
slinalg
.
Cholesky
])
@register_opt2
([
theano
.
tensor
.
slinalg
.
Cholesky
],
'fast_compile'
)
def
local_gpu_cholesky
(
op
,
context_name
,
inputs
,
outputs
):
if
not
cusolver_available
:
return
return
GpuCholesky
()
# Do not register in fast_run or fast_compile.
# Do not register in fast_run or fast_compile.
# It will be added to fast_run if the GPU is enabled.
# It will be added to fast_run if the GPU is enabled.
optdb
.
register
(
'gpua_scanOp_make_inplace'
,
optdb
.
register
(
'gpua_scanOp_make_inplace'
,
...
...
theano/gpuarray/tests/test_linalg.py
浏览文件 @
ace491ba
...
@@ -158,9 +158,9 @@ class TestGpuCholesky(unittest.TestCase):
...
@@ -158,9 +158,9 @@ class TestGpuCholesky(unittest.TestCase):
def
test_diag_chol
(
self
):
def
test_diag_chol
(
self
):
# Diagonal matrix input Cholesky test.
# Diagonal matrix input Cholesky test.
# make sure all diagonal elements are positive so positive-definite
for
lower
in
[
True
,
False
]:
for
lower
in
[
True
,
False
]:
for
inplace
in
[
True
,
False
]:
for
inplace
in
[
True
,
False
]:
# make sure all diagonal elements are positive so positive-definite
A_val
=
np
.
diag
(
np
.
random
.
uniform
(
size
=
5
)
.
astype
(
"float32"
)
+
1
)
A_val
=
np
.
diag
(
np
.
random
.
uniform
(
size
=
5
)
.
astype
(
"float32"
)
+
1
)
self
.
compare_gpu_cholesky_to_np
(
A_val
,
lower
=
lower
,
inplace
=
inplace
)
self
.
compare_gpu_cholesky_to_np
(
A_val
,
lower
=
lower
,
inplace
=
inplace
)
...
...
theano/gpuarray/tests/test_opt.py
浏览文件 @
ace491ba
...
@@ -17,7 +17,7 @@ from ..basic_ops import (
...
@@ -17,7 +17,7 @@ from ..basic_ops import (
from
..blas
import
GpuGemm
from
..blas
import
GpuGemm
from
..elemwise
import
GpuCAReduceCuda
,
GpuCAReduceCPY
,
GpuElemwise
from
..elemwise
import
GpuCAReduceCuda
,
GpuCAReduceCPY
,
GpuElemwise
from
..subtensor
import
GpuSubtensor
from
..subtensor
import
GpuSubtensor
from
..linalg
import
GpuCusolverSolve
,
cusolver_available
from
..linalg
import
GpuCusolverSolve
,
cusolver_available
,
GpuCholesky
from
.config
import
mode_with_gpu
,
mode_without_gpu
,
test_ctx_name
,
SkipTest
from
.config
import
mode_with_gpu
,
mode_without_gpu
,
test_ctx_name
,
SkipTest
...
@@ -584,6 +584,23 @@ def test_local_lift_solve():
...
@@ -584,6 +584,23 @@ def test_local_lift_solve():
utt
.
assert_allclose
(
f_cpu
(
A_val
,
b_val
),
f_gpu
(
A_val
,
b_val
))
utt
.
assert_allclose
(
f_cpu
(
A_val
,
b_val
),
f_gpu
(
A_val
,
b_val
))
def
test_local_lift_cholesky
():
if
not
cusolver_available
:
raise
SkipTest
(
'No cuSolver'
)
A
=
tensor
.
fmatrix
()
o
=
slinalg
.
cholesky
(
A
)
f_cpu
=
theano
.
function
([
A
],
o
)
f_gpu
=
theano
.
function
([
A
],
o
,
mode
=
mode_with_gpu
)
assert
not
any
(
isinstance
(
n
.
op
,
slinalg
.
Cholesky
)
for
n
in
f_gpu
.
maker
.
fgraph
.
apply_nodes
)
assert
any
(
isinstance
(
n
.
op
,
GpuCholesky
)
for
n
in
f_gpu
.
maker
.
fgraph
.
apply_nodes
)
M_val
=
np
.
random
.
normal
(
size
=
(
3
,
3
))
.
astype
(
"float32"
)
# A = M.dot(M) will be positive definite for all non-singular M
A_val
=
M_val
.
dot
(
M_val
.
T
)
utt
.
assert_allclose
(
f_cpu
(
A_val
),
f_gpu
(
A_val
))
def
test_local_gpua_advanced_incsubtensor
():
def
test_local_gpua_advanced_incsubtensor
():
# test a corner case reported at gh-5589
# test a corner case reported at gh-5589
target
=
tensor
.
ftensor4
()
target
=
tensor
.
ftensor4
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论