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);
55 int inputShapeIndex = boost::numeric_cast<
int>(inputShapeDimensions) - 1;
56 int alphaShapeIndex = boost::numeric_cast<
int>(alphaShapeDimensions) - 1;
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.",
PreluLayer(const char *name)
const char * GetName() const override
unsigned int GetNumDimensions() const
virtual const TensorInfo & GetTensorInfo() const =0
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
void ValidateTensorShapesFromInputs() override
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
virtual void VisitPreluLayer(const IConnectableLayer *layer, const char *name=nullptr)=0
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
virtual std::unique_ptr< IWorkload > CreatePrelu(const PreluQueueDescriptor &descriptor, const WorkloadInfo &info) const
const TensorShape & GetShape() const
const TensorInfo & GetTensorInfo() const override
void Accept(ILayerVisitor &visitor) const override
PreluLayer * Clone(Graph &graph) const override
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
const InputSlot & GetInputSlot(unsigned int index) const override