7 #include "../Serializer.hpp" 9 #include <doctest/doctest.h> 14 const std::vector<armnn::TensorInfo>& inputInfos,
15 const std::vector<armnn::TensorInfo>& outputInfos)
16 : m_LayerName(layerName)
17 , m_InputTensorInfos(inputInfos)
18 , m_OutputTensorInfos(outputInfos)
23 const std::vector<armnn::ConstTensor>& constants,
42 CHECK(std::string(name) == m_LayerName.c_str());
47 for (
unsigned int i = 0; i < m_InputTensorInfos.size(); i++)
50 CHECK(connectedOutput);
53 CHECK(connectedInfo.
GetShape() == m_InputTensorInfos[i].GetShape());
61 for (
unsigned int i = 0; i < m_OutputTensorInfos.size(); i++)
64 CHECK(outputInfo.
GetShape() == m_OutputTensorInfos[i].GetShape());
76 if (expectedPtr ==
nullptr)
78 CHECK_MESSAGE(actualPtr ==
nullptr, tensorName +
" should not exist");
82 CHECK_MESSAGE(actualPtr !=
nullptr, tensorName +
" should have been set");
83 if (actualPtr !=
nullptr)
89 tensorName +
" shapes don't match");
92 tensorName +
" data types don't match");
95 tensorName +
" (GetNumBytes) data sizes do not match");
99 const char* expectedData =
static_cast<const char*
>(expectedPtr->
GetMemoryArea());
100 const char* actualData =
static_cast<const char*
>(actualPtr->
GetMemoryArea());
102 for (
unsigned int i = 0; i < expectedPtr->
GetNumBytes(); ++i)
104 same = expectedData[i] == actualData[i];
110 CHECK_MESSAGE(same, tensorName +
" data does not match");
124 CompareConstTensorData<const float*>(
129 CompareConstTensorData<const uint8_t*>(
133 CompareConstTensorData<const int8_t*>(
137 CompareConstTensorData<const int32_t*>(
142 MESSAGE(
"Unexpected datatype");
149 std::vector<std::uint8_t>
const serializerVector{serializerString.begin(), serializerString.end()};
150 return IDeserializer::Create()->CreateNetworkFromBinary(serializerVector);
157 serializer->Serialize(network);
159 std::stringstream stream;
160 serializer->SaveSerializedToStream(stream);
162 std::string serializerString{stream.str()};
163 return serializerString;
virtual unsigned int GetNumOutputSlots() const =0
Returns the number of connectable output slots.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
virtual unsigned int GetNumInputSlots() const =0
Returns the number of connectable input slots.
const TensorShape & GetShape() const
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
const TensorShape & GetShape() const
Main network class which provides the interface for building up a neural network. ...
unsigned int GetNumElements() const
MemoryType GetMemoryArea() const
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
constexpr const char * GetDataTypeName(DataType dataType)
Base class for all descriptors.
An output connection slot for a layer.
void VerifyNameAndConnections(const armnn::IConnectableLayer *layer, const char *name)
int32_t GetQuantizationOffset() const
float GetQuantizationScale() const
DataType GetDataType() const
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
LayerVerifierBase(const std::string &layerName, const std::vector< armnn::TensorInfo > &inputInfos, const std::vector< armnn::TensorInfo > &outputInfos)
const TensorInfo & GetInfo() const
void VerifyConstTensors(const std::string &tensorName, const armnn::ConstTensor *expectedPtr, const armnn::ConstTensor *actualPtr)
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
std::unique_ptr< ISerializer, void(*)(ISerializer *serializer)> ISerializerPtr
void CompareConstTensor(const armnn::ConstTensor &tensor1, const armnn::ConstTensor &tensor2)
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
static ISerializerPtr Create()
virtual const TensorInfo & GetTensorInfo() const =0
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
DataType GetDataType() const
std::string SerializeNetwork(const armnn::INetwork &network)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
unsigned int GetNumBytes() const