Release 18.08
[platform/upstream/armnn.git] / src / armnn / layers / ConvertFp16ToFp32Layer.cpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
4 //
5
6 #include "ConvertFp16ToFp32Layer.hpp"
7 #include "LayerCloneBase.hpp"
8
9 #include <armnn/TypesUtils.hpp>
10
11 #include <backends/WorkloadData.hpp>
12 #include <backends/WorkloadFactory.hpp>
13
14 namespace armnn
15 {
16
17 ConvertFp16ToFp32Layer::ConvertFp16ToFp32Layer(const char* name)
18     : Layer(1, 1, LayerType::ConvertFp16ToFp32, name)
19 {
20 }
21
22 std::unique_ptr<IWorkload> ConvertFp16ToFp32Layer::CreateWorkload(const Graph& graph,
23     const IWorkloadFactory& factory) const
24 {
25     ConvertFp16ToFp32QueueDescriptor descriptor;
26     return factory.CreateConvertFp16ToFp32(descriptor, PrepInfoAndDesc(descriptor, graph));
27 }
28
29 ConvertFp16ToFp32Layer* ConvertFp16ToFp32Layer::Clone(Graph& graph) const
30 {
31     return CloneBase<ConvertFp16ToFp32Layer>(graph, GetName());
32 }
33
34 void ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs()
35 {
36     VerifyLayerConnections(1, CHECK_LOCATION());
37
38     auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
39
40     BOOST_ASSERT(inferredShapes.size() == 1);
41
42     ConditionalThrowIfNotEqual<LayerValidationException>(
43         "ConvertFp16ToFp32Layer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
44         GetOutputSlot(0).GetTensorInfo().GetShape(),
45         inferredShapes[0]);
46 }
47
48 } // namespace armnn