22 for (
auto&& layer : layers)
24 for (
auto&& it = layer->BeginInputSlots(); it != layer->EndInputSlots(); ++it)
26 result.push_back(&(*it));
38 for (
auto&& layer : layers)
40 for (
auto&& it = layer->BeginOutputSlots(); it != layer->EndOutputSlots(); ++it)
42 result.push_back(&(*it));
48 bool checkDataTypeInputandOutput(
const Layer& layer)
50 auto inputInfo = layer.GetInputSlot(0).GetConnection()->GetTensorInfo();
51 auto outputInfo = layer.GetOutputSlot(0).GetTensorInfo();
52 bool sameDataType = (inputInfo.GetDataType() == outputInfo.GetDataType());
59 bool sameScale = (inputInfo.GetQuantizationScale() == outputInfo.GetQuantizationScale());
60 bool sameOffset = (inputInfo.GetQuantizationOffset() == outputInfo.GetQuantizationOffset());
62 return (sameScale && sameOffset);
79 std::vector<Layer*> untouchedVector;
80 for (
const auto& pair : untouched)
82 Layer* layer = pair.second;
90 template<
typename LayerType>
99 replacementLayer->SetAdditionalInfoForObject(std::make_shared<ActivationDescriptor>(activationDesc));
103 {baseLayer, activationLayer});
106 optimizationViews.
AddSubstitution({substitutionSubgraph, replacementSubgraph});
107 return replacementLayer;
110 template<
typename LayerType>
120 replacementLayer->SetAdditionalInfoForObject(std::make_shared<ActivationDescriptor>(activationDesc));
124 {baseLayer, activationLayer});
127 optimizationViews.
AddSubstitution({substitutionSubgraph, replacementSubgraph});
128 return replacementLayer;
131 template<
typename LayerType>
144 replacementLayer->m_Weight = std::move(baseLayer->m_Weight);
145 replacementLayer->m_Bias = std::move(baseLayer->m_Bias);
147 return replacementLayer;
constexpr bool IsQuantizedType()
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
void ReportUntouchedLayers(OptimizationViews &optimizationViews, std::map< LayerGuid, Layer *> untouched)
std::vector< OutputSlot * > OutputSlots
void AddSubstitution(SubstitutionPair &&substitution)
This layer represents an activation operation with the specified activation function.
Copyright (c) 2021 ARM Limited and Contributors.
LayerType * FuseLayerWithParameters(OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
The SubgraphView class represents a subgraph of a Graph.
LayerType * FuseLayerWithoutParameters(OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
SubgraphView::InputSlots CreateInputsFrom(const std::vector< Layer *> &layers)
An ActivationDescriptor for the ActivationLayer.
void AddUntouchedSubgraph(SubgraphView &&subgraph)
std::vector< InputSlot * > InputSlots
SubgraphView::OutputSlots CreateOutputsFrom(const std::vector< Layer *> &layers)
LayerType * FuseLayerWithWeightsAndBiases(OptimizationViews &optimizationViews, LayerType *baseLayer, ActivationLayer *activationLayer, ActivationDescriptor &activationDesc, std::string name)
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...