diff options
author | Milos Puzovic <Milos.Puzovic@arm.com> | 2022-10-28 16:49:15 +0100 |
---|---|---|
committer | Milos Puzovic <milos.puzovic@arm.com> | 2022-11-01 15:04:10 +0000 |
commit | a7077e9b8cc2d93a84249ee665776d09963e08a0 (patch) | |
tree | 2f810da77d32380e65f6561f80f2dcd2404beb86 /src/cpu/operators/CpuDepthwiseConv2d.cpp | |
parent | 199982fc01bcce10120cd6df03d11829a215c85c (diff) | |
download | ComputeLibrary-a7077e9b8cc2d93a84249ee665776d09963e08a0.tar.gz |
Updateable weights in depthwise convolution
Check whether weights are defined as constant, if they are not constant then do not pack them if they are already packed so that they can be updated.
Signed-off-by: Milos Puzovic <Milos.Puzovic@arm.com>
Change-Id: I73447e31e3660b05f8f40e04ea4ea2003eb9b802
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8539
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/cpu/operators/CpuDepthwiseConv2d.cpp')
-rw-r--r-- | src/cpu/operators/CpuDepthwiseConv2d.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/cpu/operators/CpuDepthwiseConv2d.cpp b/src/cpu/operators/CpuDepthwiseConv2d.cpp index c93ffb113d..f69ecdc5bf 100644 --- a/src/cpu/operators/CpuDepthwiseConv2d.cpp +++ b/src/cpu/operators/CpuDepthwiseConv2d.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Arm Limited. + * Copyright (c) 2021-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -88,6 +88,7 @@ void CpuDepthwiseConv2d::CpuDepthwiseConv2dOptimizedInternal::configure(ITensorI _is_nchw = src->data_layout() == DataLayout::NCHW; _permute = _is_nchw; _is_prepared = false; + _are_weights_const = weights->are_values_constant(); // Configure pipeline _is_activationlayer_enabled = info.act_info.enabled() && !CpuDepthwiseConv2dAssemblyDispatch::is_activation_supported(info.act_info); @@ -218,6 +219,25 @@ void CpuDepthwiseConv2d::CpuDepthwiseConv2dOptimizedInternal::run(ITensorPack &t void CpuDepthwiseConv2d::CpuDepthwiseConv2dOptimizedInternal::prepare(ITensorPack &tensors) { + // if weights are not constant then we need to repack so that weights + // can be updated in-place + if(!_are_weights_const) + { + auto weights = tensors.get_const_tensor(TensorType::ACL_SRC_1); + auto bias = tensors.get_const_tensor(TensorType::ACL_SRC_2); + auto packed_weights = tensors.get_tensor(TensorType::ACL_INT_4); + + ITensorPack pack_opt; + pack_opt.add_tensor(TensorType::ACL_SRC_1, weights); + pack_opt.add_tensor(TensorType::ACL_SRC_2, bias); + pack_opt.add_tensor(TensorType::ACL_INT_1, packed_weights); + + // Prepare optimized function + _dwc_optimized_func->prepare(pack_opt); + + return; + } + if(!_is_prepared) { auto weights = tensors.get_const_tensor(TensorType::ACL_SRC_1); |