MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / UseArraysExtraInfo

Function UseArraysExtraInfo

tensorflow/lite/toco/tooling_util.cc:2349–2385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2347}
2348
2349void UseArraysExtraInfo(Model* model, bool quantize_output) {
2350 for (const auto& entry : model->flags.arrays_extra_info().entries()) {
2351 const auto matches = ScanArrayNames(*model, entry);
2352 for (const auto& matched_name : matches) {
2353 auto& array = model->GetArray(matched_name);
2354 if (entry.has_min() || entry.has_max()) {
2355 CHECK_EQ(entry.has_min(), entry.has_max());
2356 auto& minmax = array.GetOrCreateMinMax();
2357 minmax.min = entry.min();
2358 minmax.max = entry.max();
2359 }
2360 if (entry.has_data_type() && quantize_output) {
2361 array.final_data_type =
2362 ConvertIODataTypeToArrayDataType(entry.data_type());
2363 }
2364 if (entry.has_shape()) {
2365 array.clear_shape();
2366 // Make sure to create the shape even if there are no dims, to
2367 // correctly record 0-D shapes.
2368 array.mutable_shape();
2369 for (const auto& dim : entry.shape().dims()) {
2370 array.mutable_shape()->mutable_dims()->push_back(dim);
2371 }
2372 }
2373 if (entry.has_constant_float_value()) {
2374 CHECK(array.has_shape());
2375 if (array.data_type == ArrayDataType::kFloat) {
2376 auto& data = array.GetMutableBuffer<ArrayDataType::kFloat>().data;
2377 data.resize(RequiredBufferSizeForShape(array.shape()));
2378 for (float& f : data) {
2379 f = entry.constant_float_value();
2380 }
2381 }
2382 }
2383 }
2384 }
2385}
2386
2387void UndoWeightsShuffling(Model* model) {
2388 for (const auto& op : model->operators) {

Callers 1

TransformWithStatusFunction · 0.85

Calls 14

ScanArrayNamesFunction · 0.85
has_shapeMethod · 0.80
clear_shapeMethod · 0.80
mutable_dimsMethod · 0.80
minMethod · 0.45
maxMethod · 0.45
data_typeMethod · 0.45
mutable_shapeMethod · 0.45
dimsMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected