Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
dc464643
提交
dc464643
authored
11月 30, 2016
作者:
Frédéric Bastien
提交者:
GitHub
11月 30, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5303 from khaotik/pygpu_dot_speedup
GPU gemv->dot speedup for new backend
上级
89849eb7
307bdf51
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
30 行增加
和
6 行删除
+30
-6
blas.py
theano/gpuarray/blas.py
+30
-6
没有找到文件。
theano/gpuarray/blas.py
浏览文件 @
dc464643
...
@@ -52,6 +52,7 @@ class GpuGemv(BlasOp):
...
@@ -52,6 +52,7 @@ class GpuGemv(BlasOp):
y
=
as_gpuarray_variable
(
y
,
ctx_name
)
y
=
as_gpuarray_variable
(
y
,
ctx_name
)
alpha
=
as_tensor_variable
(
alpha
)
.
astype
(
'float64'
)
alpha
=
as_tensor_variable
(
alpha
)
.
astype
(
'float64'
)
beta
=
as_tensor_variable
(
beta
)
.
astype
(
'float64'
)
beta
=
as_tensor_variable
(
beta
)
.
astype
(
'float64'
)
assert
alpha
.
ndim
==
0
assert
alpha
.
ndim
==
0
assert
beta
.
ndim
==
0
assert
beta
.
ndim
==
0
assert
A
.
ndim
==
2
assert
A
.
ndim
==
2
...
@@ -91,6 +92,8 @@ class GpuGemv(BlasOp):
...
@@ -91,6 +92,8 @@ class GpuGemv(BlasOp):
%(fail)
s
%(fail)
s
}
}
"""
%
vars
"""
%
vars
# in case of possible speed up using blas dot,
# temporary hack A to 1D for vector-vector dot
code
+=
"""
code
+=
"""
if (PyGpuArray_DIM(
%(A)
s, 1) == 0) {
if (PyGpuArray_DIM(
%(A)
s, 1) == 0) {
int code;
int code;
...
@@ -99,11 +102,32 @@ class GpuGemv(BlasOp):
...
@@ -99,11 +102,32 @@ class GpuGemv(BlasOp):
PyErr_SetString(PyExc_RuntimeError, "Memset failed");
PyErr_SetString(PyExc_RuntimeError, "Memset failed");
%(fail)
s
%(fail)
s
}
}
} else if (pygpu_blas_rgemv(cb_no_trans,
} else if ( PyGpuArray_DIM(
%(A)
s, 0) == 1
((dtype_
%(alpha)
s *)PyArray_DATA(
%(alpha)
s))[0],
&&((dtype_
%(alpha)
s*)PyArray_DATA(
%(alpha)
s))[0] == (dtype_
%(alpha)
s)1.
%(A)
s,
%(x)
s,
&&((dtype_
%(beta)
s*)PyArray_DATA(
%(beta)
s))[0] == (dtype_
%(beta)
s)0.
((dtype_
%(beta)
s *)PyArray_DATA(
%(beta)
s))[0],
) {
%(out)
s, 0) == -1) {
%(out)
s->ga.nd = 0;
%(A)
s->ga.nd = 1;
%(A)
s->ga.dimensions[0] =
%(A)
s->ga.dimensions[1];
if (
%(A)
s->ga.flags & GA_C_CONTIGUOUS) {
ssize_t a_stride0 =
%(A)
s->ga.strides[0];
%(A)
s->ga.strides[0] =
%(A)
s->ga.strides[1];
if (pygpu_blas_rdot(
%(x)
s,
%(A)
s,
%(y)
s, 0) == -1) {
%(fail)
s
}
%(A)
s->ga.strides[0] = a_stride0;
} else if (pygpu_blas_rdot(
%(x)
s,
%(A)
s,
%(y)
s, 0) == -1) {
%(fail)
s
}
%(out)
s->ga.nd = 1;
%(A)
s->ga.nd = 2;
%(A)
s->ga.dimensions[0] = 1;
} else if (
pygpu_blas_rgemv(cb_no_trans,
((dtype_
%(alpha)
s *)PyArray_DATA(
%(alpha)
s))[0],
%(A)
s,
%(x)
s,
((dtype_
%(beta)
s *)PyArray_DATA(
%(beta)
s))[0],
%(out)
s, 0) == -1) {
%(fail)
s
%(fail)
s
}
}
"""
%
vars
"""
%
vars
...
@@ -114,7 +138,7 @@ class GpuGemv(BlasOp):
...
@@ -114,7 +138,7 @@ class GpuGemv(BlasOp):
return
code
return
code
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
5
,)
return
(
6
,)
gpugemv_no_inplace
=
GpuGemv
(
inplace
=
False
)
gpugemv_no_inplace
=
GpuGemv
(
inplace
=
False
)
gpugemv_inplace
=
GpuGemv
(
inplace
=
True
)
gpugemv_inplace
=
GpuGemv
(
inplace
=
True
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论