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
杨迪
NiuTrans.Tensor
Commits
e02c6b92
Commit
e02c6b92
authored
Jul 05, 2018
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename MultiplyElementWise as Multiply
parent
a91f6809
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
42 行增加
和
42 行删除
+42
-42
source/core/CHeader.h
+1
-1
source/core/Multiply.cpp
+4
-4
source/core/Multiply.cu
+3
-3
source/core/Multiply.cuh
+5
-5
source/core/Multiply.h
+5
-5
source/function/Softmax.cu
+3
-3
source/sample/fnnlm/FNNLM.cpp
+1
-1
source/test/TMultiply.cpp
+14
-14
source/test/TMultiply.h
+4
-4
source/test/Test.cpp
+1
-1
source/test/Test.h
+1
-1
没有找到文件。
source/core/CHeader.h
查看文件 @
e02c6b92
...
...
@@ -42,7 +42,7 @@
#include "MatrixMULBatchedCPU.h"
#include "Merge.h"
#include "MergeBlockLists.h"
#include "Multiply
ElementWise
.h"
#include "Multiply.h"
#include "Negate.h"
#include "Normalize.h"
#include "Power.h"
...
...
source/core/Multiply
ElementWise
.cpp
→
source/core/Multiply.cpp
查看文件 @
e02c6b92
...
...
@@ -20,8 +20,8 @@
*/
#include "../XTensor.h"
#include "Multiply
ElementWise
.h"
#include "Multiply
ElementWise
.cuh"
#include "Multiply.h"
#include "Multiply.cuh"
namespace
nts
{
// namespace nts(NiuTrans.Tensor)
/*
...
...
@@ -34,7 +34,7 @@ where i is the index of the item
>> alpha - the coefficient
>>
*/
void
Multiply
ElementWise
(
XTensor
*
a
,
XTensor
*
b
,
XTensor
*
c
,
int
leadingDim
,
DTYPE
alpha
)
void
Multiply
(
XTensor
*
a
,
XTensor
*
b
,
XTensor
*
c
,
int
leadingDim
,
DTYPE
alpha
)
{
int
leadingDimRDI
=
a
->
order
-
leadingDim
-
1
;
CheckNTErrors
((
a
->
unitNum
<=
c
->
unitNum
&&
b
->
unitNum
<=
c
->
unitNum
),
...
...
@@ -43,7 +43,7 @@ void MultiplyElementWise(XTensor * a, XTensor * b, XTensor * c, int leadingDim,
#ifdef USE_CUDA
if
(
a
->
devID
>=
0
||
b
->
devID
>=
0
||
c
->
devID
>=
0
)
{
CudaMultiply
ElementWise
(
a
,
b
,
c
,
leadingDim
,
alpha
);
CudaMultiply
(
a
,
b
,
c
,
leadingDim
,
alpha
);
return
;
}
#endif
...
...
source/core/Multiply
ElementWise
.cu
→
source/core/Multiply.cu
查看文件 @
e02c6b92
...
...
@@ -21,8 +21,8 @@
#include "../XDevice.h"
#include "../XTensor.h"
#include "Multiply
ElementWise
.h"
#include "Multiply
ElementWise
.cuh"
#include "Multiply.h"
#include "Multiply.cuh"
namespace nts { // namespace nts(NiuTrans.Tensor)
...
...
@@ -120,7 +120,7 @@ where i is the item index
>> alpha - the coefficient
*/
extern "C"
void CudaMultiply
ElementWise
(XTensor * a, XTensor * b, XTensor * c, int leadingDim, DTYPE alpha)
void CudaMultiply(XTensor * a, XTensor * b, XTensor * c, int leadingDim, DTYPE alpha)
{
int leadingDimRDI = a->order - leadingDim - 1;
CheckNTErrors((a->unitNum <= c->unitNum && b->unitNum <= c->unitNum),
...
...
source/core/Multiply
ElementWise
.cuh
→
source/core/Multiply.cuh
查看文件 @
e02c6b92
...
...
@@ -19,10 +19,10 @@
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-04-24
*/
#ifndef __MULTIPLY
ELEMENTWISE
_CUH__
#define __MULTIPLY
ELEMENTWISE
_CUH__
#ifndef __MULTIPLY_CUH__
#define __MULTIPLY_CUH__
#include "Multiply
ElementWise
.h"
#include "Multiply.h"
namespace nts { // namespace nts(NiuTrans.Tensor)
...
...
@@ -42,11 +42,11 @@ void KernelMulElementWiseTensorDynamic(DTYPE * a, DTYPE * b, DTYPE * c, DTYPE al
/* element-wise product of two tensors */
extern "C"
void CudaMultiply
ElementWise(XTensor * a, XTensor * b, XTensor * c, int leadingDim, DTYPE alpha
);
void CudaMultiply
(XTensor * a, XTensor * b, XTensor * c, int leadingDim = 0, DTYPE alpha = 0
);
#endif // USE_CUDA
} // namespace nts(NiuTrans.Tensor)
#endif // __MULTIPLY
ELEMENTWISE
_CUH__
#endif // __MULTIPLY_CUH__
source/core/Multiply
ElementWise
.h
→
source/core/Multiply.h
查看文件 @
e02c6b92
...
...
@@ -19,8 +19,8 @@
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-04-24
*/
#ifndef __MULTIPLY
ELEMENTWISE
_H__
#define __MULTIPLY
ELEMENTWISE
_H__
#ifndef __MULTIPLY_H__
#define __MULTIPLY_H__
#include "../XTensor.h"
...
...
@@ -28,8 +28,8 @@ namespace nts { // namespace nts(NiuTrans.Tensor)
/* element-wise product of two tensors */
extern
"C"
void
Multiply
ElementWise
(
XTensor
*
a
,
XTensor
*
b
,
XTensor
*
c
,
int
leadingDim
,
DTYPE
alpha
=
0
);
void
Multiply
(
XTensor
*
a
,
XTensor
*
b
,
XTensor
*
c
,
int
leadingDim
=
0
,
DTYPE
alpha
=
0
);
}
// namespace nts(NiuTrans.Tensor)
#endif // __MULTIPLYELEMENTWISE_H__
\ No newline at end of file
#endif // __MULTIPLY_H__
\ No newline at end of file
source/function/Softmax.cu
查看文件 @
e02c6b92
...
...
@@ -23,7 +23,7 @@
#include "Softmax.cuh"
#include "Loss.cuh"
#include "../core/ReduceSum.h"
#include "../core/Multiply
ElementWise
.h"
#include "../core/Multiply.h"
#include "../core/Unsqueeze.h"
#include "../core/Sum.h"
#include "../XDevice.h"
...
...
@@ -288,7 +288,7 @@ void CudaSoftmaxBackward(XTensor * gold, XTensor * y, XTensor * x,
beta->data = mem->AllocBuf(mem->devID, beta->unitNum * beta->unitSize);
/* \beta = \sum_i (dE/dy_i * y_i) */
Multiply
ElementWise
(dedy, y, ytmp, 0);
Multiply(dedy, y, ytmp, 0);
ReduceSum(ytmp, beta, leadDim);
/* ytmp = dE/dy_j - \beta */
...
...
@@ -296,7 +296,7 @@ void CudaSoftmaxBackward(XTensor * gold, XTensor * y, XTensor * x,
Sum(dedy, ytmp, ytmp, -1.0F);
/* dE/ds_j = y_j * ytmp = y_j * (dE/dy_j - \beta) */
Multiply
ElementWise
(y, ytmp, dedx, 0);
Multiply(y, ytmp, dedx, 0);
mem->ReleaseBuf(mem->devID, y->unitNum * y->unitSize);
mem->ReleaseBuf(mem->devID, beta->unitNum * beta->unitSize);
...
...
source/sample/fnnlm/FNNLM.cpp
查看文件 @
e02c6b92
...
...
@@ -485,7 +485,7 @@ float GetProb(XTensor &output, XTensor &gold, XTensor * wordProbs)
InitTensor
(
&
probs
,
&
output
);
/* probs[i,j] = output[i,j] * gold[i,j] */
Multiply
ElementWise
(
&
output
,
&
gold
,
&
probs
,
0
);
Multiply
(
&
output
,
&
gold
,
&
probs
,
0
);
/* probability of each word */
XTensor
wprobs
;
...
...
source/test/TMultiply
ElementWise
.cpp
→
source/test/TMultiply.cpp
查看文件 @
e02c6b92
...
...
@@ -21,13 +21,13 @@
#include "../XTensor.h"
#include "../XDevice.h"
#include "../core/Multiply
ElementWise
.h"
#include "../core/Multiply.h"
namespace
nts
{
// namespace nts(NiuTrans.Tensor)
/* case 1: element-wise product of two tensors, c(i) = a(i)*b(i) + \alpha * c(i)
* In this case, (2 * 1) (2 * 1) -> (2 * 1), leadingDim=0, alpha=0.
*/
bool
TestMultiply
ElementWise
1
()
bool
TestMultiply1
()
{
/* a source tensor of size 2 * 1 */
int
sOrder1
=
2
;
...
...
@@ -77,7 +77,7 @@ bool TestMultiplyElementWise1()
t
->
SetZeroAll
();
/* call multiplyelementwise function */
Multiply
ElementWise
(
s1
,
s2
,
t
,
0
);
Multiply
(
s1
,
s2
,
t
,
0
);
/* check results */
cpuTest
=
t
->
CheckData
(
answer
,
tUnitNum
);
...
...
@@ -97,7 +97,7 @@ bool TestMultiplyElementWise1()
tGPU
->
SetZeroAll
();
/* call multiplyelementwise function */
Multiply
ElementWise
(
sGPU1
,
sGPU2
,
tGPU
,
0
);
Multiply
(
sGPU1
,
sGPU2
,
tGPU
,
0
);
/* check results */
gpuTest
=
tGPU
->
CheckData
(
answer
,
tUnitNum
);
...
...
@@ -123,7 +123,7 @@ bool TestMultiplyElementWise1()
/* case 2: element-wise product of two tensors, c(i) = a(i)*b(i) + \alpha * c(i)
* In this case, (2 * 2) (2 * 2) -> (2 * 2), leadingDim=0, alpha=0.
*/
bool
TestMultiply
ElementWise
2
()
bool
TestMultiply2
()
{
/* a source tensor of size (2 * 2) */
int
sOrder1
=
2
;
...
...
@@ -176,7 +176,7 @@ bool TestMultiplyElementWise2()
t
->
SetZeroAll
();
/* call multiplyelementwise function */
Multiply
ElementWise
(
s1
,
s2
,
t
,
0
);
Multiply
(
s1
,
s2
,
t
,
0
);
/* check results */
cpuTest
=
t
->
CheckData
(
answer
,
tUnitNum
);
...
...
@@ -196,7 +196,7 @@ bool TestMultiplyElementWise2()
tGPU
->
SetZeroAll
();
/* call multiplyelementwise function */
Multiply
ElementWise
(
sGPU1
,
sGPU2
,
tGPU
,
0
);
Multiply
(
sGPU1
,
sGPU2
,
tGPU
,
0
);
/* check results */
gpuTest
=
tGPU
->
CheckData
(
answer
,
tUnitNum
);
...
...
@@ -218,7 +218,7 @@ bool TestMultiplyElementWise2()
/* case 3: element-wise product of two tensors, c(i) = a(i)*b(i) + \alpha * c(i)
* In this case, (2 * 2) (2 * 2) -> (2 * 2), leadingDim=1, alpha=0.
*/
bool
TestMultiply
ElementWise
3
()
bool
TestMultiply3
()
{
/* a source tensor of size (2 * 2) */
int
sOrder1
=
2
;
...
...
@@ -271,7 +271,7 @@ bool TestMultiplyElementWise3()
t
->
SetZeroAll
();
/* call multiplyelementwise function */
Multiply
ElementWise
(
s1
,
s2
,
t
,
1
);
Multiply
(
s1
,
s2
,
t
,
1
);
/* check results */
cpuTest
=
t
->
CheckData
(
answer
,
tUnitNum
);
...
...
@@ -291,7 +291,7 @@ bool TestMultiplyElementWise3()
tGPU
->
SetZeroAll
();
/* call multiplyelementwise function */
Multiply
ElementWise
(
sGPU1
,
sGPU2
,
tGPU
,
1
);
Multiply
(
sGPU1
,
sGPU2
,
tGPU
,
1
);
/* check results */
gpuTest
=
tGPU
->
CheckData
(
answer
,
tUnitNum
);
...
...
@@ -317,13 +317,13 @@ TODO!!
/* test for MultiplyElementWise Function */
extern
"C"
bool
TestMultiply
ElementWise
()
bool
TestMultiply
()
{
XPRINT
(
0
,
stdout
,
"[TEST MULTIPLYELEMENTWISE] -------------
\n
"
);
bool
returnFlag
=
true
,
caseFlag
=
true
;
/* case 1 test */
caseFlag
=
TestMultiply
ElementWise
1
();
caseFlag
=
TestMultiply1
();
if
(
!
caseFlag
)
{
returnFlag
=
false
;
...
...
@@ -333,7 +333,7 @@ bool TestMultiplyElementWise()
XPRINT
(
0
,
stdout
,
">> case 1 passed!
\n
"
);
/* case 2 test */
caseFlag
=
TestMultiply
ElementWise
2
();
caseFlag
=
TestMultiply2
();
if
(
!
caseFlag
)
{
returnFlag
=
false
;
...
...
@@ -343,7 +343,7 @@ bool TestMultiplyElementWise()
XPRINT
(
0
,
stdout
,
">> case 2 passed!
\n
"
);
/* case 3 test */
caseFlag
=
TestMultiply
ElementWise
3
();
caseFlag
=
TestMultiply3
();
if
(
!
caseFlag
)
{
returnFlag
=
false
;
...
...
source/test/TMultiply
ElementWise
.h
→
source/test/TMultiply.h
查看文件 @
e02c6b92
...
...
@@ -19,16 +19,16 @@
* $Created by: Lin Ye (email: linye2015@outlook.com) 2018-06-15
*/
#ifndef __TEST_MULTIPLY
ELEMENTWISE
_H__
#define __TEST_MULTIPLY
ELEMENTWISE
_H__
#ifndef __TEST_MULTIPLY_H__
#define __TEST_MULTIPLY_H__
#include "../core/Multiply
ElementWise
.h"
#include "../core/Multiply.h"
namespace
nts
{
// namespace nts(NiuTrans.Tensor)
/* test for MultiplyElementWise Function */
extern
"C"
bool
TestMultiply
ElementWise
();
bool
TestMultiply
();
}
// namespace nts(NiuTrans.Tensor)
#endif // __TEST_MULTIPLYELEMENTWISE_H__
source/test/Test.cpp
查看文件 @
e02c6b92
...
...
@@ -35,7 +35,7 @@ bool Test()
wrong
=
!
TestMatrixMul2D
()
||
wrong
;
wrong
=
!
TestMatrixMulBatchedCPU
()
||
wrong
;
wrong
=
!
TestMerge
()
||
wrong
;
wrong
=
!
TestMultiply
ElementWise
()
||
wrong
;
wrong
=
!
TestMultiply
()
||
wrong
;
wrong
=
!
TestNegate
()
||
wrong
;
wrong
=
!
TestNormalize
()
||
wrong
;
//wrong = !TestPower() || wrong;
...
...
source/test/Test.h
查看文件 @
e02c6b92
...
...
@@ -28,7 +28,7 @@
#include "TMatrixMul2D.h"
#include "TMatrixMULBatchedCPU.h"
#include "TMerge.h"
#include "TMultiply
ElementWise
.h"
#include "TMultiply.h"
#include "TNegate.h"
#include "TNormalize.h"
#include "TPower.h"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论