7 #include "../Serializer.hpp" 12 const std::vector<armnn::TensorInfo>& inputInfos,
13 const std::vector<armnn::TensorInfo>& outputInfos)
14 : m_LayerName(layerName)
15 , m_InputTensorInfos(inputInfos)
16 , m_OutputTensorInfos(outputInfos)
21 const std::vector<armnn::ConstTensor>& constants,
40 BOOST_TEST(name == m_LayerName.c_str());
45 for (
unsigned int i = 0; i < m_InputTensorInfos.size(); i++)
48 BOOST_CHECK(connectedOutput);
51 BOOST_TEST(connectedInfo.
GetShape() == m_InputTensorInfos[i].GetShape());
55 BOOST_TEST(connectedInfo.
GetQuantizationScale() == m_InputTensorInfos[i].GetQuantizationScale());
59 for (
unsigned int i = 0; i < m_OutputTensorInfos.size(); i++)
62 BOOST_TEST(outputInfo.
GetShape() == m_OutputTensorInfos[i].GetShape());
75 if (expectedPtr ==
nullptr)
77 BOOST_CHECK_MESSAGE(actualPtr ==
nullptr, tensorName +
" should not exist");
81 BOOST_CHECK_MESSAGE(actualPtr !=
nullptr, tensorName +
" should have been set");
82 if (actualPtr !=
nullptr)
88 tensorName +
" shapes don't match");
91 tensorName +
" data types don't match");
94 tensorName +
" (GetNumBytes) data sizes do not match");
98 const char* expectedData =
static_cast<const char*
>(expectedPtr->
GetMemoryArea());
99 const char* actualData =
static_cast<const char*
>(actualPtr->
GetMemoryArea());
101 for (
unsigned int i = 0; i < expectedPtr->
GetNumBytes(); ++i)
103 same = expectedData[i] == actualData[i];
109 BOOST_CHECK_MESSAGE(same, tensorName +
" data does not match");
123 CompareConstTensorData<const float*>(
128 CompareConstTensorData<const uint8_t*>(
132 CompareConstTensorData<const int8_t*>(
136 CompareConstTensorData<const int32_t*>(
141 BOOST_TEST_MESSAGE(
"Unexpected datatype");
148 std::vector<std::uint8_t>
const serializerVector{serializerString.begin(), serializerString.end()};
149 return IDeserializer::Create()->CreateNetworkFromBinary(serializerVector);
156 serializer->Serialize(network);
158 std::stringstream stream;
159 serializer->SaveSerializedToStream(stream);
161 std::string serializerString{stream.str()};
162 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