Skip to content

Commit a21ae09

Browse files
authored
Merge pull request #24 from foss-for-synopsys-dwc-arc-processors/fix_har_example_gnu
renamed wrappers to prevent conflict with built-in GNU function in har example
2 parents 01a0829 + f00b9fe commit a21ae09

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

examples/example_har_smartphone/har_smartphone_model.c

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,15 @@ static const mli_tensor L4_fc_bias = {
256256
// (MODEL_BIT_DEPTH define)
257257
//
258258
//==============================================================
259-
static inline mli_status relu(const mli_tensor *in, const mli_relu_cfg *cfg, mli_tensor *out);
259+
static inline mli_status nn_relu(const mli_tensor *in, const mli_relu_cfg *cfg, mli_tensor *out);
260260

261-
static inline mli_status fully_connected(
261+
static inline mli_status nn_fully_connected(
262262
const mli_tensor *in,
263263
const mli_tensor *weights,
264264
const mli_tensor *bias,
265265
mli_tensor *out);
266266

267-
static inline mli_status lstm_cell(
267+
static inline mli_status nn_lstm_cell(
268268
const mli_tensor *in,
269269
const mli_tensor *prev_out,
270270
const mli_tensor *weights,
@@ -274,15 +274,15 @@ static inline mli_status lstm_cell(
274274
mli_tensor *out);
275275

276276
#if defined(CUSTOM_USER_LSTM_LAYER3)
277-
static inline mli_status sigm(const mli_tensor *in, mli_tensor *out);
277+
static inline mli_status nn_sigm(const mli_tensor *in, mli_tensor *out);
278278

279-
static inline mli_status tanh(const mli_tensor *in, mli_tensor *out);
279+
static inline mli_status nn_tanh(const mli_tensor *in, mli_tensor *out);
280280

281-
static inline mli_status eltwise_mul(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out);
281+
static inline mli_status nn_eltwise_mul(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out);
282282

283-
static inline mli_status eltwise_add(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out);
283+
static inline mli_status nn_eltwise_add(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out);
284284

285-
static inline mli_status rnn_cell(
285+
static inline mli_status nn_rnn_cell(
286286
const mli_tensor *in,
287287
const mli_tensor *prev_out,
288288
const mli_tensor *weights,
@@ -327,7 +327,7 @@ void har_smartphone_net(const char * debug_ir_root) {
327327
//=======================================
328328
ir_tensor_Y.el_params.fx.frac_bits = FC1_OUT_FRAQ;
329329
user_fc_on_multiple_samples(&input, &ir_tensor_Y);
330-
relu(&ir_tensor_Y, &L1_relu_cfg, &ir_tensor_X);
330+
nn_relu(&ir_tensor_Y, &L1_relu_cfg, &ir_tensor_X);
331331

332332
// LAYER 2
333333
//=======================================
@@ -341,7 +341,7 @@ void har_smartphone_net(const char * debug_ir_root) {
341341
lstm_prev_tensor.el_params.fx.frac_bits = LSTM2_OUT_FRAQ;
342342
lstm_cell_tensor.el_params.fx.frac_bits = LSTM2_CELL_FRAQ;
343343

344-
lstm_cell(&ir_tensor_X, &lstm_prev_tensor, &L2_lstm_wt, &L2_lstm_bias,
344+
nn_lstm_cell(&ir_tensor_X, &lstm_prev_tensor, &L2_lstm_wt, &L2_lstm_bias,
345345
&L2_lstm_cfg, &lstm_cell_tensor, &ir_tensor_Y);
346346

347347
// LAYER 3
@@ -362,7 +362,7 @@ void har_smartphone_net(const char * debug_ir_root) {
362362
// LAYER 4
363363
//=======================================
364364
output.el_params.fx.frac_bits = FC4_OUT_FRAQ;
365-
fully_connected(&ir_tensor_X, &L4_fc_wt, &L4_fc_bias, &output);
365+
nn_fully_connected(&ir_tensor_X, &L4_fc_wt, &L4_fc_bias, &output);
366366
} else {
367367
// Version A: Wrapped by service code for profiling and IR results checking purpose
368368
//========================================================================================
@@ -380,7 +380,7 @@ void har_smartphone_net(const char * debug_ir_root) {
380380
check_result(debug_ir_root, "ir_fc1.idx", &ir_tensor_Y, cycle_cnt, ret);
381381
layer1_cycles += cycle_cnt;
382382

383-
PROFILE(ret = relu(&ir_tensor_Y, &L1_relu_cfg, &ir_tensor_X));
383+
PROFILE(ret = nn_relu(&ir_tensor_Y, &L1_relu_cfg, &ir_tensor_X));
384384
check_result(debug_ir_root, "ir_relu1.idx", &ir_tensor_X, cycle_cnt, ret);
385385
layer1_cycles += cycle_cnt;
386386

@@ -397,7 +397,7 @@ void har_smartphone_net(const char * debug_ir_root) {
397397
lstm_prev_tensor.el_params.fx.frac_bits = LSTM2_OUT_FRAQ;
398398
lstm_cell_tensor.el_params.fx.frac_bits = LSTM2_CELL_FRAQ;
399399

400-
PROFILE(ret = lstm_cell(&ir_tensor_X, &lstm_prev_tensor,
400+
PROFILE(ret = nn_lstm_cell(&ir_tensor_X, &lstm_prev_tensor,
401401
&L2_lstm_wt, &L2_lstm_bias, &L2_lstm_cfg, &lstm_cell_tensor, &ir_tensor_Y));
402402
check_result(debug_ir_root, "ir_lstm2.idx", &ir_tensor_Y, cycle_cnt, ret);
403403
layer2_cycles += cycle_cnt;
@@ -422,7 +422,7 @@ void har_smartphone_net(const char * debug_ir_root) {
422422
// LAYER 4
423423
//=======================================
424424
output.el_params.fx.frac_bits = FC4_OUT_FRAQ;
425-
PROFILE(ret = fully_connected(&ir_tensor_X, &L4_fc_wt, &L4_fc_bias, &output));
425+
PROFILE(ret = nn_fully_connected(&ir_tensor_X, &L4_fc_wt, &L4_fc_bias, &output));
426426
check_result(debug_ir_root, "ir_fc4.idx", &output, cycle_cnt, ret);
427427
layer4_cycles += cycle_cnt;
428428

@@ -457,7 +457,7 @@ static mli_status user_fc_on_multiple_samples(const mli_tensor *layer_input, mli
457457
unsigned next_out_add = mli_hlp_count_elem_num(&L1_fc_bias, 0) * mli_hlp_tensor_element_size(&fc1_in);
458458
unsigned next_in_add = fc1_in.capacity;
459459
for (int batch_idx = 0; batch_idx < layer_input->shape[0]; batch_idx++) {
460-
ret_val = fully_connected(&fc1_in, &L1_fc_wt, &L1_fc_bias, &fc1_out);
460+
ret_val = nn_fully_connected(&fc1_in, &L1_fc_wt, &L1_fc_bias, &fc1_out);
461461
if (ret_val != MLI_STATUS_OK)
462462
return ret_val;
463463

@@ -488,7 +488,7 @@ static mli_status user_lstm_batch_to_last(
488488
mli_tensor *out) {
489489
#if !defined(CUSTOM_USER_LSTM_LAYER3)
490490
// Might be replaced with MLI function
491-
return lstm_cell(in, prev_out, weights, bias, lstm_cfg, cell, out);
491+
return nn_lstm_cell(in, prev_out, weights, bias, lstm_cfg, cell, out);
492492
#else
493493
mli_status ret_val = MLI_STATUS_OK;
494494

@@ -514,7 +514,7 @@ static mli_status user_lstm_batch_to_last(
514514
if (ret_val != MLI_STATUS_OK)
515515
return ret_val;
516516

517-
ret_val = rnn_cell(&rnn_in, rnn_prev, weights, bias, &rnn_cfg, ir_tensor);
517+
ret_val = nn_rnn_cell(&rnn_in, rnn_prev, weights, bias, &rnn_cfg, ir_tensor);
518518
if (ret_val != MLI_STATUS_OK)
519519
return ret_val;
520520

@@ -539,36 +539,36 @@ static mli_status user_lstm_batch_to_last(
539539
//===============================================================
540540
for (int batch_idx = 0; batch_idx < in->shape[0]; batch_idx++) {
541541
//Step 2: Applying non-linearity
542-
ret_val = sigm(&in_gate, &in_gate);
542+
ret_val = nn_sigm(&in_gate, &in_gate);
543543
if (ret_val == MLI_STATUS_OK)
544-
ret_val = tanh(&g_tsr, &g_tsr);
544+
ret_val = nn_tanh(&g_tsr, &g_tsr);
545545
if (ret_val == MLI_STATUS_OK)
546-
ret_val = sigm(&forget_gate, &forget_gate);
546+
ret_val = nn_sigm(&forget_gate, &forget_gate);
547547
if (ret_val == MLI_STATUS_OK)
548-
ret_val = sigm(&out_gate, &out_gate);
548+
ret_val = nn_sigm(&out_gate, &out_gate);
549549
if (ret_val != MLI_STATUS_OK)
550550
return ret_val;
551551

552552
// Step 3: Pointwise operations
553-
ret_val = eltwise_mul(&forget_gate, cell, cell);
553+
ret_val = nn_eltwise_mul(&forget_gate, cell, cell);
554554
if (ret_val == MLI_STATUS_OK)
555-
ret_val = eltwise_mul(&in_gate, &g_tsr, &new_g);
555+
ret_val = nn_eltwise_mul(&in_gate, &g_tsr, &new_g);
556556
if (ret_val == MLI_STATUS_OK)
557-
ret_val = eltwise_add(cell, &new_g, cell);
557+
ret_val = nn_eltwise_add(cell, &new_g, cell);
558558
if (ret_val != MLI_STATUS_OK)
559559
return ret_val;
560560

561561
// Step 4: Calculate next output
562-
ret_val = tanh(cell, out);
562+
ret_val = nn_tanh(cell, out);
563563
if (ret_val == MLI_STATUS_OK)
564-
ret_val = eltwise_mul(out, &out_gate, out);
564+
ret_val = nn_eltwise_mul(out, &out_gate, out);
565565
if (ret_val != MLI_STATUS_OK)
566566
return ret_val;
567567

568568
//Next sample: Step 1: Fully connected
569569
if (batch_idx < in->shape[0]-1) {
570570
rnn_in.data += next_in_add;
571-
ret_val = rnn_cell(&rnn_in, rnn_prev, weights, bias, &rnn_cfg, ir_tensor);
571+
ret_val = nn_rnn_cell(&rnn_in, rnn_prev, weights, bias, &rnn_cfg, ir_tensor);
572572
if (ret_val != MLI_STATUS_OK)
573573
return ret_val;
574574

@@ -617,47 +617,47 @@ static void check_result(const char * ir_root, const char * ref_file, mli_tensor
617617
// MLI Functions wrappers: Kernels w/o weights
618618
//========================================================================================
619619
#if (MODEL_BIT_DEPTH != MODEL_FX_8)
620-
static inline mli_status relu(const mli_tensor *in, const mli_relu_cfg *cfg, mli_tensor *out) {
620+
static inline mli_status nn_relu(const mli_tensor *in, const mli_relu_cfg *cfg, mli_tensor *out) {
621621
return mli_krn_relu_fx16(in, cfg, out);
622622
}
623623

624624
#if defined(CUSTOM_USER_LSTM_LAYER3)
625-
static inline mli_status sigm(const mli_tensor *in, mli_tensor *out) {
625+
static inline mli_status nn_sigm(const mli_tensor *in, mli_tensor *out) {
626626
return mli_krn_sigm_fx16(in, out);
627627
}
628628

629-
static inline mli_status tanh(const mli_tensor *in, mli_tensor *out) {
629+
static inline mli_status nn_tanh(const mli_tensor *in, mli_tensor *out) {
630630
return mli_krn_tanh_fx16(in, out);
631631
}
632632

633-
static inline mli_status eltwise_mul(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out) {
633+
static inline mli_status nn_eltwise_mul(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out) {
634634
return mli_krn_eltwise_mul_fx16(in1, in2, out);
635635
}
636636

637-
static inline mli_status eltwise_add(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out) {
637+
static inline mli_status nn_eltwise_add(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out) {
638638
return mli_krn_eltwise_add_fx16(in1, in2, out);
639639
}
640640
#endif
641641

642642
#else // MODEL_BIT_DEPTH == (MODEL_FX_8W16D || MODEL_FX_8W16D)
643-
static inline mli_status relu(const mli_tensor *in, const mli_relu_cfg *cfg, mli_tensor *out) {
643+
static inline mli_status nn_relu(const mli_tensor *in, const mli_relu_cfg *cfg, mli_tensor *out) {
644644
return mli_krn_relu_fx8(in, cfg, out);
645645
}
646646

647647
#if defined(CUSTOM_USER_LSTM_LAYER3)
648-
static inline mli_status sigm(const mli_tensor *in, mli_tensor *out) {
648+
static inline mli_status nn_sigm(const mli_tensor *in, mli_tensor *out) {
649649
return mli_krn_sigm_fx8(in, out);
650650
}
651651

652-
static inline mli_status tanh(const mli_tensor *in, mli_tensor *out) {
652+
static inline mli_status nn_tanh(const mli_tensor *in, mli_tensor *out) {
653653
return mli_krn_tanh_fx8(in, out);
654654
}
655655

656-
static inline mli_status eltwise_mul(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out) {
656+
static inline mli_status nn_eltwise_mul(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out) {
657657
return mli_krn_eltwise_mul_fx8(in1, in2, out);
658658
}
659659

660-
static inline mli_status eltwise_add(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out) {
660+
static inline mli_status nn_eltwise_add(const mli_tensor *in1, const mli_tensor *in2, mli_tensor *out) {
661661
return mli_krn_eltwise_add_fx8(in1, in2, out);
662662
}
663663
#endif
@@ -668,15 +668,15 @@ static inline mli_status eltwise_add(const mli_tensor *in1, const mli_tensor *in
668668
// MLI Functions wrappers: Kernels with weights
669669
//========================================================================================
670670
#if (MODEL_BIT_DEPTH == MODEL_FX_8)
671-
static inline mli_status fully_connected(
671+
static inline mli_status nn_fully_connected(
672672
const mli_tensor *in,
673673
const mli_tensor *weights,
674674
const mli_tensor *bias,
675675
mli_tensor *out) {
676676
return mli_krn_fully_connected_fx8(in, weights, bias, out);
677677
}
678678

679-
static inline mli_status lstm_cell(
679+
static inline mli_status nn_lstm_cell(
680680
const mli_tensor *in,
681681
const mli_tensor *prev_out,
682682
const mli_tensor *weights,
@@ -688,7 +688,7 @@ static inline mli_status lstm_cell(
688688
}
689689

690690
#if defined(CUSTOM_USER_LSTM_LAYER3)
691-
static inline mli_status rnn_cell(
691+
static inline mli_status nn_rnn_cell(
692692
const mli_tensor *in,
693693
const mli_tensor *prev_out,
694694
const mli_tensor *weights,
@@ -700,15 +700,15 @@ static inline mli_status rnn_cell(
700700
#endif
701701

702702
#elif (MODEL_BIT_DEPTH == MODEL_FX_16)
703-
static inline mli_status fully_connected(
703+
static inline mli_status nn_fully_connected(
704704
const mli_tensor *in,
705705
const mli_tensor *weights,
706706
const mli_tensor *bias,
707707
mli_tensor *out) {
708708
return mli_krn_fully_connected_fx16(in, weights, bias, out);
709709
}
710710

711-
static inline mli_status lstm_cell(
711+
static inline mli_status nn_lstm_cell(
712712
const mli_tensor *in,
713713
const mli_tensor *prev_out,
714714
const mli_tensor *weights,
@@ -720,7 +720,7 @@ static inline mli_status lstm_cell(
720720
}
721721

722722
#if defined(CUSTOM_USER_LSTM_LAYER3)
723-
static inline mli_status rnn_cell(
723+
static inline mli_status nn_rnn_cell(
724724
const mli_tensor *in,
725725
const mli_tensor *prev_out,
726726
const mli_tensor *weights,
@@ -732,15 +732,15 @@ static inline mli_status rnn_cell(
732732
#endif
733733

734734
#else // MODEL_BIT_DEPTH == MODEL_FX_8W16D
735-
static inline mli_status fully_connected(
735+
static inline mli_status nn_fully_connected(
736736
const mli_tensor *in,
737737
const mli_tensor *weights,
738738
const mli_tensor *bias,
739739
mli_tensor *out) {
740740
return mli_krn_fully_connected_fx8w16d(in, weights, bias, out);
741741
}
742742

743-
static inline mli_status lstm_cell(
743+
static inline mli_status nn_lstm_cell(
744744
const mli_tensor *in,
745745
const mli_tensor *prev_out,
746746
const mli_tensor *weights,
@@ -752,7 +752,7 @@ static inline mli_status lstm_cell(
752752
}
753753

754754
#if defined(CUSTOM_USER_LSTM_LAYER3)
755-
static inline mli_status rnn_cell(
755+
static inline mli_status nn_rnn_cell(
756756
const mli_tensor *in,
757757
const mli_tensor *prev_out,
758758
const mli_tensor *weights,

0 commit comments

Comments
 (0)