19 void UpdateOutputSlotToFp32(OutputSlot& outputSlot)
21 const TensorInfo& origTensorInfo = outputSlot.GetTensorInfo();
22 TensorInfo newTensorInfo(origTensorInfo);
24 outputSlot.SetTensorInfo(newTensorInfo);
27 void ChangeOutputFp16ToFp32(Layer& layer)
29 for (
auto&& outputSlot = layer.BeginOutputSlots(); outputSlot != layer.EndOutputSlots(); ++outputSlot)
33 UpdateOutputSlotToFp32(*outputSlot);
42 bool expectCorrectInputType)
44 std::vector<ConvertFp16ToFp32Layer*> convertLayers;
50 bool allowInsert =
true;
51 if (expectCorrectInputType)
54 OutputSlot* connectedOutputSlot = inputSlot->GetConnectedOutputSlot();
61 const std::string name =
62 std::string(
"convert_fp16_to_fp32-" + std::to_string(inputSlot->GetSlotIndex()) +
"-") +
72 convertLayers.emplace_back(convertLayer);
83 std::vector<ConvertFp32ToFp16Layer*> convertLayers;
84 convertLayers.reserve(numOutputSlots);
87 ChangeOutputFp16ToFp32(layer);
90 for (
unsigned int slotIndex = 0u; slotIndex < numOutputSlots; ++slotIndex)
95 const std::string name =
96 std::string(
"convert_fp32_to_fp16-" + std::to_string(slotIndex) +
"-") + layer.
GetName();
105 convertLayers.emplace_back(convertLayer);
109 return convertLayers;
114 std::vector<DebugLayer*> debugLayers;
118 uint32_t outputSlotIdx = 0;
121 const std::string debugName = std::string(
"DebugLayerAfter") + layer.
GetNameStr() +
"_" +
122 std::to_string(outputSlotIdx);
130 throw armnn::Exception(
"unable to set output tensor info for the debug layer.");
140 debugLayers.emplace_back(debugLayer);
This layer converts data type Float 16 to Float 32.
This layer converts data type Float 32 to Float 16.
This layer visualizes the data flowing through the network.
Base class for all ArmNN exceptions so that users can filter to just those.
LayerT * InsertNewLayer(InputSlot &insertBefore, Args &&... args)
Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itse...
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
void SetBackendId(const BackendId &id) override
Set the backend of the IConnectableLayer.
std::vector< OutputSlot >::iterator EndOutputSlots()
const char * GetName() const override
Returns the name of the layer.
std::vector< OutputSlot >::iterator BeginOutputSlots()
std::vector< InputSlot >::iterator EndInputSlots()
const std::string & GetNameStr() const
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
std::vector< InputSlot >::iterator BeginInputSlots()
void SetTensorInfo(const TensorInfo &tensorInfo) override
const TensorInfo & GetTensorInfo() const override
void SetDataType(DataType type)
DataType GetDataType() const
Copyright (c) 2021 ARM Limited and Contributors.
std::vector< DebugLayer * > InsertDebugLayerAfter(Graph &graph, Layer &layer, bool toFile)
std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter(Graph &graph, Layer &layer)
std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
@ CpuRef
CPU Execution: Reference C++ kernels.