From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- ...ruct_parser_flatbuffers_serialize_fixture.xhtml | 699 +++++++++++++++++++++ 1 file changed, 699 insertions(+) create mode 100644 20.02/struct_parser_flatbuffers_serialize_fixture.xhtml (limited to '20.02/struct_parser_flatbuffers_serialize_fixture.xhtml') diff --git a/20.02/struct_parser_flatbuffers_serialize_fixture.xhtml b/20.02/struct_parser_flatbuffers_serialize_fixture.xhtml new file mode 100644 index 0000000000..6e01cc2bb6 --- /dev/null +++ b/20.02/struct_parser_flatbuffers_serialize_fixture.xhtml @@ -0,0 +1,699 @@ + + + + + + + + + + + + + +ArmNN: ParserFlatbuffersSerializeFixture Struct Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
ParserFlatbuffersSerializeFixture Struct Reference
+
+
+ +

#include <ParserFlatbuffersSerializeFixture.hpp>

+
+Inheritance diagram for ParserFlatbuffersSerializeFixture:
+
+
+ + +PositiveActivationFixture + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

+Public Member Functions

 ParserFlatbuffersSerializeFixture ()
 
void Setup ()
 
void SetupSingleInputSingleOutput (const std::string &inputName, const std::string &outputName)
 
bool ReadStringToBinary ()
 
template<std::size_t NumOutputDimensions, armnn::DataType ArmnnType, typename DataType = armnn::ResolveType<ArmnnType>>
void RunTest (unsigned int layersId, const std::vector< DataType > &inputData, const std::vector< DataType > &expectedOutputData)
 Executes the network with the given input tensor and checks the result against the given output tensor. More...
 
template<std::size_t NumOutputDimensions, armnn::DataType ArmnnInputType, armnn::DataType ArmnnOutputType, typename InputDataType = armnn::ResolveType<ArmnnInputType>, typename OutputDataType = armnn::ResolveType<ArmnnOutputType>>
void RunTest (unsigned int layersId, const std::vector< InputDataType > &inputData, const std::vector< OutputDataType > &expectedOutputData)
 
template<std::size_t NumOutputDimensions, armnn::DataType ArmnnType, typename DataType = armnn::ResolveType<ArmnnType>>
void RunTest (unsigned int layersId, const std::map< std::string, std::vector< DataType >> &inputData, const std::map< std::string, std::vector< DataType >> &expectedOutputData)
 Executes the network with the given input tensors and checks the results against the given output tensors. More...
 
template<std::size_t NumOutputDimensions, armnn::DataType ArmnnInputType, armnn::DataType ArmnnOutputType, typename InputDataType = armnn::ResolveType<ArmnnInputType>, typename OutputDataType = armnn::ResolveType<ArmnnOutputType>>
void RunTest (unsigned int layersId, const std::map< std::string, std::vector< InputDataType >> &inputData, const std::map< std::string, std::vector< OutputDataType >> &expectedOutputData)
 
void CheckTensors (const TensorRawPtr &tensors, size_t shapeSize, const std::vector< int32_t > &shape, armnnSerializer::TensorInfo tensorType, const std::string &name, const float scale, const int64_t zeroPoint)
 
+ + + + + + + + + + + + + + + + +

+Public Attributes

std::vector< uint8_t > m_GraphBinary
 
std::string m_JsonString
 
std::unique_ptr< IDeserializer, void(*)(IDeserializer *parser)> m_Parser
 
armnn::IRuntimePtr m_Runtime
 
armnn::NetworkId m_NetworkIdentifier
 
std::string m_SingleInputName
 If the single-input-single-output overload of Setup() is called, these will store the input and output name so they don't need to be passed to the single-input-single-output overload of RunTest(). More...
 
std::string m_SingleOutputName
 
+

Detailed Description

+
+

Definition at line 27 of file ParserFlatbuffersSerializeFixture.hpp.

+

Constructor & Destructor Documentation

+ +

◆ ParserFlatbuffersSerializeFixture()

+ +
+
+ + + + + +
+ + + + + + + +
ParserFlatbuffersSerializeFixture ()
+
+inline
+
+ +

