Skip to content

Commit a89e019

Browse files
FarenlaytJaccovG
authored andcommitted
Add pragmas and remove extra variables
1 parent cae4521 commit a89e019

17 files changed

+98
-47
lines changed

lib/gen/codegen.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ def set_wrapper_hierarchy(self, varlist):
147147

148148
def set_wrapper_variables(self, variables):
149149
self.wrapper_variables.update(variables)
150+
151+
def clean_wrapper_variables(self):
152+
self.wrapper_variables = {}
150153

151154
def print_variables(self):
152155
string = ""

lib/gen/mli_krn_avepool_gen.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,12 @@
107107
# Generate the output file
108108
#------------------------------------------------------------
109109
c = Codegen()
110-
c.set_wrapper_variables({'stride_w' : "cfg->stride_width", 'stride_h' : "cfg->stride_height"})
111110
c.set_wrapper_variables({'kernel_w' : "cfg->kernel_width", 'kernel_h' : "cfg->kernel_height"})
112111
c.set_wrapper_variables({'padding_top' : "cfg->padding_top"})
113112
c.set_wrapper_variables({'padding_bot' : "cfg->padding_bottom"})
114113
c.set_wrapper_variables({'padding_left' : "cfg->padding_left"})
115114
c.set_wrapper_variables({'padding_right' : "cfg->padding_right"})
116-
c.set_wrapper_hierarchy(['stride_w', 'stride_h', 'kernel_w', 'kernel_h', 'padding'])
115+
c.set_wrapper_hierarchy(['kernel_w', 'kernel_h', 'padding'])
117116
c.set_wrapper_if_tree(False)
118117

119118
#------------------------------------------------------------

lib/gen/mli_krn_conv2d_gen.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,12 @@
263263
# Generate the HWC output file
264264
#------------------------------------------------------------
265265
c = Codegen()
266-
c.set_wrapper_variables({'stride_w' : "cfg->stride_width", 'stride_h' : "cfg->stride_height"})
267266
c.set_wrapper_variables({'kernel_w' : "weights->shape[KRNL_W_DIM_HWC]", 'kernel_h' : "weights->shape[KRNL_H_DIM_HWC]"})
268-
c.set_wrapper_variables({'in_ch' : "in->shape[KRNL_C_DIM_HWC]"})
269267
c.set_wrapper_variables({'padding_top' : "cfg->padding_top"})
270268
c.set_wrapper_variables({'padding_bot' : "cfg->padding_bottom"})
271269
c.set_wrapper_variables({'padding_left' : "cfg->padding_left"})
272270
c.set_wrapper_variables({'padding_right' : "cfg->padding_right"})
273-
c.set_wrapper_hierarchy(['stride_w', 'stride_h', 'kernel_w', 'kernel_h', 'in_ch', 'padding'])
271+
c.set_wrapper_hierarchy(['kernel_w', 'kernel_h', 'padding'])
274272
c.set_wrapper_if_tree(False)
275273

276274
if "sa8_sa8_sa32" in sys.argv or no_args:

lib/gen/mli_krn_maxpool_gen.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@
164164
# Create a new list of specialization functions for hwc fx8
165165
#------------------------------------------------------------
166166

167+
c.clean_wrapper_variables()
168+
c.set_wrapper_variables({'kernel_w' : "cfg->kernel_width", 'kernel_h' : "cfg->kernel_height"})
169+
c.set_wrapper_variables({'padding_top' : "cfg->padding_top"})
170+
c.set_wrapper_variables({'padding_bot' : "cfg->padding_bottom"})
171+
c.set_wrapper_variables({'padding_left' : "cfg->padding_left"})
172+
c.set_wrapper_variables({'padding_right' : "cfg->padding_right"})
173+
c.set_wrapper_hierarchy(['kernel_w', 'kernel_h', 'padding'])
174+
c.set_wrapper_if_tree(False)
175+
167176
fbase = ("krn", "maxpool", "hwc", "fx8", f_args)
168177

169178
f_list_hwc_fx8 = [f.copy_and_replace_base(fbase) for f in f_list_hwc]

