Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NiuTrans.Tensor
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
Emmay
NiuTrans.Tensor
Commits
561a9e58
Commit
561a9e58
authored
Jul 10, 2018
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update cuda code for Sum
parent
f5161a0d
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
10 行增加
和
12 行删除
+10
-12
source/core/arithmetic/Sum.cpp
+1
-1
source/core/arithmetic/Sum.cu
+2
-4
source/core/arithmetic/Sum.cuh
+1
-1
source/core/movement/CopyValues.cu
+4
-4
source/core/movement/CopyValues.cuh
+1
-1
source/test/TSum.cpp
+1
-1
没有找到文件。
source/core/arithmetic/Sum.cpp
查看文件 @
561a9e58
...
...
@@ -37,7 +37,7 @@ return a pointer
*/
void
_Sum
(
const
XTensor
*
a
,
const
XTensor
*
b
,
XTensor
*
c
,
DTYPE
beta
)
{
CheckNTErrors
(
a
&&
b
&&
c
,
"Empty tensor
s in addition
!"
);
CheckNTErrors
(
a
&&
b
&&
c
,
"Empty tensor
input
!"
);
CheckNTErrors
(
a
->
unitNum
==
b
->
unitNum
&&
a
->
unitNum
==
c
->
unitNum
,
"Unmatched tensors in addition!"
);
CheckNTErrors
(
a
->
dataType
==
b
->
dataType
&&
a
->
dataType
==
c
->
dataType
,
...
...
source/core/arithmetic/Sum.cu
查看文件 @
561a9e58
...
...
@@ -51,11 +51,9 @@ tensor summation c = a + b * \beta (cuda version)
>> c - where we put a+b*\beta. we save it in a if c is NULL
>> beta - the scaling factor
*/
void _CudaSum(
XTensor * a,
XTensor * b, XTensor * c, DTYPE beta)
void _CudaSum(
const XTensor * a, const
XTensor * b, XTensor * c, DTYPE beta)
{
if (c == NULL)
c = a;
CheckNTErrors(a && b && c, "Empty tensor input!");
CheckNTErrors((a->unitNum == b->unitNum && a->unitNum == c->unitNum),
"Unmatched tensors in addition!");
CheckNTErrors((a->dataType == b->dataType && a->dataType == c->dataType),
...
...
source/core/arithmetic/Sum.cuh
查看文件 @
561a9e58
...
...
@@ -34,7 +34,7 @@ void KernelADD(DTYPE * a, DTYPE * b, DTYPE * c, int size, DTYPE beta = (DTYPE)1.
/* tensor summation c = a + b * \beta (cuda version) */
extern "C"
void _CudaSum(
XTensor * a,
XTensor * b, XTensor * c = NULL, DTYPE beta = (DTYPE)1.0);
void _CudaSum(
const XTensor * a, const
XTensor * b, XTensor * c = NULL, DTYPE beta = (DTYPE)1.0);
/* tensor summation c = a + b * \beta (cuda version) with an input handle */
extern "C"
...
...
source/core/movement/CopyValues.cu
查看文件 @
561a9e58
...
...
@@ -35,7 +35,7 @@ copy a range of elements from a source vector to a target vector
>> stream - the stream for creating the job pipeline
<< return - succeed or not
*/
bool CudaCopyValues(XTensor * s, XTensor * t, XStream * stream)
bool CudaCopyValues(
const
XTensor * s, XTensor * t, XStream * stream)
{
if (s == NULL || t == NULL)
return false;
...
...
@@ -67,10 +67,10 @@ bool CudaCopyValues(XTensor * s, XTensor * t, XStream * stream)
}
/* sparse -> sparse */
else if (s->isSparse && t->isSparse &&
s->dataType == DEFAULT_DTYPE &&
t->dataType == DEFAULT_DTYPE)
s->dataType == DEFAULT_DTYPE &&
t->dataType == DEFAULT_DTYPE)
{
int num = s->
GetNonzeroSize()
;
int num = s->
unitNumNonZero
;
int size = sizeof(int) + num * (s->unitSize + sizeof(int));
if (stream == NULL)
...
...
source/core/movement/CopyValues.cuh
查看文件 @
561a9e58
...
...
@@ -30,7 +30,7 @@ namespace nts { // namespace nts(NiuTrans.Tensor)
/* copy all elements from a source matrix to a target matrix */
extern "C"
bool CudaCopyValues(XTensor * s, XTensor * t, XStream * stream = NULL);
bool CudaCopyValues(
const
XTensor * s, XTensor * t, XStream * stream = NULL);
#endif // USE_CUDA
...
...
source/test/TSum.cpp
查看文件 @
561a9e58
...
...
@@ -73,7 +73,7 @@ bool TestSum1()
bGPU
->
SetData
(
bData
,
unitNum
);
/* call sum function */
_Sum
(
aGPU
,
bGPU
);
_Sum
(
aGPU
,
bGPU
,
aGPU
);
/* check results */
gpuTest
=
aGPU
->
CheckData
(
answer
,
unitNum
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论