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
06053721
Commit
06053721
authored
Jul 13, 2019
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c++ 11 by default
parent
e184cac4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
23 行增加
和
18 行删除
+23
-18
source/tensor/XDevice.cpp
+0
-4
source/tensor/XGlobal.h
+1
-5
source/tensor/XTensor.cpp
+19
-5
source/tensor/XTensor.h
+3
-4
没有找到文件。
source/tensor/XDevice.cpp
查看文件 @
06053721
...
...
@@ -266,10 +266,6 @@ XDevManager::XDevManager()
{
Clear
();
Init
();
#ifndef USE_CPP11
fprintf
(
stderr
,
"Warning!!! c++ 11 is RECOMMENDED for compilation.
\n
"
);
#endif
}
/* de-constructor */
...
...
source/tensor/XGlobal.h
查看文件 @
06053721
...
...
@@ -43,13 +43,9 @@
/* the nts (NiuTrans.Tensor) namespace */
namespace
nts
{
#if (__cplusplus >= 201103L || _MSC_VER >= 1700)
#define USE_CPP11
#endif
#define _XINLINE_
//#define DOUBELPRICSION
//#define DOUBELPRICSION
#ifdef DOUBELPRICSION
#define DTYPE double
...
...
source/tensor/XTensor.cpp
查看文件 @
06053721
...
...
@@ -171,7 +171,7 @@ XTensor::XTensor(const XTensor &reference)
As "reference" is constant, we cannot reset reference.data
here. So we save the ADDRESS of reference.data in
reference.dataP, and do this work by updating "*reference.dataP".
This is VERY trick and might not be the best solution :) */
This is VERY trick
y
and might not be the best solution :) */
*
reference
.
dataP
=
NULL
;
}
else
{
...
...
@@ -193,7 +193,6 @@ XTensor::XTensor(const XTensor &reference)
}
/* copy constructor (with right value reference) */
#ifdef USE_CPP11
XTensor
::
XTensor
(
const
XTensor
&&
reference
)
{
Init
();
...
...
@@ -212,7 +211,7 @@ XTensor::XTensor(const XTensor &&reference)
As "reference" is constant, we cannot reset reference.data
here. So we save the ADDRESS of reference.data in
reference.dataP, and do this work by updating "*reference.dataP".
This is VERY trick and might not be the best solution :) */
This is VERY trick
y
and might not be the best solution :) */
*
reference
.
dataP
=
NULL
;
XLink
::
Replace
(
&
reference
,
this
);
...
...
@@ -220,7 +219,6 @@ XTensor::XTensor(const XTensor &&reference)
isInit
=
true
;
isTmp
=
reference
.
isTmp
;
}
#endif
/* de-constructor */
XTensor
::~
XTensor
()
...
...
@@ -445,7 +443,7 @@ XTensor& XTensor::operator= (const XTensor&& tensor)
As "reference" is constant, we cannot reset reference.data
here. So we save the ADDRESS of reference.data in
reference.dataP, and do this work by updating "*reference.dataP".
This is VERY trick and might not be the best solution :) */
This is VERY trick
y
and might not be the best solution :) */
*
tensor
.
dataP
=
NULL
;
XLink
::
Replace
(
&
tensor
,
this
);
...
...
@@ -520,6 +518,7 @@ void XTensor::SetDevice(int myDevId, XMem * myMem)
{
if
(
myMem
!=
NULL
)
{
FlushToMem
(
myMem
);
isInGlobalMem
=
false
;
}
else
{
ShowNTErrors
(
"TODO!"
);
...
...
@@ -1295,6 +1294,21 @@ bool XTensor::Set(DTYPE value, int index[], int size)
}
/*
set the value of a cell with its offset in the array
>> value - the value we intend to set
>> offset - the offset in the array
*/
bool
XTensor
::
Set
(
DTYPE
value
,
int
offset
)
{
CheckNTErrors
(
offset
>=
0
&&
offset
<
unitNum
,
"Invalid index!"
);
CheckNTErrors
(
data
!=
NULL
,
"Cannot use an uninitialized tensor!"
);
DTYPE
*
d
=
(
DTYPE
*
)
data
+
offset
;
return
SetToDevice
(
devID
,
d
,
value
);
}
/*
set the value of a cell in a 1d tensor
>> value - value we tend to set
>> i - item offset
...
...
source/tensor/XTensor.h
查看文件 @
06053721
...
...
@@ -194,9 +194,7 @@ public:
XTensor
(
const
XTensor
&
reference
);
/* copy constructor (with right value reference) */
#ifdef USE_CPP11
XTensor
(
const
XTensor
&&
reference
);
#endif
/* de-constructor */
~
XTensor
();
...
...
@@ -217,9 +215,7 @@ public:
XTensor
&
operator
=
(
const
XTensor
&
tensor
);
/* overloading of the equal-sign (with right value reference) */
#ifdef USE_CPP11
XTensor
&
operator
=
(
const
XTensor
&&
tensor
);
#endif
/* overloading of the plus-sign */
XTensor
operator
+
(
const
XTensor
&
tensor
)
const
;
...
...
@@ -361,6 +357,9 @@ public:
/* set the value of a cell */
bool
Set
(
DTYPE
value
,
int
index
[],
int
size
=
-
1
);
/* set the value of a cell with its offset in the array */
bool
Set
(
DTYPE
value
,
int
offset
);
/* set the value of a cell in a 1d tensor */
bool
Set1D
(
DTYPE
value
,
int
i
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论