Commit f1e69d00 by xiaotong

copy constructor

parent 561a9e58
......@@ -197,8 +197,7 @@ XTensor::XTensor(const XTensor &reference)
SetDataPointer();
id = MakeTensorID();
ShallowCopy(reference);
isInit = false;
isTmp = false;
data = NULL;
dataHost = NULL;
if(reference.isTmp){
......@@ -214,15 +213,14 @@ XTensor::XTensor(const XTensor &reference)
*reference.dataP = NULL;
}
else{
DestroyData();
if(isInit){
devID = reference.devID;
mem = reference.mem;
}
InitTensor(this, &reference);
CopyValues(&reference, this);
}
isInit = false;
isTmp = false;
}
/* de-constructor */
......@@ -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) */
const int XTensor::GetNonzeroSize()
int XTensor::GetNonzeroSize()
{
if(!isSparse){
XPRINT(1, stderr, "WARNING! Counting non-zero elements in a dense tensor might be slow!\n");
......
......@@ -55,10 +55,8 @@ struct XLink;
#define UNSAFE_BUT_FAST_MEM
#define FAST_MATRIX
/*
We implemente the tensor class here.
*/
class XTensor
/* XTensor is a class to do everything a tensor can do :) */
struct XTensor
{
public:
/* id */
......@@ -282,7 +280,7 @@ public:
bool Add2D(DTYPE value, int ni, int mi);
/* get the number of non-zero elements (in a sparse tensor) */
const int GetNonzeroSize();
int GetNonzeroSize();
/* set the tensor as "temporary" */
void SetTMP(bool myIsTmp = true);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论