30 auto layer = CloneBase<PreluLayer>(graph,
GetName());
32 return std::move(layer);
37 BOOST_ASSERT(inputShapes.size() == 2);
45 BOOST_ASSERT(inputShapeDimensions > 0);
46 BOOST_ASSERT(alphaShapeDimensions > 0);
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 BOOST_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 };
107 BOOST_ASSERT(inferredShapes.size() == 1);
109 ConditionalThrowIfNotEqual<LayerValidationException>(
110 "PreluLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
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.
Copyright (c) 2020 ARM Limited.
PreluLayer(const char *name)
Constructor to create a PreluLayer.
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.
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.
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
unsigned int GetNumDimensions() const
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
virtual std::unique_ptr< IWorkload > CreatePrelu(const PreluQueueDescriptor &descriptor, const WorkloadInfo &info) const