Tensor Tiling Library
 
Loading...
Searching...
No Matches
TTL_debug.h
Go to the documentation of this file.
1/*
2 * TTL_debug.h
3 *
4 * Copyright (c) 2023 Mobileye
5 *
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19/**
20 * @def __TTL_create_dumper
21 * @brief Create a call the provides a CR as well
22 *
23 * When using dump functions from the code we generally want a CR.
24 */
25
26/**
27 * @brief Print a debug copy of a TTL_shape_t type
28 *
29 * Output debug of the TTL_shape_t passed using printf
30 *
31 * @param ttl_shape The tile to print debug info for.
32 */
33static inline void __TTL_dump_shape_t(const TTL_shape_t *const ttl_shape) {
34 printf("TTL_shape_t: %d,%d,%d ", ttl_shape->width, ttl_shape->height, ttl_shape->depth);
35}
36
37static inline void __TTL_dump_shape(const TTL_shape_t *const variable) {
38 __TTL_dump_shape_t(variable);
39 printf("\n");
40};
41
42/**
43 * @brief Print a debug copy of a TTL_layout_t type
44 *
45 * Output debug of the TTL_layout_t passed using printf
46 *
47 * @param ttl_layout The tile to print debug info for.
48 */
49static inline void __TTL_dump_layout_t(const TTL_layout_t *const ttl_layout) {
50 printf("TTL_layout_t: %d,%d ", ttl_layout->row_spacing, ttl_layout->plane_spacing);
51}
52
53static inline void __TTL_dump_layout(const TTL_layout_t *const variable) {
54 __TTL_dump_layout_t(variable);
55 printf("\n");
56};
57
58/**
59 * @brief Print a debug copy of a TTL_offset_t type
60 *
61 * Output debug of the TTL_offset_t passed using printf
62 *
63 * @param ttl_offset The offset 3d to print debug info for.
64 */
65static inline void __TTL_dump_offset_t(const TTL_offset_t *const ttl_offset) {
66 printf("TTL_offset_t: %d,%d,%d ", ttl_offset->x, ttl_offset->y, ttl_offset->z);
67}
68
69static inline void __TTL_dump_offset(const TTL_offset_t *const variable) {
70 __TTL_dump_offset_t(variable);
71 printf("\n");
72};
73
74/**
75 * @brief Print a debug copy of a TTL_overlap_t type
76 *
77 * Output debug of the TTL_overlap_t passed using printf
78 *
79 * @param ttl_overlap The overlap to print debug info for.
80 */
81static inline void __TTL_dump_overlap_t(const TTL_overlap_t *const ttl_overlap) {
82 printf("TTL_overlap_t: %d,%d,%d ", ttl_overlap->width, ttl_overlap->height, ttl_overlap->depth);
83}
84
85static inline void __TTL_dump_overlap(const TTL_overlap_t *const variable) {
86 __TTL_dump_overlap_t(variable);
87 printf("\n");
88};
89
90/**
91 * @brief Print a debug copy of a TTL_augmentation_t type
92 *
93 * Output debug of the TTL_augmentation_t passed using printf
94 *
95 * @param ttl_augmented The overlap to print debug info for.
96 */
97static inline void __TTL_dump_augmentation_t(const TTL_augmentation_t *const ttl_augmented) {
98 printf("TTL_augmentation_t: (%d,%d),(%d,%d),(%d,%d), ",
99 ttl_augmented->left,
100 ttl_augmented->right,
101 ttl_augmented->top,
102 ttl_augmented->bottom,
103 ttl_augmented->front,
104 ttl_augmented->back);
105}
106
107static inline void __TTL_dump_augmentation(const TTL_augmentation_t *const variable) {
108 __TTL_dump_augmentation_t(variable);
109 printf("\n");
110};
111
112/**
113 * @brief Print a debug copy of a TTL_tile_t type
114 *
115 * Output debug of the TTL_tile_t passed using printf
116 *
117 * @param ttl_tile The tile to print debug info for.
118 */
119static inline void __TTL_dump_tile_t(const TTL_tile_t *const ttl_tile) {
120 printf("TTL_tile_t: ");
121 __TTL_dump_shape_t(&ttl_tile->shape);
122 __TTL_dump_offset_t(&ttl_tile->offset);
123}
124
125static inline void __TTL_dump_tile(const TTL_tile_t *const variable) {
126 __TTL_dump_tile_t(variable);
127 printf("\n");
128};
129
130/**
131 * @brief Print a debug copy of a TTL_int_tensor_t type
132 *
133 * Output debug of the TTL_tile_t passed using printf
134 *
135 * @param ttl_int_tensor The internal tensor to print debug info for.
136 */
137static inline void __TTL_dump_const_int_tensor_t(const TTL_const_int_tensor_t *const ttl_int_tensor) {
138 printf("TTL_int_tensor_t: %p,%d ", ttl_int_tensor->base, ttl_int_tensor->elem_size);
139 __TTL_dump_layout_t(&ttl_int_tensor->layout);
140 __TTL_dump_shape_t(&ttl_int_tensor->shape);
141}
142
143static inline void __TTL_dump_int_tensor_t(const TTL_int_tensor_t *const ttl_int_tensor) {
144 __TTL_dump_const_int_tensor_t(TTL_to_const_tensor(ttl_int_tensor));
145}
146
147static inline void __TTL_dump_int_tensor(const TTL_int_tensor_t *const variable) {
148 __TTL_dump_int_tensor_t(variable);
149 printf("\n");
150};
151
152/**
153 * @brief Print a debug copy of a TTL_int_sub_tensor_t type
154 *
155 * Output debug of the TTL_int_sub_tensor_t passed using printf
156 *
157 * @param ttl_int_sub_tensor The internal tensor to print debug info for.
158 */
159static inline void __TTL_dump_int_sub_tensor_t(const TTL_int_sub_tensor_t *const ttl_int_sub_tensor) {
160 printf("TTL_int_sub_tensor_t: ");
161 __TTL_dump_int_tensor_t(&ttl_int_sub_tensor->tensor);
162 __TTL_dump_shape(&ttl_int_sub_tensor->origin.shape);
163 __TTL_dump_offset_t(&ttl_int_sub_tensor->origin.sub_offset);
164}
165
166static inline void __TTL_dump_int_sub_tensor(const TTL_int_sub_tensor_t *const variable) {
167 __TTL_dump_int_sub_tensor_t(variable);
168 printf("\n");
169};
170
171/**
172 * @brief Print a debug copy of a TTL_ext_tensor_t type
173 *
174 * Output debug of the TTL_tile_t passed using printf
175 *
176 * @param ttl_ext_tensor The external tensor to print debug info for.
177 */
178static inline void __TTL_dump_const_ext_tensor_t(const TTL_const_ext_tensor_t *const ttl_const_ext_tensor) {
179 printf("TTL_ext_tensor_t: "
180 "%p"
181 ",%d ",
182 (__global void *)ttl_const_ext_tensor->base,
183 ttl_const_ext_tensor->elem_size);
184 __TTL_dump_layout_t(&ttl_const_ext_tensor->layout);
185 __TTL_dump_shape_t(&ttl_const_ext_tensor->shape);
186}
187
188static inline void __TTL_dump_ext_tensor_t(const TTL_ext_tensor_t *const ttl_ext_tensor) {
189 __TTL_dump_const_ext_tensor_t(TTL_to_const_tensor(ttl_ext_tensor));
190}
191
192static inline void __TTL_dump_ext_tensor(const TTL_ext_tensor_t *const variable) {
193 __TTL_dump_ext_tensor_t(variable);
194 printf("\n");
195};
196
197/**
198 * @brief Print a debug copy of a TTL_tiler_t type
199 *
200 * Output debug of the TTL_tiler_t passed using printf
201 *
202 * @param ttl_tiler The tiler to print debug info for.
203 */
204static inline void __TTL_dump_tiler_t(const TTL_tiler_t *const ttl_tiler) {
205 printf("TTL_tiler_t: ");
206 __TTL_dump_shape_t(&ttl_tiler->space);
207 __TTL_dump_shape_t(&ttl_tiler->tile);
208 __TTL_dump_overlap_t(&ttl_tiler->overlap);
209 printf("Cache: %d,%d,%d,%d,%d ",
210 ttl_tiler->cache.number_of_tiles,
211 ttl_tiler->cache.tiles_in_width,
212 ttl_tiler->cache.tiles_in_height,
213 ttl_tiler->cache.tiles_in_depth,
214 ttl_tiler->cache.tiles_in_plane);
215}
216
217static inline void __TTL_dump_tiler(const TTL_tiler_t *const variable) {
218 __TTL_dump_tiler_t(variable);
219 printf("\n");
220};
221
222/**
223 * @brief Internal non-API helper function to allow debugging of exports and
224 * imports
225 *
226 * @param is_export
227 * @param internal_tensor
228 * @param external_tensor
229 * @param access_type
230 * @param event
231 * @param line
232 */
233static inline void __TTL_dump_transaction(const bool is_export, const TTL_const_int_tensor_t *const internal_tensor,
234 const TTL_const_ext_tensor_t *const external_tensor, const int access_type,
235 const TTL_event_t *const event, const unsigned int line) {
236 printf(is_export ? "Export " : "Import ");
237 __TTL_dump_shape_t(&internal_tensor->shape);
238 __TTL_dump_event(event);
239 printf(" AccessType: %d\n ", access_type);
240 __TTL_dump_const_ext_tensor_t(external_tensor);
241 printf("\n ");
242 __TTL_dump_const_int_tensor_t(internal_tensor);
243 printf("\n line: %d\n", line);
244}
245
246static inline void __TTL_dump_wait(int num_events, TTL_event_t *events, const unsigned int line) {
247 printf("TTL_WAIT: ");
248 for (int i = 0; i < num_events; i++) {
249 __TTL_dump_event(&events[i]);
250 }
251 printf("\n line: %d\n", line);
252}
TTL_const_ext_void_tensor_t TTL_const_ext_tensor_t
TTL_ext_void_tensor_t TTL_ext_tensor_t
static const TTL_const_ext_void_tensor_t * TTL_to_const_tensor(const TTL_ext_void_tensor_t *const tensor)
TTL_int_void_sub_tensor_t TTL_int_sub_tensor_t
TTL_const_int_void_tensor_t TTL_const_int_tensor_t
TTL_int_void_tensor_t TTL_int_tensor_t
event_t TTL_event_t
TTL_event_t is a pseudonym for OpenCL event_t.
#define __global
The opencl __global namespace is not supported in C.
Definition c/TTL_types.h:26
3D description of the augmented margins
Definition TTL_tiles.h:49
TTL_augmented_dim_t right
Right hand augmentation in elements.
Definition TTL_tiles.h:51
TTL_augmented_dim_t back
Back augmentation in elements.
Definition TTL_tiles.h:55
TTL_augmented_dim_t bottom
Bottom augmentation in elements.
Definition TTL_tiles.h:53
TTL_augmented_dim_t top
Top augmentation in elements.
Definition TTL_tiles.h:52
TTL_augmented_dim_t left
Left hand augmentation in elements.
Definition TTL_tiles.h:50
TTL_augmented_dim_t front
Front augmentation in elements.
Definition TTL_tiles.h:54
struct TTL_int_void_sub_tensor_t::@266046156211021141270372070244026262143005251323 origin
Description of a Tensor layout in memory.
TTL_dim_t row_spacing
The distance between the start of consequtive rows in units of elements.
TTL_dim_t plane_spacing
The distance between the start of consequtive planes in units of elements.
Description of the 3D offset of an object.
TTL_offset_dim_t z
Offset in dimension z.
TTL_offset_dim_t y
Offset in dimension y.
TTL_offset_dim_t x
Offset in dimension x.
Description of the overlap in 3D space of adjacent tiles.
TTL_overlap_dim_t depth
depth overlap in elements
TTL_overlap_dim_t height
height overlap in elements
TTL_overlap_dim_t width
width overlap in elements
Description of a Shape.
TTL_dim_t depth
Number of planes along dimension z.
TTL_dim_t width
Number of elements along dimension x.
TTL_dim_t height
Number of rows along dimension y.
TTL_offset_t offset
Definition TTL_tiles.h:126
TTL_shape_t shape
Definition TTL_tiles.h:125
TTL_tiler_t is the basic unit that describes how a tile is subdivided.
Definition TTL_tiles.h:135
TTL_dim_t tiles_in_width
Definition TTL_tiles.h:147
struct TTL_tiler_t::@346103000177117034076065313020113027262217277043 cache
Precomputed information to speed up later reuse.
TTL_shape_t tile
Definition TTL_tiles.h:137
TTL_overlap_t overlap
When zeroes represent no overlap.
Definition TTL_tiles.h:139
TTL_dim_t tiles_in_depth
Definition TTL_tiles.h:149
TTL_dim_t tiles_in_plane
Definition TTL_tiles.h:150
TTL_shape_t space
Represents the space to be tiled such as an image.
Definition TTL_tiles.h:136
TTL_dim_t tiles_in_height
Definition TTL_tiles.h:148
TTL_dim_t number_of_tiles
Definition TTL_tiles.h:146