diff options
Diffstat (limited to 'src/armnn/layers/CastLayer.cpp')
-rw-r--r-- | src/armnn/layers/CastLayer.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/armnn/layers/CastLayer.cpp b/src/armnn/layers/CastLayer.cpp new file mode 100644 index 0000000000..16dd9a3744 --- /dev/null +++ b/src/armnn/layers/CastLayer.cpp @@ -0,0 +1,55 @@ +// +// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// +#include "CastLayer.hpp" + +#include "LayerCloneBase.hpp" +#include <armnn/TypesUtils.hpp> + +#include <backendsCommon/WorkloadData.hpp> +#include <backendsCommon/WorkloadFactory.hpp> + +namespace armnn +{ + +CastLayer::CastLayer(const char* name) + : Layer(1, 1, LayerType::Cast, name) +{ +} + +std::unique_ptr<IWorkload> CastLayer::CreateWorkload(const IWorkloadFactory& factory) const +{ + CastQueueDescriptor descriptor; + SetAdditionalInfo(descriptor); + + return factory.CreateCast(descriptor, PrepInfoAndDesc(descriptor)); +} + +CastLayer* CastLayer::Clone(Graph& graph) const +{ + return CloneBase<CastLayer>(graph, GetName()); +} + +void CastLayer::ValidateTensorShapesFromInputs() +{ + VerifyLayerConnections(1, CHECK_LOCATION()); + + const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape(); + + VerifyShapeInferenceType(outputShape, m_ShapeInferenceMethod); + + auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() }); + + ARMNN_ASSERT(inferredShapes.size() == 1); + + ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "CastLayer"); +} + +void CastLayer::Accept(ILayerVisitor& visitor) const +{ + IgnoreUnused(visitor); + throw armnn::Exception("CastLayer VisitCastLayer is not implemented"); +} + +} // namespace armnn |