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
d3ec5df8
Commit
d3ec5df8
authored
Jul 22, 2019
by
linye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. implement SetData by template 2. update float16 datatype of SetData
parent
4b54d3d0
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
112 行增加
和
222 行删除
+112
-222
source/network/Main.cpp
+2
-2
source/network/XBackwardLoss.cpp
+2
-18
source/tensor/core/getandset/SetData.cpp
+55
-135
source/tensor/core/getandset/SetData.cu
+0
-0
source/tensor/core/getandset/SetData.cuh
+6
-10
source/tensor/core/getandset/SetData.h
+7
-17
source/tensor/function/DropoutWithIndex.cpp
+1
-1
source/tensor/function/Loss.cpp
+3
-3
source/tensor/test/TDropout.cpp
+6
-6
source/tensor/test/TReduceSum.cpp
+15
-15
source/tensor/test/TSetData.cpp
+0
-0
source/tensor/test/TSpread.cpp
+2
-2
source/tensor/test/TSumDim.cpp
+6
-6
source/tensor/test/Test.cpp
+7
-7
没有找到文件。
source/network/Main.cpp
查看文件 @
d3ec5df8
...
...
@@ -399,8 +399,8 @@ void xcTest()
InitTensor2D
(
&
t2
,
2
,
4
,
X_FLOAT
,
0
,
NULL
);
XTensor
tensor
;
_SetDataFixed
Float
(
&
t1
,
1.0
F
);
_SetDataFixed
Float
(
&
t2
,
2.0
F
);
_SetDataFixed
(
&
t1
,
1.0
F
);
_SetDataFixed
(
&
t2
,
2.0
F
);
tensor
=
t1
+
t2
;
...
...
source/network/XBackwardLoss.cpp
查看文件 @
d3ec5df8
...
...
@@ -52,15 +52,7 @@ void XLossGrad::MakeGrad(XTensor * node, bool isEfficient)
XTensor
*
dedy
=
output
->
grad
;
if
(
income
.
tailNum
==
1
)
{
if
(
dedy
->
dataType
==
X_FLOAT
)
_SetDataFixedFloat
(
dedy
,
1.0
F
);
else
if
(
dedy
->
dataType
==
X_DOUBLE
)
_SetDataFixedDouble
(
dedy
,
1.0
);
else
if
(
dedy
->
dataType
==
X_INT
)
_SetDataFixedInt
(
dedy
,
1
);
else
ShowNTErrors
(
"TODO"
);
_SetDataFixed
(
dedy
,
1.0
F
);
return
;
}
...
...
@@ -144,15 +136,7 @@ void XLossGrad::Compute(XTensor * gold, XTensor * y,
LOSS_FUNCTION_NAME
lossName
)
{
if
(
gold
==
NULL
){
if
(
dedy
->
dataType
==
X_FLOAT
)
_SetDataFixedFloat
(
dedy
,
1.0
F
);
else
if
(
dedy
->
dataType
==
X_DOUBLE
)
_SetDataFixedDouble
(
dedy
,
1.0
);
else
if
(
dedy
->
dataType
==
X_INT
)
_SetDataFixedInt
(
dedy
,
1
);
else
{
ShowNTErrors
(
"TODO"
);
}
_SetDataFixed
(
dedy
,
1.0
F
);
return
;
}
...
...
source/tensor/core/getandset/SetData.cpp
查看文件 @
d3ec5df8
...
...
@@ -25,6 +25,7 @@
#include "SetData.cuh"
#include "../../XUtility.h"
#include "../movement/CopyValues.h"
#include "ConvertDataType.h"
#if !defined( WIN32 ) && !defined( _WIN32 )
#include "sys/time.h"
...
...
@@ -77,153 +78,78 @@ void _SetDataFanInOut(XTensor * tensor, DTYPE gain)
}
/*
generate data items with a fixed value
p
generate data items with a fixed value
>> tensor - the tensor whose data array would be initialized
>>
p
- pointer to the number for initializing the tensor
>>
value
- pointer to the number for initializing the tensor
*/
void
_SetDataFixed
(
XTensor
*
tensor
,
void
*
valuePointer
)
template
<
class
T
>
void
_SetDataFixed
(
XTensor
*
tensor
,
T
value
)
{
#ifdef USE_CUDA
if
(
tensor
->
devID
>=
0
)
{
_CudaSetDataFixed
(
tensor
,
value
);
return
;
}
#endif
int
num
=
tensor
->
unitNum
;
if
(
tensor
->
dataType
==
X_INT
){
int
p
=
*
(
int
*
)
valuePointer
;
if
(
tensor
->
devID
<
0
){
int
*
d
=
(
int
*
)
tensor
->
data
;
if
(
num
%
4
==
0
){
for
(
int
i
=
0
;
i
<
num
;
i
+=
4
){
d
[
i
]
=
p
;
d
[
i
+
1
]
=
p
;
d
[
i
+
2
]
=
p
;
d
[
i
+
3
]
=
p
;
}
}
else
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
d
[
i
]
=
p
;
if
(
tensor
->
dataType
==
X_INT
)
{
int
*
d
=
(
int
*
)
tensor
->
data
;
int
v
=
(
int
)
value
;
if
(
num
%
4
==
0
)
{
for
(
int
i
=
0
;
i
<
num
;
i
+=
4
)
{
d
[
i
]
=
v
;
d
[
i
+
1
]
=
v
;
d
[
i
+
2
]
=
v
;
d
[
i
+
3
]
=
v
;
}
}
else
{
#ifdef USE_CUDA
_CudaSetDataFixedInt
(
tensor
,
p
);
#endif
else
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
d
[
i
]
=
v
;
}
}
else
if
(
tensor
->
dataType
==
X_FLOAT
){
float
p
=
*
(
float
*
)
valuePointer
;
if
(
tensor
->
devID
<
0
){
float
*
d
=
(
float
*
)
tensor
->
data
;
if
(
num
%
4
==
0
){
for
(
int
i
=
0
;
i
<
num
;
i
+=
4
){
d
[
i
]
=
p
;
d
[
i
+
1
]
=
p
;
d
[
i
+
2
]
=
p
;
d
[
i
+
3
]
=
p
;
}
}
else
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
d
[
i
]
=
p
;
else
if
(
tensor
->
dataType
==
X_FLOAT
)
{
float
*
d
=
(
float
*
)
tensor
->
data
;
float
v
=
(
float
)
value
;
if
(
num
%
4
==
0
)
{
for
(
int
i
=
0
;
i
<
num
;
i
+=
4
)
{
d
[
i
]
=
v
;
d
[
i
+
1
]
=
v
;
d
[
i
+
2
]
=
v
;
d
[
i
+
3
]
=
v
;
}
}
else
{
#ifdef USE_CUDA
_CudaSetDataFixedFloat
(
tensor
,
p
);
#endif
else
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
d
[
i
]
=
v
;
}
}
else
if
(
tensor
->
dataType
==
X_DOUBLE
){
double
p
=
*
(
double
*
)
valuePointer
;
if
(
tensor
->
devID
<
0
){
double
*
d
=
(
double
*
)
tensor
->
data
;
if
(
num
%
4
==
0
){
for
(
int
i
=
0
;
i
<
num
;
i
+=
4
){
d
[
i
]
=
p
;
d
[
i
+
1
]
=
p
;
d
[
i
+
2
]
=
p
;
d
[
i
+
3
]
=
p
;
}
}
else
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
d
[
i
]
=
p
;
else
if
(
tensor
->
dataType
==
X_DOUBLE
)
{
double
*
d
=
(
double
*
)
tensor
->
data
;
double
v
=
(
double
)
value
;
if
(
num
%
4
==
0
)
{
for
(
int
i
=
0
;
i
<
num
;
i
+=
4
)
{
d
[
i
]
=
v
;
d
[
i
+
1
]
=
v
;
d
[
i
+
2
]
=
v
;
d
[
i
+
3
]
=
v
;
}
}
else
{
#ifdef USE_CUDA
_CudaSetDataFixedDouble
(
tensor
,
p
);
#endif
else
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
d
[
i
]
=
v
;
}
}
else
{
ShowNTErrors
(
"TODO"
);
}
}
/*
generate data items with a fixed value p (in default type)
>> tensor - the tensor whose data array would be initialized
>> p - number in default type
*/
void
SetDataFixed
(
XTensor
&
tensor
,
DTYPE
p
)
{
_SetDataFixed
(
&
tensor
,
&
p
);
}
/*
generate data items with a fixed value p (in integer)
>> tensor - the tensor whose data array would be initialized
>> p - an integer
*/
void
SetDataFixedInt
(
XTensor
&
tensor
,
int
p
)
{
CheckNTErrors
(
tensor
.
dataType
==
X_INT
,
"An integer tensor is required!"
);
_SetDataFixed
(
&
tensor
,
&
p
);
}
/*
generate data items with a fixed value p (in integer)
>> tensor - the tensor whose data array would be initialized
>> p - an int-valued number
*/
void
_SetDataFixedInt
(
XTensor
*
tensor
,
int
p
)
{
CheckNTErrors
(
tensor
->
dataType
==
X_INT
,
"the tensor must be in X_INT!"
);
if
(
p
==
0
)
tensor
->
SetZeroAll
();
else
_SetDataFixed
(
tensor
,
&
p
);
}
/*
generate data items with a fixed value p (in float)
>> tensor - the tensor whose data array would be initialized
>> p - a float-valued number
*/
void
_SetDataFixedFloat
(
XTensor
*
tensor
,
float
p
)
{
CheckNTErrors
(
tensor
->
dataType
==
X_FLOAT
,
"the tensor must be in X_FLOAT!"
);
if
(
p
==
0
)
tensor
->
SetZeroAll
();
else
_SetDataFixed
(
tensor
,
&
p
);
ShowNTErrors
(
"TODO"
);
}
/*
generate data items with a fixed value p (in double)
>> tensor - the tensor whose data array would be initialized
>> p - a double-valued number
*/
void
_SetDataFixedDouble
(
XTensor
*
tensor
,
double
p
)
{
CheckNTErrors
(
tensor
->
dataType
==
X_DOUBLE
,
"the tensor must be in X_DOUBLE!"
);
if
(
p
==
0
)
tensor
->
SetZeroAll
();
else
_SetDataFixed
(
tensor
,
&
p
);
}
template
void
_SetDataFixed
<
int
>
(
XTensor
*
,
int
);
template
void
_SetDataFixed
<
float
>
(
XTensor
*
,
float
);
template
void
_SetDataFixed
<
double
>
(
XTensor
*
,
double
);
/*
set data items along with a given dimension (and keep the remaining items unchanged)
...
...
@@ -396,7 +322,7 @@ generate data items with a uniform distribution in [lower, upper]
>> lower - lower value of the range
>> upper - upper value of the range
*/
void
_SetDataRand
(
const
XTensor
*
tensor
,
DTYPE
lower
,
DTYPE
upper
)
void
_SetDataRand
(
XTensor
*
tensor
,
DTYPE
lower
,
DTYPE
upper
)
{
CheckNTErrors
(
upper
>
lower
,
"the high value must be greater than low value!"
);
...
...
@@ -433,10 +359,6 @@ void _SetDataRand(const XTensor * tensor, DTYPE lower, DTYPE upper)
#ifdef USE_CUDA
_CudaSetDataRand
(
tensor
,
lower
,
upper
);
#endif
//XTensor * t2 = NewTensor(tensor->order, tensor->dimSize, tensor->dataType, tensor->denseRatio, -1);
//_SetDataRand(t2, low, high);
//_CopyValues(t2, tensor);
//delete t2;
}
}
...
...
@@ -449,10 +371,8 @@ the item to a pre-defined value if the item >= p, set the item to 0 otherwise
>> p - the threshold
>> value - the value we intend to assign to the item
*/
void
_SetDataRandP
(
const
XTensor
*
tensor
,
DTYPE
lower
,
DTYPE
upper
,
DTYPE
p
,
DTYPE
value
)
void
_SetDataRandP
(
XTensor
*
tensor
,
DTYPE
lower
,
DTYPE
upper
,
DTYPE
p
,
DTYPE
value
)
{
CheckNTErrors
(
tensor
->
dataType
==
DEFAULT_DTYPE
,
"TODO"
);
if
(
tensor
->
devID
<
0
)
{
_SetDataRand
(
tensor
,
lower
,
upper
);
...
...
source/tensor/core/getandset/SetData.cu
查看文件 @
d3ec5df8
差异被折叠。
点击展开。
source/tensor/core/getandset/SetData.cuh
查看文件 @
d3ec5df8
...
...
@@ -19,6 +19,7 @@
/*
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-07-18
* I'm surprised that I did not write this file till today.
* $Update by: Lin Ye (email: linye2015@outlook.com) 2019-07-22 float16 added
*/
#ifndef __SETDATA_CUH__
...
...
@@ -28,14 +29,9 @@
namespace nts { // namespace nts(NiuTrans.Tensor)
/* generate data items with a fixed value p (in int) */
void _CudaSetDataFixedInt(XTensor * tensor, int p);
/* generate data items with a fixed value p (in float) */
void _CudaSetDataFixedFloat(XTensor * tensor, float p);
/* generate data items with a fixed value p (in double) */
void _CudaSetDataFixedDouble(XTensor * tensor, double p);
/* generate data items with a fixed value p (in int, float, float16, double) */
template<class T>
void _CudaSetDataFixed(XTensor * tensor, T p);
/* set data items along with a given dimension (and keep the remaining items unchanged) */
void _CudaSetDataDim(XTensor * tensor, int beg, int len, int dim, DTYPE p);
...
...
@@ -47,11 +43,11 @@ void _CudaSetDataIndexed(XTensor * source, XTensor * modify, int dim, int index)
void _CudaSetDataLowTri(XTensor * tensor, DTYPE p, int shift);
/* generate data items with a uniform distribution in [lower, upper] */
void _CudaSetDataRand(
const
XTensor * tensor, DTYPE lower, DTYPE upper);
void _CudaSetDataRand(XTensor * tensor, DTYPE lower, DTYPE upper);
/* generate data items with a uniform distribution in [lower, upper] and set
the item to a pre-defined value if the item >= p, set the item to 0 otherwise */
void _CudaSetDataRandP(
const
XTensor * tensor, DTYPE lower, DTYPE upper, DTYPE p, DTYPE value);
void _CudaSetDataRandP(XTensor * tensor, DTYPE lower, DTYPE upper, DTYPE p, DTYPE value);
/* set the data with an array of offsets */
void _CudaSetDataWithOffset(XTensor * tensor, MTYPE * offsets, DTYPE value, MTYPE num);
...
...
source/tensor/core/getandset/SetData.h
查看文件 @
d3ec5df8
...
...
@@ -24,29 +24,19 @@
#define __SETDATA_H__
#include "../../XTensor.h"
#include "SetData.cuh"
namespace
nts
{
// namespace nts(NiuTrans.Tensor)
/* generate data items with a xavier initialization */
void
_SetDataFanInOut
(
XTensor
*
tensor
,
DTYPE
gain
=
1
.
0
F
);
/* generate data items with a fixed value p */
void
_SetDataFixed
(
XTensor
*
tensor
,
void
*
valuePointer
);
/
//
* generate data items with a fixed value p */
//
void _SetDataFixed(XTensor * tensor, void * valuePointer);
/* generate data items with a fixed value p (in default type) */
void
SetDataFixed
(
XTensor
&
tensor
,
DTYPE
p
);
/* generate data items with a fixed value p (in integer) */
void
SetDataFixedInt
(
XTensor
&
tensor
,
int
p
);
/* generate data items with a fixed value p (in int) */
void
_SetDataFixedInt
(
XTensor
*
tensor
,
int
p
);
/* generate data items with a fixed value p (in float) */
void
_SetDataFixedFloat
(
XTensor
*
tensor
,
float
p
);
/* generate data items with a fixed value p (in double) */
void
_SetDataFixedDouble
(
XTensor
*
tensor
,
double
p
);
template
<
class
T
>
void
_SetDataFixed
(
XTensor
*
tensor
,
T
value
);
/* set data items along with a given dimension (and keep the remaining items unchanged) */
void
_SetDataDim
(
XTensor
*
tensor
,
int
beg
,
int
len
,
int
dim
,
DTYPE
p
);
...
...
@@ -58,11 +48,11 @@ void _SetDataIndexed(XTensor * source, XTensor * modify, int dim, int index);
void
_SetDataLowTri
(
XTensor
*
tensor
,
DTYPE
p
,
int
shift
);
/* generate data items with a uniform distribution in [lower, upper] */
void
_SetDataRand
(
const
XTensor
*
tensor
,
DTYPE
lower
,
DTYPE
upper
);
void
_SetDataRand
(
XTensor
*
tensor
,
DTYPE
lower
,
DTYPE
upper
);
/* generate data items with a uniform distribution in [lower, upper] and set
the item to a pre-defined value if the item >= p, set the item to 0 otherwise */
void
_SetDataRandP
(
const
XTensor
*
tensor
,
DTYPE
lower
,
DTYPE
upper
,
DTYPE
p
,
DTYPE
value
);
void
_SetDataRandP
(
XTensor
*
tensor
,
DTYPE
lower
,
DTYPE
upper
,
DTYPE
p
,
DTYPE
value
);
/* generate data items with a normal distribution with specified mean and standard deviation */
void
_SetDataRandN
(
XTensor
*
tensor
,
DTYPE
mean
=
0
.
0
F
,
DTYPE
standardDeviation
=
1
.
0
F
);
...
...
source/tensor/function/DropoutWithIndex.cpp
查看文件 @
d3ec5df8
...
...
@@ -70,7 +70,7 @@ XTensor DropoutWithIndex(const XTensor &x, XTensor &maskIndex, DTYPE scale)
InitTensor1D
(
&
c
,
x
.
unitNum
,
x
.
dataType
,
x
.
devID
,
x
.
mem
);
_SetDataFixed
Float
(
&
c
,
1.0
F
);
_SetDataFixed
(
&
c
,
1.0
F
);
_DropoutWithIndex
(
&
x
,
&
maskIndex
,
&
c
);
...
...
source/tensor/function/Loss.cpp
查看文件 @
d3ec5df8
...
...
@@ -385,11 +385,11 @@ void _LossBackward(XTensor * dedy, XTensor * t, XTensor * y,
{
if
(
t
==
NULL
){
if
(
dedy
->
dataType
==
X_FLOAT
)
_SetDataFixed
Float
(
dedy
,
1.0
F
);
_SetDataFixed
(
dedy
,
1.0
F
);
else
if
(
dedy
->
dataType
==
X_DOUBLE
)
_SetDataFixed
Double
(
dedy
,
1.0
);
_SetDataFixed
(
dedy
,
1.0
);
else
if
(
dedy
->
dataType
==
X_INT
)
_SetDataFixed
Int
(
dedy
,
1
);
_SetDataFixed
(
dedy
,
1
);
else
{
ShowNTErrors
(
"TODO"
);
}
...
...
source/tensor/test/TDropout.cpp
查看文件 @
d3ec5df8
...
...
@@ -50,7 +50,7 @@ bool TestDropout1()
XTensor
yUser
;
/* initialize variables */
_SetDataFixed
Float
(
x
,
1.0
F
);
_SetDataFixed
(
x
,
1.0
F
);
y
->
SetZeroAll
();
/* call Dropout function */
...
...
@@ -88,7 +88,7 @@ bool TestDropout1()
XTensor
yUserGPU
;
/* initialize variables */
_SetDataFixed
Float
(
xGPU
,
1.0
F
);
_SetDataFixed
(
xGPU
,
1.0
F
);
yGPU
->
SetZeroAll
();
/* call Dropout function */
...
...
@@ -157,10 +157,10 @@ bool TestDropout2()
XTensor
*
dedy
=
NewTensor
(
order
,
dimSize
);
/* initialize variables */
_SetDataFixed
Float
(
x
,
1.0
F
);
_SetDataFixed
(
x
,
1.0
F
);
y
->
SetZeroAll
();
dedx
->
SetZeroAll
();
_SetDataFixed
Float
(
dedy
,
1.5
F
);
_SetDataFixed
(
dedy
,
1.5
F
);
/* call Dropout function */
float
dropProb
=
0.5
F
;
...
...
@@ -183,10 +183,10 @@ bool TestDropout2()
XTensor
*
dedyGPU
=
NewTensor
(
order
,
dimSize
,
X_FLOAT
,
1.0
F
,
0
);
/* initialize variables */
_SetDataFixed
Float
(
xGPU
,
1.0
F
);
_SetDataFixed
(
xGPU
,
1.0
F
);
yGPU
->
SetZeroAll
();
dedxGPU
->
SetZeroAll
();
_SetDataFixed
Float
(
dedyGPU
,
1.5
F
);
_SetDataFixed
(
dedyGPU
,
1.5
F
);
/* call Dropout function */
_Dropout
(
xGPU
,
yGPU
,
seed
,
dropProb
);
...
...
source/tensor/test/TReduceSum.cpp
查看文件 @
d3ec5df8
...
...
@@ -196,8 +196,8 @@ bool TestReduceSum2()
XTensor
tUser
;
/* initialize variables */
_SetDataFixed
Float
(
s
,
1.0
F
);
_SetDataFixed
Float
(
answer
,
(
float
)
s
->
GetDim
(
1
));
_SetDataFixed
(
s
,
1.0
F
);
_SetDataFixed
(
answer
,
(
float
)
s
->
GetDim
(
1
));
/* call ReduceSum function */
_ReduceSum
(
s
,
t
,
1
);
...
...
@@ -216,7 +216,7 @@ bool TestReduceSum2()
XTensor
tUserGPU
;
/* initialize variables */
_SetDataFixed
Float
(
sGPU
,
1.0
F
);
_SetDataFixed
(
sGPU
,
1.0
F
);
/* call ReduceSum function */
_ReduceSum
(
sGPU
,
tGPU
,
1
);
...
...
@@ -285,8 +285,8 @@ bool TestReduceSum3()
XTensor
tUser
;
/* initialize variables */
_SetDataFixed
Float
(
s
,
1.0
F
);
_SetDataFixed
Float
(
answer
,
(
float
)
s
->
GetDim
(
1
));
_SetDataFixed
(
s
,
1.0
F
);
_SetDataFixed
(
answer
,
(
float
)
s
->
GetDim
(
1
));
/* call ReduceSum function */
_ReduceSum
(
s
,
t
,
1
);
...
...
@@ -305,7 +305,7 @@ bool TestReduceSum3()
XTensor
tUserGPU
;
/* initialize variables */
_SetDataFixed
Float
(
sGPU
,
1.0
F
);
_SetDataFixed
(
sGPU
,
1.0
F
);
/* call ReduceSum function */
_ReduceSum
(
sGPU
,
tGPU
,
1
);
...
...
@@ -374,8 +374,8 @@ bool TestReduceSum4()
XTensor
tUser
;
/* initialize variables */
_SetDataFixed
Float
(
s
,
1.0
F
);
_SetDataFixed
Float
(
answer
,
(
float
)
s
->
GetDim
(
1
));
_SetDataFixed
(
s
,
1.0
F
);
_SetDataFixed
(
answer
,
(
float
)
s
->
GetDim
(
1
));
/* call ReduceSum function */
_ReduceSum
(
s
,
t
,
1
);
...
...
@@ -394,7 +394,7 @@ bool TestReduceSum4()
XTensor
tUserGPU
;
/* initialize variables */
_SetDataFixed
Float
(
sGPU
,
1.0
F
);
_SetDataFixed
(
sGPU
,
1.0
F
);
/* call ReduceSum function */
_ReduceSum
(
sGPU
,
tGPU
,
1
);
...
...
@@ -465,8 +465,8 @@ bool TestReduceSum5()
XTensor
tUser
;
/* initialize variables */
_SetDataFixed
Float
(
s
,
1.0
F
);
_SetDataFixed
Float
(
answer
,
(
float
)
s
->
GetDim
(
1
));
_SetDataFixed
(
s
,
1.0
F
);
_SetDataFixed
(
answer
,
(
float
)
s
->
GetDim
(
1
));
/* call ReduceSum function */
_ReduceSum
(
s
,
t
,
1
);
...
...
@@ -485,7 +485,7 @@ bool TestReduceSum5()
XTensor
tUserGPU
;
/* initialize variables */
_SetDataFixed
Float
(
sGPU
,
1.0
F
);
_SetDataFixed
(
sGPU
,
1.0
F
);
/* call ReduceSum function */
_ReduceSum
(
sGPU
,
tGPU
,
1
);
...
...
@@ -556,8 +556,8 @@ bool TestReduceSum6()
XTensor
tUser
;
/* initialize variables */
_SetDataFixed
Float
(
s
,
1.0
F
);
_SetDataFixed
Float
(
answer
,
(
float
)
s
->
GetDim
(
1
));
_SetDataFixed
(
s
,
1.0
F
);
_SetDataFixed
(
answer
,
(
float
)
s
->
GetDim
(
1
));
/* call ReduceSum function */
_ReduceSum
(
s
,
t
,
1
);
...
...
@@ -576,7 +576,7 @@ bool TestReduceSum6()
XTensor
tUserGPU
;
/* initialize variables */
_SetDataFixed
Float
(
sGPU
,
1.0
F
);
_SetDataFixed
(
sGPU
,
1.0
F
);
/* call ReduceSum function */
_ReduceSum
(
sGPU
,
tGPU
,
1
);
...
...
source/tensor/test/TSetData.cpp
查看文件 @
d3ec5df8
差异被折叠。
点击展开。
source/tensor/test/TSpread.cpp
查看文件 @
d3ec5df8
...
...
@@ -90,7 +90,7 @@ bool TestSpread1()
XTensor
*
modify
=
NewTensor
(
dataOrder
,
dataDimSize
);
/* Initialize variables */
_SetDataFixed
Float
(
s
,
0.0
F
);
_SetDataFixed
(
s
,
0.0
F
);
modify
->
SetData
(
data
,
dataUnitNum
);
/* call _Spread function */
...
...
@@ -108,7 +108,7 @@ bool TestSpread1()
XTensor
*
modifyGPU
=
NewTensor
(
dataOrder
,
dataDimSize
,
X_FLOAT
,
1.0
F
,
0
);
/* Initialize variables */
_SetDataFixed
Float
(
sGPU
,
0.0
F
);
_SetDataFixed
(
sGPU
,
0.0
F
);
modifyGPU
->
SetData
(
data
,
dataUnitNum
);
/* call _Spread function */
...
...
source/tensor/test/TSumDim.cpp
查看文件 @
d3ec5df8
...
...
@@ -295,8 +295,8 @@ bool TestSumDim3()
/* initialize variables */
a
->
SetZeroAll
();
cMe
->
SetZeroAll
();
_SetDataFixed
Float
(
b
,
1.0
F
);
_SetDataFixed
Float
(
answer
,
1.0
F
);
_SetDataFixed
(
b
,
1.0
F
);
_SetDataFixed
(
answer
,
1.0
F
);
/* call SumDim function */
_SumDim
(
a
,
b
,
c
,
1
);
...
...
@@ -322,7 +322,7 @@ bool TestSumDim3()
/* Initialize variables */
aGPU
->
SetZeroAll
();
cMe
->
SetZeroAll
();
_SetDataFixed
Float
(
bGPU
,
1.0
F
);
_SetDataFixed
(
bGPU
,
1.0
F
);
/* call sum function */
_SumDim
(
aGPU
,
bGPU
,
cGPU
,
1
);
...
...
@@ -404,8 +404,8 @@ bool TestSumDim4()
/* initialize variables */
a
->
SetZeroAll
();
cMe
->
SetZeroAll
();
_SetDataFixed
Float
(
b
,
1.0
F
);
_SetDataFixed
Float
(
answer
,
1.0
F
);
_SetDataFixed
(
b
,
1.0
F
);
_SetDataFixed
(
answer
,
1.0
F
);
/* call SumDim function */
_SumDim
(
a
,
b
,
c
,
1
);
...
...
@@ -431,7 +431,7 @@ bool TestSumDim4()
/* Initialize variables */
aGPU
->
SetZeroAll
();
cMe
->
SetZeroAll
();
_SetDataFixed
Float
(
bGPU
,
1.0
F
);
_SetDataFixed
(
bGPU
,
1.0
F
);
/* call sum function */
_SumDim
(
aGPU
,
bGPU
,
cGPU
,
1
);
...
...
source/tensor/test/Test.cpp
查看文件 @
d3ec5df8
...
...
@@ -30,7 +30,7 @@ bool Test()
XPRINT
(
0
,
stdout
,
"Testing the XTensor utilites ...
\n\n
"
);
//wrong = !TestAbsolute() || wrong;
wrong
=
!
TestClip
()
||
wrong
;
//
wrong = !TestClip() || wrong;
//wrong = !TestCompare() || wrong;
//wrong = !TestConcatenate() || wrong;
//wrong = !TestConcatenateSolely() || wrong;
...
...
@@ -38,8 +38,8 @@ bool Test()
//wrong = !TestConvertDataType() || wrong;
//wrong = !TestCopyIndexed() || wrong;
//wrong = !TestCopyValues() || wrong;
wrong
=
!
TestDiv
()
||
wrong
;
wrong
=
!
TestDivDim
()
||
wrong
;
//
wrong = !TestDiv() || wrong;
//
wrong = !TestDivDim() || wrong;
//wrong = !TestExp() || wrong;
//wrong = !TestGather() || wrong;
//wrong = !TestLog() || wrong;
...
...
@@ -49,7 +49,7 @@ bool Test()
//wrong = !TestMatrixMulBatched() || wrong;
//wrong = !TestMerge() || wrong;
//wrong = !TestMultiply() || wrong;
wrong
=
!
TestMultiplyDim
()
||
wrong
;
//
wrong = !TestMultiplyDim() || wrong;
//wrong = !TestNegate() || wrong;
//wrong = !TestNormalize() || wrong;
//wrong = !TestPower() || wrong;
...
...
@@ -60,17 +60,17 @@ bool Test()
//wrong = !TestReduceSumSquared() || wrong;
//wrong = !TestReduceVariance() || wrong;
//wrong = !TestRound() || wrong;
wrong
=
!
TestScaleAndShift
()
||
wrong
;
//
wrong = !TestScaleAndShift() || wrong;
//wrong = !TestSelect() || wrong;
//wrong = !TestSetAscendingOrder() || wrong;
//
wrong = !TestSetData() || wrong;
wrong
=
!
TestSetData
()
||
wrong
;
//wrong = !TestSign() || wrong;
//wrong = !TestSin() || wrong;
//wrong = !TestSort() || wrong;
//wrong = !TestSplit() || wrong;
//wrong = !TestSpread() || wrong;
//wrong = !TestSub() || wrong;
wrong
=
!
TestSum
()
||
wrong
;
//
wrong = !TestSum() || wrong;
//wrong = !TestSumByColumnTV() || wrong;
//wrong = !TestSumByColumnVT() || wrong;
//wrong = !TestSumDim() || wrong;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论