Commit fb2bdabe by xiaotong

dump mem info

parent 1037cc81
......@@ -63,7 +63,6 @@
/* the nts (NiuTrans.Tensor) namespace */
namespace nts{
MTYPE xtensorMemUsed = 0;
int tensorIDGlobal = 0;
MUTEX_HANDLE tensorMutex;
XTensor NULLTensor;
......@@ -255,16 +254,13 @@ void XTensor::Init()
/* delete data arrays */
void XTensor::DestroyData()
{
MUTEX_LOCK(tensorMutex);
xtensorMemUsed += GetDataSizeInChar();
MUTEX_UNLOCK(tensorMutex);
if(data != NULL && mem == NULL && !isShared)
XMemFree(devID, data);
else if(data != NULL && isInGlobalMem)
FreeData(this, mem);
else if(data != NULL)
mem->Release(data, GetDataSizeInChar(), signature);
data = NULL;
if(dataHost != NULL)
......@@ -1301,12 +1297,8 @@ bool XTensor::Resize(const int myOrder, const int * myDimSize,
if(data != NULL){
if (mem == NULL)
XMemFree(devID, data);
else{
else
mem->Release(data, GetDataSizeInChar(), signature);
MUTEX_LOCK(tensorMutex);
xtensorMemUsed -= GetDataSizeInChar();
MUTEX_UNLOCK(tensorMutex);
}
}
signature = mem != NULL ? mem->GetSignature() : 0;
......@@ -1373,12 +1365,9 @@ bool XTensor::Resize(const int myOrder, const int * myDimSize,
d = new int[size];
memset(d, 0, size);
}
else
else{
d = (int*)mem->Alloc(mem->devID, size);
MUTEX_LOCK(tensorMutex);
xtensorMemUsed += size;
MUTEX_UNLOCK(tensorMutex);
}
if(d == NULL)
return false;
......
......@@ -387,9 +387,6 @@ public:
void FreeData(XTensor * matrix, XMem * myMem = NULL, bool useBuf = false);
};
/* record of mem consumption (for XTensor) */
extern MTYPE xtensorMemUsed;
/* we make a unique id for every tensor */
extern int tensorIDGlobal;
extern MUTEX_HANDLE tensorMutex;
......
......@@ -207,7 +207,7 @@ void _SoftmaxBackward(XTensor * gold, XTensor * y, XTensor * x,
DTYPE * gp = gold != NULL ? (DTYPE*)gold->data : NULL;
DTYPE * op = (DTYPE*)y->data;
DTYPE * sp = (DTYPE*)dedx->data;
DTYPE * yp = (DTYPE*)dedy->data;
DTYPE * yp = NULL;
if(lossName == CROSSENTROPY){
if(gold->isSparse){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论