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

Method ParseSpaceToDepth

src/armnnTfLiteParser/TfLiteParser.cpp:2437–2477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2435}
2436
2437void TfLiteParserImpl::ParseSpaceToDepth(size_t subgraphIndex, size_t operatorIndex)
2438{
2439 CHECK_MODEL(m_Model, subgraphIndex, operatorIndex);
2440
2441 TfLiteParserImpl::TensorRawPtrVector inputs = GetInputs(m_Model, subgraphIndex, operatorIndex);
2442 CHECK_VALID_SIZE(inputs.size(), 1);
2443 TfLiteParserImpl::TensorRawPtrVector outputs = GetOutputs(m_Model, subgraphIndex, operatorIndex);
2444 CHECK_VALID_SIZE(outputs.size(), 1);
2445
2446 armnn::SpaceToDepthDescriptor descriptor;
2447
2448 const auto& operatorPtr = m_Model->subgraphs[subgraphIndex]->operators[operatorIndex];
2449 const auto* options = operatorPtr->builtin_options.AsSpaceToDepthOptions();
2450 auto blockSize = options->block_size;
2451 if (blockSize < 2)
2452 {
2453 throw ParseException(
2454 fmt::format("Operation has invalid block size: {} Block size should be >= 2 {}",
2455 blockSize,
2456 CHECK_LOCATION().AsString()));
2457 }
2458 descriptor.m_BlockSize = armnn::numeric_cast<uint32_t>(blockSize);
2459
2460 auto layerName = fmt::format("SpaceToDepth:{}:{}", subgraphIndex, operatorIndex);
2461 IConnectableLayer* layer = m_Network->AddSpaceToDepthLayer(descriptor, layerName.c_str());
2462
2463 if (!layer)
2464 {
2465 throw NullPointerException(fmt::format("Layer {} pointer is null {}",
2466 operatorIndex, CHECK_LOCATION().AsString()));
2467 }
2468
2469 TensorInfo outputTensorInfo = OutputTensorInfoFromInputs(subgraphIndex, operatorIndex, layer, 0, {0});
2470 layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
2471
2472 auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex));
2473 RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0]});
2474
2475 auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex));
2476 RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]});
2477}
2478
2479armnn::TensorInfo TfLiteParserImpl::OutputShapeOfSqueeze(std::vector<uint32_t> squeezeDims,
2480 const armnn::TensorInfo& inputTensorInfo)

Callers

nothing calls this directly

Calls 10

ParseExceptionClass · 0.85
formatEnum · 0.85
AsUnsignedVectorFunction · 0.85
AddSpaceToDepthLayerMethod · 0.80
GetOutputSlotMethod · 0.80
sizeMethod · 0.45
AsStringMethod · 0.45
c_strMethod · 0.45
SetTensorInfoMethod · 0.45

Tested by

no test coverage detected