Compute Library
 20.08
IWeightsManager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
25 #ifndef ARM_COMPUTE_IWEIGHTSMANAGER_H
26 #define ARM_COMPUTE_IWEIGHTSMANAGER_H
27 
30 
31 #include <map>
32 
33 namespace arm_compute
34 {
35 /** Weights manager interface to handle weights transformations */
37 {
38 public:
39  /** Constructor */
41  /** Default Destructor */
42  virtual ~IWeightsManager() = default;
43  /** Prevent instances of this class to be copy constructed */
44  IWeightsManager(const IWeightsManager &) = delete;
45  /** Prevent instances of this class to be copied */
46  IWeightsManager &operator=(const IWeightsManager &) = delete;
47  /** Allow instances of this class to be move constructed */
48  IWeightsManager(IWeightsManager &&) = default;
49  /** Allow instances of this class to be moved */
51 
52  /** Start managing a weights tensor
53  *
54  * @param[in] weights Pointer to the weights tensor to be managed
55  * @param[in] parent Parent node in case where the weights are coming from a previous reshape function
56  */
57  void manage(const ITensor *weights, ITransformWeights *parent = nullptr);
58  /** Run the reshape function.
59  *
60  * @param[in] weights Pointer to the weights tensor we want to reshape
61  * @param[in] weights_transform Weights transformation object
62  *
63  * @return The reshaped tensor
64  */
65  ITensor *run(const ITensor *weights, ITransformWeights *weights_transform);
66  /** Acquire the requested reshape tensor of the selected weights
67  *
68  * @param[in] weights Pointer to the weights tensor to be managed
69  * @param[in] weights_transform Weights transformation object
70  */
71  ITensor *acquire(const ITensor *weights, ITransformWeights *weights_transform);
72  /** Check if the weights are managed
73  *
74  * @param[in] weights Pointer to the weights tensor we want to check if managed
75  *
76  * @return True if the weights tensor is managed else false
77  */
78  bool are_weights_managed(const ITensor *weights);
79 
80 private:
81  std::map<const ITensor *, std::vector<ITransformWeights *>> _managed_weights;
82  std::map<const ITensor *, ITransformWeights *> _managed_weights_parents;
83 };
84 } // arm_compute
85 #endif /*ARM_COMPUTE_IWEIGHTSMANAGER_H */
void manage(const ITensor *weights, ITransformWeights *parent=nullptr)
Start managing a weights tensor.
Interface for NEON tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2020 Arm Limited.
bool are_weights_managed(const ITensor *weights)
Check if the weights are managed.
virtual ~IWeightsManager()=default
Default Destructor.
Weights manager interface to handle weights transformations.
IWeightsManager & operator=(const IWeightsManager &)=delete
Prevent instances of this class to be copied.
Weights tensor transform interface In order to identify the different reshape functions,...
ITensor * run(const ITensor *weights, ITransformWeights *weights_transform)
Run the reshape function.
ITensor * acquire(const ITensor *weights, ITransformWeights *weights_transform)
Acquire the requested reshape tensor of the selected weights.