Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NiuTrans.Tensor
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
8
Issues
8
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
NiuTrans
NiuTrans.Tensor
Commits
75385ebe
Commit
75385ebe
authored
Jun 11, 2019
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add MODX to make the functions accept dimension index with a minus value
parent
e87cf208
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
21 行增加
和
3 行删除
+21
-3
source/tensor/XGlobal.h
+3
-1
source/tensor/core/arithmetic/DivDim.cpp
+4
-0
source/tensor/core/arithmetic/MultiplyDim.cpp
+6
-2
source/tensor/core/arithmetic/SubDim.cpp
+4
-0
source/tensor/core/arithmetic/SumDim.cpp
+4
-0
没有找到文件。
source/tensor/XGlobal.h
查看文件 @
75385ebe
...
...
@@ -157,7 +157,9 @@ extern bool useCUDA;
#define XPRINT7(VERBOSE,FILEH,STR,ARG,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) {if(VERBOSE<=verboseLevel) {fprintf(FILEH,STR,ARG,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7);FFLUSH(FILEH);}}
#define XPRINT8(VERBOSE,FILEH,STR,ARG,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) {if(VERBOSE<=verboseLevel) {fprintf(FILEH,STR,ARG,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8);FFLUSH(FILEH);}}
#define B2I(V) V==0?false:true
#define B2I(V) V == 0 ? false : true
#define MODX(a, b) int(b == 0 ? a : a - floor(double(a)/b) * b)
/* BLAS interfaces */
#ifdef DOUBELPRICSION
...
...
source/tensor/core/arithmetic/DivDim.cpp
查看文件 @
75385ebe
...
...
@@ -42,6 +42,8 @@ i.e., a is divided with b by broadcasting
*/
void
_DivDim
(
const
XTensor
*
a
,
const
XTensor
*
b
,
XTensor
*
c
,
int
n
,
DTYPE
alpha
)
{
n
=
MODX
(
n
,
a
->
order
);
CheckNTErrors
(
a
&&
b
&&
c
,
"Empty tensor input!"
);
CheckNTErrors
(
a
->
unitNum
==
c
->
unitNum
,
"Unmatched tensors in division!"
);
CheckNTErrors
(
a
->
dataType
==
b
->
dataType
&&
a
->
dataType
==
c
->
dataType
,
...
...
@@ -151,6 +153,8 @@ XTensor DivDim(const XTensor &a, const XTensor &b, int n, DTYPE alpha)
{
XTensor
c
(
&
a
);
c
.
SetTMPFlag
();
n
=
MODX
(
n
,
a
.
order
);
/* call _Div function */
_DivDim
(
&
a
,
&
b
,
&
c
,
n
,
alpha
);
...
...
source/tensor/core/arithmetic/MultiplyDim.cpp
查看文件 @
75385ebe
...
...
@@ -42,8 +42,10 @@ i.e., a is multiplied with b by broadcasting
>> n - the dimension index
>> alpha - the scaling factor
*/
void
_MultiplyDim
(
const
XTensor
*
a
,
const
XTensor
*
b
,
XTensor
*
c
,
int
n
,
DTYPE
alpha
)
{
void
_MultiplyDim
(
const
XTensor
*
a
,
const
XTensor
*
b
,
XTensor
*
c
,
int
n
,
DTYPE
alpha
)
{
n
=
MODX
(
n
,
a
->
order
);
CheckNTErrors
(
a
&&
b
&&
c
,
"Empty tensor input!"
);
CheckNTErrors
(
a
->
unitNum
==
c
->
unitNum
,
"Unmatched tensors in multiplication!"
);
CheckNTErrors
(
a
->
dataType
==
b
->
dataType
&&
a
->
dataType
==
c
->
dataType
,
...
...
@@ -151,6 +153,8 @@ XTensor MultiplyDim(const XTensor &a, const XTensor &b, int n)
XTensor
c
(
&
a
);
c
.
SetTMPFlag
();
n
=
MODX
(
n
,
a
.
order
);
/* call _Multiply function */
_MultiplyDim
(
&
a
,
&
b
,
&
c
,
n
,
0
);
...
...
source/tensor/core/arithmetic/SubDim.cpp
查看文件 @
75385ebe
...
...
@@ -42,6 +42,8 @@ i.e., a is subtracted with b by broadcasting
*/
void
_SubDim
(
const
XTensor
*
a
,
const
XTensor
*
b
,
XTensor
*
c
,
int
n
,
DTYPE
beta
)
{
n
=
MODX
(
n
,
a
->
order
);
CheckNTErrors
(
a
&&
b
&&
c
,
"Empty tensor input!"
);
CheckNTErrors
(
a
->
unitNum
==
c
->
unitNum
,
"Unmatched tensors in subtraction!"
);
CheckNTErrors
(
a
->
dataType
==
b
->
dataType
&&
a
->
dataType
==
c
->
dataType
,
...
...
@@ -152,6 +154,8 @@ XTensor SubDim(const XTensor &a, const XTensor &b, int n, DTYPE beta)
XTensor
c
(
&
a
);
c
.
SetTMPFlag
();
n
=
MODX
(
n
,
a
.
order
);
/* call _Sub function */
_SubDim
(
&
a
,
&
b
,
&
c
,
n
,
beta
);
...
...
source/tensor/core/arithmetic/SumDim.cpp
查看文件 @
75385ebe
...
...
@@ -46,6 +46,8 @@ i.e., a is summed with b by broadcasting
*/
void
_SumDim
(
const
XTensor
*
a
,
const
XTensor
*
b
,
XTensor
*
c
,
int
n
,
DTYPE
beta
)
{
n
=
MODX
(
n
,
a
->
order
);
CheckNTErrors
(
a
&&
b
&&
c
,
"Empty tensor input!"
);
CheckNTErrors
(
a
->
unitNum
==
c
->
unitNum
,
"Unmatched tensors in addition!"
);
CheckNTErrors
(
a
->
dataType
==
b
->
dataType
&&
a
->
dataType
==
c
->
dataType
,
...
...
@@ -169,6 +171,8 @@ XTensor SumDim(const XTensor &a, const XTensor &b, int n, DTYPE beta)
{
XTensor
c
(
&
a
);
c
.
SetTMPFlag
();
n
=
MODX
(
n
,
a
.
order
);
/* call _SumDim function */
_SumDim
(
&
a
,
&
b
,
&
c
,
n
,
beta
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论