Skip to content

Commit

Permalink
extend snitch support
Browse files Browse the repository at this point in the history
  • Loading branch information
tahaelbayad committed Dec 6, 2024
1 parent 1619545 commit 1e1c295
Show file tree
Hide file tree
Showing 25 changed files with 71 additions and 11 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
url = https://github.com/pulp-platform/pulp-nnx.git
[submodule "CMSIS-NN"]
path = TargetLibraries/CMSIS/third_party/CMSIS-NN
url = https://github.com/ARM-software/CMSIS-NN.git
url = https://github.com/ARM-software/CMSIS-NN.git
[submodule "TargetLibraries/Snitch/third_party/pulp-nn-mixed"]
path = TargetLibraries/Snitch/third_party/pulp-nn-mixed
url = https://github.com/Victor-Jung/pulp-nn-mixed.git
44 changes: 35 additions & 9 deletions DeeployTest/Platforms/Snitch/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#include "testinputs.h"
#include "testoutputs.h"

// #define NOPRINT
// #define NOTEST
// #define CI

int main(void) {

uint32_t core_id = snrt_global_core_idx();
Expand All @@ -48,8 +52,9 @@ int main(void) {
snrt_global_compute_core_num(), snrt_cluster_num() * snrt_cluster_dm_core_num(), snrt_cluster_num());
#endif

#ifndef NOPRINT
printf("Initializing...\r\n");

#endif
InitNetwork(core_id, 1);

#ifndef CI
Expand All @@ -59,15 +64,17 @@ int main(void) {
DeeployNetwork_inputs_bytes[buf]);
}
for (uint32_t buf = 0; buf < DeeployNetwork_num_outputs; buf++) {
printf("testInputVector%d @ %p\r\n", buf, testOutputVector[buf]);
printf("testOutputVector%d @ %p\r\n", buf, testOutputVector[buf]);
printf("DeeployNetwork_output_%d @ %p and %u elements\r\n", buf, DeeployNetwork_outputs[buf],
DeeployNetwork_outputs_bytes[buf]);
}

printf("Initialized\r\n");
#endif

#ifndef NOPRINT
printf("Copy inputs...\r\n");
#endif

// WIESEP: Copy inputs to allocated memory
for (uint32_t buf = 0; buf < DeeployNetwork_num_inputs; buf++) {
Expand All @@ -80,18 +87,31 @@ int main(void) {
#endif
}

#ifndef NOPRINT
if (snrt_is_dm_core()) {
printf("Running network...\r\n");
}
#endif

snrt_cluster_hw_barrier();

#ifndef BANSHEE_SIMULATION
if (snrt_is_dm_core()) {
printf("Running network...\r\n");
ResetTimer();
StartTimer();
}
#endif // BANSHEE_SIMULATION

// ResetTimer();
// StartTimer();
if (snrt_is_compute_core()) {
RunNetwork(compute_core_id, num_compute_cores);
RunNetwork(compute_core_id, num_compute_cores);

uint32_t runtimeCycles = 0;
#ifndef BANSHEE_SIMULATION
if (snrt_is_dm_core()) {
runtimeCycles = getCycles();
DUMP(runtimeCycles);
StopTimer();
}
// StopTimer();
#endif // BANSHEE_SIMULATION

snrt_cluster_hw_barrier();

Expand All @@ -105,6 +125,8 @@ int main(void) {
#ifndef CI
printf("Output:\r\n");
#endif

#ifndef NOTEST
int32_t tot_err = 0;
uint32_t tot = 0;
int32_t diff;
Expand All @@ -127,8 +149,12 @@ int main(void) {
}
}
}
printf("Runtime: %u cycles\r\n", getCycles());
printf("Errors: %u out of %u \r\n", tot_err, tot);
#endif

#ifndef NOPRINT
printf("Runtime: %u cycles\r\n", runtimeCycles);
#endif
}

snrt_cluster_hw_barrier();
Expand Down
Binary file added DeeployTest/Tests/TestAdderLarge/inputs.npz
Binary file not shown.
22 changes: 22 additions & 0 deletions DeeployTest/Tests/TestAdderLarge/network.onnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
 onnx1.14.0:�
&
input_0
input_1output_0Add"AddAddNetZ#
input_0



�
�Z#
input_1



�
�b$
output_0



�
�B
Binary file added DeeployTest/Tests/TestAdderLarge/outputs.npz
Binary file not shown.
Binary file added DeeployTest/Tests/TestRQAdd/activations.npz
Binary file not shown.
Binary file added DeeployTest/Tests/TestRQAdd/inputs.npz
Binary file not shown.
Binary file added DeeployTest/Tests/TestRQAdd/network.onnx
Binary file not shown.
Binary file added DeeployTest/Tests/TestRQAdd/outputs.npz
Binary file not shown.
Binary file added DeeployTest/Tests/TestiNoNorm/activations.npz
Binary file not shown.
Binary file added DeeployTest/Tests/TestiNoNorm/inputs.npz
Binary file not shown.
Binary file added DeeployTest/Tests/TestiNoNorm/network.onnx
Binary file not shown.
Binary file added DeeployTest/Tests/TestiNoNorm/outputs.npz
Binary file not shown.
Binary file added DeeployTest/Tests/TestiSoftmaxLarge/activations.npz
Binary file not shown.
Binary file added DeeployTest/Tests/TestiSoftmaxLarge/inputs.npz
Binary file not shown.
Binary file added DeeployTest/Tests/TestiSoftmaxLarge/network.onnx
Binary file not shown.
Binary file added DeeployTest/Tests/TestiSoftmaxLarge/outputs.npz
Binary file not shown.
Binary file modified DeeployTest/Tests/testGEMM/inputs.npz
Binary file not shown.
Binary file modified DeeployTest/Tests/testGEMM/network.onnx
Binary file not shown.
Binary file modified DeeployTest/Tests/testGEMM/outputs.npz
Binary file not shown.
Binary file added DeeployTest/Tests/testRQGEMMTransB/inputs.npz
Binary file not shown.
Binary file added DeeployTest/Tests/testRQGEMMTransB/network.onnx
Binary file not shown.
Binary file added DeeployTest/Tests/testRQGEMMTransB/outputs.npz
Binary file not shown.
10 changes: 9 additions & 1 deletion DeeployTest/testRunner_tiled_snitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@
default = 9,
help = 'Set number of cluster cores')
parser.set_defaults(toolchain_install_dir = "/usr/pack/riscv-1.0-kgf/pulp-llvm-0.12.0")
parser.add_argument('--simulator',
metavar = "<simulator>",
dest = "simulator",
type = str,
choices = ["banshee", "vsim", "vsim.gui"],
default = "banshee",
help = "Select the simulator to use")

args = parser.parse_args()

testRunner = TestRunner(platform = "Snitch", simulator = "banshee", tiling = True, argument_parser = parser)
testRunner = TestRunner(platform = "Snitch", simulator = args.simulator, tiling = True, argument_parser = parser)

testRunner.cmake_args += f" -D NUM_CORES={args.cores}"

Expand Down
1 change: 1 addition & 0 deletions TargetLibraries/Snitch/third_party/pulp-nn-mixed
Submodule pulp-nn-mixed added at 46cbce

0 comments on commit 1e1c295

Please sign in to comment.