From 72f13bdaaca9e9c8f6ff340dd675e08926737bba Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Tue, 9 Mar 2021 15:51:32 +0000 Subject: Fix segmentation fault on CLSoftmaxLayer CLSoftmaxLayer's late allocation was causing segmentation fault for some cases where MemoryManager is managed by the caller of CLSoftmaxLayer function. Make allocation of intermediate tensor happen earlier to fix the issue. Resolves: COMPMID-4298 Change-Id: I6936287939971a93f4a4286c4b9ece6f60ec9f7a Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5241 Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice Comments-Addressed: Arm Jenkins --- src/runtime/CL/functions/CLSoftmaxLayer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/runtime/CL/functions/CLSoftmaxLayer.cpp') diff --git a/src/runtime/CL/functions/CLSoftmaxLayer.cpp b/src/runtime/CL/functions/CLSoftmaxLayer.cpp index 938a10a7c0..e0bb6c3333 100644 --- a/src/runtime/CL/functions/CLSoftmaxLayer.cpp +++ b/src/runtime/CL/functions/CLSoftmaxLayer.cpp @@ -71,6 +71,7 @@ void CLSoftmaxLayerGeneric::configure(const CLCompileContext &compile_co SoftmaxKernelInfo softmax_info{ beta, IS_LOG, input->info()->data_type(), axis }; _impl->op->configure(compile_context, *input->info(), *output->info(), softmax_info); + allocate_workspace(); } template @@ -90,8 +91,8 @@ void CLSoftmaxLayerGeneric::allocate_workspace() _impl->workspace_tensors.emplace_back(memory_info.type, std::make_unique()); auto tensor = _impl->workspace_tensors.back().second.get(); ARM_COMPUTE_ERROR_ON_NULLPTR(tensor); - _impl->memory_group.manage(tensor); tensor->allocator()->init(tensor_info); + _impl->memory_group.manage(tensor); tensor->allocator()->allocate(); }); } @@ -99,8 +100,6 @@ void CLSoftmaxLayerGeneric::allocate_workspace() template void CLSoftmaxLayerGeneric::run() { - allocate_workspace(); - // Acquire all the temporaries MemoryGroupResourceScope scope_mg(_impl->memory_group); -- cgit v1.2.1