Definition at line 29 of file ParserFlatbuffersSerializeFixture.hpp.

+
29  :
30  m_Parser(IDeserializer::Create()),
33  {
34  }
static IRuntimePtr Create(const CreationOptions &options)
Definition: Runtime.cpp:32
+ +
std::unique_ptr< IDeserializer, void(*)(IDeserializer *parser)> m_Parser
+ + +
+
+
+

Member Function Documentation

+ +

◆ CheckTensors()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void CheckTensors (const TensorRawPtrtensors,
size_t shapeSize,
const std::vector< int32_t > & shape,
armnnSerializer::TensorInfo tensorType,
const std::string & name,
const float scale,
const int64_t zeroPoint 
)
+
+inline
+
+ +

Definition at line 153 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

References armnn::IgnoreUnused().

+
156  {
157  armnn::IgnoreUnused(name);
158  BOOST_CHECK_EQUAL(shapeSize, tensors->dimensions()->size());
159  BOOST_CHECK_EQUAL_COLLECTIONS(shape.begin(), shape.end(),
160  tensors->dimensions()->begin(), tensors->dimensions()->end());
161  BOOST_CHECK_EQUAL(tensorType.dataType(), tensors->dataType());
162  BOOST_CHECK_EQUAL(scale, tensors->quantizationScale());
163  BOOST_CHECK_EQUAL(zeroPoint, tensors->quantizationOffset());
164  }
void IgnoreUnused(Ts &&...)
+
+
+
+ +

◆ ReadStringToBinary()

+ +
+
+ + + + + +
+ + + + + + + +
bool ReadStringToBinary ()
+
+inline
+
+ +

Definition at line 91 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

References deserialize_schema_end, deserialize_schema_start, and RunTest().

+ +

Referenced by Setup().

+
92  {
93  std::string schemafile(&deserialize_schema_start, &deserialize_schema_end);
94 
95  // parse schema first, so we can use it to parse the data after
96  flatbuffers::Parser parser;
97 
98  bool ok = parser.Parse(schemafile.c_str());
99  BOOST_ASSERT_MSG(ok, "Failed to parse schema file");
100 
101  ok &= parser.Parse(m_JsonString.c_str());
102  BOOST_ASSERT_MSG(ok, "Failed to parse json input");
103 
104  if (!ok)
105  {
106  return false;
107  }
108 
109  {
110  const uint8_t* bufferPtr = parser.builder_.GetBufferPointer();
111  size_t size = static_cast<size_t>(parser.builder_.GetSize());
112  m_GraphBinary.assign(bufferPtr, bufferPtr+size);
113  }
114  return ok;
115  }
const char deserialize_schema_start
+
const char deserialize_schema_end
+ + +
+
+
+ +

◆ RunTest() [1/4]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void RunTest (unsigned int layersId,
const std::vector< DataType > & inputData,
const std::vector< DataType > & expectedOutputData 
)
+
+ +

Executes the network with the given input tensor and checks the result against the given output tensor.

+

This overload assumes the network has a single input and a single output.

+ +

Definition at line 168 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

Referenced by ReadStringToBinary().

+
171 {
172  RunTest<NumOutputDimensions, ArmnnType, ArmnnType, DataType, DataType>(layersId, inputData, expectedOutputData);
173 }
+
+
+ +

◆ RunTest() [2/4]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void RunTest (unsigned int layersId,
const std::vector< InputDataType > & inputData,
const std::vector< OutputDataType > & expectedOutputData 
)
+
+ +

Definition at line 180 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

References m_SingleInputName, and m_SingleOutputName.

+
183 {
184  RunTest<NumOutputDimensions, ArmnnInputType, ArmnnOutputType>(layersId,
185  { { m_SingleInputName, inputData } },
186  { { m_SingleOutputName, expectedOutputData } });
187 }
+
std::string m_SingleInputName
If the single-input-single-output overload of Setup() is called, these will store the input and outpu...
+
+
+
+ +

