MCPcopy Create free account
hub / github.com/ARM-software/armnn / ToTensorInfo

Function ToTensorInfo

src/armnnTfLiteParser/TfLiteParser.cpp:452–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450}
451
452armnn::TensorInfo ToTensorInfo(TfLiteParserImpl::TensorRawPtr tensorPtr,
453 const std::vector<unsigned int>& shape,
454 const bool outputTensor = false)
455{
456 armnn::DataType type;
457 CHECK_TENSOR_PTR(tensorPtr);
458
459 switch (tensorPtr->type)
460 {
461 case tflite::TensorType_UINT8:
462 type = armnn::DataType::QAsymmU8;
463 break;
464 case tflite::TensorType_FLOAT32:
465 type = armnn::DataType::Float32;
466 break;
467 case tflite::TensorType_FLOAT16:
468 type = armnn::DataType::Float16;
469 break;
470 case tflite::TensorType_INT8:
471 if (tensorPtr->quantization->zero_point.size() == 1)
472 {
473 // Per-tensor
474 type = armnn::DataType::QAsymmS8;
475 }
476 else
477 {
478 // Per-channel
479 type = armnn::DataType::QSymmS8;
480 }
481 break;
482 case tflite::TensorType_INT16:
483 type = armnn::DataType::QSymmS16;
484 break;
485 case tflite::TensorType_INT32:
486 type = armnn::DataType::Signed32;
487 break;
488 case tflite::TensorType_INT64:
489 type = armnn::DataType::Signed64;
490 break;
491 case tflite::TensorType_BOOL:
492 type = armnn::DataType::Boolean;
493 break;
494 default:
495 {
496 CheckLocation location = CHECK_LOCATION();
497 throw ParseException(
498 fmt::format("Unsupported data type {} = {} for tensor: {}. {}",
499 tensorPtr->type,
500 tflite::EnumNameTensorType(tensorPtr->type),
501 tensorPtr->name,
502 location.AsString()));
503 }
504 }
505 TensorShape tensorShape;
506
507 std::vector<unsigned int> safeShape = shape;
508 if (shape.size() == 0)
509 {

Callers 15

InputTensorInfoMethod · 0.70
ParseExpandDimsMethod · 0.70
ParseBroadcastToMethod · 0.70
ParseScatterNdMethod · 0.70
ParseMeanMethod · 0.70
ParseReshapeMethod · 0.70
ParseReverseV2Method · 0.70
ParseTileMethod · 0.70

Calls 12

ParseExceptionClass · 0.85
formatEnum · 0.85
copyFunction · 0.85
AsUnsignedVectorFunction · 0.85
push_backMethod · 0.80
TensorShapeClass · 0.50
sizeMethod · 0.45
AsStringMethod · 0.45
dataMethod · 0.45
getMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected