Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
Tensor.LowPrecision
概览
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
linye
Tensor.LowPrecision
Commits
e434b79c
Commit
e434b79c
authored
5 years ago
by
linye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
email updated
parent
e605710c
隐藏空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
77 行增加
和
48 行删除
+77
-48
source/network/Main.cpp
+24
-0
source/tensor/core/arithmetic/Div.cu
+1
-1
source/tensor/core/arithmetic/Sum.cu
+1
-1
source/tensor/core/arithmetic/XTensorBLAS.cu
+1
-1
source/tensor/core/math/Clip.cu
+36
-31
source/tensor/core/math/Clip.cuh
+2
-2
source/tensor/core/reduce/ReduceMax.cu
+1
-1
source/tensor/core/reduce/ReduceSum.cu
+1
-1
source/tensor/function/HardTanH.cu
+1
-1
source/tensor/function/LogSoftmax.cu
+1
-1
source/tensor/test/TConvertDataType.cpp
+1
-1
source/tensor/test/TDiv.cpp
+1
-1
source/tensor/test/THardTanH.cpp
+1
-1
source/tensor/test/TLogSoftmax.cpp
+1
-1
source/tensor/test/TMatrixMul.cpp
+1
-1
source/tensor/test/TReduceMax.cpp
+1
-1
source/tensor/test/TReduceSum.cpp
+1
-1
source/tensor/test/TSum.cpp
+1
-1
没有找到文件。
source/network/Main.cpp
查看文件 @
e434b79c
...
...
@@ -46,6 +46,7 @@ void HardTanHFP16Test();
void
ReduceMaxFP16Test
();
void
ReduceSumFP16Test
();
void
LogSoftmaxFP16Test
();
void
ClipFP16Test
();
using
namespace
nts
;
using
namespace
fnnlm
;
...
...
@@ -82,6 +83,9 @@ int main(int argc, const char ** argv )
//LogSoftmaxFP16Test();
//return 0;
ClipFP16Test
();
return
0
;
if
(
argc
>
1
&&
!
strcmp
(
argv
[
1
],
"-test"
))
Test
();
else
if
(
argc
>
1
&&
!
strcmp
(
argv
[
1
],
"-fnnlm"
))
...
...
@@ -100,6 +104,26 @@ int main(int argc, const char ** argv )
return
0
;
}
void
ClipFP16Test
()
{
XTensor
a
;
XTensor
intA
;
XTensor
b
;
XTensor
intB
;
InitTensor2D
(
&
a
,
1
,
10
,
X_FLOAT
,
0
);
a
.
SetDataRand
(
-
10.0
F
,
10.0
F
);
a
.
Dump
(
stderr
,
"a:"
);
intA
=
ConvertDataType
(
a
,
X_INT
);
intB
=
Clip
(
intA
,
-
1
,
1
);
b
=
ConvertDataType
(
intB
,
X_FLOAT
);
b
.
Dump
(
stderr
,
"b:"
);
}
void
LogSoftmaxFP16Test
()
{
XTensor
a
;
...
...
This diff is collapsed.
Click to expand it.
source/tensor/core/arithmetic/Div.cu
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-04-24
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-05 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-05 float16 added
*/
#include "../../XDevice.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/core/arithmetic/Sum.cu
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-04-24
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-02 float16/int/int8 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-02 float16/int/int8 added
*/
#include "../../XDevice.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/core/arithmetic/XTensorBLAS.cu
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-04-24
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-06 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-06 float16 added
*/
#include "../../XUtility.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/core/math/Clip.cu
查看文件 @
e434b79c
...
...
@@ -17,6 +17,7 @@
/*
* $Created by: Lin Ye (email: linye2015@outlook.com) 2018-08-03
* $Update by: Lin Ye (email: linye2015@outlook.com) 2019-07-06 float16/int/int8 added
*/
#include "../../XDevice.h"
...
...
@@ -35,34 +36,20 @@ set each entry to its clip value (CUDA Kernel)
>> upper - the upper border
>> size - size of the data array
*/
template <class T>
__global__
void KernelClip(DTYPE * a, DTYPE * b, DTYPE lower, DTYPE
upper, int size)
void KernelClip(T * a, T * b, T lower, T
upper, int size)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < size) {
if (a[i] > upper)
b[i] = upper;
else if (a[i] < lower)
b[i] = lower;
else
b[i] = a[i];
}
}
int i = blockDim.x * blockIdx.x + threadIdx.x;
/*
set each entry to its clip value with float16 data type value (CUDA Kernel)
This is for float16 computation
>> a - pointer to input data array
>> b - pointer to output data array
>> lower - the lower border
>> upper - the upper border
>> size - size of the data array
*/
__global__
void KernelClip(__half * a, __half * b, DTYPE lower, DTYPE upper, int size)
{
return;
if (i < size) {
if (a[i] > upper)
b[i] = upper;
else if (a[i] < lower)
b[i] = lower;
else
b[i] = a[i];
}
}
/*
...
...
@@ -88,12 +75,30 @@ void _CudaClip(const XTensor * a, XTensor * b, DTYPE lower, DTYPE upper)
int devIDBackup;
ProtectCudaDev(a->devID, devIDBackup);
if (a->dataType == DEFAULT_DTYPE) {
KernelClip << <blocks, threads >> >((DTYPE*)a->data, (DTYPE*)b->data, lower, upper, a->unitNum);
}
else if (a->dataType == X_FLOAT16) {
KernelClip << <blocks, threads >> >((__half*)a->data, (__half*)b->data, lower, upper, a->unitNum);
}
if (a->dataType == DEFAULT_DTYPE) {
KernelClip << <blocks, threads >> >((DTYPE*)a->data, (DTYPE*)b->data, lower, upper, a->unitNum);
}
else if (a->dataType == X_FLOAT16) {
unsigned short temp1 = FloatToFloat16(lower);
unsigned short temp2 = FloatToFloat16(upper);
half lower1 = *((half *)&temp1);
half upper1 = *((half *)&temp2);
KernelClip << <blocks, threads >> >((__half*)a->data, (__half*)b->data, lower1, upper1, a->unitNum);
}
else if (a->dataType == X_INT) {
int lower1 = (int)lower;
int upper1 = (int)upper;
KernelClip << <blocks, threads >> >((int *)a->data, (int *)b->data, lower1, upper1, a->unitNum);
}
else if (a->dataType == X_INT8) {
__int8 lower1 = (__int8)lower;
__int8 upper1 = (__int8)upper;
KernelClip << <blocks, threads >> >((__int8 *)a->data, (__int8 *)b->data, lower1, upper1, a->unitNum);
}
else {
ShowNTErrors("TODO!");
}
...
...
This diff is collapsed.
Click to expand it.
source/tensor/core/math/Clip.cuh
查看文件 @
e434b79c
...
...
@@ -29,8 +29,8 @@ namespace nts { // namespace nts(NiuTrans.Tensor)
#ifdef USE_CUDA
/* set each entry to its clip value (CUDA Kernel) */
__global__
void KernelClip(
DTYPE * a, DTYPE * b, DTYPE lower, DTYPE
upper, int size);
template <class T>
__global__
void KernelClip(
T * a, T * b, T lower, T
upper, int size);
/* set each entry to its clip value (CUDA Kernel) with float16 data type*/
__global__
...
...
This diff is collapsed.
Click to expand it.
source/tensor/core/reduce/ReduceMax.cu
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-04-24
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-03 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-03 float16 added
*/
#include "../../XDevice.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/core/reduce/ReduceSum.cu
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-04-24
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-03 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-03 float16 added
*/
#include "../../XDevice.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/function/HardTanH.cu
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-04-25
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-04 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-04 float16 added
*/
#include "HardTanH.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/function/LogSoftmax.cu
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-04-26
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-01 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-01 float16 added
*/
#include "LogSoftmax.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/test/TConvertDataType.cpp
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: Xu Chen (email: hello_master1954@163.com) 2018-07-12
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-06 int8 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-06 int8 added
*/
#include "TConvertDataType.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/test/TDiv.cpp
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: Xu Chen (email: hello_master1954@163.com) 2018-08-01
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-06 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-06 float16 added
*/
#include "TDiv.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/test/THardTanH.cpp
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: Lin Ye (email: linye2015@outlook.com) 2018-06-20
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-06 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-06 float16 added
*/
#include "../XTensor.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/test/TLogSoftmax.cpp
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: Xu Chen (email: hello_master1954@163.com) 2018-07-02
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-06 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-06 float16 added
*/
#include "../XUtility.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/test/TMatrixMul.cpp
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: Xu Chen (email: hello_master1954@163.com) 2018-06-14
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-06 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-06 float16 added
*/
#include "TMatrixMul.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/test/TReduceMax.cpp
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: Xu Chen (email: hello_master1954@163.com) 2018-06-30
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-06 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-06 float16 added
*/
#include "TReduceMax.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/test/TReduceSum.cpp
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: LI Yinqiao (email: li.yin.qiao.2012@hotmail.com) 2018-04-30
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-06 float16 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-06 float16 added
*/
#include "TReduceSum.h"
...
...
This diff is collapsed.
Click to expand it.
source/tensor/test/TSum.cpp
查看文件 @
e434b79c
...
...
@@ -17,7 +17,7 @@
/*
* $Created by: LI Yinqiao (li.yin.qiao.2012@hotmail.com) 2018-04-30
* $Update by: Lin Ye (linye2015@outlook.com) 2019-07-06 float16/int/int8 added
* $Update by: Lin Ye (
email:
linye2015@outlook.com) 2019-07-06 float16/int/int8 added
*/
#include "TSum.h"
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论