2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
5 #include "ConvertFp32ToFp16Layer.hpp"
7 #include "LayerCloneBase.hpp"
9 #include <armnn/TypesUtils.hpp>
10 #include <backendsCommon/WorkloadData.hpp>
11 #include <backendsCommon/WorkloadFactory.hpp>
16 ConvertFp32ToFp16Layer::ConvertFp32ToFp16Layer(const char* name)
17 : Layer(1, 1, LayerType::ConvertFp32ToFp16, name)
21 std::unique_ptr<IWorkload> ConvertFp32ToFp16Layer::CreateWorkload(const Graph& graph,
22 const IWorkloadFactory& factory) const
24 ConvertFp32ToFp16QueueDescriptor descriptor;
25 return factory.CreateConvertFp32ToFp16(descriptor, PrepInfoAndDesc(descriptor, graph));
28 ConvertFp32ToFp16Layer* ConvertFp32ToFp16Layer::Clone(Graph& graph) const
30 return CloneBase<ConvertFp32ToFp16Layer>(graph, GetName());
33 void ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs()
35 VerifyLayerConnections(1, CHECK_LOCATION());
37 auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
39 BOOST_ASSERT(inferredShapes.size() == 1);
41 ConditionalThrowIfNotEqual<LayerValidationException>(
42 "ConvertFp32ToFp16Layer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
43 GetOutputSlot(0).GetTensorInfo().GetShape(),