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
0d6a5f7d
Commit
0d6a5f7d
authored
Jul 05, 2018
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tensor connections
parent
4a0b5fed
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
40 行增加
和
2 行删除
+40
-2
source/XLink.cpp
+12
-0
source/XLink.h
+5
-1
source/XName.h
+6
-1
source/core/Sort.cpp
+5
-0
source/core/TopK.cpp
+6
-0
source/core/Unsqueeze.cpp
+6
-0
没有找到文件。
source/XLink.cpp
查看文件 @
0d6a5f7d
...
@@ -188,5 +188,17 @@ void XLink::AddParamToHead(XTensor * h, DTYPE param)
...
@@ -188,5 +188,17 @@ void XLink::AddParamToHead(XTensor * h, DTYPE param)
h
->
income
.
AddParam
(
param
);
h
->
income
.
AddParam
(
param
);
}
}
/*
add an integer parameter
>> h - head
>> param - parameter we want introduce
*/
void
XLink
::
AddParamToHeadInt
(
XTensor
*
h
,
int
param
)
{
if
(
h
!=
NULL
)
return
;
h
->
income
.
AddParam
(
&
param
,
sizeof
(
int
));
}
}
// namespace nts(NiuTrans.Tensor)
}
// namespace nts(NiuTrans.Tensor)
source/XLink.h
查看文件 @
0d6a5f7d
...
@@ -105,9 +105,13 @@ struct XLink
...
@@ -105,9 +105,13 @@ struct XLink
static
static
void
MakeLink
(
XTensor
*
t1
,
XTensor
*
t2
,
XTensor
*
h
,
const
char
*
typeName
);
void
MakeLink
(
XTensor
*
t1
,
XTensor
*
t2
,
XTensor
*
h
,
const
char
*
typeName
);
/* add
parameters
*/
/* add
a parameter
*/
static
static
void
AddParamToHead
(
XTensor
*
h
,
DTYPE
param
);
void
AddParamToHead
(
XTensor
*
h
,
DTYPE
param
);
/* add an integer parameter */
static
void
AddParamToHeadInt
(
XTensor
*
h
,
int
param
);
};
};
}
// namespace nts(NiuTrans.Tensor)
}
// namespace nts(NiuTrans.Tensor)
...
...
source/XName.h
查看文件 @
0d6a5f7d
...
@@ -28,8 +28,13 @@
...
@@ -28,8 +28,13 @@
namespace
nts
{
// namespace nts(NiuTrans.Tensor)
namespace
nts
{
// namespace nts(NiuTrans.Tensor)
#define MATH_SUM "M_SUM"
#define MATH_MATMUL "M_MATMUL"
#define MATH_MATMUL "M_MATMUL"
#define MATH_SELECTRANGE "M_SELECTRANGE"
#define MATH_SORT "M_SORT"
#define MATH_SUM "M_SUM"
#define MATH_TOPK "M_TOPK"
#define MATH_UNSQUEEZE "M_UNSQUEEZE"
}
// namespace nts(NiuTrans.Tensor)
}
// namespace nts(NiuTrans.Tensor)
...
...
source/core/Sort.cpp
查看文件 @
0d6a5f7d
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "../XTensor.h"
#include "../XTensor.h"
#include "../XUtility.h"
#include "../XUtility.h"
#include "../XName.h"
#include "Sort.h"
#include "Sort.h"
#include "Sort.cuh"
#include "Sort.cuh"
...
@@ -38,6 +39,10 @@ void Sort(XTensor * a, XTensor * index, int dim)
...
@@ -38,6 +39,10 @@ void Sort(XTensor * a, XTensor * index, int dim)
CheckNTErrors
((
a
->
order
==
index
->
order
),
"Unmatched input tensors!"
);
CheckNTErrors
((
a
->
order
==
index
->
order
),
"Unmatched input tensors!"
);
CheckNTErrors
((
index
->
dataType
==
X_INT
),
"Wrong data type!"
);
CheckNTErrors
((
index
->
dataType
==
X_INT
),
"Wrong data type!"
);
/* make tensor connections */
XLink
::
MakeLink
(
a
,
NULL
,
index
,
MATH_SORT
);
XLink
::
AddParamToHeadInt
(
index
,
dim
);
int
dimRDI
=
a
->
order
-
dim
-
1
;
int
dimRDI
=
a
->
order
-
dim
-
1
;
/* make the index tensor */
/* make the index tensor */
index
->
SetAscendingOrder
(
dim
);
index
->
SetAscendingOrder
(
dim
);
...
...
source/core/TopK.cpp
查看文件 @
0d6a5f7d
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
*/
*/
#include "../XTensor.h"
#include "../XTensor.h"
#include "../XName.h"
#include "TopK.h"
#include "TopK.h"
#include "TopK.cuh"
#include "TopK.cuh"
...
@@ -39,6 +40,11 @@ void TopK(XTensor * a, XTensor * b, XTensor * index, int dim, int k)
...
@@ -39,6 +40,11 @@ void TopK(XTensor * a, XTensor * b, XTensor * index, int dim, int k)
CheckNTErrors
((
index
==
NULL
||
a
->
order
==
index
->
order
),
"Unmatched input tensors!"
);
CheckNTErrors
((
index
==
NULL
||
a
->
order
==
index
->
order
),
"Unmatched input tensors!"
);
CheckNTErrors
((
index
->
dataType
==
X_INT
),
"Wrong data type!"
);
CheckNTErrors
((
index
->
dataType
==
X_INT
),
"Wrong data type!"
);
/* make tensor connections */
XLink
::
MakeLink
(
a
,
b
,
index
,
MATH_TOPK
);
XLink
::
AddParamToHeadInt
(
index
,
dim
);
XLink
::
AddParamToHeadInt
(
index
,
k
);
int
dimRDI
=
a
->
order
-
dim
-
1
;
int
dimRDI
=
a
->
order
-
dim
-
1
;
for
(
int
i
=
0
;
i
<
a
->
order
;
i
++
)
{
for
(
int
i
=
0
;
i
<
a
->
order
;
i
++
)
{
if
(
i
==
dimRDI
)
{
if
(
i
==
dimRDI
)
{
...
...
source/core/Unsqueeze.cpp
查看文件 @
0d6a5f7d
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
*/
*/
#include "../XTensor.h"
#include "../XTensor.h"
#include "../XName.h"
#include "Unsqueeze.h"
#include "Unsqueeze.h"
#include "MergeBlockLists.h"
#include "MergeBlockLists.h"
#include "Unsqueeze.cuh"
#include "Unsqueeze.cuh"
...
@@ -39,6 +40,11 @@ void Unsqueeze(XTensor * a, XTensor * b, int dim, int dSize)
...
@@ -39,6 +40,11 @@ void Unsqueeze(XTensor * a, XTensor * b, int dim, int dSize)
CheckNTErrors
((
a
->
order
==
b
->
order
-
1
),
"Unmatched tensors!"
);
CheckNTErrors
((
a
->
order
==
b
->
order
-
1
),
"Unmatched tensors!"
);
CheckNTErrors
((
a
->
unitSize
==
b
->
unitSize
),
"Unmatched tensors!"
);
CheckNTErrors
((
a
->
unitSize
==
b
->
unitSize
),
"Unmatched tensors!"
);
/* make tensor connections */
XLink
::
MakeLink
(
a
,
NULL
,
b
,
MATH_UNSQUEEZE
);
XLink
::
AddParamToHeadInt
(
b
,
dim
);
XLink
::
AddParamToHeadInt
(
b
,
dSize
);
int
dimRDI
=
b
->
order
-
dim
-
1
;
int
dimRDI
=
b
->
order
-
dim
-
1
;
for
(
int
i
=
0
;
i
<
b
->
order
;
i
++
)
{
for
(
int
i
=
0
;
i
<
b
->
order
;
i
++
)
{
if
(
i
<
dimRDI
)
{
if
(
i
<
dimRDI
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论