|
|
|
@ -11,6 +11,11 @@ void free_sublayer(layer *l) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void free_layer(layer l) |
|
|
|
|
{ |
|
|
|
|
free_layer_custom(l, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void free_layer_custom(layer l, int keep_cudnn_desc) |
|
|
|
|
{ |
|
|
|
|
if (l.share_layer != NULL) return; // don't free shared layers
|
|
|
|
|
if (l.antialiasing) { |
|
|
|
@ -204,31 +209,33 @@ void free_layer(layer l) |
|
|
|
|
if (l.last_prev_state_gpu) cuda_free(l.last_prev_state_gpu); |
|
|
|
|
if (l.last_prev_cell_gpu) cuda_free(l.last_prev_cell_gpu); |
|
|
|
|
if (l.cell_gpu) cuda_free(l.cell_gpu); |
|
|
|
|
#ifdef CUDNN_DISABLED // shouldn't be used for -map
|
|
|
|
|
if (l.srcTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.srcTensorDesc)); |
|
|
|
|
if (l.dstTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dstTensorDesc)); |
|
|
|
|
if (l.srcTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.srcTensorDesc16)); |
|
|
|
|
if (l.dstTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dstTensorDesc16)); |
|
|
|
|
if (l.dsrcTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dsrcTensorDesc)); |
|
|
|
|
if (l.ddstTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.ddstTensorDesc)); |
|
|
|
|
if (l.dsrcTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dsrcTensorDesc16)); |
|
|
|
|
if (l.ddstTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.ddstTensorDesc16)); |
|
|
|
|
if (l.normTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.normTensorDesc)); |
|
|
|
|
if (l.normDstTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.normDstTensorDesc)); |
|
|
|
|
if (l.normDstTensorDescF16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.normDstTensorDescF16)); |
|
|
|
|
#ifdef CUDNN // shouldn't be used for -map
|
|
|
|
|
if (!keep_cudnn_desc) { |
|
|
|
|
if (l.srcTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.srcTensorDesc)); |
|
|
|
|
if (l.dstTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dstTensorDesc)); |
|
|
|
|
if (l.srcTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.srcTensorDesc16)); |
|
|
|
|
if (l.dstTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dstTensorDesc16)); |
|
|
|
|
if (l.dsrcTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dsrcTensorDesc)); |
|
|
|
|
if (l.ddstTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.ddstTensorDesc)); |
|
|
|
|
if (l.dsrcTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dsrcTensorDesc16)); |
|
|
|
|
if (l.ddstTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.ddstTensorDesc16)); |
|
|
|
|
if (l.normTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.normTensorDesc)); |
|
|
|
|
if (l.normDstTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.normDstTensorDesc)); |
|
|
|
|
if (l.normDstTensorDescF16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.normDstTensorDescF16)); |
|
|
|
|
|
|
|
|
|
if (l.weightDesc) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.weightDesc)); |
|
|
|
|
if (l.weightDesc16) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.weightDesc16)); |
|
|
|
|
if (l.dweightDesc) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.dweightDesc)); |
|
|
|
|
if (l.dweightDesc16) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.dweightDesc16)); |
|
|
|
|
if (l.weightDesc) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.weightDesc)); |
|
|
|
|
if (l.weightDesc16) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.weightDesc16)); |
|
|
|
|
if (l.dweightDesc) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.dweightDesc)); |
|
|
|
|
if (l.dweightDesc16) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.dweightDesc16)); |
|
|
|
|
|
|
|
|
|
if (l.convDesc) CHECK_CUDNN(cudnnDestroyConvolutionDescriptor(l.convDesc)); |
|
|
|
|
if (l.convDesc) CHECK_CUDNN(cudnnDestroyConvolutionDescriptor(l.convDesc)); |
|
|
|
|
|
|
|
|
|
if (l.poolingDesc) CHECK_CUDNN(cudnnDestroyPoolingDescriptor(l.poolingDesc)); |
|
|
|
|
if (l.poolingDesc) CHECK_CUDNN(cudnnDestroyPoolingDescriptor(l.poolingDesc)); |
|
|
|
|
|
|
|
|
|
//cudnnConvolutionFwdAlgo_t fw_algo, fw_algo16;
|
|
|
|
|
//cudnnConvolutionBwdDataAlgo_t bd_algo, bd_algo16;
|
|
|
|
|
//cudnnConvolutionBwdFilterAlgo_t bf_algo, bf_algo16;
|
|
|
|
|
//cudnnConvolutionFwdAlgo_t fw_algo, fw_algo16;
|
|
|
|
|
//cudnnConvolutionBwdDataAlgo_t bd_algo, bd_algo16;
|
|
|
|
|
//cudnnConvolutionBwdFilterAlgo_t bf_algo, bf_algo16;
|
|
|
|
|
} |
|
|
|
|
#endif // CUDNN
|
|
|
|
|
|
|
|
|
|
#endif // GPU
|
|
|
|
|