MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Commit

Method Commit

tensorflow/lite/simple_memory_arena.cc:104–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104TfLiteStatus SimpleMemoryArena::Commit(TfLiteContext* context) {
105 size_t required_size = RequiredBufferSize();
106 if (required_size > underlying_buffer_size_) {
107 char* new_alloc = new char[required_size];
108 char* new_underlying_buffer_aligned_ptr = reinterpret_cast<char*>(
109 AlignTo(arena_alignment_, reinterpret_cast<intptr_t>(new_alloc)));
110
111 // If the arena had been previously allocated, copy over the old memory.
112 // Since Alloc pointers are offset based, they will remain valid in the new
113 // memory block.
114 if (high_water_mark_ > 0 && underlying_buffer_size_ > 0) {
115 size_t copy_amount = std::min(
116 underlying_buffer_.get() + underlying_buffer_size_ -
117 underlying_buffer_aligned_ptr_,
118 new_alloc + required_size - new_underlying_buffer_aligned_ptr);
119 memcpy(new_underlying_buffer_aligned_ptr, underlying_buffer_aligned_ptr_,
120 copy_amount);
121 }
122
123 underlying_buffer_.reset(new_alloc);
124 underlying_buffer_size_ = required_size;
125 underlying_buffer_aligned_ptr_ = new_underlying_buffer_aligned_ptr;
126 }
127 committed_ = true;
128 return underlying_buffer_ != nullptr ? kTfLiteOk : kTfLiteError;
129}
130
131TfLiteStatus SimpleMemoryArena::ResolveAlloc(TfLiteContext* context,
132 const ArenaAlloc& alloc,

Callers

nothing calls this directly

Calls 4

AlignToFunction · 0.85
minFunction · 0.50
getMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected