Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix network template for GAP9 #66

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions dory/Hardware_targets/PULP/GAP9/Templates/network_c_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void ${prefix}execute_layer_fork(void *args) {
#endif
}

void ${prefix}network_run(void *l2_buffer, size_t l2_buffer_size, void *l2_final_output, int exec${", void *L2_input_h" if not l3_supported else ""})
struct ${prefix}network_run_token ${prefix}network_run_async(void *l2_buffer, size_t l2_buffer_size, void *l2_final_output, int exec, int initial_dir${", void *L2_input_h" if not l3_supported else ""})
{
struct pi_device cluster_dev = {0};
struct pi_cluster_conf conf;
Expand All @@ -135,8 +135,9 @@ void ${prefix}network_run(void *l2_buffer, size_t l2_buffer_size, void *l2_final
args[1] = (unsigned int) l2_buffer_size;
args[2] = (unsigned int) l2_final_output;
args[3] = (unsigned int) exec;
args[4] = (unsigned int) initial_dir;
% if not l3_supported:
args[4] = (unsigned int) L2_input_h;
args[5] = (unsigned int) L2_input_h;
% endif
// open cluster...
pi_cluster_task(&cluster_task, ${prefix}network_run_cluster, args);
Expand All @@ -149,20 +150,33 @@ void ${prefix}network_run(void *l2_buffer, size_t l2_buffer_size, void *l2_final
#endif
cluster_task.slave_stack_size = ${slave_stack};
pi_cluster_send_task_to_cl(&cluster_dev, &cluster_task);
pi_cluster_close(&cluster_dev);
return (struct ${prefix}network_run_token) {
.cluster_dev = cluster_dev
};
}

void ${prefix}network_run_wait(struct ${prefix}network_run_token token)
{
pi_cluster_close(&token.cluster_dev);
% if 'Perf_final' in verbose_level:
print_perf("Final", ${prefix}cycle_network_execution, ${MACs});
% endif
}

void ${prefix}network_run(void *l2_buffer, size_t l2_buffer_size, void *l2_final_output, int exec, int initial_dir${", void *L2_input_h" if not l3_supported else ""})
{
${prefix}network_run_wait(network_run_async(l2_buffer, l2_buffer_size, l2_final_output, exec, initial_dir${", L2_input_h" if not l3_supported else ""}));
}

void ${prefix}network_run_cluster(void *args) {
unsigned int * real_args = (unsigned int *) args;
void * l2_buffer = (void *) real_args[0];
size_t l2_buffer_size = (size_t) real_args[1];
void * l2_final_output = (void *) real_args[2];
int exec = (int) real_args[3];
int dir = (int) real_args[4];
% if not l3_supported:
void * L2_input_h = (void *)real_args[4];
void * L2_input_h = (void *)real_args[5];
% endif
/*
- initial buffer allocation L2 and L1
Expand All @@ -177,7 +191,6 @@ void ${prefix}network_run_cluster(void *args) {
void *L3_weights_curr = L3_weights;
void *bypass_activations = NULL;

int dir = 1;
int residual_number = 0;
int bypass_dimension = 0;
% if not l3_supported:
Expand Down
199 changes: 0 additions & 199 deletions dory/Hardware_targets/PULP/GAP9/Templates/network_h_template.h

This file was deleted.

2 changes: 1 addition & 1 deletion test_PULP.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_network(network, capsys, compat, appdir):
try:
proc = subprocess.run(cmd, check=True, capture_output=True, text=True, timeout=360)
except subprocess.CalledProcessError as e:
assert False, f"Building application failed with exit status {e.returncode}\nBuild error:\n{e.stderr}"
assert False, f"Building application failed with exit status {e.returncode}\nBuild output:\n{e.stdout}\nBuild error:\n{e.stderr}"
except subprocess.TimeoutExpired as e:
print(f"Test timed out...\nSTDOUT:")
if e.output is not None:
Expand Down