• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 Arm Limited.
3  *
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"
36 #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"
41 #include "src/core/NEON/kernels/assembly/arm_gemm.hpp"
42 #include "utils/TypePrinter.h"
43 
44 #include <array>
45 #include <cstdio>
46 
47 namespace arm_compute
48 {
49 #ifndef DOXYGEN_SKIP_THIS
50 int TracePoint::g_depth = 0;
51 
TracePoint(Layer layer,const std::string & class_name,void * object,Args && args)52 TracePoint::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 
~TracePoint()71 TracePoint::~TracePoint()
72 {
73     --g_depth;
74 }
75 
to_string(const arm_gemm::Activation & arg)76 std::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 
to_string(const arm_gemm::GemmArgs & arg)92 std::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 
to_string(const ITensor & arg)112 std::string to_string(const ITensor &arg)
113 {
114     std::stringstream str;
115     str << "TensorInfo(" << *arg.info() << ")";
116     return str.str();
117 }
118 
to_ptr_string(const void * arg)119 std::string to_ptr_string(const void *arg)
120 {
121     std::stringstream ss;
122     ss << arg;
123     return ss.str();
124 }
125 
126 TRACE_TO_STRING(ThresholdType)
127 TRACE_TO_STRING(IDetectionWindowArray)
128 TRACE_TO_STRING(ICoordinates2DArray)
129 TRACE_TO_STRING(IMultiImage)
130 using pair_uint = std::pair<unsigned int, unsigned int>;
131 TRACE_TO_STRING(pair_uint)
132 TRACE_TO_STRING(IKeyPointArray)
133 TRACE_TO_STRING(IDistribution1D)
134 TRACE_TO_STRING(IHOG)
135 TRACE_TO_STRING(ILut)
136 TRACE_TO_STRING(IPyramid)
137 TRACE_TO_STRING(IMultiHOG)
138 TRACE_TO_STRING(ISize2DArray)
139 TRACE_TO_STRING(MemoryGroup)
140 TRACE_TO_STRING(BoxNMSLimitInfo)
141 TRACE_TO_STRING(DepthwiseConvolutionReshapeInfo)
142 TRACE_TO_STRING(DWCWeightsKernelInfo)
143 TRACE_TO_STRING(DWCKernelInfo)
144 TRACE_TO_STRING(GEMMLHSMatrixInfo)
145 TRACE_TO_STRING(GEMMRHSMatrixInfo)
146 TRACE_TO_STRING(GEMMKernelInfo)
147 TRACE_TO_STRING(InstanceNormalizationLayerKernelInfo)
148 TRACE_TO_STRING(SoftmaxKernelInfo)
149 TRACE_TO_STRING(FuseBatchNormalizationType)
150 TRACE_TO_STRING(DirectConvolutionLayerOutputStageKernelInfo)
151 TRACE_TO_STRING(FFTScaleKernelInfo)
152 TRACE_TO_STRING(GEMMLowpOutputStageInfo)
153 TRACE_TO_STRING(FFT1DInfo)
154 TRACE_TO_STRING(FFT2DInfo)
155 TRACE_TO_STRING(FFTDigitReverseKernelInfo)
156 TRACE_TO_STRING(FFTRadixStageKernelInfo)
157 TRACE_TO_STRING(IWeightsManager)
158 TRACE_TO_STRING(Coordinates2D)
159 TRACE_TO_STRING(ITensorInfo)
160 TRACE_TO_STRING(InternalKeypoint)
161 TRACE_TO_STRING(arm_gemm::Nothing)
162 TRACE_TO_STRING(PixelValue)
163 TRACE_TO_STRING(std::allocator<ITensor const *>)
164 using array_f32 = std::array<float, 9ul>;
165 TRACE_TO_STRING(array_f32)
166 
167 CONST_REF_CLASS(arm_gemm::GemmArgs)
168 CONST_REF_CLASS(arm_gemm::Nothing)
169 CONST_REF_CLASS(arm_gemm::Activation)
170 CONST_REF_CLASS(DirectConvolutionLayerOutputStageKernelInfo)
171 CONST_REF_CLASS(GEMMLowpOutputStageInfo)
172 CONST_REF_CLASS(DWCWeightsKernelInfo)
173 CONST_REF_CLASS(DWCKernelInfo)
174 CONST_REF_CLASS(DepthwiseConvolutionReshapeInfo)
175 CONST_REF_CLASS(GEMMLHSMatrixInfo)
176 CONST_REF_CLASS(GEMMRHSMatrixInfo)
177 CONST_REF_CLASS(GEMMKernelInfo)
178 CONST_REF_CLASS(InstanceNormalizationLayerKernelInfo)
179 CONST_REF_CLASS(SoftmaxKernelInfo)
180 CONST_REF_CLASS(PaddingMode)
181 CONST_REF_CLASS(Coordinates)
182 CONST_REF_CLASS(FFT1DInfo)
183 CONST_REF_CLASS(FFT2DInfo)
184 CONST_REF_CLASS(FFTDigitReverseKernelInfo)
185 CONST_REF_CLASS(FFTRadixStageKernelInfo)
186 CONST_REF_CLASS(FFTScaleKernelInfo)
187 CONST_REF_CLASS(MemoryGroup)
188 CONST_REF_CLASS(IWeightsManager)
189 CONST_REF_CLASS(ActivationLayerInfo)
190 CONST_REF_CLASS(PoolingLayerInfo)
191 CONST_REF_CLASS(PadStrideInfo)
192 CONST_REF_CLASS(NormalizationLayerInfo)
193 CONST_REF_CLASS(Size2D)
194 CONST_REF_CLASS(WeightsInfo)
195 CONST_REF_CLASS(GEMMInfo)
196 CONST_REF_CLASS(GEMMReshapeInfo)
197 CONST_REF_CLASS(Window)
198 CONST_REF_CLASS(BorderSize)
199 CONST_REF_CLASS(BorderMode)
200 CONST_REF_CLASS(PhaseType)
201 CONST_REF_CLASS(MagnitudeType)
202 CONST_REF_CLASS(Termination)
203 CONST_REF_CLASS(ReductionOperation)
204 CONST_REF_CLASS(InterpolationPolicy)
205 CONST_REF_CLASS(SamplingPolicy)
206 CONST_REF_CLASS(DataType)
207 CONST_REF_CLASS(DataLayout)
208 CONST_REF_CLASS(Channel)
209 CONST_REF_CLASS(ConvertPolicy)
210 CONST_REF_CLASS(TensorShape)
211 CONST_REF_CLASS(PixelValue)
212 CONST_REF_CLASS(Strides)
213 CONST_REF_CLASS(WinogradInfo)
214 CONST_REF_CLASS(RoundingPolicy)
215 CONST_REF_CLASS(MatrixPattern)
216 CONST_REF_CLASS(NonLinearFilterFunction)
217 CONST_REF_CLASS(ThresholdType)
218 CONST_REF_CLASS(ROIPoolingLayerInfo)
219 CONST_REF_CLASS(BoundingBoxTransformInfo)
220 CONST_REF_CLASS(ComparisonOperation)
221 CONST_REF_CLASS(ArithmeticOperation)
222 CONST_REF_CLASS(BoxNMSLimitInfo)
223 CONST_REF_CLASS(FuseBatchNormalizationType)
224 CONST_REF_CLASS(ElementWiseUnary)
225 CONST_REF_CLASS(ComputeAnchorsInfo)
226 CONST_REF_CLASS(PriorBoxLayerInfo)
227 CONST_REF_CLASS(DetectionOutputLayerInfo)
228 CONST_REF_CLASS(Coordinates2D)
229 CONST_REF_CLASS(std::vector<const ITensor *>)
230 CONST_REF_CLASS(std::vector<ITensor *>)
231 CONST_REF_CLASS(std::vector<pair_uint>)
232 CONST_REF_CLASS(pair_uint)
233 CONST_REF_CLASS(array_f32)
234 
235 CONST_PTR_CLASS(ITensor)
236 CONST_PTR_CLASS(ITensorInfo)
237 CONST_PTR_CLASS(IWeightsManager)
238 CONST_PTR_CLASS(InternalKeypoint)
239 CONST_PTR_CLASS(IDetectionWindowArray)
240 CONST_PTR_CLASS(ICoordinates2DArray)
241 CONST_PTR_CLASS(IMultiImage)
242 CONST_PTR_CLASS(Window)
243 CONST_PTR_CLASS(IKeyPointArray)
244 CONST_PTR_CLASS(HOGInfo)
245 CONST_PTR_CLASS(IDistribution1D)
246 CONST_PTR_CLASS(IHOG)
247 CONST_PTR_CLASS(ILut)
248 CONST_PTR_CLASS(IPyramid)
249 CONST_PTR_CLASS(IMultiHOG)
250 CONST_PTR_CLASS(ISize2DArray)
251 CONST_PTR_CLASS(std::allocator<ITensor const *>)
252 CONST_PTR_CLASS(std::vector<unsigned int>)
253 
254 CONST_REF_SIMPLE(bool)
255 CONST_REF_SIMPLE(uint64_t)
256 CONST_REF_SIMPLE(int64_t)
257 CONST_REF_SIMPLE(uint32_t)
258 CONST_REF_SIMPLE(int32_t)
259 CONST_REF_SIMPLE(int16_t)
260 CONST_REF_SIMPLE(float)
261 
262 CONST_PTR_ADDRESS(float)
263 CONST_PTR_ADDRESS(uint8_t)
264 CONST_PTR_ADDRESS(void)
265 CONST_PTR_ADDRESS(short)
266 CONST_PTR_ADDRESS(int)
267 CONST_PTR_ADDRESS(uint64_t)
268 CONST_PTR_ADDRESS(uint32_t)
269 CONST_PTR_ADDRESS(uint16_t)
270 
271 template <>
272 TracePoint::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 
278 template <>
operator <<(TracePoint::Args && tp,const uint8_t & arg)279 TracePoint::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
286