24 BOOST_ASSERT_MSG(
m_Mean !=
nullptr,
"BatchNormalizationLayer: Mean data should not be null.");
25 BOOST_ASSERT_MSG(
m_Variance !=
nullptr,
"BatchNormalizationLayer: Variance data should not be null.");
26 BOOST_ASSERT_MSG(
m_Beta !=
nullptr,
"BatchNormalizationLayer: Beta data should not be null.");
27 BOOST_ASSERT_MSG(
m_Gamma !=
nullptr,
"BatchNormalizationLayer: Gamma data should not be null.");
41 auto layer = CloneBase<BatchNormalizationLayer>(graph,
m_Param,
GetName());
43 layer->
m_Mean =
m_Mean ? std::make_unique<ScopedCpuTensorHandle>(*m_Mean) :
nullptr;
44 layer->m_Variance =
m_Variance ? std::make_unique<ScopedCpuTensorHandle>(*m_Variance) :
nullptr;
45 layer->m_Beta =
m_Beta ? std::make_unique<ScopedCpuTensorHandle>(*m_Beta) :
nullptr;
46 layer->m_Gamma =
m_Gamma ? std::make_unique<ScopedCpuTensorHandle>(*m_Gamma) :
nullptr;
48 return std::move(layer);
57 BOOST_ASSERT(inferredShapes.size() == 1);
59 ConditionalThrowIfNotEqual<LayerValidationException>(
60 "BatchNormalizationLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
void ValidateTensorShapesFromInputs() override
const char * GetName() const override
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
virtual const TensorInfo & GetTensorInfo() const =0
This layer represents a batch normalization operation.
std::unique_ptr< ScopedCpuTensorHandle > m_Gamma
A unique pointer to store Gamma values.
const ConstCpuTensorHandle * m_Mean
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
virtual std::unique_ptr< IWorkload > CreateBatchNormalization(const BatchNormalizationQueueDescriptor &descriptor, const WorkloadInfo &info) const
const ConstCpuTensorHandle * m_Variance
std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >> ConstantTensors
const BatchNormalizationDescriptor & GetParameters() const
std::unique_ptr< ScopedCpuTensorHandle > m_Variance
A unique pointer to store Variance values.
virtual void VisitBatchNormalizationLayer(const IConnectableLayer *layer, const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr)=0
BatchNormalizationDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
BatchNormalizationLayer * Clone(Graph &graph) const override
const ConstCpuTensorHandle * m_Gamma
void Accept(ILayerVisitor &visitor) const override
std::unique_ptr< ScopedCpuTensorHandle > m_Mean
A unique pointer to store Mean values.
std::unique_ptr< ScopedCpuTensorHandle > m_Beta
A unique pointer to store Beta values.
BatchNormalizationLayer(const BatchNormalizationDescriptor ¶m, const char *name)
ConstantTensors GetConstantTensorsByRef() override
const TensorShape & GetShape() const
const TensorInfo & GetTensorInfo() const override
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
const ConstCpuTensorHandle * m_Beta
const InputSlot & GetInputSlot(unsigned int index) const override