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 --- 20.02/_activation_serialization_tests_8cpp.xhtml | 186 +++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 20.02/_activation_serialization_tests_8cpp.xhtml (limited to '20.02/_activation_serialization_tests_8cpp.xhtml') diff --git a/20.02/_activation_serialization_tests_8cpp.xhtml b/20.02/_activation_serialization_tests_8cpp.xhtml new file mode 100644 index 0000000000..2ff39bc54e --- /dev/null +++ b/20.02/_activation_serialization_tests_8cpp.xhtml @@ -0,0 +1,186 @@ + + + + + + + + + + + + + +ArmNN: src/armnnSerializer/test/ActivationSerializationTests.cpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
ActivationSerializationTests.cpp File Reference
+
+
+
#include "../Serializer.hpp"
+#include <armnn/Descriptors.hpp>
+#include <armnn/INetwork.hpp>
+#include <armnn/IRuntime.hpp>
+#include <armnnDeserializer/IDeserializer.hpp>
+#include <armnn/utility/IgnoreUnused.hpp>
+#include <boost/test/unit_test.hpp>
+#include <sstream>
+
+

Go to the source code of this file.

+ + + + +

+Functions

 BOOST_AUTO_TEST_CASE (ActivationSerialization)
 
+

Function Documentation

+ +

◆ BOOST_AUTO_TEST_CASE()

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (ActivationSerialization )
+
+ +

Definition at line 32 of file ActivationSerializationTests.cpp.

+ +

References BOOST_AUTO_TEST_SUITE_END(), IOutputSlot::Connect(), armnn::CpuRef, IDeserializer::Create(), INetwork::Create(), IRuntime::Create(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), ActivationDescriptor::m_A, ActivationDescriptor::m_B, ActivationDescriptor::m_Function, armnn::Optimize(), options, armnn::ReLu, Serializer::SaveSerializedToStream(), Serializer::Serialize(), and IOutputSlot::SetTensorInfo().

+
33 {
35 
36  armnn::TensorInfo inputInfo(armnn::TensorShape({1, 2, 2, 1}), armnn::DataType::Float32, 1.0f, 0);
37  armnn::TensorInfo outputInfo(armnn::TensorShape({1, 2, 2, 1}), armnn::DataType::Float32, 4.0f, 0);
38 
39  // Construct network
41 
42  armnn::ActivationDescriptor descriptor;
44  descriptor.m_A = 0;
45  descriptor.m_B = 0;
46 
47  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0, "input");
48  armnn::IConnectableLayer* const activationLayer = network->AddActivationLayer(descriptor, "activation");
49  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0, "output");
50 
51  inputLayer->GetOutputSlot(0).Connect(activationLayer->GetInputSlot(0));
52  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
53 
54  activationLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
55  activationLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
56 
58  serializer.Serialize(*network);
59 
60  std::stringstream stream;
61  serializer.SaveSerializedToStream(stream);
62 
63  std::string const serializerString{stream.str()};
64  std::vector<std::uint8_t> const serializerVector{serializerString.begin(), serializerString.end()};
65 
66  armnn::INetworkPtr deserializedNetwork = parser->CreateNetworkFromBinary(serializerVector);
67 
68  VerifyActivationName visitor;
69  deserializedNetwork->Accept(visitor);
70 
71  armnn::IRuntime::CreationOptions options; // default options
73  auto deserializedOptimized = Optimize(*deserializedNetwork, { armnn::Compute::CpuRef }, run->GetDeviceSpec());
74 
75  armnn::NetworkId networkIdentifier;
76 
77  // Load graph into runtime
78  run->LoadNetwork(networkIdentifier, std::move(deserializedOptimized));
79 
80  std::vector<float> inputData {0.0f, -5.3f, 42.0f, -42.0f};
81  armnn::InputTensors inputTensors
82  {
83  {0, armnn::ConstTensor(run->GetInputTensorInfo(networkIdentifier, 0), inputData.data())}
84  };
85 
86  std::vector<float> expectedOutputData {0.0f, 0.0f, 42.0f, 0.0f};
87 
88  std::vector<float> outputData(4);
89  armnn::OutputTensors outputTensors
90  {
91  {0, armnn::Tensor(run->GetOutputTensorInfo(networkIdentifier, 0), outputData.data())}
92  };
93  run->EnqueueWorkload(networkIdentifier, inputTensors, outputTensors);
94  BOOST_CHECK_EQUAL_COLLECTIONS(outputData.begin(), outputData.end(),
95  expectedOutputData.begin(), expectedOutputData.end());
96 }
+
static IRuntimePtr Create(const CreationOptions &options)
Definition: Runtime.cpp:32
+
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:61
+
CPU Execution: Reference C++ kernels.
+ + +
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
Definition: IRuntime.hpp:24
+
static IDeserializerPtr Create()
+
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
Definition: Tensor.hpp:225
+
void Serialize(const armnn::INetwork &inNetwork) override
Serializes the network to ArmNN SerializedGraph.
+
int NetworkId
Definition: IRuntime.hpp:19
+ +
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
+
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:191
+
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
+
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::unique_ptr< IDeserializer, void(*)(IDeserializer *parser)> IDeserializerPtr
+
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:20
+
bool SaveSerializedToStream(std::ostream &stream) override
Serializes the SerializedGraph to the stream.
+ +
float m_A
Alpha upper bound value used by the activation functions. (BoundedReLu, Linear, TanH).
Definition: Descriptors.hpp:37
+
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
+ +
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
Definition: INetwork.hpp:101
+
virtual int Connect(IInputSlot &destination)=0
+
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
+
float m_B
Beta lower bound value used by the activation functions. (BoundedReLu, Linear, TanH).
Definition: Descriptors.hpp:39
+
static INetworkPtr Create()
Definition: Network.cpp:49
+
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu, LeakyReLu, Abs, Sqrt, Square).
Definition: Descriptors.hpp:35
+
+
+
+
+
+ + + + -- cgit v1.2.1