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
a91f6809
Commit
a91f6809
authored
Jul 05, 2018
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tensor connections for ReduceMax and ReduceSum
parent
ea8c6aea
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
3 行删除
+17
-3
source/XName.h
+2
-0
source/core/ReduceMax.cpp
+8
-3
source/core/ReduceSum.cpp
+7
-0
没有找到文件。
source/XName.h
查看文件 @
a91f6809
...
...
@@ -29,6 +29,8 @@
namespace
nts
{
// namespace nts(NiuTrans.Tensor)
#define MATH_MATMUL "M_MATMUL"
#define MATH_REDUCEMAX "M_REDUCEMAX"
#define MATH_REDUCESUM "M_REDUCESUM"
#define MATH_SELECTRANGE "M_SELECTRANGE"
#define MATH_SORT "M_SORT"
#define MATH_SUM "M_SUM"
...
...
source/core/ReduceMax.cpp
查看文件 @
a91f6809
...
...
@@ -20,6 +20,7 @@
*/
#include "../XTensor.h"
#include "../XName.h"
#include "ReduceMax.h"
#include "ReduceMax.cuh"
...
...
@@ -34,7 +35,7 @@ get the max value of the items along a dimension of the tensor.
void
ReduceMax
(
XTensor
*
input
,
XTensor
*
output
,
int
dim
)
{
CheckNTErrors
((
input
->
devID
==
output
->
devID
||
(
input
->
devID
<
0
&&
output
->
devID
<
0
)),
"This code must be run on the same device!"
);
"This code must be run on the same device!"
);
CheckNTErrors
((
input
&&
output
),
"Empty input or output tensors!"
);
CheckNTErrors
((
input
->
order
==
output
->
order
+
1
),
"Incorrect tensor sizes!"
);
CheckNTErrors
((
input
->
order
>
dim
&&
dim
>=
0
),
"Illegal dimension to reduce!"
);
...
...
@@ -44,14 +45,18 @@ void ReduceMax(XTensor * input, XTensor * output, int dim)
for
(
int
i
=
0
;
i
<
input
->
order
;
i
++
){
if
(
i
<
dimRDI
){
CheckNTErrors
((
input
->
dimSizeRDI
[
i
]
==
output
->
dimSizeRDI
[
i
]),
"Unmatched tensors!"
);
"Unmatched tensors!"
);
}
else
if
(
i
>
dimRDI
){
CheckNTErrors
((
input
->
dimSizeRDI
[
i
]
==
output
->
dimSizeRDI
[
i
-
1
]),
"Unmatched tensors!"
);
"Unmatched tensors!"
);
}
}
/* make tensor connections */
XLink
::
MakeLink
(
input
,
NULL
,
output
,
MATH_REDUCEMAX
);
XLink
::
AddParamToHeadInt
(
output
,
dim
);
if
(
input
->
devID
>=
0
){
#ifdef USE_CUDA
CudaReduceMax
(
input
,
output
,
dim
);
...
...
source/core/ReduceSum.cpp
查看文件 @
a91f6809
...
...
@@ -22,6 +22,7 @@
#include <math.h>
#include "ReduceSum.h"
#include "ReduceSum.cuh"
#include "../XName.h"
namespace
nts
{
// namespace nts(NiuTrans.Tensor)
...
...
@@ -58,6 +59,12 @@ void ReduceSum(XTensor * input, XTensor * output, int dim, XTensor * shift, DTYP
}
}
/* make tensor connections */
XLink
::
MakeLink
(
input
,
shift
,
output
,
MATH_REDUCESUM
);
XLink
::
AddParamToHeadInt
(
output
,
dim
);
XLink
::
AddParamToHead
(
output
,
power
);
XLink
::
AddParamToHeadInt
(
output
,
isExp
);
if
(
input
->
devID
>=
0
){
#ifdef USE_CUDA
CudaReduceSum
(
input
,
output
,
dim
,
shift
,
power
,
isExp
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论