Weights tensor transform interface * In order to identify the different reshape functions, each reshape function has * to generate a unique id. We use the following conversion using an unsigned 32bit value: * * Lower two bits store the target: * 00 -> Neon * 01 -> CL * 11 -> Unused * * Five bits store the id of the reshape function: * 00000 -> FullyConnectedLayerReshapeWeights * 00001
| 58 | * |
| 59 | * */ |
| 60 | class ITransformWeights |
| 61 | { |
| 62 | public: |
| 63 | /** Default Constructor */ |
| 64 | ITransformWeights() = default; |
| 65 | /** Default Destructor */ |
| 66 | virtual ~ITransformWeights() = default; |
| 67 | /** Prevent instances of this class to be copy constructed */ |
| 68 | ITransformWeights(const ITransformWeights &) = delete; |
| 69 | /** Prevent instances of this class to be copied */ |
| 70 | ITransformWeights &operator=(const ITransformWeights &) = delete; |
| 71 | /** Allow instances of this class to be move constructed */ |
| 72 | ITransformWeights(ITransformWeights &&other) |
| 73 | { |
| 74 | *this = std::move(other); |
| 75 | } |
| 76 | /** Allow instances of this class to be moved */ |
| 77 | ITransformWeights &operator=(ITransformWeights &&other) |
| 78 | { |
| 79 | if (this != &other) |
| 80 | { |
| 81 | _num_refcount = other._num_refcount.load(); |
| 82 | _reshape_run = other._reshape_run; |
| 83 | } |
| 84 | return *this; |
| 85 | } |
| 86 | |
| 87 | /** Get a pointer to the transformed weights |
| 88 | * |
| 89 | * @return The pointer to the transformed ITensor weights |
| 90 | */ |
| 91 | virtual ITensor *get_weights() = 0; |
| 92 | /** Function that returns a unique id of the reshape function |
| 93 | * |
| 94 | * @return The computed unique id |
| 95 | */ |
| 96 | virtual uint32_t uid() = 0; |
| 97 | /** Run the transformation function */ |
| 98 | virtual void run() = 0; |
| 99 | /** Release transformed weights memory */ |
| 100 | virtual void release() = 0; |
| 101 | /** Increase the object's refcount */ |
| 102 | void increase_refcount() |
| 103 | { |
| 104 | ++_num_refcount; |
| 105 | } |
| 106 | |
| 107 | /** Decrease the object's refcount and return the updated value |
| 108 | * |
| 109 | * @return The updated refcount |
| 110 | * */ |
| 111 | int32_t decrease_refcount() |
| 112 | { |
| 113 | return --_num_refcount; |
| 114 | } |
| 115 | |
| 116 | /** Function that returns a flag on whether the weights are reshaped or not |
| 117 | * |