lib/src/kernels/convolution/mli_krn_conv2d_nhwc_sa8_sa8_sa32.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,8 @@ mli_status mli_krn_conv2d_nhwc_sa8_sa8_sa32(
588588
const mli_tensor * bias,
589589
const mli_conv2d_cfg * cfg,
590590
mli_tensor * out) {
591-
int stride_w = cfg->stride_width;
592-
int stride_h = cfg->stride_height;
593591
int kernel_w = weights->shape[KRNL_W_DIM_HWC];
594592
int kernel_h = weights->shape[KRNL_H_DIM_HWC];
595-
int in_ch = in->shape[KRNL_C_DIM_HWC];
596593
int padding_top = cfg->padding_top;
597594
int padding_bot = cfg->padding_bottom;
598595
int padding_left = cfg->padding_left;
@@ -618,11 +615,8 @@ char * mli_debug_krn_conv2d_nhwc_sa8_sa8_sa32(
618615
const mli_tensor * bias,
619616
const mli_conv2d_cfg * cfg,
620617
mli_tensor * out) {
621-
int stride_w = cfg->stride_width;
622-
int stride_h = cfg->stride_height;
623618
int kernel_w = weights->shape[KRNL_W_DIM_HWC];
624619
int kernel_h = weights->shape[KRNL_H_DIM_HWC];
625-
int in_ch = in->shape[KRNL_C_DIM_HWC];
626620
int padding_top = cfg->padding_top;
627621
int padding_bot = cfg->padding_bottom;
628622
int padding_left = cfg->padding_left;

lib/src/kernels/convolution/mli_krn_dotprod.h

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ static void __attribute__ ((always_inline)) dotprod2D_hwc_v (
6060
in_row_step -= width * in_col_step;
6161
kern_row_step -= width * kern_col_step;
6262

63+
#pragma clang diagnostic push
64+
#pragma clang diagnostic ignored "-Wpass-failed"
6365
#pragma clang loop unroll(full)
6466
for (int32_t row = 0; row < height; row++) {
6567
#pragma clang loop unroll(full)
@@ -73,6 +75,7 @@ static void __attribute__ ((always_inline)) dotprod2D_hwc_v (
7375
in += in_row_step;
7476
krn += kern_row_step;
7577
}
78+
#pragma clang diagnostic pop
7679
}
7780

7881
//The function uses pointers to pointers for in and krn.
@@ -91,7 +94,8 @@ static void __attribute__ ((always_inline)) dotprod2D_hwc_d (
9194
int kern_row_step) {
9295
in_row_step -= width * in_col_step;
9396
kern_row_step -= width * kern_col_step;
94-
97+
#pragma clang diagnostic push
98+
#pragma clang diagnostic ignored "-Wpass-failed"
9599
#pragma clang loop unroll(full)
96100
for (int32_t row = 0; row < height; row++) {
97101
#pragma clang loop unroll(full)
@@ -103,6 +107,7 @@ static void __attribute__ ((always_inline)) dotprod2D_hwc_d (
103107
*in += in_row_step;
104108
*krn += kern_row_step;
105109
}
110+
#pragma clang diagnostic pop
106111
}
107112

108113
//The function uses pointers to pointers for in and krn.
@@ -122,6 +127,8 @@ static void __attribute__ ((always_inline)) dotprod2D_hwc_v (
122127

123128
in_row_step -= width * in_col_step;
124129
kern_row_step -= width * kern_col_step;
130+
#pragma clang diagnostic push
131+
#pragma clang diagnostic ignored "-Wpass-failed"
125132
#pragma clang loop unroll(full)
126133
for (int32_t row = 0; row < height; row++) {
127134
#pragma clang loop unroll(full)
@@ -135,6 +142,7 @@ static void __attribute__ ((always_inline)) dotprod2D_hwc_v (
135142
*in += in_row_step;
136143
*krn += kern_row_step;
137144
}
145+
#pragma clang diagnostic pop
138146
}
139147

140148
//The function uses pointers to pointers for in and krn.
@@ -154,6 +162,8 @@ static acc_T __attribute__ ((always_inline)) dotprod2D_inp_width_v(
154162
int in_width_step) {
155163
in_row_step -= width * in_col_step;
156164
kern_row_step -= width * kern_col_step;
165+
#pragma clang diagnostic push
166+
#pragma clang diagnostic ignored "-Wpass-failed"
157167
#pragma clang loop unroll(full)
158168
for (int row = 0; row < height; row++) {
159169
#pragma clang loop unroll(full)
@@ -168,6 +178,7 @@ static acc_T __attribute__ ((always_inline)) dotprod2D_inp_width_v(
168178
*inp += in_row_step;
169179
*krn += kern_row_step;
170180
}
181+
#pragma clang diagnostic pop
171182
return *accu;
172183
}
173184

@@ -212,7 +223,8 @@ static void __attribute__ ((always_inline)) dotprod2D_hwc_d (
212223
int kern_row_step) {
213224
in_row_step -= width * in_col_step;
214225
kern_row_step -= width * kern_col_step;
215-
226+
#pragma clang diagnostic push
227+
#pragma clang diagnostic ignored "-Wpass-failed"
216228
#pragma clang loop unroll(full)
217229
for (int32_t row = 0; row < height; row++) {
218230
#pragma clang loop unroll(full)
@@ -224,6 +236,7 @@ static void __attribute__ ((always_inline)) dotprod2D_hwc_d (
224236
in += in_row_step;
225237
krn += kern_row_step;
226238
}
239+
#pragma clang diagnostic pop
227240
}
228241

229242
template < typename in_T, typename w_T, typename acc_T >
@@ -248,6 +261,8 @@ static inline void __attribute__ ((always_inline)) dotprod2D (
248261
in_row_step -= width;
249262
kern_row_step -= width;
250263
__builtin_assume (height > 0);
264+
#pragma clang diagnostic push
265+
#pragma clang diagnostic ignored "-Wpass-failed"
251266
#pragma clang loop unroll(full)
252267
for (int row = 0; row < height; row++) {
253268
#pragma clang loop unroll(full)
@@ -257,6 +272,7 @@ static inline void __attribute__ ((always_inline)) dotprod2D (
257272
in += in_row_step;
258273
krn += kern_row_step;
259274
}
275+
#pragma clang diagnostic pop
260276
}
261277

262278
template < typename in_T, typename w_T, typename acc_T >
@@ -272,6 +288,8 @@ static inline void __attribute__ ((always_inline)) dotprod2D_unroll2 (
272288

273289
in_row_step -= width;
274290
kern_row_step -= width;
291+
#pragma clang diagnostic push
292+
#pragma clang diagnostic ignored "-Wpass-failed"
275293
#pragma clang loop unroll(full)
276294
for (int row = 0; row < height; row++) {
277295
__builtin_assume (width % 2 == 0);
@@ -285,6 +303,7 @@ static inline void __attribute__ ((always_inline)) dotprod2D_unroll2 (
285303
in += in_row_step;
286304
krn += kern_row_step;
287305
}
306+
#pragma clang diagnostic pop
288307
}
289308

290309
template <typename in_T, typename w_T, typename acc_T>
@@ -298,6 +317,8 @@ static inline void __attribute__((always_inline)) dotprod2D_odd(
298317
acc_T *accu) {
299318
in_row_step -= width;
300319
kern_row_step -= width;
320+
#pragma clang diagnostic push
321+
#pragma clang diagnostic ignored "-Wpass-failed"
301322
#pragma clang loop unroll(full)
302323
for (int row = 0; row < height; row++) {
303324
#pragma clang loop unroll(full)
@@ -309,6 +330,7 @@ static inline void __attribute__((always_inline)) dotprod2D_odd(
309330
in += in_row_step;
310331
krn += kern_row_step;
311332
}
333+
#pragma clang diagnostic pop
312334
}
313335
template < typename in_T, typename w_T, typename acc_T >
314336
static inline void __attribute__ ((always_inline)) dotprod2D_unroll4 (
@@ -330,6 +352,8 @@ static inline void __attribute__ ((always_inline)) dotprod2D_unroll4 (
330352
* unroll of 4 the dmac is not directly after the corresponding load
331353
* which reduces the stalls.
332354
*/
355+
#pragma clang diagnostic push
356+
#pragma clang diagnostic ignored "-Wpass-failed"
333357
#pragma clang loop unroll(full)
334358
for (int clmn = 0; clmn < width / 4; clmn++) {
335359
mli_prv_load_mac_vec4 (accu, in, krn);
@@ -339,6 +363,7 @@ static inline void __attribute__ ((always_inline)) dotprod2D_unroll4 (
339363
in += in_row_step;
340364
krn += kern_row_step;
341365
}
366+
#pragma clang diagnostic pop
342367
}
343368

344369
template < typename in_T, typename w_T, typename acc_T >
@@ -354,6 +379,8 @@ static inline void __attribute__ ((always_inline)) dotprod2D_mac4 (
354379

355380
in_row_step -= width;
356381
kern_row_step -= width;
382+
#pragma clang diagnostic push
383+
#pragma clang diagnostic ignored "-Wpass-failed"
357384
#pragma clang loop unroll(full)
358385
for (int row = 0; row < height; row++) {
359386
__builtin_assume (width % 4 == 0);
@@ -366,6 +393,7 @@ static inline void __attribute__ ((always_inline)) dotprod2D_mac4 (
366393
in += in_row_step;
367394
krn += kern_row_step;
368395
}
396+
#pragma clang diagnostic pop
369397
}
370398
template < typename in_T, typename w_T, typename acc_T >
371399
static inline void __attribute__ ((always_inline)) dotprod2D_unroll4_plus1 (
@@ -381,6 +409,8 @@ static inline void __attribute__ ((always_inline)) dotprod2D_unroll4_plus1 (
381409
in_row_step -= width;
382410
kern_row_step -= width;
383411
__builtin_assume (height > 0);
412+
#pragma clang diagnostic push
413+
#pragma clang diagnostic ignored "-Wpass-failed"
384414
#pragma clang loop unroll(full)
385415
for (int row = 0; row < height; row++) {
386416
/* unroll of 2 enables the use of dmac
@@ -399,6 +429,7 @@ static inline void __attribute__ ((always_inline)) dotprod2D_unroll4_plus1 (
399429
in += in_row_step;
400430
krn += kern_row_step;
401431
}
432+
#pragma clang diagnostic pop
402433
}
403434

404435
template < typename in_T, typename w_T, typename acc_T >
@@ -415,6 +446,8 @@ static inline void __attribute__ ((always_inline)) dotprod2D_unroll4_plus2 (
415446
in_row_step -= width;
416447
kern_row_step -= width;
417448
__builtin_assume (height > 0);
449+
#pragma clang diagnostic push
450+
#pragma clang diagnostic ignored "-Wpass-failed"
418451
#pragma clang loop unroll(full)
419452
for (int row = 0; row < height; row++) {
420453
__builtin_assume (width % 2 == 0);
@@ -434,6 +467,7 @@ static inline void __attribute__ ((always_inline)) dotprod2D_unroll4_plus2 (
434467
in += in_row_step;
435468
krn += kern_row_step;
436469
}
470+
#pragma clang diagnostic pop
437471
}
438472

439473
template < typename in_T, typename w_T, typename acc_T >
@@ -450,6 +484,8 @@ static inline void __attribute__ ((always_inline)) dotprod2D_unroll4_plus3 (
450484
in_row_step -= width;
451485
kern_row_step -= width;
452486
__builtin_assume (height > 0);
487+
#pragma clang diagnostic push
488+
#pragma clang diagnostic ignored "-Wpass-failed"
453489
#pragma clang loop unroll(full)
454490
for (int row = 0; row < height; row++) {
455491
/* unroll of 2 enables the use of dmac
@@ -471,6 +507,7 @@ static inline void __attribute__ ((always_inline)) dotprod2D_unroll4_plus3 (
471507
in += in_row_step;
472508
krn += kern_row_step;
473509
}
510+
#pragma clang diagnostic pop
474511
}
475512

476513
template < typename in_T, typename w_T, typename acc_T > static inline void
@@ -532,7 +569,8 @@ dotprod2D_v_simple (
532569
acc_T * accu) {
533570
in_row_step -= width;
534571
kern_row_step -= width;
535-
572+
#pragma clang diagnostic push
573+
#pragma clang diagnostic ignored "-Wpass-failed"
536574
#pragma clang loop unroll(full)
537575
for (int32_t row = 0; row < height; row++) {
538576
#pragma clang loop unroll(full)
@@ -546,6 +584,7 @@ dotprod2D_v_simple (
546584
in += in_row_step;
547585
krn += kern_row_step;
548586
}
587+
#pragma clang diagnostic pop
549588
}
550589

551590
template < typename in_T, typename w_T, typename acc_T > static inline void
@@ -568,6 +607,8 @@ dotprod3D_v_simple (
568607
__builtin_assume(in_ch > 0);
569608
__builtin_assume(height > 1);
570609
for (int in_ch_idx = 0; in_ch_idx < in_ch; in_ch_idx++) {
610+
#pragma clang diagnostic push
611+
#pragma clang diagnostic ignored "-Wpass-failed"
571612
#pragma clang loop unroll(full)
572613
for (int row = 0; row < height-1; row++) {
573614
#pragma clang loop unroll(full)
@@ -595,6 +636,7 @@ dotprod3D_v_simple (
595636
in += in_ch_step;
596637
krn += kern_ch_step;
597638
}
639+
#pragma clang diagnostic pop
598640
}
599641

600642

@@ -612,6 +654,8 @@ static acc_T __attribute__ ((always_inline)) dotprod2D_inp_width_v(
612654
int in_width_step) {
613655
in_row_step -= width * in_col_step;
614656
kern_row_step -= width * kern_col_step;
657+
#pragma clang diagnostic push
658+
#pragma clang diagnostic ignored "-Wpass-failed"
615659
#pragma clang loop unroll(full)
616660
for (int row = 0; row < height; row++) {
617661
#pragma clang loop unroll(full)
@@ -626,6 +670,7 @@ static acc_T __attribute__ ((always_inline)) dotprod2D_inp_width_v(
626670
inp += in_row_step;
627671
krn += kern_row_step;
628672
}
673+
#pragma clang diagnostic pop
629674
return *accu;
630675
}
631676

@@ -649,6 +694,8 @@ static inline void __attribute__ ((always_inline)) dotprod2D_v_odd_even (
649694
#else
650695
kern_row_step -= (width + 1);
651696
#endif
697+
#pragma clang diagnostic push
698+
#pragma clang diagnostic ignored "-Wpass-failed"
652699
#pragma clang loop unroll(full)
653700
for (int row = 0; row < height; row++) {
654701
#ifdef K_ODD
@@ -707,6 +754,7 @@ static inline void __attribute__ ((always_inline)) dotprod2D_v_odd_even (
707754
in += in_row_step;
708755
krn += kern_row_step;
709756
}
757+
#pragma clang diagnostic pop
710758
}
711759

712760
template < typename in_T, typename w_T, typename acc_T >

lib/src/kernels/pooling/mli_krn_avepool_chw_fx16.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,8 +2418,6 @@ mli_status mli_krn_avepool_chw_fx16_generic(const mli_tensor * in, const mli_poo
24182418

24192419

24202420
mli_status mli_krn_avepool_chw_fx16(const mli_tensor * in, const mli_pool_cfg * cfg, mli_tensor * out) {
2421-
int stride_w = cfg->stride_width;
2422-
int stride_h = cfg->stride_height;
24232421
int kernel_w = cfg->kernel_width;
24242422
int kernel_h = cfg->kernel_height;
24252423
int padding_top = cfg->padding_top;
@@ -2496,8 +2494,6 @@ mli_status mli_krn_avepool_chw_fx16(const mli_tensor * in, const mli_pool_cfg *
24962494
}
24972495
}
24982496
char * mli_debug_krn_avepool_chw_fx16(const mli_tensor * in, const mli_pool_cfg * cfg, mli_tensor * out) {
2499-
int stride_w = cfg->stride_width;
2500-
int stride_h = cfg->stride_height;
25012497
int kernel_w = cfg->kernel_width;
25022498
int kernel_h = cfg->kernel_height;
25032499
int padding_top = cfg->padding_top;

0 commit comments

Comments
 (0)