◆ RunTest() [3/4]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void RunTest (unsigned int layersId,
const std::map< std::string, std::vector< DataType >> & inputData,
const std::map< std::string, std::vector< DataType >> & expectedOutputData 
)
+
+ +

Executes the network with the given input tensors and checks the results against the given output tensors.

+

This overload supports multiple inputs and multiple outputs, identified by name.

+ +

Definition at line 190 of file ParserFlatbuffersSerializeFixture.hpp.

+
193 {
194  RunTest<NumOutputDimensions, ArmnnType, ArmnnType, DataType, DataType>(layersId, inputData, expectedOutputData);
195 }
+
+
+ +

◆ RunTest() [4/4]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void RunTest (unsigned int layersId,
const std::map< std::string, std::vector< InputDataType >> & inputData,
const std::map< std::string, std::vector< OutputDataType >> & expectedOutputData 
)
+
+ +

Definition at line 202 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

References CompareTensors(), m_NetworkIdentifier, m_Parser, m_Runtime, and armnn::VerifyTensorInfoDataType().

+
206 {
207  auto ConvertBindingInfo = [](const armnnDeserializer::BindingPointInfo& bindingInfo)
208  {
209  return std::make_pair(bindingInfo.m_BindingId, bindingInfo.m_TensorInfo);
210  };
211 
212  // Setup the armnn input tensors from the given vectors.
213  armnn::InputTensors inputTensors;
214  for (auto&& it : inputData)
215  {
216  armnn::BindingPointInfo bindingInfo = ConvertBindingInfo(
217  m_Parser->GetNetworkInputBindingInfo(layersId, it.first));
218  armnn::VerifyTensorInfoDataType(bindingInfo.second, ArmnnInputType);
219  inputTensors.push_back({ bindingInfo.first, armnn::ConstTensor(bindingInfo.second, it.second.data()) });
220  }
221 
222  // Allocate storage for the output tensors to be written to and setup the armnn output tensors.
223  std::map<std::string, boost::multi_array<OutputDataType, NumOutputDimensions>> outputStorage;
224  armnn::OutputTensors outputTensors;
225  for (auto&& it : expectedOutputData)
226  {
227  armnn::BindingPointInfo bindingInfo = ConvertBindingInfo(
228  m_Parser->GetNetworkOutputBindingInfo(layersId, it.first));
229  armnn::VerifyTensorInfoDataType(bindingInfo.second, ArmnnOutputType);
230  outputStorage.emplace(it.first, MakeTensor<OutputDataType, NumOutputDimensions>(bindingInfo.second));
231  outputTensors.push_back(
232  { bindingInfo.first, armnn::Tensor(bindingInfo.second, outputStorage.at(it.first).data()) });
233  }
234 
235  m_Runtime->EnqueueWorkload(m_NetworkIdentifier, inputTensors, outputTensors);
236 
237  // Compare each output tensor to the expected values
238  for (auto&& it : expectedOutputData)
239  {
240  armnn::BindingPointInfo bindingInfo = ConvertBindingInfo(
241  m_Parser->GetNetworkOutputBindingInfo(layersId, it.first));
242  auto outputExpected = MakeTensor<OutputDataType, NumOutputDimensions>(bindingInfo.second, it.second);
243  BOOST_TEST(CompareTensors(outputExpected, outputStorage[it.first]));
244  }
245 }
boost::test_tools::predicate_result CompareTensors(const boost::multi_array< T, n > &a, const boost::multi_array< T, n > &b, bool compareBoolean=false)
+ +
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
Definition: Tensor.hpp:225
+
std::unique_ptr< IDeserializer, void(*)(IDeserializer *parser)> m_Parser
+ +
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:191
+
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:199
+
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
Definition: Tensor.hpp:226
+ +
std::pair< armnn::LayerBindingId, armnn::TensorInfo > BindingPointInfo
Definition: Tensor.hpp:146
+
void VerifyTensorInfoDataType(const armnn::TensorInfo &info, armnn::DataType dataType)
Definition: TypesUtils.hpp:296
+
+
+
+ +

◆ Setup()

