| 81 | } |
| 82 | |
| 83 | TfLiteStatus SimpleMemoryArena::Deallocate(TfLiteContext* context, |
| 84 | const ArenaAlloc& alloc) { |
| 85 | if (alloc.size == 0) { |
| 86 | return kTfLiteOk; |
| 87 | } |
| 88 | |
| 89 | int erased_allocs_count = 0; |
| 90 | auto it = allocs_.begin(); |
| 91 | while (it != allocs_.end()) { |
| 92 | if (it->offset == alloc.offset) { |
| 93 | TF_LITE_ENSURE_EQ(context, it->size, alloc.size); |
| 94 | erased_allocs_count++; |
| 95 | it = allocs_.erase(it); |
| 96 | } else { |
| 97 | ++it; |
| 98 | } |
| 99 | } |
| 100 | TF_LITE_ENSURE_EQ(context, erased_allocs_count, 1); |
| 101 | return kTfLiteOk; |
| 102 | } |
| 103 | |
| 104 | TfLiteStatus SimpleMemoryArena::Commit(TfLiteContext* context) { |
| 105 | size_t required_size = RequiredBufferSize(); |