MCPcopy Create free account
hub / github.com/Samsung/ONE / cook_operands

Method cook_operands

compiler/tflchef/core/src/ModelChef.cpp:276–645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276template <typename T> void ModelChef::cook_operands(const T &graph)
277{
278 int32_t buffer_start = _buffer_vec.size();
279 int32_t buffer_index = 0;
280
281 // Create buffer(s) 1~n(I) for input(s)
282 const auto size_input = graph.input_size();
283 for (int ci = 0; ci < size_input; ++ci)
284 {
285 tflite::BufferBuilder buffer_builder{*_flatbuffer_builder};
286 _buffer_vec.emplace_back(buffer_builder.Finish());
287 }
288 // Create buffer(s) n(I)+1~n(I)+n(O) for output(s)
289 const auto size_output = graph.output_size();
290 for (int co = 0; co < size_output; ++co)
291 {
292 tflite::BufferBuilder buffer_builder{*_flatbuffer_builder};
293 _buffer_vec.emplace_back(buffer_builder.Finish());
294 }
295
296 auto input_names = as_dataset(graph.input()).vectorize();
297 auto output_names = as_dataset(graph.output()).vectorize();
298
299 for (const auto &operand : graph.operand())
300 {
301 assert(operand.has_name());
302 assert(operand.has_type());
303
304 flatbuffers::Offset<tflite::SparsityParameters> sparsity_index;
305
306 flatbuffers::Offset<flatbuffers::Vector<int32_t>> shape;
307 std::vector<int32_t> dims;
308 if (operand.has_shape())
309 {
310 dims = as_dims(operand.shape());
311 shape = _flatbuffer_builder->CreateVector(dims);
312 }
313
314 auto name = _flatbuffer_builder->CreateString(operand.name());
315
316 buffer_index = 0;
317
318 // Create Buffer if filler is specified
319 if (operand.has_filler())
320 {
321 const auto &filler = operand.filler();
322
323 assert(filler.has_tag());
324
325 auto args = ranged_arguments(filler.arg().begin(), filler.arg().end());
326 auto chef = data_chef_registry(operand.type()).lookup(filler.tag()).create(args);
327
328 assert(chef != nullptr);
329
330 // Create Data
331 int32_t count = (element_count(dims) > 0) ? element_count(dims) : filler.arg_size();
332 auto data_vec = chef->generate(count);
333

Callers

nothing calls this directly

Calls 15

as_datasetFunction · 0.85
ranged_argumentsFunction · 0.85
make_dim_metadata_vecFunction · 0.85
as_tflite_dimensiontypeFunction · 0.85
as_tflite_tensortypeFunction · 0.85
has_typeMethod · 0.80
tagMethod · 0.80
push_backMethod · 0.80
GetDataMethod · 0.80
GetDimMetadataMethod · 0.80

Tested by

no test coverage detected