+ +
+
+ + + + + +
+ + + + + + + +
void Setup ()
+
+inline
+
+ +

Definition at line 47 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

References armnn::CpuRef, armnn::Optimize(), ReadStringToBinary(), and armnn::Success.

+ +

Referenced by SetupSingleInputSingleOutput().

+
48  {
49  bool ok = ReadStringToBinary();
50  if (!ok)
51  {
52  throw armnn::Exception("LoadNetwork failed while reading binary input");
53  }
54 
55  armnn::INetworkPtr network =
56  m_Parser->CreateNetworkFromBinary(m_GraphBinary);
57 
58  if (!network)
59  {
60  throw armnn::Exception("The parser failed to create an ArmNN network");
61  }
62 
63  auto optimized = Optimize(*network, {armnn::Compute::CpuRef},
64  m_Runtime->GetDeviceSpec());
65 
66  std::string errorMessage;
67  armnn::Status ret = m_Runtime->LoadNetwork(m_NetworkIdentifier, move(optimized), errorMessage);
68 
69  if (ret != armnn::Status::Success)
70  {
71  throw armnn::Exception(
72  boost::str(
73  boost::format("The runtime failed to load the network. "
74  "Error was: %1%. in %2% [%3%:%4%]") %
75  errorMessage %
76  __func__ %
77  __FILE__ %
78  __LINE__));
79  }
80 
81  }
CPU Execution: Reference C++ kernels.
+ + +
std::unique_ptr< IDeserializer, void(*)(IDeserializer *parser)> m_Parser
+ +
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
Create an optimized version of the network.
Definition: Network.cpp:890
+
Status
enumeration
Definition: Types.hpp:26
+ +
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
+
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
+ +
+
+
+ +

◆ SetupSingleInputSingleOutput()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
void SetupSingleInputSingleOutput (const std::string & inputName,
const std::string & outputName 
)
+
+inline
+
+ +

Definition at line 83 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

References Setup().

+
84  {
85  // Store the input and output name so they don't need to be passed to the single-input-single-output RunTest().
86  m_SingleInputName = inputName;
87  m_SingleOutputName = outputName;
88  Setup();
89  }
+ +
std::string m_SingleInputName
If the single-input-single-output overload of Setup() is called, these will store the input and outpu...
+
+
+
+

Member Data Documentation

+ +

◆ m_GraphBinary

+ +
+
+ + + + +
std::vector<uint8_t> m_GraphBinary
+
+ +

Definition at line 36 of file ParserFlatbuffersSerializeFixture.hpp.

+ +
+
+ +

◆ m_JsonString

+ +
+
+ + + + +
std::string m_JsonString
+
+ +

Definition at line 37 of file ParserFlatbuffersSerializeFixture.hpp.

+ +
+
+ +

◆ m_NetworkIdentifier

+ +
+
+ + + + +
armnn::NetworkId m_NetworkIdentifier
+
+ +

Definition at line 40 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

Referenced by RunTest().

+ +
+
+ +

◆ m_Parser

+ +
+
+ + + + +
std::unique_ptr<IDeserializer, void (*)(IDeserializer* parser)> m_Parser
+
+ +

Definition at line 38 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

Referenced by RunTest().

+ +
+
+ +

◆ m_Runtime

+ +
+
+ + + + +
armnn::IRuntimePtr m_Runtime
+
+ +

Definition at line 39 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

Referenced by RunTest().

+ +
+
+ +

◆ m_SingleInputName

+ +
+
+ + + + +
std::string m_SingleInputName
+
+ +

If the single-input-single-output overload of Setup() is called, these will store the input and output name so they don't need to be passed to the single-input-single-output overload of RunTest().

+ +

Definition at line 44 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

Referenced by RunTest().

+ +
+
+ +

◆ m_SingleOutputName

+ +
+
+ + + + +
std::string m_SingleOutputName
+
+ +

Definition at line 45 of file ParserFlatbuffersSerializeFixture.hpp.

+ +

Referenced by RunTest().

+ +
+
+
The documentation for this struct was generated from the following file: +
+
+ + + + -- cgit v1.2.1