IVGCVSW-1946: Remove armnn/src from the include paths
[platform/upstream/armnn.git] / src / armnn / layers / PermuteLayer.cpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "PermuteLayer.hpp"
6
7 #include "LayerCloneBase.hpp"
8
9 #include <armnn/TypesUtils.hpp>
10 #include <backendsCommon/WorkloadData.hpp>
11 #include <backendsCommon/WorkloadFactory.hpp>
12
13 #include <Permute.hpp>
14
15 namespace armnn
16 {
17
18 PermuteLayer::PermuteLayer(const PermuteDescriptor& param, const char* name)
19     : LayerWithParameters(1, 1, LayerType::Permute, param, name)
20 {
21 }
22
23 std::unique_ptr<IWorkload> PermuteLayer::CreateWorkload(const Graph& graph, const IWorkloadFactory& factory) const
24 {
25     PermuteQueueDescriptor descriptor;
26     return factory.CreatePermute(descriptor, PrepInfoAndDesc(descriptor, graph));
27 }
28
29 PermuteLayer* PermuteLayer::Clone(Graph& graph) const
30 {
31     return CloneBase<PermuteLayer>(graph, m_Param, GetName());
32 }
33
34 std::vector<TensorShape> PermuteLayer::InferOutputShapes(const std::vector<TensorShape>& inputShapes) const
35 {
36     BOOST_ASSERT(inputShapes.size() == 1);
37     const TensorShape& inShape = inputShapes[0];
38     return std::vector<TensorShape> ({armnnUtils::Permuted(inShape, m_Param.m_DimMappings)});
39 }
40
41 void PermuteLayer::ValidateTensorShapesFromInputs()
42 {
43     VerifyLayerConnections(1, CHECK_LOCATION());
44
45     auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
46
47     BOOST_ASSERT(inferredShapes.size() == 1);
48
49     ConditionalThrowIfNotEqual<LayerValidationException>(
50         "PermuteLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
51         GetOutputSlot(0).GetTensorInfo().GetShape(),
52         inferredShapes[0]);
53 }
54
55 } // namespace armnn