Initialize costs with zeros in GPU CTC's C wrapper

上级 ea887edd
...@@ -163,7 +163,7 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations, ...@@ -163,7 +163,7 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations,
{ {
Py_XDECREF( *out_costs ); Py_XDECREF( *out_costs );
*out_costs = pygpu_empty( 1, &cost_size, GA_FLOAT, GA_C_ORDER, *out_costs = pygpu_zeros( 1, &cost_size, GA_FLOAT, GA_C_ORDER,
gpu_context, Py_None ); gpu_context, Py_None );
if ( NULL == *out_costs ) if ( NULL == *out_costs )
...@@ -176,6 +176,10 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations, ...@@ -176,6 +176,10 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations,
return 1; return 1;
} }
} }
else
{
GpuArray_memset( &((*out_costs)->ga), 0 );
}
switch ( (*out_costs)->ga.typecode ) switch ( (*out_costs)->ga.typecode )
{ {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论