Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a8996904
提交
a8996904
authored
3月 31, 2017
作者:
Thomas George
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gpu cholesky now using tril/triu from pygpu.basic
上级
8289fc6b
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
43 行删除
+10
-43
linalg.py
theano/gpuarray/linalg.py
+10
-43
没有找到文件。
theano/gpuarray/linalg.py
浏览文件 @
a8996904
...
@@ -16,8 +16,10 @@ from numpy.linalg.linalg import LinAlgError
...
@@ -16,8 +16,10 @@ from numpy.linalg.linalg import LinAlgError
try
:
try
:
import
pygpu
import
pygpu
from
pygpu.basic
import
triu
,
tril
pygpu_available
=
True
except
ImportError
:
except
ImportError
:
p
ass
p
ygpu_available
=
False
cusolver_available
=
False
cusolver_available
=
False
try
:
try
:
...
@@ -63,44 +65,6 @@ def attach_cusolver_handle_to_context(ctx):
...
@@ -63,44 +65,6 @@ def attach_cusolver_handle_to_context(ctx):
ctx
.
cusolver_handle
=
cusolver
.
cusolverDnCreate
()
ctx
.
cusolver_handle
=
cusolver
.
cusolverDnCreate
()
def
tril
(
A
,
ctx
):
tmpl
=
Template
(
"""
KERNEL void tril(GLOBAL_MEM ga_float *a, ga_uint N) {
unsigned int idx = blockIdx.y*blockDim.x*gridDim.x+
blockIdx.x*blockDim.x+threadIdx.x;
unsigned int ix = idx/${cols};
unsigned int iy = idx
%
${cols};
if (idx < N) {
if (ix < iy)
a[idx] = 0.0;
}
}
"""
)
src
=
tmpl
.
substitute
(
cols
=
A
.
shape
[
0
])
spec
=
[
GpuArray
,
'uint32'
]
k
=
GpuKernel
(
src
,
"tril"
,
spec
,
context
=
ctx
)
return
k
(
A
,
A
.
shape
[
0
]
*
A
.
shape
[
1
],
n
=
A
.
shape
[
0
])
def
triu
(
A
,
ctx
):
tmpl
=
Template
(
"""
KERNEL void triu(GLOBAL_MEM ga_float *a, ga_uint N) {
unsigned int idx = blockIdx.y*blockDim.x*gridDim.x+
blockIdx.x*blockDim.x+threadIdx.x;
unsigned int ix = idx/${cols};
unsigned int iy = idx
%
${cols};
if (idx < N) {
if (ix > iy)
a[idx] = 0.0;
}
}
"""
)
src
=
tmpl
.
substitute
(
cols
=
A
.
shape
[
0
])
spec
=
[
GpuArray
,
'uint32'
]
k
=
GpuKernel
(
src
,
"triu"
,
spec
,
context
=
ctx
)
return
k
(
A
,
A
.
shape
[
0
]
*
A
.
shape
[
1
],
n
=
A
.
shape
[
0
])
class
GpuCusolverSolve
(
Op
):
class
GpuCusolverSolve
(
Op
):
"""
"""
CUSOLVER GPU solver OP.
CUSOLVER GPU solver OP.
...
@@ -288,9 +252,12 @@ class GpuCholesky(Op):
...
@@ -288,9 +252,12 @@ class GpuCholesky(Op):
def
make_node
(
self
,
inp
):
def
make_node
(
self
,
inp
):
if
not
cusolver_available
:
if
not
cusolver_available
:
raise
RuntimeError
(
'CUSOLVER is not available and '
raise
RuntimeError
(
'CUSOLVER is not available and '
'GpuC
usolverSolve
Op can not be constructed.'
)
'GpuC
holesky
Op can not be constructed.'
)
if
skcuda
.
__version__
<=
'0.5.1'
:
if
skcuda
.
__version__
<=
'0.5.1'
:
warnings
.
warn
(
'The GpuSolve op requires scikit-cuda > 0.5.1 to work with CUDA 8'
)
warnings
.
warn
(
'The GpuSolve op requires scikit-cuda > 0.5.1 to work with CUDA 8'
)
if
not
pygpu_available
:
raise
RuntimeError
(
'Missing pygpu or triu/tril functions.'
'Try updating libgpuarray?'
)
context_name
=
basic_ops
.
infer_context_name
(
inp
)
context_name
=
basic_ops
.
infer_context_name
(
inp
)
inp
=
basic_ops
.
as_gpuarray_variable
(
inp
,
context_name
)
inp
=
basic_ops
.
as_gpuarray_variable
(
inp
,
context_name
)
...
@@ -367,9 +334,9 @@ class GpuCholesky(Op):
...
@@ -367,9 +334,9 @@ class GpuCholesky(Op):
# 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
# Note : we should probably check for c or f order in triu instead of here
# Note : we should probably check for c or f order in triu instead of here
if
self
.
lower
and
L
.
flags
[
'C_CONTIGUOUS'
]
or
(
not
self
.
lower
and
L
.
flags
[
'F_CONTIGUOUS'
])
:
if
self
.
lower
:
tril
(
L
,
context
)
tril
(
L
)
else
:
else
:
triu
(
L
,
context
)
triu
(
L
)
outputs
[
0
][
0
]
=
L
outputs
[
0
][
0
]
=
L
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论