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
f1e69d00
Commit
f1e69d00
authored
Jul 10, 2018
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy constructor
parent
561a9e58
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
10 行增加
和
14 行删除
+10
-14
source/XTensor.cpp
+7
-9
source/XTensor.h
+3
-5
没有找到文件。
source/XTensor.cpp
查看文件 @
f1e69d00
...
@@ -197,8 +197,7 @@ XTensor::XTensor(const XTensor &reference)
...
@@ -197,8 +197,7 @@ XTensor::XTensor(const XTensor &reference)
SetDataPointer
();
SetDataPointer
();
id
=
MakeTensorID
();
id
=
MakeTensorID
();
ShallowCopy
(
reference
);
ShallowCopy
(
reference
);
isInit
=
false
;
data
=
NULL
;
isTmp
=
false
;
dataHost
=
NULL
;
dataHost
=
NULL
;
if
(
reference
.
isTmp
){
if
(
reference
.
isTmp
){
...
@@ -214,15 +213,14 @@ XTensor::XTensor(const XTensor &reference)
...
@@ -214,15 +213,14 @@ XTensor::XTensor(const XTensor &reference)
*
reference
.
dataP
=
NULL
;
*
reference
.
dataP
=
NULL
;
}
}
else
{
else
{
DestroyData
();
devID
=
reference
.
devID
;
if
(
isInit
){
mem
=
reference
.
mem
;
devID
=
reference
.
devID
;
mem
=
reference
.
mem
;
}
InitTensor
(
this
,
&
reference
);
InitTensor
(
this
,
&
reference
);
CopyValues
(
&
reference
,
this
);
CopyValues
(
&
reference
,
this
);
}
}
isInit
=
false
;
isTmp
=
false
;
}
}
/* de-constructor */
/* de-constructor */
...
@@ -985,7 +983,7 @@ increase the value of a cell in a 2d tensor
...
@@ -985,7 +983,7 @@ increase the value of a cell in a 2d tensor
}
}
/* get the number of non-zero elements (in a sparse tensor) */
/* get the number of non-zero elements (in a sparse tensor) */
const
int
XTensor
::
GetNonzeroSize
()
int
XTensor
::
GetNonzeroSize
()
{
{
if
(
!
isSparse
){
if
(
!
isSparse
){
XPRINT
(
1
,
stderr
,
"WARNING! Counting non-zero elements in a dense tensor might be slow!
\n
"
);
XPRINT
(
1
,
stderr
,
"WARNING! Counting non-zero elements in a dense tensor might be slow!
\n
"
);
...
...
source/XTensor.h
查看文件 @
f1e69d00
...
@@ -55,10 +55,8 @@ struct XLink;
...
@@ -55,10 +55,8 @@ struct XLink;
#define UNSAFE_BUT_FAST_MEM
#define UNSAFE_BUT_FAST_MEM
#define FAST_MATRIX
#define FAST_MATRIX
/*
/* XTensor is a class to do everything a tensor can do :) */
We implemente the tensor class here.
struct
XTensor
*/
class
XTensor
{
{
public
:
public
:
/* id */
/* id */
...
@@ -282,7 +280,7 @@ public:
...
@@ -282,7 +280,7 @@ public:
bool
Add2D
(
DTYPE
value
,
int
ni
,
int
mi
);
bool
Add2D
(
DTYPE
value
,
int
ni
,
int
mi
);
/* get the number of non-zero elements (in a sparse tensor) */
/* get the number of non-zero elements (in a sparse tensor) */
const
int
GetNonzeroSize
();
int
GetNonzeroSize
();
/* set the tensor as "temporary" */
/* set the tensor as "temporary" */
void
SetTMP
(
bool
myIsTmp
=
true
);
void
SetTMP
(
bool
myIsTmp
=
true
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论