Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[luci/export] Introduce check_size_limit #13868

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/luci/export/src/CircleExporterUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

#include <mio/circle/schema_generated.h>

// limitation of current flatbuffers file size
inline constexpr unsigned int FLATBUFFERS_SIZE_MAX = 2147483648;

namespace luci
{

Expand Down Expand Up @@ -60,6 +63,12 @@ void set_tensor_index(loco::Node *node, const CircleTensorIndex &tensor_id);
void clear_tensor_index(loco::Node *node);
CircleTensorIndex get_tensor_index(loco::Node *node);

// check if Flatbuffer builder can no longer hold the given amount of the data
inline bool check_size_limit(flatbuffers::FlatBufferBuilder &fb, const uint64_t data_size)
{
return data_size > FLATBUFFERS_SIZE_MAX - fb.GetSize();
}

} // namespace luci

#endif // __CIRCLE_EXPORTER_UTILS_H__