From a3e57c20a0b7a174f0c357676a4da40a248d04db Mon Sep 17 00:00:00 2001 From: Viet-Hoa Do Date: Mon, 13 Mar 2023 16:20:04 +0000 Subject: Add dynamic weights for CPU fully connected layer Resolves: COMPMID-5917 Signed-off-by: Viet-Hoa Do Change-Id: I073067b490f2a1b96b81a037ea431c9a2e5c7503 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9322 Reviewed-by: Gunes Bayir Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins Benchmark: Arm Jenkins --- src/runtime/NEON/functions/NEFullyConnectedLayer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/runtime/NEON') diff --git a/src/runtime/NEON/functions/NEFullyConnectedLayer.cpp b/src/runtime/NEON/functions/NEFullyConnectedLayer.cpp index 919e5ed84f..891487efd3 100644 --- a/src/runtime/NEON/functions/NEFullyConnectedLayer.cpp +++ b/src/runtime/NEON/functions/NEFullyConnectedLayer.cpp @@ -49,6 +49,7 @@ struct NEFullyConnectedLayer::Impl experimental::MemoryRequirements aux_mem_req{}; bool is_prepared{ false }; + bool dynamic_weights{ false }; }; NEFullyConnectedLayer::~NEFullyConnectedLayer() = default; @@ -87,6 +88,12 @@ void NEFullyConnectedLayer::configure(const ITensor *input, const ITensor *weigh _impl->aux_mem_req = _impl->op->workspace(); _impl->run_pack = { { ACL_SRC_0, input }, { ACL_SRC_1, weights }, { ACL_SRC_2, biases }, { ACL_DST, output } }; _impl->workspace = manage_workspace(_impl->aux_mem_req, _impl->memory_group, _impl->run_pack, _impl->run_pack); + + _impl->dynamic_weights = + !weights->info()->are_values_constant() && + fc_info.transpose_weights && + !fc_info.are_weights_reshaped && + !fc_info.retain_internal_weights; } Status NEFullyConnectedLayer::has_opt_impl(arm_compute::WeightFormat &expected_weight_format, const ITensorInfo *input, const ITensorInfo *weights, @@ -104,7 +111,10 @@ Status NEFullyConnectedLayer::validate(const ITensorInfo *input, const ITensorIn void NEFullyConnectedLayer::run() { - prepare(); + if(!_impl->dynamic_weights) + { + prepare(); + } MemoryGroupResourceScope scope_mg(_impl->memory_group); _impl->op->run(_impl->run_pack); -- cgit v1.2.1