14 #include <boost/algorithm/string.hpp> 15 #include <boost/lexical_cast.hpp> 16 #include <boost/test/unit_test.hpp> 24 return (opening ==
'{' && closing ==
'}') || (opening ==
'[' && closing ==
']');
29 std::stack<char> expStack;
30 for (
size_t i = 0; i < exp.length(); ++i)
32 if (exp[i] ==
'{' || exp[i] ==
'[')
34 expStack.push(exp[i]);
36 else if (exp[i] ==
'}' || exp[i] ==
']')
48 return expStack.empty();
53 std::vector<double> numbers;
55 std::string numberString;
56 for (
size_t i = 0; i < exp.size(); ++i)
62 else if (exp[i] ==
']' && inArray)
66 boost::trim_if(numberString, boost::is_any_of(
"\t,\n"));
67 numbers.push_back(std::stod(numberString));
69 catch (std::invalid_argument
const& e)
71 BOOST_FAIL(
"Could not convert measurements to double: " + numberString);
77 else if (exp[i] ==
',' && inArray)
81 boost::trim_if(numberString, boost::is_any_of(
"\t,\n"));
82 numbers.push_back(std::stod(numberString));
84 catch (std::invalid_argument
const& e)
86 BOOST_FAIL(
"Could not convert measurements to double: " + numberString);
90 else if (exp[i] !=
'[' && inArray && exp[i] !=
',' && exp[i] !=
' ')
92 numberString += exp[i];
100 std::vector<std::string> sections;
102 std::stack<size_t> s;
103 for (
size_t i = 0; i < exp.size(); i++)
105 if (exp.at(i) ==
'{')
109 else if (exp.at(i) ==
'}')
111 size_t from = s.top();
113 sections.push_back(exp.substr(from, i - from + 1));
122 using namespace armnn;
141 softmaxDescriptor.
m_Axis = 1;
164 BOOST_FAIL(
"Error occurred during Optimization, Optimize() returned nullptr.");
168 auto error = runtime->LoadNetwork(netId, std::move(optNet));
172 std::vector<uint8_t> inputData
177 std::vector<uint8_t> outputData(5);
185 {0,
armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())}
188 runtime->GetProfiler(netId)->EnableProfiling(
true);
191 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
192 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
193 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
196 std::stringstream ss;
197 profilerManager.GetProfiler()->Print(ss);
214 for (
size_t i = 0; i < sectionVector.size(); ++i)
216 if (boost::contains(sectionVector[i],
"\"ArmNN\":")
217 || boost::contains(sectionVector[i],
"\"inference_measurements\":"))
219 sectionVector.erase(sectionVector.begin() +
static_cast<int>(i));
224 BOOST_CHECK(std::all_of(sectionVector.begin(), sectionVector.end(),
225 [](std::string i) {
return boost::contains(i,
"\"raw\":"); }));
227 BOOST_CHECK(std::all_of(sectionVector.begin(), sectionVector.end(),
228 [](std::string i) {
return boost::contains(i,
"\"unit\":"); }));
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());
239 BOOST_CHECK(boost::contains(result,
"inference_measurements"));
257 "OpenClKernelTimer/: softmax_layer_max_shift_exp_sum_quantized_serial GWS[,,]"));
262 "NeonKernelTimer/: NEFillBorderKernel"));
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
bool AreParenthesesMatching(const std::string &exp)
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
void SetQuantizationScale(float scale)
bool m_EnableGpuProfiling
bool AreMatchingPair(const char opening, const char closing)
static INetworkPtr Create()
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
GPU Execution: OpenCL: ArmCompute.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
static IRuntimePtr Create(const CreationOptions &options)
A SoftmaxDescriptor for the SoftmaxLayer.
CPU Execution: NEON: ArmCompute.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
void ValidateProfilerJson(std::string &result)
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
std::string GetSoftmaxProfilerJson(const std::vector< armnn::BackendId > &backends)
void SetQuantizationOffset(int32_t offset)
virtual int Connect(IInputSlot &destination)=0
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
void RunSoftmaxProfilerJsonPrinterTest(const std::vector< armnn::BackendId > &backends)
static ProfilerManager & GetInstance()
int m_Axis
Scalar, defaulted to the last index (-1), specifying the dimension the activation will be performed o...
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
std::vector< double > ExtractMeasurements(const std::string &exp)
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
std::vector< std::string > ExtractSections(const std::string &exp)