Skip to content

Commit

Permalink
refactor: move misplaced TF_LITE_REMOVE_VIRTUAL_DELETEs to private:
Browse files Browse the repository at this point in the history
Move several TF_LITE_REMOVE_VIRTUAL_DELETE declarations that are
wrongly in a public section of their classes. To have the intended
effect, as documented in t/l/m/compatibility.h, these must be in a
private section.
  • Loading branch information
rkuester committed Oct 17, 2024
1 parent 7b3a2bd commit c107f42
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ class NonPersistentArenaBufferAllocator : public INonPersistentBufferAllocator {
// takes in account any temporary allocations.
size_t GetAvailableMemory(size_t alignment) const override;

TF_LITE_REMOVE_VIRTUAL_DELETE

private:
// The memory arena that this allocator manages.
uint8_t* const buffer_head_;
Expand All @@ -97,6 +95,8 @@ class NonPersistentArenaBufferAllocator : public INonPersistentBufferAllocator {
// Count of outstanding temp buffers.
int temp_buffer_count_ = 0;
bool resizable_buffer_allocated_ = false;

TF_LITE_REMOVE_VIRTUAL_DELETE
};

} // namespace tflite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class PersistentArenaBufferAllocator : public IPersistentBufferAllocator {
// Returns the size of all persistent allocations in bytes.
size_t GetPersistentUsedBytes() const override;

TF_LITE_REMOVE_VIRTUAL_DELETE
private:
// The memory arena that this allocator manages.
uint8_t* const buffer_head_;
Expand All @@ -51,6 +50,8 @@ class PersistentArenaBufferAllocator : public IPersistentBufferAllocator {
// So in essence, the allocated region grows from the bottom and emulates
// SingleArenaBufferAllocator's persistent part.
uint8_t* tail_temp_;

TF_LITE_REMOVE_VIRTUAL_DELETE
};

} // namespace tflite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ class SingleArenaBufferAllocator : public INonPersistentBufferAllocator,
// account any temporary allocations.
size_t GetUsedBytes() const;

TF_LITE_REMOVE_VIRTUAL_DELETE

protected:
// Returns a pointer to the current end of the head buffer.
uint8_t* head() const;
Expand All @@ -137,6 +135,8 @@ class SingleArenaBufferAllocator : public INonPersistentBufferAllocator,
intptr_t temp_buffer_ptr_check_sum_ = 0;
// Count of outstanding temp buffers.
int temp_buffer_count_ = 0;

TF_LITE_REMOVE_VIRTUAL_DELETE
};

} // namespace tflite
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/lite/micro/micro_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ class MicroBuiltinDataAllocator : public TfLiteBridgeBuiltinDataAllocator {
// of the model.
}

TF_LITE_REMOVE_VIRTUAL_DELETE

private:
IPersistentBufferAllocator* persistent_allocator_;

TF_LITE_REMOVE_VIRTUAL_DELETE
};

MicroMemoryPlanner* CreateMemoryPlanner(
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/lite/micro/micro_mutable_op_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ TFLMRegistration* Register_DETECTION_POSTPROCESS();
template <unsigned int tOpCount>
class MicroMutableOpResolver : public MicroOpResolver {
public:
TF_LITE_REMOVE_VIRTUAL_DELETE

explicit MicroMutableOpResolver() {}

const TFLMRegistration* FindOp(tflite::BuiltinOperator op) const override {
Expand Down Expand Up @@ -704,6 +702,8 @@ class MicroMutableOpResolver : public MicroOpResolver {
BuiltinOperator builtin_codes_[tOpCount];
TfLiteBridgeBuiltinParseFunction builtin_parsers_[tOpCount];
unsigned int num_buitin_ops_ = 0;

TF_LITE_REMOVE_VIRTUAL_DELETE
};

}; // namespace tflite
Expand Down

0 comments on commit c107f42

Please sign in to comment.