Commit fb2bdabe by xiaotong

dump mem info

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