From a7a74361dc8de813172503d8e1cd5d8c56817fb8 Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Fri, 23 Apr 2021 10:32:48 +0100 Subject: Fix Depthwise failure in Cpu backend Resolves: COMPMID-4395 Change-Id: Ib3dfdc42e95998c1e5713d6ec1bdaa83299b0360 Signed-off-by: Michalis Spyrou Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5488 Reviewed-by: Giorgio Arena Reviewed-by: TeresaARM Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- src/runtime/NEON/functions/NEDepthwiseConvolutionLayer.cpp | 5 ++--- src/runtime/cpu/operators/CpuDepthwiseConvolution.cpp | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/runtime/NEON/functions/NEDepthwiseConvolutionLayer.cpp b/src/runtime/NEON/functions/NEDepthwiseConvolutionLayer.cpp index 1d7b1c677b..da9610ef42 100644 --- a/src/runtime/NEON/functions/NEDepthwiseConvolutionLayer.cpp +++ b/src/runtime/NEON/functions/NEDepthwiseConvolutionLayer.cpp @@ -121,7 +121,7 @@ void NEDepthwiseConvolutionLayer::NEDepthwiseConvolutionLayerOptimizedInternal:: _impl->permuted_output.info()->set_quantization_info(output->info()->quantization_info()); // Configure optimized depthwise - dwc_optimized_func->configure(_impl->permuted_input.info(), _impl->permuted_weights.info(), biases->info(), _impl->permuted_output.info(), info); + dwc_optimized_func->configure(_impl->permuted_input.info(), _impl->permuted_weights.info(), biases == nullptr ? nullptr : biases->info(), _impl->permuted_output.info(), info); // Configure the function to transform the convoluted output to ACL's native ordering format NCHW _impl->permuted_output.info()->set_data_layout(DataLayout::NHWC); @@ -132,7 +132,7 @@ void NEDepthwiseConvolutionLayer::NEDepthwiseConvolutionLayerOptimizedInternal:: } else { - dwc_optimized_func->configure(_impl->src->info(), _impl->weights->info(), biases->info(), _impl->dst->info(), info); + dwc_optimized_func->configure(_impl->src->info(), _impl->weights->info(), biases == nullptr ? nullptr : biases->info(), _impl->dst->info(), info); } // Allocate memory based on the internal memory requirements @@ -184,7 +184,6 @@ void NEDepthwiseConvolutionLayer::NEDepthwiseConvolutionLayerOptimizedInternal:: if(_impl->permute) { _impl->permuted_weights.allocator()->allocate(); - _impl->weights->mark_as_unused(); } if(!_impl->permuted_weights.is_used()) diff --git a/src/runtime/cpu/operators/CpuDepthwiseConvolution.cpp b/src/runtime/cpu/operators/CpuDepthwiseConvolution.cpp index 183a2af0cd..6d097280e0 100644 --- a/src/runtime/cpu/operators/CpuDepthwiseConvolution.cpp +++ b/src/runtime/cpu/operators/CpuDepthwiseConvolution.cpp @@ -170,7 +170,7 @@ void CpuDepthwiseConvolution::CpuDepthwiseConvolutionOptimizedInternal::run(ITen if(_permute) { ITensorPack pack; - auto src = tensors.get_tensor(TensorType::ACL_SRC_0); + auto src = tensors.get_const_tensor(TensorType::ACL_SRC_0); auto src_perm = tensors.get_tensor(TensorType::ACL_INT_0); pack.add_tensor(TensorType::ACL_SRC, src); pack.add_tensor(TensorType::ACL_DST, src_perm); @@ -247,6 +247,8 @@ void CpuDepthwiseConvolution::CpuDepthwiseConvolutionOptimizedInternal::prepare( pack.add_tensor(TensorType::ACL_DST, permuted_weights); _permute_weights->run(pack); + weights->mark_as_unused(); + ITensorPack pack_opt; pack_opt.add_const_tensor(TensorType::ACL_SRC_1, permuted_weights); pack_opt.add_tensor(TensorType::ACL_SRC_2, bias); -- cgit v1.2.1