| 129 | } |
| 130 | |
| 131 | void CLFullyConnectedLayer::prepare() |
| 132 | { |
| 133 | if (!_impl->is_prepared) |
| 134 | { |
| 135 | allocate_tensors(_impl->aux_mem_req, _impl->workspace); |
| 136 | if (!_impl->dynamic_weights) |
| 137 | { |
| 138 | _impl->op->prepare(_impl->run_pack); |
| 139 | |
| 140 | // Release temporary tensors that are only used in prepare stage |
| 141 | release_temporaries<CLTensor>(_impl->aux_mem_req, _impl->workspace); |
| 142 | |
| 143 | // Handle weights managed infrastructure |
| 144 | if (_impl->weights_manager != nullptr && |
| 145 | _impl->weights_manager->are_weights_managed(_impl->original_weights)) |
| 146 | { |
| 147 | // Ensure that b gets marked as unused (memory released) only after the last function which uses b also finishes its prepare |
| 148 | // This is for cases where multiple functions share the same b (weights) |
| 149 | // Therefore when a function marks original b as unused, we pre-mark it in weights manager, and mark it back to used so that it doesn't get released before its last reference |
| 150 | const ITensor *original_b = _impl->original_weights; |
| 151 | if (!original_b->is_used()) |
| 152 | { |
| 153 | _impl->weights_manager->pre_mark_as_unused(original_b); |
| 154 | } |
| 155 | _impl->original_weights->mark_as_used(); |
| 156 | _impl->weights_manager->release(_impl->original_weights); |
| 157 | } |
| 158 | } |
| 159 | _impl->is_prepared = true; |
| 160 | } |
| 161 | } |
| 162 | } // namespace arm_compute |
nothing calls this directly
no test coverage detected