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
fbef372b
Commit
fbef372b
authored
6 years ago
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reload of *
parent
27635638
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
24 行增加
和
8 行删除
+24
-8
source/Main.cpp
+3
-3
source/XTensor.cpp
+7
-0
source/XTensor.h
+3
-0
source/core/math/ScaleAndShift.cpp
+11
-5
没有找到文件。
source/Main.cpp
查看文件 @
fbef372b
...
...
@@ -45,7 +45,7 @@ int main( int argc, const char ** argv )
//_CrtSetBreakAlloc(78);
/* a tiny test */
if
(
1
)
if
(
0
)
SmallTest
();
if
(
argc
>
1
&&
!
strcmp
(
argv
[
1
],
"-test"
))
...
...
@@ -76,9 +76,9 @@ void SmallTest()
b
=
Sum
(
a
,
Multiply
(
a
,
a
));
XTensor
c
=
b
;
XTensor
c
=
a
*
b
+
a
;
XTensor
d
=
b
+
a
+
Linear
(
c
,
0.5
F
);
XTensor
d
=
a
+
b
+
Linear
(
c
,
0.5
F
);
a
.
Dump
(
stderr
,
"a: "
);
b
.
Dump
(
stderr
,
"b: "
);
...
...
This diff is collapsed.
Click to expand it.
source/XTensor.cpp
查看文件 @
fbef372b
...
...
@@ -41,6 +41,7 @@
#include "core/shape/MergeBlockLists.h"
#include "core/movement/CopyValues.h"
#include "core/arithmetic/Sum.h"
#include "core/arithmetic/Multiply.h"
#ifdef USE_CUDA
...
...
@@ -315,6 +316,12 @@ XTensor XTensor::operator+ (const XTensor& tensor)
return
Sum
(
*
this
,
tensor
);
}
/* overloading of the multiply-sign */
XTensor
XTensor
::
operator
*
(
const
XTensor
&
tensor
)
{
return
Multiply
(
*
this
,
tensor
);
}
/*
judge whether the two matrices are in the same type and size
>> a - input tensor
...
...
This diff is collapsed.
Click to expand it.
source/XTensor.h
查看文件 @
fbef372b
...
...
@@ -187,6 +187,9 @@ public:
/* overloading of the plus-sign */
XTensor
operator
+
(
const
XTensor
&
tensor
);
/* overloading of the multiply-sign */
XTensor
operator
*
(
const
XTensor
&
tensor
);
/* judge whether the two matrices are in the same type and size */
static
bool
IsIdentical
(
XTensor
*
a
,
XTensor
*
b
);
...
...
This diff is collapsed.
Click to expand it.
source/core/math/ScaleAndShift.cpp
查看文件 @
fbef372b
...
...
@@ -53,18 +53,24 @@ void _ScaleAndShift(const XTensor * a, XTensor * b, DTYPE scale, DTYPE shift)
int
num
=
a
->
unitNumNonZero
;
char
*
d
=
(
char
*
)
a
->
data
+
sizeof
(
int
);
char
*
f
=
d
+
(
sizeof
(
int
)
+
sizeof
(
DTYPE
))
*
0
+
sizeof
(
int
);
char
*
db
=
(
char
*
)
b
->
data
+
sizeof
(
int
);
char
*
fb
=
db
+
(
sizeof
(
int
)
+
sizeof
(
DTYPE
))
*
0
+
sizeof
(
int
);
for
(
int
i
=
0
;
i
<
num
;
i
++
){
DTYPE
*
v
=
(
DTYPE
*
)
f
;
*
v
=
*
v
*
scale
+
shift
;
DTYPE
*
vb
=
(
DTYPE
*
)
fb
;
*
vb
=
*
v
*
scale
+
shift
;
f
+=
sizeof
(
int
)
+
sizeof
(
DTYPE
);
fb
+=
sizeof
(
int
)
+
sizeof
(
DTYPE
);
}
}
/* dense tensor */
else
{
DTYPE
*
v
=
(
DTYPE
*
)
a
->
data
;
for
(
int
i
=
0
;
i
<
a
->
unitNum
;
i
++
){
*
v
=
*
v
*
scale
+
shift
;
v
++
;
DTYPE
*
va
=
(
DTYPE
*
)
a
->
data
;
DTYPE
*
vb
=
(
DTYPE
*
)
b
->
data
;
for
(
int
i
=
0
;
i
<
b
->
unitNum
;
i
++
){
*
vb
=
*
va
*
scale
+
shift
;
va
++
;
vb
++
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论