| 185 | } |
| 186 | |
| 187 | TfLiteStatus ArenaPlanner::ExecuteAllocations(int first_node, int last_node) { |
| 188 | // Grow the size of `allocs_` if necessary. This allows allocating temporary |
| 189 | // tensors in op's `prepare` function. |
| 190 | TF_LITE_ENSURE(context_, graph_info_->num_tensors() >= allocs_.size()); |
| 191 | allocs_.resize(graph_info_->num_tensors()); |
| 192 | |
| 193 | TF_LITE_ENSURE_STATUS(CalculateAllocations(first_node, last_node)); |
| 194 | TF_LITE_ENSURE_STATUS(Commit()); |
| 195 | |
| 196 | for (int i = 0; i < static_cast<int>(graph_info_->num_tensors()); ++i) { |
| 197 | // TODO(ahentz): we could do this only for the tensors that were modified |
| 198 | // in CalculateAllocations(), instead of redoing it for tensors that |
| 199 | // already had proper pointers. However we must be very careful, because |
| 200 | // SimpleMemoryArena::Commit() could move the base pointer. |
| 201 | TF_LITE_ENSURE_STATUS(ResolveTensorAllocation(i)); |
| 202 | } |
| 203 | |
| 204 | return kTfLiteOk; |
| 205 | } |
| 206 | |
| 207 | TfLiteStatus ArenaPlanner::Commit() { |
| 208 | TF_LITE_ENSURE_STATUS(arena_.Commit(context_)); |