Skip to content

Commit 30a99a9

Browse files
Luka Macanlukamac
authored andcommitted
Refactor network functions
1 parent be3d6dd commit 30a99a9

File tree

4 files changed

+166
-173
lines changed

4 files changed

+166
-173
lines changed

dory/Hardware_targets/PULP/Common/Templates/main.c.t

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ unsigned int PMU_set_voltage(unsigned int Voltage, unsigned int CheckFrequencies
4242

4343

4444
void application(void * arg) {
45-
/*
46-
Opening of Filesystem and Ram
47-
*/
48-
% if l3_supported:
45+
% if l3_supported:
46+
// Opening of Filesystem and Ram
4947
mem_init();
50-
${prefix}network_initialize();
48+
5149
% endif
52-
/*
53-
Allocating space for input
54-
*/
50+
// Initializing network
51+
${prefix}network_t network;
52+
${prefix}network_initialize(&network);
53+
54+
// Allocating space for input
5555
void *l2_buffer = pi_l2_malloc(${l2_buffer_size});
5656
if (NULL == l2_buffer) {
5757
#ifdef VERBOSE
@@ -64,7 +64,6 @@ void application(void * arg) {
6464
#endif
6565
size_t l2_input_size = ${int(DORY_HW_graph[0].tiling_dimensions["L2"]["input_activation_memory"])};
6666
size_t input_size = 1000000;
67-
int initial_dir = 1;
6867
% if l3_supported:
6968

7069
void *ram_input = ram_malloc(input_size);
@@ -80,15 +79,25 @@ void application(void * arg) {
8079
% if l3_supported:
8180
ram_read(l2_buffer, ram_input, l2_input_size);
8281
% endif
83-
${prefix}network_run(l2_buffer, ${l2_buffer_size}, l2_buffer, ${"0" if single_input else "exec"}, initial_dir${f", {prefix}L2_input_h{' + exec * l2_input_size' if not single_input else ''}" if not l3_supported else ""});
82+
${prefix}network_args_t args = {
83+
.l2_buffer = l2_buffer,
84+
.l2_buffer_size = ${l2_buffer_size},
85+
.l2_final_output = l2_buffer,
86+
.exec = ${"0" if single_input else "exec"},
87+
.initial_allocator_dir = 1,
88+
% if not l3_supported:
89+
.l2_input_h = ${prefix}L2_input_h${' + exec * l2_input_size' if not single_input else ''}
90+
% endif
91+
};
92+
${prefix}network_run(&network, &args);
8493

8594
% if not single_input:
8695
}
8796
% endif
8897
% if l3_supported:
8998
ram_free(ram_input, input_size);
90-
${prefix}network_terminate();
9199
% endif
100+
${prefix}network_terminate(&network);
92101
pi_l2_free(l2_buffer, ${l2_buffer_size});
93102
}
94103

0 commit comments

Comments
 (0)