blob: 1aed59b78186b10bf6972281ecaf53703dc9a4a5 [file] [log] [blame]
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "ActivationLayer.hpp"
#include "LayerCloneBase.hpp"
#include <armnn/TypesUtils.hpp>
#include <backendsCommon/WorkloadData.hpp>
#include <backendsCommon/WorkloadFactory.hpp>
namespace armnn
{
ActivationLayer::ActivationLayer(const ActivationDescriptor& param, const char* name)
: LayerWithParameters(1, 1, LayerType::Activation, param, name)
{
}
std::unique_ptr<IWorkload> ActivationLayer::CreateWorkload(const IWorkloadFactory& factory) const
{
ActivationQueueDescriptor descriptor;
return factory.CreateActivation(descriptor, PrepInfoAndDesc(descriptor));
}
ActivationLayer* ActivationLayer::Clone(Graph& graph) const
{
return CloneBase<ActivationLayer>(graph, m_Param, GetName());
}
void ActivationLayer::ValidateTensorShapesFromInputs(ShapeInferenceMethod shapeInferenceMethod)
{
IgnoreUnused(shapeInferenceMethod);
VerifyLayerConnections(1, CHECK_LOCATION());
auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
ARMNN_ASSERT(inferredShapes.size() == 1);
ConditionalThrowIfNotEqual<LayerValidationException>(
"ActivationLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
GetOutputSlot(0).GetTensorInfo().GetShape(),
inferredShapes[0]);
}
void ActivationLayer::Accept(ILayerVisitor& visitor) const
{
visitor.VisitActivationLayer(this, GetParameters(), GetName());
}
} // namespace armnn