25 BOOST_ASSERT_MSG(
m_Weight !=
nullptr,
"FullyConnectedLayer: Weights data should not be null.");
32 BOOST_ASSERT_MSG(
m_Bias !=
nullptr,
"FullyConnectedLayer: Bias data should not be null.");
40 auto layer = CloneBase<FullyConnectedLayer>(graph,
m_Param,
GetName());
42 layer->
m_Weight =
m_Weight ? std::make_unique<ScopedCpuTensorHandle>(*m_Weight) :
nullptr;
43 if (layer->m_Param.m_BiasEnabled)
45 layer->m_Bias =
m_Bias ? std::make_unique<ScopedCpuTensorHandle>(*m_Bias) :
nullptr;
48 return std::move(layer);
53 BOOST_ASSERT(inputShapes.size() == 2);
58 unsigned int batches = inputShape[0];
61 return std::vector<TensorShape>({
TensorShape({batches, weightShape[dimIdx]})});
69 BOOST_ASSERT_MSG(
m_Weight !=
nullptr,
"FullyConnectedLayer: Weights data should not be null.");
73 m_Weight->GetTensorInfo().GetShape() });
75 BOOST_ASSERT(inferredShapes.size() == 1);
77 ConditionalThrowIfNotEqual<LayerValidationException>(
78 "FullyConnectedLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
virtual void VisitFullyConnectedLayer(const IConnectableLayer *layer, const FullyConnectedDescriptor &fullyConnectedDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)=0
const char * GetName() const override
ConstantTensors GetConstantTensorsByRef() override
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
virtual const TensorInfo & GetTensorInfo() const =0
const ConstCpuTensorHandle * m_Weight
std::unique_ptr< ScopedCpuTensorHandle > m_Bias
A unique pointer to store Bias values.
const ConstCpuTensorHandle * m_Bias
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
bool m_BiasEnabled
Enable/disable bias.
FullyConnectedLayer * Clone(Graph &graph) const override
This layer represents a fully connected operation.
std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >> ConstantTensors
const FullyConnectedDescriptor & GetParameters() const
void ValidateTensorShapesFromInputs() override
FullyConnectedDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
void FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, Decoder< float > &rWeightDecoder, Decoder< float > &rBiasDecoder, const bool biasEnabled, const unsigned int K, const bool transposeWeights)
Performs a matrix multiplication and optionally adds a bias.
A FullyConnectedDescriptor for the FullyConnectedLayer.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
bool m_TransposeWeightMatrix
Enable/disable transpose weight matrix.
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
virtual std::unique_ptr< IWorkload > CreateFullyConnected(const FullyConnectedQueueDescriptor &descriptor, const WorkloadInfo &info) const
FullyConnectedLayer(const FullyConnectedDescriptor ¶m, const char *name)
const TensorShape & GetShape() const
const TensorInfo & GetTensorInfo() const override
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
void Accept(ILayerVisitor &visitor) const override
const InputSlot & GetInputSlot(unsigned int index) const override