blob: 69374fbc8cd96f74106233b2bf20e2d744e410c4 [file] [log] [blame]
Anthony Barbierb4670212018-05-18 16:55:39 +01001/*
Giorgio Arenac5a61392021-01-06 15:13:08 +00002 * Copyright (c) 2020-2021 Arm Limited.
Anthony Barbierb4670212018-05-18 16:55:39 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/TracePoint.h"
25
26#include "arm_compute/core/HOGInfo.h"
27#include "arm_compute/core/IArray.h"
28#include "arm_compute/core/IDistribution1D.h"
29#include "arm_compute/core/IHOG.h"
30#include "arm_compute/core/ILut.h"
31#include "arm_compute/core/IMultiHOG.h"
32#include "arm_compute/core/IMultiImage.h"
33#include "arm_compute/core/IPyramid.h"
34#include "arm_compute/core/ITensor.h"
35#include "arm_compute/core/KernelDescriptors.h"
Anthony Barbierb4670212018-05-18 16:55:39 +010036#include "arm_compute/core/PixelValue.h"
37#include "arm_compute/core/Window.h"
38#include "arm_compute/runtime/FunctionDescriptors.h"
39#include "arm_compute/runtime/IWeightsManager.h"
40#include "arm_compute/runtime/MemoryGroup.h"
Michalis Spyrouebcebf12020-10-21 00:04:14 +010041#include "src/core/NEON/kernels/assembly/arm_gemm.hpp"
Anthony Barbierb4670212018-05-18 16:55:39 +010042#include "utils/TypePrinter.h"
43
44#include <array>
45#include <cstdio>
46
47namespace arm_compute
48{
49#ifndef DOXYGEN_SKIP_THIS
50int TracePoint::g_depth = 0;
51
52TracePoint::TracePoint(Layer layer, const std::string &class_name, void *object, Args &&args)
53 : _depth(++g_depth)
54{
55 ARM_COMPUTE_UNUSED(layer, object, args);
56 const std::string indentation = " ";
57 std::string prefix = "";
58 for(int i = 0; i < _depth; ++i)
59 {
60 prefix += indentation;
61 prefix += indentation;
62 }
63 printf("%s%s::configure(", prefix.c_str(), class_name.c_str());
64 for(auto &arg : args.args)
65 {
66 printf("\n%s%s%s", prefix.c_str(), indentation.c_str(), arg.c_str());
67 }
68 printf("\n%s)\n", prefix.c_str());
69}
70
71TracePoint::~TracePoint()
72{
73 --g_depth;
74}
75
76std::string to_string(const arm_gemm::Activation &arg)
77{
78 switch(arg.type)
79 {
80 case arm_gemm::Activation::Type::None:
81 return "None";
82 case arm_gemm::Activation::Type::ReLU:
83 return "ReLU";
84 case arm_gemm::Activation::Type::BoundedReLU:
85 return "BoundedReLU";
86 default:
87 ARM_COMPUTE_ERROR("Not supported");
88 return "Uknown";
89 };
90}
91
92std::string to_string(const arm_gemm::GemmArgs &arg)
93{
94 std::stringstream str;
95 for(size_t k = 0; k < arg._ci->get_cpu_num(); ++k)
96 {
97 str << "[CPUCore " << k << "]" << to_string(arg._ci->get_cpu_model(0)) << " ";
98 }
99 str << "Msize= " << arg._Msize << " ";
100 str << "Nsize= " << arg._Nsize << " ";
101 str << "Ksize= " << arg._Ksize << " ";
102 str << "nbatches= " << arg._nbatches << " ";
103 str << "nmulti= " << arg._nmulti << " ";
104 str << "trA= " << arg._trA << " ";
105 str << "trB= " << arg._trB << " ";
106 str << "Activation= " << to_string(arg._act) << " ";
107 str << "maxthreads= " << arg._maxthreads << " ";
108 str << "pretransposed_hint= " << arg._pretransposed_hint << " ";
109 return str.str();
110}
111
112std::string to_string(const ITensor &arg)
113{
114 std::stringstream str;
115 str << "TensorInfo(" << *arg.info() << ")";
116 return str.str();
117}
118
119std::string to_ptr_string(const void *arg)
120{
121 std::stringstream ss;
122 ss << arg;
123 return ss.str();
124}
125
Giorgio Arenac5a61392021-01-06 15:13:08 +0000126ARM_COMPUTE_TRACE_TO_STRING(ThresholdType)
127ARM_COMPUTE_TRACE_TO_STRING(IDetectionWindowArray)
128ARM_COMPUTE_TRACE_TO_STRING(ICoordinates2DArray)
129ARM_COMPUTE_TRACE_TO_STRING(IMultiImage)
Anthony Barbierb4670212018-05-18 16:55:39 +0100130using pair_uint = std::pair<unsigned int, unsigned int>;
Giorgio Arenac5a61392021-01-06 15:13:08 +0000131ARM_COMPUTE_TRACE_TO_STRING(pair_uint)
132ARM_COMPUTE_TRACE_TO_STRING(IKeyPointArray)
133ARM_COMPUTE_TRACE_TO_STRING(IDistribution1D)
134ARM_COMPUTE_TRACE_TO_STRING(IHOG)
135ARM_COMPUTE_TRACE_TO_STRING(ILut)
136ARM_COMPUTE_TRACE_TO_STRING(IPyramid)
137ARM_COMPUTE_TRACE_TO_STRING(IMultiHOG)
138ARM_COMPUTE_TRACE_TO_STRING(ISize2DArray)
139ARM_COMPUTE_TRACE_TO_STRING(MemoryGroup)
140ARM_COMPUTE_TRACE_TO_STRING(BoxNMSLimitInfo)
141ARM_COMPUTE_TRACE_TO_STRING(DepthwiseConvolutionReshapeInfo)
142ARM_COMPUTE_TRACE_TO_STRING(DWCWeightsKernelInfo)
143ARM_COMPUTE_TRACE_TO_STRING(DWCKernelInfo)
144ARM_COMPUTE_TRACE_TO_STRING(GEMMLHSMatrixInfo)
145ARM_COMPUTE_TRACE_TO_STRING(GEMMRHSMatrixInfo)
146ARM_COMPUTE_TRACE_TO_STRING(GEMMKernelInfo)
147ARM_COMPUTE_TRACE_TO_STRING(InstanceNormalizationLayerKernelInfo)
148ARM_COMPUTE_TRACE_TO_STRING(SoftmaxKernelInfo)
149ARM_COMPUTE_TRACE_TO_STRING(FuseBatchNormalizationType)
150ARM_COMPUTE_TRACE_TO_STRING(DirectConvolutionLayerOutputStageKernelInfo)
151ARM_COMPUTE_TRACE_TO_STRING(FFTScaleKernelInfo)
152ARM_COMPUTE_TRACE_TO_STRING(GEMMLowpOutputStageInfo)
153ARM_COMPUTE_TRACE_TO_STRING(FFT1DInfo)
154ARM_COMPUTE_TRACE_TO_STRING(FFT2DInfo)
155ARM_COMPUTE_TRACE_TO_STRING(FFTDigitReverseKernelInfo)
156ARM_COMPUTE_TRACE_TO_STRING(FFTRadixStageKernelInfo)
157ARM_COMPUTE_TRACE_TO_STRING(IWeightsManager)
158ARM_COMPUTE_TRACE_TO_STRING(Coordinates2D)
159ARM_COMPUTE_TRACE_TO_STRING(ITensorInfo)
160ARM_COMPUTE_TRACE_TO_STRING(InternalKeypoint)
161ARM_COMPUTE_TRACE_TO_STRING(arm_gemm::Nothing)
162ARM_COMPUTE_TRACE_TO_STRING(PixelValue)
163ARM_COMPUTE_TRACE_TO_STRING(std::allocator<ITensor const *>)
Anthony Barbierb4670212018-05-18 16:55:39 +0100164using array_f32 = std::array<float, 9ul>;
Giorgio Arenac5a61392021-01-06 15:13:08 +0000165ARM_COMPUTE_TRACE_TO_STRING(array_f32)
Anthony Barbierb4670212018-05-18 16:55:39 +0100166
Giorgio Arenac5a61392021-01-06 15:13:08 +0000167ARM_COMPUTE_CONST_REF_CLASS(arm_gemm::GemmArgs)
168ARM_COMPUTE_CONST_REF_CLASS(arm_gemm::Nothing)
169ARM_COMPUTE_CONST_REF_CLASS(arm_gemm::Activation)
170ARM_COMPUTE_CONST_REF_CLASS(DirectConvolutionLayerOutputStageKernelInfo)
171ARM_COMPUTE_CONST_REF_CLASS(GEMMLowpOutputStageInfo)
172ARM_COMPUTE_CONST_REF_CLASS(DWCWeightsKernelInfo)
173ARM_COMPUTE_CONST_REF_CLASS(DWCKernelInfo)
174ARM_COMPUTE_CONST_REF_CLASS(DepthwiseConvolutionReshapeInfo)
175ARM_COMPUTE_CONST_REF_CLASS(GEMMLHSMatrixInfo)
176ARM_COMPUTE_CONST_REF_CLASS(GEMMRHSMatrixInfo)
177ARM_COMPUTE_CONST_REF_CLASS(GEMMKernelInfo)
178ARM_COMPUTE_CONST_REF_CLASS(InstanceNormalizationLayerKernelInfo)
179ARM_COMPUTE_CONST_REF_CLASS(SoftmaxKernelInfo)
180ARM_COMPUTE_CONST_REF_CLASS(PaddingMode)
181ARM_COMPUTE_CONST_REF_CLASS(Coordinates)
182ARM_COMPUTE_CONST_REF_CLASS(FFT1DInfo)
183ARM_COMPUTE_CONST_REF_CLASS(FFT2DInfo)
184ARM_COMPUTE_CONST_REF_CLASS(FFTDigitReverseKernelInfo)
185ARM_COMPUTE_CONST_REF_CLASS(FFTRadixStageKernelInfo)
186ARM_COMPUTE_CONST_REF_CLASS(FFTScaleKernelInfo)
187ARM_COMPUTE_CONST_REF_CLASS(MemoryGroup)
188ARM_COMPUTE_CONST_REF_CLASS(IWeightsManager)
189ARM_COMPUTE_CONST_REF_CLASS(ActivationLayerInfo)
190ARM_COMPUTE_CONST_REF_CLASS(PoolingLayerInfo)
191ARM_COMPUTE_CONST_REF_CLASS(PadStrideInfo)
192ARM_COMPUTE_CONST_REF_CLASS(NormalizationLayerInfo)
193ARM_COMPUTE_CONST_REF_CLASS(Size2D)
194ARM_COMPUTE_CONST_REF_CLASS(WeightsInfo)
195ARM_COMPUTE_CONST_REF_CLASS(GEMMInfo)
196ARM_COMPUTE_CONST_REF_CLASS(GEMMReshapeInfo)
197ARM_COMPUTE_CONST_REF_CLASS(Window)
198ARM_COMPUTE_CONST_REF_CLASS(BorderSize)
199ARM_COMPUTE_CONST_REF_CLASS(BorderMode)
200ARM_COMPUTE_CONST_REF_CLASS(PhaseType)
201ARM_COMPUTE_CONST_REF_CLASS(MagnitudeType)
202ARM_COMPUTE_CONST_REF_CLASS(Termination)
203ARM_COMPUTE_CONST_REF_CLASS(ReductionOperation)
204ARM_COMPUTE_CONST_REF_CLASS(InterpolationPolicy)
205ARM_COMPUTE_CONST_REF_CLASS(SamplingPolicy)
206ARM_COMPUTE_CONST_REF_CLASS(DataType)
207ARM_COMPUTE_CONST_REF_CLASS(DataLayout)
208ARM_COMPUTE_CONST_REF_CLASS(Channel)
209ARM_COMPUTE_CONST_REF_CLASS(ConvertPolicy)
210ARM_COMPUTE_CONST_REF_CLASS(TensorShape)
211ARM_COMPUTE_CONST_REF_CLASS(PixelValue)
212ARM_COMPUTE_CONST_REF_CLASS(Strides)
213ARM_COMPUTE_CONST_REF_CLASS(WinogradInfo)
214ARM_COMPUTE_CONST_REF_CLASS(RoundingPolicy)
215ARM_COMPUTE_CONST_REF_CLASS(MatrixPattern)
216ARM_COMPUTE_CONST_REF_CLASS(NonLinearFilterFunction)
217ARM_COMPUTE_CONST_REF_CLASS(ThresholdType)
218ARM_COMPUTE_CONST_REF_CLASS(ROIPoolingLayerInfo)
219ARM_COMPUTE_CONST_REF_CLASS(BoundingBoxTransformInfo)
220ARM_COMPUTE_CONST_REF_CLASS(ComparisonOperation)
221ARM_COMPUTE_CONST_REF_CLASS(ArithmeticOperation)
222ARM_COMPUTE_CONST_REF_CLASS(BoxNMSLimitInfo)
223ARM_COMPUTE_CONST_REF_CLASS(FuseBatchNormalizationType)
224ARM_COMPUTE_CONST_REF_CLASS(ElementWiseUnary)
225ARM_COMPUTE_CONST_REF_CLASS(ComputeAnchorsInfo)
226ARM_COMPUTE_CONST_REF_CLASS(PriorBoxLayerInfo)
227ARM_COMPUTE_CONST_REF_CLASS(DetectionOutputLayerInfo)
228ARM_COMPUTE_CONST_REF_CLASS(Coordinates2D)
229ARM_COMPUTE_CONST_REF_CLASS(std::vector<const ITensor *>)
230ARM_COMPUTE_CONST_REF_CLASS(std::vector<ITensor *>)
231ARM_COMPUTE_CONST_REF_CLASS(std::vector<pair_uint>)
232ARM_COMPUTE_CONST_REF_CLASS(pair_uint)
233ARM_COMPUTE_CONST_REF_CLASS(array_f32)
Anthony Barbierb4670212018-05-18 16:55:39 +0100234
Giorgio Arenac5a61392021-01-06 15:13:08 +0000235ARM_COMPUTE_CONST_PTR_CLASS(ITensor)
236ARM_COMPUTE_CONST_PTR_CLASS(ITensorInfo)
237ARM_COMPUTE_CONST_PTR_CLASS(IWeightsManager)
238ARM_COMPUTE_CONST_PTR_CLASS(InternalKeypoint)
239ARM_COMPUTE_CONST_PTR_CLASS(IDetectionWindowArray)
240ARM_COMPUTE_CONST_PTR_CLASS(ICoordinates2DArray)
241ARM_COMPUTE_CONST_PTR_CLASS(IMultiImage)
242ARM_COMPUTE_CONST_PTR_CLASS(Window)
243ARM_COMPUTE_CONST_PTR_CLASS(IKeyPointArray)
244ARM_COMPUTE_CONST_PTR_CLASS(HOGInfo)
245ARM_COMPUTE_CONST_PTR_CLASS(IDistribution1D)
246ARM_COMPUTE_CONST_PTR_CLASS(IHOG)
247ARM_COMPUTE_CONST_PTR_CLASS(ILut)
248ARM_COMPUTE_CONST_PTR_CLASS(IPyramid)
249ARM_COMPUTE_CONST_PTR_CLASS(IMultiHOG)
250ARM_COMPUTE_CONST_PTR_CLASS(ISize2DArray)
251ARM_COMPUTE_CONST_PTR_CLASS(std::allocator<ITensor const *>)
252ARM_COMPUTE_CONST_PTR_CLASS(std::vector<unsigned int>)
Anthony Barbierb4670212018-05-18 16:55:39 +0100253
Giorgio Arenac5a61392021-01-06 15:13:08 +0000254ARM_COMPUTE_CONST_REF_SIMPLE(bool)
255ARM_COMPUTE_CONST_REF_SIMPLE(uint64_t)
256ARM_COMPUTE_CONST_REF_SIMPLE(int64_t)
257ARM_COMPUTE_CONST_REF_SIMPLE(uint32_t)
258ARM_COMPUTE_CONST_REF_SIMPLE(int32_t)
259ARM_COMPUTE_CONST_REF_SIMPLE(int16_t)
260ARM_COMPUTE_CONST_REF_SIMPLE(float)
Anthony Barbierb4670212018-05-18 16:55:39 +0100261
Giorgio Arenac5a61392021-01-06 15:13:08 +0000262ARM_COMPUTE_CONST_PTR_ADDRESS(float)
263ARM_COMPUTE_CONST_PTR_ADDRESS(uint8_t)
264ARM_COMPUTE_CONST_PTR_ADDRESS(void)
265ARM_COMPUTE_CONST_PTR_ADDRESS(short)
266ARM_COMPUTE_CONST_PTR_ADDRESS(int)
267ARM_COMPUTE_CONST_PTR_ADDRESS(uint64_t)
268ARM_COMPUTE_CONST_PTR_ADDRESS(uint32_t)
269ARM_COMPUTE_CONST_PTR_ADDRESS(uint16_t)
Anthony Barbierb4670212018-05-18 16:55:39 +0100270
271template <>
272TracePoint::Args &&operator<<(TracePoint::Args &&tp, const uint16_t &arg)
273{
274 tp.args.push_back("uint16_t(" + support::cpp11::to_string<unsigned int>(arg) + ")");
275 return std::move(tp);
276}
277
278template <>
279TracePoint::Args &&operator<<(TracePoint::Args &&tp, const uint8_t &arg)
280{
281 tp.args.push_back("uint8_t(" + support::cpp11::to_string<unsigned int>(arg) + ")");
282 return std::move(tp);
283}
284#endif /* DOXYGEN_SKIP_THIS */
285} // namespace arm_compute