Add missing calls to cuda_exit in CTC GPU wrapper

上级 6480164d
...@@ -142,8 +142,12 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations, ...@@ -142,8 +142,12 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations,
break; break;
default: default:
ctc_context_destroy( context ); ctc_context_destroy( context );
cuda_exit( gpu_context->ctx );
PyErr_SetString( PyExc_TypeError, PyErr_SetString( PyExc_TypeError,
"GpuConnectionistTemporalClassification: Unsupported type for activations." ); "GpuConnectionistTemporalClassification: Unsupported type for activations." );
return 1; return 1;
} }
...@@ -154,6 +158,8 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations, ...@@ -154,6 +158,8 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations,
// Destroy previous CTC context before returning exception // Destroy previous CTC context before returning exception
ctc_context_destroy( context ); ctc_context_destroy( context );
cuda_exit( gpu_context->ctx );
PyErr_Format( PyExc_MemoryError, PyErr_Format( PyExc_MemoryError,
"GpuConnectionistTemporalClassification: Could not allocate memory for input lengths." ); "GpuConnectionistTemporalClassification: Could not allocate memory for input lengths." );
return 1; return 1;
...@@ -167,6 +173,8 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations, ...@@ -167,6 +173,8 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations,
// Destroy previous CTC context before returning exception // Destroy previous CTC context before returning exception
ctc_context_destroy( context ); ctc_context_destroy( context );
cuda_exit( gpu_context->ctx );
PyErr_Format( PyExc_MemoryError, PyErr_Format( PyExc_MemoryError,
"GpuConnectionistTemporalClassification: Could not allocate memory for labels and their lengths." ); "GpuConnectionistTemporalClassification: Could not allocate memory for labels and their lengths." );
return 1; return 1;
...@@ -194,7 +202,7 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations, ...@@ -194,7 +202,7 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations,
} }
else else
{ {
GpuArray_memset( &((*out_costs)->ga), 0 ); GpuArray_memset( &((*out_costs)->ga), 0 );
} }
costs = (float *) PyGpuArray_DEV_DATA( *out_costs ); costs = (float *) PyGpuArray_DEV_DATA( *out_costs );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论