Fixed a slow memory leak that occurred when using cuDNN and tensors were created.

This commit is contained in:
Davis King 2017-03-05 15:36:26 -05:00
parent 84cd330c70
commit ee09185101

View File

@ -191,15 +191,13 @@ namespace dlib
int nc
)
{
if (n == 0 || nr == 0 || nc == 0 || k == 0)
if (handle)
{
if (handle)
{
cudnnDestroyTensorDescriptor((cudnnTensorDescriptor_t)handle);
handle = nullptr;
}
cudnnDestroyTensorDescriptor((cudnnTensorDescriptor_t)handle);
handle = nullptr;
}
else
if (n != 0 && nr != 0 && nc != 0 && k != 0)
{
cudnnTensorDescriptor_t h;
CHECK_CUDNN(cudnnCreateTensorDescriptor(&h));