aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/runtime/IWeightsManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'arm_compute/runtime/IWeightsManager.h')
-rw-r--r--arm_compute/runtime/IWeightsManager.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/arm_compute/runtime/IWeightsManager.h b/arm_compute/runtime/IWeightsManager.h
index 12aa1da8a7..de8a92faa3 100644
--- a/arm_compute/runtime/IWeightsManager.h
+++ b/arm_compute/runtime/IWeightsManager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Arm Limited.
+ * Copyright (c) 2019, 2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -76,10 +76,28 @@ public:
* @return True if the weights tensor is managed else false
*/
bool are_weights_managed(const ITensor *weights);
+ /** Release weights refcount and mark as unused if reaches 0
+ *
+ * @param[in] weights Weights to release
+ */
+ void release(const ITensor *weights);
+ /** Pre-mark the weights as unused. The weights tensor will get marked as unused only when the counter goes to 0
+ *
+ * @param weights Weights to mark unused
+ */
+ void pre_mark_as_unused(const ITensor *weights);
+
+private:
+ struct CounterElement
+ {
+ bool is_unused{false};
+ std::atomic<int> counter{1};
+ };
private:
std::map<const ITensor *, std::vector<ITransformWeights *>> _managed_weights;
+ std::map<const ITensor *, CounterElement> _managed_counter;
std::map<const ITensor *, ITransformWeights *> _managed_weights_parents;
};
-} // arm_compute
-#endif /*ARM_COMPUTE_IWEIGHTSMANAGER_H */ \ No newline at end of file
+} // namespace arm_compute
+#endif /*ARM_COMPUTE_IWEIGHTSMANAGER_H */