2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
5 #include "ReshapeLayer.hpp"
7 #include "LayerCloneBase.hpp"
9 #include <armnn/TypesUtils.hpp>
10 #include <backends/WorkloadData.hpp>
11 #include <backends/WorkloadFactory.hpp>
16 ReshapeLayer::ReshapeLayer(const ReshapeDescriptor& param, const char* name)
17 : LayerWithParameters(1, 1, LayerType::Reshape, param, name)
21 std::unique_ptr<IWorkload> ReshapeLayer::CreateWorkload(const Graph& graph,
22 const IWorkloadFactory& factory) const
24 ReshapeQueueDescriptor descriptor;
25 return factory.CreateReshape(descriptor, PrepInfoAndDesc(descriptor, graph));
28 ReshapeLayer* ReshapeLayer::Clone(Graph& graph) const
30 return CloneBase<ReshapeLayer>(graph, m_Param, GetName());
33 std::vector<TensorShape> ReshapeLayer::InferOutputShapes(const std::vector<TensorShape>& inputShapes) const
35 return std::vector<TensorShape>({ m_Param.m_TargetShape });
38 void ReshapeLayer::ValidateTensorShapesFromInputs()
40 VerifyLayerConnections(1, CHECK_LOCATION());
42 auto inferredShapes = InferOutputShapes({ });
44 BOOST_ASSERT(inferredShapes.size() == 1);
46 ConditionalThrowIfNotEqual<LayerValidationException>(
47 "ReshapeLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
48 GetOutputSlot(0).GetTensorInfo().GetShape(),