Skip to content

[flatbuffers] Update to flatbuffers v23.5.26 #39

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
40 changes: 20 additions & 20 deletions runtime/executor/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,19 @@ bool parse_cond_value(const EValue& cond_value) {

} // namespace

Error Method::parse_values(
const flatbuffers::Vector<
flatbuffers::Offset<executorch_flatbuffer::EValue>>* flatbuffer_values,
size_t* num_parsed) {
for (size_t i = 0; i < n_value_; ++i) {
Error Method::parse_values() {
auto flatbuffer_values = serialization_plan_->values();
ET_CHECK(flatbuffer_values != nullptr);
size_t n_value = flatbuffer_values->size();
values_ = ET_ALLOCATE_LIST_OR_RETURN_ERROR(
memory_manager_->get_runtime_allocator(), EValue, n_value);

// n_value_ counts the number of successfully-initialized values for ~Method()
// to clean up, and is incremented at the bottom of the loop. This makes it
// safe for errors to return without updating any state.
n_value_ = 0;

for (size_t i = 0; i < n_value; ++i) {
auto serialization_value = flatbuffer_values->Get(i);
switch (serialization_value->val_type()) {
case executorch_flatbuffer::KernelTypes::Null: {
Expand Down Expand Up @@ -329,7 +337,6 @@ Error Method::parse_values(
"Failed parsing tensor at index %zu: %" PRIu32,
i,
t.error());
*num_parsed = i;
return t.error();
}
new (&values_[i]) EValue(t.get());
Expand All @@ -347,7 +354,6 @@ Error Method::parse_values(
"Failed parsing tensor list at index %zu: %" PRIu32,
i,
tensors.error());
*num_parsed = i;
return tensors.error();
}
new (&values_[i]) EValue(tensors.get());
Expand All @@ -365,7 +371,6 @@ Error Method::parse_values(
"Failed parsing optional tensor list at index %zu: %" PRIu32,
i,
tensors.error());
*num_parsed = i;
return tensors.error();
}
new (&values_[i]) EValue(tensors.get());
Expand All @@ -383,8 +388,12 @@ Error Method::parse_values(
"to see which type this is.",
static_cast<uint32_t>(serialization_value->val_type()) - 1);
}

// ~Method() will try to clean up n_value_ entries in the values_ array.
// Only increment this once we know the entry is valid, so that we don't try
// to clean up an uninitialized entry.
n_value_ = i + 1;
}
*num_parsed = n_value_;
return Error::Ok;
}

Expand Down Expand Up @@ -502,18 +511,9 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
auto runtime_allocator = memory_manager_->get_runtime_allocator();

{
// Load values
auto plan_values = serialization_plan_->values();
ET_CHECK(plan_values != nullptr);
n_value_ = plan_values->size();
values_ =
ET_ALLOCATE_LIST_OR_RETURN_ERROR(runtime_allocator, EValue, n_value_);
size_t num_parsed;
Error err = parse_values(plan_values, &num_parsed);
// Parse the elements of the values_ array.
Error err = parse_values();
if (err != Error::Ok) {
// ~Method() will try to clean up entries in this list. Ensure that it
// doesn't look at any uninitialized entries.
n_value_ = num_parsed;
return err;
}
}
Expand Down
16 changes: 4 additions & 12 deletions runtime/executor/method.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@

// Forward declare flatbuffer types. This is a public header and must not
// include the generated flatbuffer header.
namespace flatbuffers {
template <typename T>
class Vector;
template <typename T>
struct Offset;
} // namespace flatbuffers
namespace executorch_flatbuffer {
struct Chain;
struct ExecutionPlan;
Expand Down Expand Up @@ -262,13 +256,11 @@ class Method final {
bool pre_allocated_input_;

/**
* Initialize the EValue table of the program. *num_parsed is the number
* of elements actually parsed, which may be less than n_value_ on failure.
* Parses the elements of the values_ array. On error, n_value_ will be set to
* the number of successfully-initialized entries so that ~Method doesn't try
* to clean up uninitialized entries.
*/
__ET_NODISCARD Error parse_values(
const flatbuffers::Vector<
flatbuffers::Offset<executorch_flatbuffer::EValue>>* fb_values,
size_t* num_parsed);
__ET_NODISCARD Error parse_values();

__ET_NODISCARD Error resolve_operator(
int32_t op_index,
Expand Down
18 changes: 14 additions & 4 deletions third-party/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -165,36 +165,46 @@ runtime.cxx_binary(
"flatbuffers/grpc/src/compiler/python_generator.cc",
"flatbuffers/grpc/src/compiler/swift_generator.cc",
"flatbuffers/grpc/src/compiler/ts_generator.cc",
"flatbuffers/src/annotated_binary_text_gen.cpp",
"flatbuffers/src/bfbs_gen_lua.cpp",
"flatbuffers/src/bfbs_gen_nim.cpp",
"flatbuffers/src/binary_annotator.cpp",
"flatbuffers/src/code_generators.cpp",
"flatbuffers/src/file_binary_writer.cpp",
"flatbuffers/src/file_name_saving_file_manager.cpp",
"flatbuffers/src/file_writer.cpp",
"flatbuffers/src/flatc.cpp",
"flatbuffers/src/flatc_main.cpp",
"flatbuffers/src/idl_gen_binary.cpp",
"flatbuffers/src/idl_gen_cpp.cpp",
"flatbuffers/src/idl_gen_csharp.cpp",
"flatbuffers/src/idl_gen_dart.cpp",
"flatbuffers/src/idl_gen_fbs.cpp",
"flatbuffers/src/idl_gen_go.cpp",
"flatbuffers/src/idl_gen_grpc.cpp",
"flatbuffers/src/idl_gen_java.cpp",
"flatbuffers/src/idl_gen_js_ts.cpp",
"flatbuffers/src/idl_gen_json_schema.cpp",
"flatbuffers/src/idl_gen_kotlin.cpp",
"flatbuffers/src/idl_gen_lobster.cpp",
"flatbuffers/src/idl_gen_lua.cpp",
"flatbuffers/src/idl_gen_php.cpp",
"flatbuffers/src/idl_gen_python.cpp",
"flatbuffers/src/idl_gen_rust.cpp",
"flatbuffers/src/idl_gen_swift.cpp",
"flatbuffers/src/idl_gen_text.cpp",
"flatbuffers/src/idl_gen_ts.cpp",
"flatbuffers/src/idl_parser.cpp",
"flatbuffers/src/reflection.cpp",
"flatbuffers/src/util.cpp",
],
include_directories = [
"flatbuffers/grpc",
"flatbuffers/include",
],
raw_headers = [
"flatbuffers/grpc/src/compiler/config.h",
"flatbuffers/grpc/src/compiler/cpp_generator.h",
"flatbuffers/grpc/src/compiler/go_generator.h",
"flatbuffers/grpc/src/compiler/java_generator.h",
"flatbuffers/grpc/src/compiler/python_generator.h",
"flatbuffers/grpc/src/compiler/python_private_generator.h",
"flatbuffers/grpc/src/compiler/schema_interface.h",
"flatbuffers/grpc/src/compiler/swift_generator.h",
"flatbuffers/grpc/src/compiler/ts_generator.h",
Expand Down
2 changes: 1 addition & 1 deletion third-party/flatbuffers
Submodule flatbuffers updated 1636 files