15 #include <boost/test/unit_test.hpp> 23 return (opening ==
'{' && closing ==
'}') || (opening ==
'[' && closing ==
']');
28 std::stack<char> expStack;
29 for (
size_t i = 0; i < exp.length(); ++i)
31 if (exp[i] ==
'{' || exp[i] ==
'[')
33 expStack.push(exp[i]);
35 else if (exp[i] ==
'}' || exp[i] ==
']')
47 return expStack.empty();
52 std::vector<double> numbers;
54 std::string numberString;
55 for (
size_t i = 0; i < exp.size(); ++i)
61 else if (exp[i] ==
']' && inArray)
66 numbers.push_back(std::stod(numberString));
68 catch (std::invalid_argument
const&)
70 BOOST_FAIL(
"Could not convert measurements to double: " + numberString);
76 else if (exp[i] ==
',' && inArray)
81 numbers.push_back(std::stod(numberString));
83 catch (std::invalid_argument
const&)
85 BOOST_FAIL(
"Could not convert measurements to double: " + numberString);
89 else if (exp[i] !=
'[' && inArray && exp[i] !=
',' && exp[i] !=
' ')
91 numberString += exp[i];
99 std::vector<std::string> sections;
101 std::stack<size_t> s;
102 for (
size_t i = 0; i < exp.size(); i++)
104 if (exp.at(i) ==
'{')
108 else if (exp.at(i) ==
'}')
110 size_t from = s.top();
112 sections.push_back(exp.substr(from, i - from + 1));
121 using namespace armnn;
123 BOOST_CHECK(!backends.empty());
140 softmaxDescriptor.
m_Axis = -1;
163 BOOST_FAIL(
"Error occurred during Optimization, Optimize() returned nullptr.");
167 auto error = runtime->LoadNetwork(netId, std::move(optNet));
171 std::vector<uint8_t> inputData
176 std::vector<uint8_t> outputData(5);
184 {0,
armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())}
187 runtime->GetProfiler(netId)->EnableProfiling(
true);
190 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
191 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
192 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
195 std::stringstream ss;
196 profilerManager.GetProfiler()->Print(ss);
205 BOOST_CHECK(!measurementsVector.empty());
213 for (
size_t i = 0; i < sectionVector.size(); ++i)
216 if (sectionVector[i].find(
"\"ArmNN\":") != std::string::npos
217 || sectionVector[i].find(
"\"inference_measurements\":") != std::string::npos)
219 sectionVector.erase(sectionVector.begin() +
static_cast<int>(i));
222 BOOST_CHECK(!sectionVector.empty());
224 BOOST_CHECK(std::all_of(sectionVector.begin(), sectionVector.end(),
225 [](std::string i) {
return (i.find(
"\"raw\":") != std::string::npos); }));
227 BOOST_CHECK(std::all_of(sectionVector.begin(), sectionVector.end(),
228 [](std::string i) {
return (i.find(
"\"unit\":") != std::string::npos); }));
232 result.erase(std::remove_if (result.begin(),result.end(),
233 [](
char c) {
return c ==
'.'; }), result.end());
234 result.erase(std::remove_if (result.begin(), result.end(), &isdigit), result.end());
235 result.erase(std::remove_if (result.begin(),result.end(),
236 [](
char c) {
return c ==
'\t'; }), result.end());
238 BOOST_CHECK(result.find(
"ArmNN") != std::string::npos);
239 BOOST_CHECK(result.find(
"inference_measurements") != std::string::npos);
256 BOOST_CHECK(result.find(
"OpenClKernelTimer/: softmax_layer_max_shift_exp_sum_quantized_serial GWS[,,]")
257 != std::string::npos);
261 BOOST_CHECK(result.find(
"NeonKernelTimer/: NEFillBorderKernel") != std::string::npos);
static IRuntimePtr Create(const CreationOptions &options)
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
int m_Axis
Scalar, defaulted to the last index (-1), specifying the dimension the activation will be performed o...
static ProfilerManager & GetInstance()
void RunSoftmaxProfilerJsonPrinterTest(const std::vector< armnn::BackendId > &backends)
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
Copyright (c) 2020 ARM Limited.
std::string GetSoftmaxProfilerJson(const std::vector< armnn::BackendId > &backends)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
bool AreMatchingPair(const char opening, const char closing)
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
std::vector< std::string > ExtractSections(const std::string &exp)
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.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
void SetQuantizationScale(float scale)
GPU Execution: OpenCL: ArmCompute.
bool m_EnableGpuProfiling
Setting this flag will allow the user to obtain GPU profiling information from the runtime...
CPU Execution: NEON: ArmCompute.
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.
void SetQuantizationOffset(int32_t offset)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
virtual int Connect(IInputSlot &destination)=0
std::string & StringTrim(std::string &str, const std::string &chars="\\\")
Trim from both the start and the end of a string.
std::vector< double > ExtractMeasurements(const std::string &exp)
static INetworkPtr Create(NetworkOptions networkOptions={})
void ValidateProfilerJson(std::string &result)
A SoftmaxDescriptor for the SoftmaxLayer.
bool AreParenthesesMatching(const std::string &exp)