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

Method ParseLocalResponseNormalization

src/armnnTfLiteParser/TfLiteParser.cpp:5098–5145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5096}
5097
5098void TfLiteParserImpl::ParseLocalResponseNormalization(size_t subgraphIndex, size_t operatorIndex)
5099{
5100 CHECK_MODEL(m_Model, subgraphIndex, operatorIndex);
5101
5102 auto inputs = GetInputs(m_Model, subgraphIndex, operatorIndex);
5103 CHECK_VALID_SIZE(inputs.size(), 1);
5104
5105 auto outputs = GetOutputs(m_Model, subgraphIndex, operatorIndex);
5106 CHECK_VALID_SIZE(outputs.size(), 1);
5107
5108 auto layerName = fmt::format("LRN:{}:{}", subgraphIndex, operatorIndex);
5109 std::string layerNameFormatted = fmt::format(layerName, subgraphIndex, operatorIndex);
5110
5111 armnn::TensorInfo inputTensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 0);
5112
5113 const auto& operatorPtr = m_Model->subgraphs[subgraphIndex]->operators[operatorIndex];
5114 const auto* options = operatorPtr->builtin_options.AsLocalResponseNormalizationOptions();
5115
5116 armnn::NormalizationDescriptor descriptor;
5117 descriptor.m_DataLayout = armnn::DataLayout::NHWC;
5118 descriptor.m_NormChannelType = armnn::NormalizationAlgorithmChannel::Across;
5119 descriptor.m_NormMethodType = armnn::NormalizationAlgorithmMethod::LocalBrightness;
5120 descriptor.m_NormSize = static_cast<uint32_t>(options->radius);
5121 descriptor.m_K = options->bias;
5122 descriptor.m_Alpha = options->alpha;
5123 descriptor.m_Beta = options->beta;
5124
5125 // ArmNN expects normSize to be the full size of the normalization
5126 // window rather than the radius as in TfLite.
5127 descriptor.m_NormSize = 1 + (2 * descriptor.m_NormSize);
5128
5129 IConnectableLayer* layer = m_Network->AddNormalizationLayer(descriptor, layerNameFormatted.c_str());
5130
5131 if (!layer)
5132 {
5133 throw NullPointerException(fmt::format("Layer {} pointer is null {}",
5134 operatorIndex, CHECK_LOCATION().AsString()));
5135 }
5136
5137 TensorInfo outputTensorInfo = OutputTensorInfoFromInputs(subgraphIndex, operatorIndex, layer, 0, {0});
5138 layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
5139
5140 auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex));
5141 RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0]});
5142
5143 auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex));
5144 RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]});
5145}
5146
5147void TfLiteParserImpl::ParseAbs(size_t subgraphIndex, size_t operatorIndex)
5148{

Callers

nothing calls this directly

Calls 9

formatEnum · 0.85
AsUnsignedVectorFunction · 0.85
AddNormalizationLayerMethod · 0.80
GetOutputSlotMethod · 0.80
sizeMethod · 0.45
c_strMethod · 0.45
AsStringMethod · 0.45
SetTensorInfoMethod · 0.45

Tested by

no test coverage detected