8 #include <TestUtils.hpp> 9 #include <doctest/doctest.h> 15 using namespace armnn;
18 TEST_CASE(
"ConvertConstFloat16DequantizeToConstFloat32")
21 const unsigned int shape[] = {1, 2, 2, 3};
27 std::vector<float> constantValues(constTensorInfo.
GetNumElements(), 4.5f);
28 ConstTensor constTensor(constTensorInfo, constantValues.data());
29 constantLayer->
m_LayerOutput = std::make_shared<ScopedTensorHandle>(constTensor);
41 auto checkConstantFloat16 = [](
const armnn::Layer *
const layer) ->
bool {
42 return IsLayerOfType<ConstantLayer>(layer) &&
45 auto checkConstantFloat32 = [](
const armnn::Layer *
const layer) ->
bool {
46 return IsLayerOfType<ConstantLayer>(layer) &&
52 &IsLayerOfType<DequantizeLayer>,
53 &IsLayerOfType<OutputLayer>));
59 &IsLayerOfType<OutputLayer>));
62 TEST_CASE(
"ConvertConstInt8DequantizeToConstFloat32")
65 const unsigned int shape[] = {1, 2, 2, 3};
71 std::vector<int8_t> constantValues(constTensorInfo.
GetNumElements(), 5);
72 ConstTensor constTensor(constTensorInfo, constantValues.data());
73 constantLayer->
m_LayerOutput = std::make_shared<ScopedTensorHandle>(constTensor);
85 auto checkConstantQAsymmS8 = [](
const armnn::Layer *
const layer) ->
bool {
86 return IsLayerOfType<ConstantLayer>(layer) &&
89 auto checkConstantFloat32 = [](
const armnn::Layer *
const layer) ->
bool {
90 return IsLayerOfType<ConstantLayer>(layer) &&
95 checkConstantQAsymmS8,
96 &IsLayerOfType<DequantizeLayer>,
97 &IsLayerOfType<OutputLayer>));
102 checkConstantFloat32,
103 &IsLayerOfType<OutputLayer>));
A layer that the constant data can be bound to.
Optimizer::Optimizations MakeOptimizations(Args &&... args)
bool CheckSequence(const armnn::Graph::ConstIterator first, const armnn::Graph::ConstIterator last)
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.
ConstIterator cbegin() const
Returns const iterator pointing to the beginning of the list. Lowercase for range-based for loops...
int Connect(InputSlot &destination)
static void Pass(Graph &graph, const Optimizations &optimizations)
Copyright (c) 2021 ARM Limited and Contributors.
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 dequantizes the input tensor.
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.
ConstIterator cend() const
Returns const iterator pointing to the end of the list. Lowercase for range-based for loops...
OptimizeForConnection< ConstantLayer, DequantizeLayer, ConvertConstDequantisationLayersToConstLayersImpl > ConvertConstDequantisationLayersToConstLayers
unsigned int GetNumElements() const