2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
5 #include "PermuteLayer.hpp"
7 #include "LayerCloneBase.hpp"
9 #include <armnn/TypesUtils.hpp>
10 #include <backends/WorkloadData.hpp>
11 #include <backends/WorkloadFactory.hpp>
13 #include <Permute.hpp>
18 PermuteLayer::PermuteLayer(const PermuteDescriptor& param, const char* name)
19 : LayerWithParameters(1, 1, LayerType::Permute, param, name)
23 std::unique_ptr<IWorkload> PermuteLayer::CreateWorkload(const Graph& graph, const IWorkloadFactory& factory) const
25 PermuteQueueDescriptor descriptor;
26 return factory.CreatePermute(descriptor, PrepInfoAndDesc(descriptor, graph));
29 PermuteLayer* PermuteLayer::Clone(Graph& graph) const
31 return CloneBase<PermuteLayer>(graph, m_Param, GetName());
34 std::vector<TensorShape> PermuteLayer::InferOutputShapes(const std::vector<TensorShape>& inputShapes) const
36 BOOST_ASSERT(inputShapes.size() == 1);
37 const TensorShape& inShape = inputShapes[0];
38 return std::vector<TensorShape> ({armnnUtils::Permuted(inShape, m_Param.m_DimMappings)});
41 void PermuteLayer::ValidateTensorShapesFromInputs()
43 VerifyLayerConnections(1, CHECK_LOCATION());
45 auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
47 BOOST_ASSERT(inferredShapes.size() == 1);
49 ConditionalThrowIfNotEqual<LayerValidationException>(
50 "PermuteLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
51 GetOutputSlot(0).GetTensorInfo().GetShape(),