// // Copyright © 2017-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #include "ReshapeLayer.hpp" #include "LayerCloneBase.hpp" #include #include #include #include namespace armnn { ReshapeLayer::ReshapeLayer(const ReshapeDescriptor& param, const char* name) : LayerWithParameters(1, 1, LayerType::Reshape, param, name) { } std::unique_ptr ReshapeLayer::CreateWorkload(const IWorkloadFactory& factory) const { ReshapeQueueDescriptor descriptor; SetAdditionalInfo(descriptor); return factory.CreateWorkload(LayerType::Reshape, descriptor, PrepInfoAndDesc(descriptor)); } ReshapeLayer* ReshapeLayer::Clone(Graph& graph) const { return CloneBase(graph, m_Param, GetName()); } std::vector ReshapeLayer::InferOutputShapes(const std::vector& inputShapes) const { IgnoreUnused(inputShapes); return std::vector({ m_Param.m_TargetShape }); } void ReshapeLayer::ValidateTensorShapesFromInputs() { VerifyLayerConnections(1, CHECK_LOCATION()); const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape(); VerifyShapeInferenceType(outputShape, m_ShapeInferenceMethod); auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetTensorInfo().GetShape() }); ARMNN_ASSERT(inferredShapes.size() == 1); ARMNN_ASSERT(inferredShapes[0].GetDimensionality() == Dimensionality::Specified); ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "ReshapeLayer"); } void ReshapeLayer::ExecuteStrategy(IStrategy& strategy) const { strategy.ExecuteStrategy(this, GetParameters(), {}, GetName()); } } // namespace armnn