blob: d67faad868b13b12085827d190770f645157253d [file] [log] [blame]
Anthony Barbierb4670212018-05-18 16:55:39 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2020 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
126TRACE_TO_STRING(ThresholdType)
127TRACE_TO_STRING(IDetectionWindowArray)
128TRACE_TO_STRING(ICoordinates2DArray)
129TRACE_TO_STRING(IMultiImage)
130using pair_uint = std::pair<unsigned int, unsigned int>;
131TRACE_TO_STRING(pair_uint)
132TRACE_TO_STRING(IKeyPointArray)
133TRACE_TO_STRING(IDistribution1D)
134TRACE_TO_STRING(IHOG)
135TRACE_TO_STRING(ILut)
136TRACE_TO_STRING(IPyramid)
137TRACE_TO_STRING(IMultiHOG)
138TRACE_TO_STRING(ISize2DArray)
139TRACE_TO_STRING(MemoryGroup)
140TRACE_TO_STRING(BoxNMSLimitInfo)
141TRACE_TO_STRING(DepthwiseConvolutionReshapeInfo)
142TRACE_TO_STRING(DWCWeightsKernelInfo)
143TRACE_TO_STRING(DWCKernelInfo)
144TRACE_TO_STRING(GEMMLHSMatrixInfo)
145TRACE_TO_STRING(GEMMRHSMatrixInfo)
146TRACE_TO_STRING(GEMMKernelInfo)
147TRACE_TO_STRING(InstanceNormalizationLayerKernelInfo)
148TRACE_TO_STRING(SoftmaxKernelInfo)
149TRACE_TO_STRING(FuseBatchNormalizationType)
150TRACE_TO_STRING(DirectConvolutionLayerOutputStageKernelInfo)
151TRACE_TO_STRING(FFTScaleKernelInfo)
152TRACE_TO_STRING(GEMMLowpOutputStageInfo)
153TRACE_TO_STRING(FFT1DInfo)
154TRACE_TO_STRING(FFT2DInfo)
155TRACE_TO_STRING(FFTDigitReverseKernelInfo)
156TRACE_TO_STRING(FFTRadixStageKernelInfo)
157TRACE_TO_STRING(IWeightsManager)
158TRACE_TO_STRING(Coordinates2D)
159TRACE_TO_STRING(ITensorInfo)
160TRACE_TO_STRING(InternalKeypoint)
161TRACE_TO_STRING(arm_gemm::Nothing)
162TRACE_TO_STRING(PixelValue)
163TRACE_TO_STRING(std::allocator<ITensor const *>)
164using array_f32 = std::array<float, 9ul>;
165TRACE_TO_STRING(array_f32)
166
167CONST_REF_CLASS(arm_gemm::GemmArgs)
168CONST_REF_CLASS(arm_gemm::Nothing)
169CONST_REF_CLASS(arm_gemm::Activation)
170CONST_REF_CLASS(DirectConvolutionLayerOutputStageKernelInfo)
171CONST_REF_CLASS(GEMMLowpOutputStageInfo)
172CONST_REF_CLASS(DWCWeightsKernelInfo)
173CONST_REF_CLASS(DWCKernelInfo)
174CONST_REF_CLASS(DepthwiseConvolutionReshapeInfo)
175CONST_REF_CLASS(GEMMLHSMatrixInfo)
176CONST_REF_CLASS(GEMMRHSMatrixInfo)
177CONST_REF_CLASS(GEMMKernelInfo)
178CONST_REF_CLASS(InstanceNormalizationLayerKernelInfo)
179CONST_REF_CLASS(SoftmaxKernelInfo)
180CONST_REF_CLASS(PaddingMode)
181CONST_REF_CLASS(Coordinates)
182CONST_REF_CLASS(FFT1DInfo)
183CONST_REF_CLASS(FFT2DInfo)
184CONST_REF_CLASS(FFTDigitReverseKernelInfo)
185CONST_REF_CLASS(FFTRadixStageKernelInfo)
186CONST_REF_CLASS(FFTScaleKernelInfo)
187CONST_REF_CLASS(MemoryGroup)
188CONST_REF_CLASS(IWeightsManager)
189CONST_REF_CLASS(ActivationLayerInfo)
190CONST_REF_CLASS(PoolingLayerInfo)
191CONST_REF_CLASS(PadStrideInfo)
192CONST_REF_CLASS(NormalizationLayerInfo)
193CONST_REF_CLASS(Size2D)
194CONST_REF_CLASS(WeightsInfo)
195CONST_REF_CLASS(GEMMInfo)
196CONST_REF_CLASS(GEMMReshapeInfo)
197CONST_REF_CLASS(Window)
198CONST_REF_CLASS(BorderSize)
199CONST_REF_CLASS(BorderMode)
200CONST_REF_CLASS(PhaseType)
201CONST_REF_CLASS(MagnitudeType)
202CONST_REF_CLASS(Termination)
203CONST_REF_CLASS(ReductionOperation)
204CONST_REF_CLASS(InterpolationPolicy)
205CONST_REF_CLASS(SamplingPolicy)
206CONST_REF_CLASS(DataType)
207CONST_REF_CLASS(DataLayout)
208CONST_REF_CLASS(Channel)
209CONST_REF_CLASS(ConvertPolicy)
210CONST_REF_CLASS(TensorShape)
211CONST_REF_CLASS(PixelValue)
212CONST_REF_CLASS(Strides)
213CONST_REF_CLASS(WinogradInfo)
214CONST_REF_CLASS(RoundingPolicy)
215CONST_REF_CLASS(MatrixPattern)
216CONST_REF_CLASS(NonLinearFilterFunction)
217CONST_REF_CLASS(ThresholdType)
218CONST_REF_CLASS(ROIPoolingLayerInfo)
219CONST_REF_CLASS(BoundingBoxTransformInfo)
220CONST_REF_CLASS(ComparisonOperation)
221CONST_REF_CLASS(ArithmeticOperation)
222CONST_REF_CLASS(BoxNMSLimitInfo)
223CONST_REF_CLASS(FuseBatchNormalizationType)
224CONST_REF_CLASS(ElementWiseUnary)
225CONST_REF_CLASS(ComputeAnchorsInfo)
226CONST_REF_CLASS(PriorBoxLayerInfo)
227CONST_REF_CLASS(DetectionOutputLayerInfo)
228CONST_REF_CLASS(Coordinates2D)
229CONST_REF_CLASS(std::vector<const ITensor *>)
230CONST_REF_CLASS(std::vector<ITensor *>)
231CONST_REF_CLASS(std::vector<pair_uint>)
232CONST_REF_CLASS(pair_uint)
233CONST_REF_CLASS(array_f32)
234
235CONST_PTR_CLASS(ITensor)
236CONST_PTR_CLASS(ITensorInfo)
237CONST_PTR_CLASS(IWeightsManager)
238CONST_PTR_CLASS(InternalKeypoint)
239CONST_PTR_CLASS(IDetectionWindowArray)
240CONST_PTR_CLASS(ICoordinates2DArray)
241CONST_PTR_CLASS(IMultiImage)
242CONST_PTR_CLASS(Window)
243CONST_PTR_CLASS(IKeyPointArray)
244CONST_PTR_CLASS(HOGInfo)
245CONST_PTR_CLASS(IDistribution1D)
246CONST_PTR_CLASS(IHOG)
247CONST_PTR_CLASS(ILut)
248CONST_PTR_CLASS(IPyramid)
249CONST_PTR_CLASS(IMultiHOG)
250CONST_PTR_CLASS(ISize2DArray)
251CONST_PTR_CLASS(std::allocator<ITensor const *>)
252CONST_PTR_CLASS(std::vector<unsigned int>)
253
254CONST_REF_SIMPLE(bool)
255CONST_REF_SIMPLE(uint64_t)
256CONST_REF_SIMPLE(int64_t)
257CONST_REF_SIMPLE(uint32_t)
258CONST_REF_SIMPLE(int32_t)
259CONST_REF_SIMPLE(int16_t)
260CONST_REF_SIMPLE(float)
261
262CONST_PTR_ADDRESS(float)
263CONST_PTR_ADDRESS(uint8_t)
264CONST_PTR_ADDRESS(void)
265CONST_PTR_ADDRESS(short)
266CONST_PTR_ADDRESS(int)
267CONST_PTR_ADDRESS(uint64_t)
268CONST_PTR_ADDRESS(uint32_t)
269CONST_PTR_ADDRESS(uint16_t)
270
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