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());
67 for (
unsigned int i = 0; i < m_OutputTensorInfos.size(); i++)
70 CHECK(outputInfo.
GetShape() == m_OutputTensorInfos[i].GetShape());
82 if (expectedPtr ==
nullptr)
84 CHECK_MESSAGE(actualPtr ==
nullptr, (tensorName +
" should not exist"));
88 CHECK_MESSAGE(actualPtr !=
nullptr, (tensorName +
" should have been set"));
89 if (actualPtr !=
nullptr)
95 (tensorName +
" shapes don't match"));
98 (tensorName +
" data types don't match"));
101 (tensorName +
" (GetNumBytes) data sizes do not match"));
105 const char* expectedData =
static_cast<const char*
>(expectedPtr->
GetMemoryArea());
106 const char* actualData =
static_cast<const char*
>(actualPtr->
GetMemoryArea());
108 for (
unsigned int i = 0; i < expectedPtr->
GetNumBytes(); ++i)
110 same = expectedData[i] == actualData[i];
116 CHECK_MESSAGE(same, (tensorName +
" data does not match"));
130 CompareConstTensorData<const float*>(
135 CompareConstTensorData<const uint8_t*>(
139 CompareConstTensorData<const int8_t*>(
143 CompareConstTensorData<const int32_t*>(
148 MESSAGE(
"Unexpected datatype");
155 std::vector<std::uint8_t>
const serializerVector{serializerString.begin(), serializerString.end()};
156 return IDeserializer::Create()->CreateNetworkFromBinary(serializerVector);
163 serializer->Serialize(network);
165 std::stringstream stream;
166 serializer->SaveSerializedToStream(stream);
168 std::string serializerString{stream.str()};
169 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 &&...)
std::vector< float > GetQuantizationScales() const
bool HasMultipleQuantizationScales() const
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