Skip to content

Commit

Permalink
[tflchef] Extract init method
Browse files Browse the repository at this point in the history
This will extract init method for flatbuffer_builder initialization.

ONE-DCO-1.0-Signed-off-by: SaeHie Park <[email protected]>
  • Loading branch information
seanshpark committed Aug 12, 2024
1 parent a1c5053 commit 4bf7119
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions compiler/tflchef/core/src/ModelChef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ namespace

struct ModelChef
{
void init(void);
void cook(const ::tflchef::ModelRecipe &model_recipe);

template <typename T> std::map<std::string, int32_t> cook_graph(const T &graph);
Expand All @@ -194,6 +195,12 @@ struct ModelChef
std::string _graph_name;
};

void ModelChef::init(void)
{
flatbuffer_builder =
std::unique_ptr<flatbuffers::FlatBufferBuilder>(new flatbuffers::FlatBufferBuilder(1024));
}

std::vector<flatbuffers::Offset<tflite::DimensionMetadata>>
make_dim_metadata_vec(flatbuffers::FlatBufferBuilder *flatbuffer_builder, int32_t dims_count,
const std::vector<int> &traversal_order_vec,
Expand Down Expand Up @@ -933,9 +940,7 @@ GeneratedModel cook(const ::tflchef::ModelRecipe &model_recipe)

ModelChef &mc = gen_model->model_chef();

mc.flatbuffer_builder =
std::unique_ptr<flatbuffers::FlatBufferBuilder>(new flatbuffers::FlatBufferBuilder(1024));

mc.init();
mc.cook(model_recipe);

// Return "GenerateModel"
Expand Down

0 comments on commit 4bf7119

Please sign in to comment.