30 auto layer = CloneBase<PreluLayer>(graph,
GetName());
32 return std::move(layer);
51 unsigned int outputDimensions = std::max(inputShapeDimensions, alphaShapeDimensions);
57 unsigned int outputShapeIndex = outputDimensions - 1;
60 while (inputShapeIndex >= 0 && alphaShapeIndex >= 0)
62 unsigned int inputDimension = inputShape[
boost::numeric_cast<
unsigned int>(inputShapeIndex)];
63 unsigned int alphaDimension = alphaShape[
boost::numeric_cast<
unsigned int>(alphaShapeIndex)];
66 ARMNN_ASSERT_MSG(inputDimension == alphaDimension || inputDimension == 1 || alphaDimension == 1,
67 "PreluLayer: Dimensions should either match or one should be of size 1");
69 outputShape[outputShapeIndex] = std::max(inputDimension, alphaDimension);
77 while (inputShapeIndex >= 0)
79 outputShape[outputShapeIndex] = inputShape[
boost::numeric_cast<
unsigned int>(inputShapeIndex)];
86 while (alphaShapeIndex >= 0)
88 outputShape[outputShapeIndex] = alphaShape[
boost::numeric_cast<
unsigned int>(alphaShapeIndex)];
94 return { outputShape };
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the PReLU type.
const TensorShape & GetShape() const
PreluLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
virtual void VisitPreluLayer(const IConnectableLayer *layer, const char *name=nullptr)=0
Function that a PReLU activation layer should call back to when its Accept(ILayerVisitor&) function i...
void Accept(ILayerVisitor &visitor) const override
Apply a visitor to this layer.
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
Copyright (c) 2020 ARM Limited.
PreluLayer(const char *name)
Constructor to create a PreluLayer.
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
#define ARMNN_ASSERT_MSG(COND, MSG)
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
By default returns inputShapes if the number of inputs are equal to number of outputs, otherwise infers the output shapes from given input shapes and layer properties.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
#define ARMNN_ASSERT(COND)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
virtual const TensorInfo & GetTensorInfo() const =0
const char * GetName() const override
Returns the name of the layer.
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of PreluLayer.
const TensorInfo & GetTensorInfo() const override
ShapeInferenceMethod m_ShapeInferenceMethod
virtual std::unique_ptr< IWorkload > CreatePrelu(const PreluQueueDescriptor &descriptor, const WorkloadInfo &info) const