6 #include "../TestUtils.hpp" 11 #include <doctest/doctest.h> 13 using namespace armnn;
19 TEST_CASE(
"ConvertConstantsFloatToBFloatTest")
26 unsigned int dims[] = { 4, 2, 1, 1 };
27 std::vector<float> floatWeights{ 0.0f, -1.0f,
42 fc->
m_Weight = std::make_unique<armnn::ScopedTensorHandle>(weights);
43 fc->GetOutputSlot().SetTensorInfo(
info);
49 fc->GetOutputSlot().Connect(output->GetInputSlot(0));
64 CHECK(data[2] ==
BFloat16(3.796875f));
65 CHECK(data[3] ==
BFloat16(3.1072295E29f));
66 CHECK(data[4] ==
BFloat16(9.131327E-10f));
67 CHECK(data[5] ==
BFloat16(-3.796875f));
68 CHECK(data[6] ==
BFloat16(-3.1072295E29f));
69 CHECK(data[7] ==
BFloat16(-9.131327E-10f));
72 TEST_CASE(
"ConvertConstantsBFloatToFloatTest")
79 unsigned int dims[] = { 4, 2, 1, 1 };
80 std::vector<float> convWeightsData{ 0.f, -1.f,
88 std::vector<uint16_t> bfWeights(8);
98 fc->
m_Weight = std::make_unique<armnn::ScopedTensorHandle>(weights);
99 fc->GetOutputSlot().SetTensorInfo(
info);
105 fc->GetOutputSlot().Connect(output->GetInputSlot(0));
117 const float* data = fc->m_Weight->GetConstTensor<
float>();
118 CHECK(data[0] == 0.0f);
119 CHECK(data[1] == -1.0f);
120 CHECK(data[2] == 3.796875f);
121 CHECK(data[3] == 3.1072295E29f);
122 CHECK(data[4] == 9.131327E-10f);
123 CHECK(data[5] == -3.796875f);
124 CHECK(data[6] == -3.1072295E29f);
125 CHECK(data[7] == -9.131327E-10f);
TEST_SUITE("TestConstTensorLayerVisitor")
Optimizer::Optimizations MakeOptimizations(Args &&... args)
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)
Copyright (c) 2021 ARM Limited and Contributors.
A layer user-provided data can be bound to (e.g. inputs, outputs).
ConvertConstants< Float32ToBFloat16, IsBFloat16Layer > ConvertConstantsFloatToBFloat
This layer represents a fully connected operation.
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store Weight values.
ConvertConstants< BFloat16ToFloat32, IsFloat32Layer > ConvertConstantsBFloatToFloat
A FullyConnectedDescriptor for the FullyConnectedLayer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
static void ConvertFloat32ToBFloat16(const float *srcFloat32Buffer, size_t numElements, void *dstBFloat16Buffer)
void SetTensorInfo(const TensorInfo &tensorInfo) override
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.