6 #include "../TestUtils.hpp" 10 #include <doctest/doctest.h> 16 TEST_CASE(
"RedirectMembersToConstantInputsFullyConnectedTest")
26 CHECK(weightsInfo.IsConstant());
27 CHECK(biasesInfo.IsConstant());
31 desc.m_ConstantWeights =
false;
40 float expectedWeightsData[] = { 1.0f, 1.0f, 1.0f, 1.0f };
41 float expectedBiasesData[] = { 2.0f, 2.0f };
46 weights->m_LayerOutput = std::make_unique<armnn::ScopedTensorHandle>(weightsTensor);
47 biases->
m_LayerOutput = std::make_unique<armnn::ScopedTensorHandle>(biasesTensor);
49 input->GetOutputSlot().SetTensorInfo(inputInfo);
55 input->GetOutputSlot(0).Connect(fcLayer->
GetInputSlot(0));
61 CHECK(fcLayer->m_Weight ==
nullptr);
62 CHECK(fcLayer->m_Bias ==
nullptr);
68 CHECK(fcLayer->m_Weight !=
nullptr);
69 CHECK(fcLayer->m_Bias !=
nullptr);
70 CHECK(fcLayer->m_Weight->GetTensorInfo().GetShape() == weightsInfo.GetShape());
71 CHECK(fcLayer->m_Bias->GetTensorInfo().GetShape() == biasesInfo.GetShape());
74 const float* weightsData = fcLayer->m_Weight->GetConstTensor<
float>();
75 CHECK(weightsData[0] == expectedWeightsData[0]);
76 CHECK(weightsData[1] == expectedWeightsData[1]);
77 CHECK(weightsData[2] == expectedWeightsData[2]);
78 CHECK(weightsData[3] == expectedWeightsData[3]);
80 const float* biasesData = fcLayer->m_Bias->GetConstTensor<
float>();
81 CHECK(biasesData[0] == expectedBiasesData[0]);
82 CHECK(biasesData[1] == expectedBiasesData[1]);
A layer that the constant data can be bound to.
Optimizer::Optimizations MakeOptimizations(Args &&... args)
std::shared_ptr< ConstTensorHandle > m_LayerOutput
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
int Connect(InputSlot &destination)
static void Pass(Graph &graph, const Optimizations &optimizations)
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
A layer user-provided data can be bound to (e.g. inputs, outputs).
This layer represents a fully connected operation.
A FullyConnectedDescriptor for the FullyConnectedLayer.
bool m_BiasEnabled
Enable/disable bias.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
void SetTensorInfo(const TensorInfo &tensorInfo) override
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
OptimizeForType< FullyConnectedLayer, RedirectMembersToConstantInputsImpl > RedirectMembersToConstantInputs