19 TEST_CASE(
"ConvertConstantsFloatToHalfTest")
26 unsigned int dims[] = { 4, 1, 1, 1 };
27 std::vector<float> floatWeights{ 1.0f, 2.0f, 3.0f, 4.0f };
35 fc->
m_Weight = std::make_unique<armnn::ScopedTensorHandle>(weights);
36 fc->GetOutputSlot().SetTensorInfo(info);
42 fc->GetOutputSlot().Connect(output->GetInputSlot(0));
54 const Half* data = fc->m_Weight->GetConstTensor<
Half>();
55 CHECK(data[0] ==
Half(1.0f));
56 CHECK(data[1] ==
Half(2.0f));
57 CHECK(data[2] ==
Half(3.0f));
58 CHECK(data[3] ==
Half(4.0f));
62 TEST_CASE(
"ConvertConstantsFloatToHalfTest_constant")
73 desc.m_ConstantWeights =
true;
77 float expectedWeightsData[] = { 1.0f, 2.0f, 3.0f, 4.0f };
78 float expectedBiasesData[] = { 2.0f, 2.0f };
88 weights->m_LayerOutput = std::make_unique<armnn::ScopedTensorHandle>(weightsTensor);
89 biases->
m_LayerOutput = std::make_unique<armnn::ScopedTensorHandle>(biasesTensor);
91 input->GetOutputSlot().SetTensorInfo(inputInfo);
94 fcLayer->GetOutputSlot().SetTensorInfo(outputInfo);
97 input->GetOutputSlot(0).Connect(fcLayer->GetInputSlot(0));
100 fcLayer->GetOutputSlot(0).Connect(output->
GetInputSlot(0));
112 const Half* data = weights->m_LayerOutput->GetConstTensor<
Half>();
113 CHECK(data[0] ==
Half(1.0f));
114 CHECK(data[1] ==
Half(2.0f));
115 CHECK(data[2] ==
Half(3.0f));
116 CHECK(data[3] ==
Half(4.0f));
120 CHECK(biasData[0] ==
Half(2.0f));
121 CHECK(biasData[1] ==
Half(2.0f));
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).
ConvertConstants< Float32ToFloat16, IsFloat16Layer > ConvertConstantsFloatToHalf
This layer represents a fully connected operation.
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store Weight values.
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
DataType GetDataType() const
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.