// // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // #include "SwitchLayer.hpp" #include "LayerCloneBase.hpp" #include #include namespace armnn { SwitchLayer::SwitchLayer(const char* name) : Layer(2, 2, LayerType::Switch, name) {} std::unique_ptr SwitchLayer::CreateWorkload(const IWorkloadFactory& factory) const { SwitchQueueDescriptor descriptor; return factory.CreateSwitch(descriptor, PrepInfoAndDesc(descriptor)); } SwitchLayer* SwitchLayer::Clone(Graph& graph) const { return CloneBase(graph, GetName()); } void SwitchLayer::ValidateTensorShapesFromInputs(ShapeInferenceMethod shapeInferenceMethod) { IgnoreUnused(shapeInferenceMethod); VerifyLayerConnections(2, CHECK_LOCATION()); ARMNN_ASSERT_MSG(GetNumOutputSlots() == 2, "SwitchLayer: The layer should return 2 outputs."); // Assuming first input is the Input and second input is the Constant std::vector inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape(), GetInputSlot(1).GetConnection()->GetTensorInfo().GetShape() }); ARMNN_ASSERT(inferredShapes.size() == 2); ConditionalThrowIfNotEqual( "SwitchLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.", GetOutputSlot(0).GetTensorInfo().GetShape(), inferredShapes[0]); ConditionalThrowIfNotEqual( "SwitchLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.", GetOutputSlot(1).GetTensorInfo().GetShape(), inferredShapes[0]); } void SwitchLayer::Accept(ILayerVisitor& visitor) const { visitor.VisitSwitchLayer(this, GetName()); } } // namespace armnn