Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
78974a1
Harmonize onnx mangling
Dec 1, 2023
646710f
Harmonize quantlib renaming last output node
Dec 1, 2023
71d75bf
Add some string parsing
Dec 5, 2023
41fd9b6
Parser fixes
lukamac Dec 19, 2023
115f8b3
Fix L3-L2 tiling
lukamac Dec 19, 2023
56553f8
Fix l2 mapping overwriting l3 layers
lukamac Dec 21, 2023
ed308bb
Fix func_names doesn't have the padded func versions
lukamac Jan 8, 2024
d8e8e7d
Fix missing node.L3_input for GAP9_NE16
lukamac Jan 8, 2024
726401d
Revert remove mapping_layers_to_C_files
lukamac Jan 8, 2024
e95828a
Add ne16 check for padded functions
lukamac Jan 8, 2024
38052e4
Bump pulp-nnx
lukamac Jan 8, 2024
7037b46
Fix padding flag passing
lukamac Jan 9, 2024
997b241
Fix unused padding with strided convolution for ne16
lukamac Jan 9, 2024
858a62b
Rewrite convolution overlap
lukamac Jan 9, 2024
fe647a5
Small rewrites for add
lukamac Jan 18, 2024
d195966
Add last checksum
lukamac Jan 18, 2024
eabcc14
Pushed fixes tested for DS-CNN on GAP8-GAP9 patching
ccioflan Jan 23, 2024
1b9ff18
Merge branch 'trainlib' into 'master'
ccioflan Jan 23, 2024
a17f8e8
Fixed template to enable partially frozen inference
ccioflan Jan 23, 2024
a66592e
Added l3 buffer, required for early exit on partially frozen nets
ccioflan Jan 26, 2024
858d196
Patched verbosity
ccioflan Jan 26, 2024
c09d57a
WIP: Upgrade pulp-nnx
lukamac Jan 30, 2024
0016719
Added GAP9_NE16 fixes (incl. l3 buffer) to prepare deployment
ccioflan Jan 30, 2024
093d98f
Copy network template to GAP9_NE16
lukamac Jan 30, 2024
9fd719c
Move dma mutex init to network
lukamac Jan 30, 2024
7d3fad7
Move ne16 init to network
lukamac Jan 30, 2024
55608d8
Allocate move ne16_tasks from static global to the stack
lukamac Jan 30, 2024
8f2da32
Move global static tiles to stack
lukamac Jan 30, 2024
2348eb6
Move global static store_conf to stack
lukamac Jan 30, 2024
4559442
Move global static monitor to stack
lukamac Jan 30, 2024
972dae5
Fix path to network template
lukamac Jan 30, 2024
6e40aca
Initialize monitors only once in network
lukamac Jan 30, 2024
441b8be
Fix missing ne16 softclear before running a new layer
lukamac Jan 30, 2024
236a07b
Merging lukamac/pr/fix-gap9-l3-l2-tiling branch
ccioflan Jan 30, 2024
2c3557f
Updated dependencies
ccioflan Jan 30, 2024
032c0d1
Fixed dependencies
ccioflan Jan 30, 2024
fbcde46
Integrated ODDA changes
ccioflan Jan 30, 2024
c85a5c9
Removed obsolete initial_dir field
ccioflan Jan 30, 2024
8c54de9
Added ODDA in lukamac/pr/fix-gap9-l3-l2-tiling
ccioflan Jan 30, 2024
bb4e5ba
Merge branch 'master' into 'lukamac/pr/fix-gap9-l3-l2-tiling-odda'
ccioflan Jan 30, 2024
2768379
Merge branch 'lukamac/pr/fix-gap9-l3-l2-tiling-odda' into 'master'
ccioflan Jan 30, 2024
3d494cf
Minor fix following merger
ccioflan Jan 30, 2024
44fb1d1
Added initial_dir var
ccioflan Jan 30, 2024
e74b792
Fixed GAP9 multi-core deployment
ccioflan Jan 30, 2024
9706289
WIP: Upgrade pulp-nnx
lukamac Jan 30, 2024
397e95c
Copy network template to GAP9_NE16
lukamac Jan 30, 2024
a9c0320
Move dma mutex init to network
lukamac Jan 30, 2024
bd19a21
Move ne16 init to network
lukamac Jan 30, 2024
0e81edb
Fixed args
ccioflan Jan 31, 2024
456816b
Move ne16_tasks from static global to the stack
lukamac Jan 30, 2024
08a5819
Move global static tiles to stack
lukamac Jan 30, 2024
361eb0c
Move global static store_conf to stack
lukamac Jan 30, 2024
ef7dcb7
Move global static monitor to stack
lukamac Jan 30, 2024
821c764
Added latest pulp-nnx
ccioflan Jan 31, 2024
f080507
Fix path to network template
lukamac Jan 30, 2024
ce5a4f4
Initialize monitors only once in network
lukamac Jan 30, 2024
fd5bdf9
Fix relu check for ne16
lukamac Feb 1, 2024
5573413
Fix ne16 relu flag in the layer template
lukamac Feb 1, 2024
a49f95c
Updating pulp-nnx to match current progress on NE16 deployment
ccioflan Mar 18, 2024
1881463
Fixed merge conflicts
ccioflan Mar 18, 2024
113ff50
Fixed pulp-nnx dependency
ccioflan Mar 18, 2024
ff420cf
Removed dereferencing
ccioflan Mar 18, 2024
c43cc04
Changed pulp-nnx reference to internal repo
ccioflan Mar 18, 2024
663ec5c
Changed pulp-nnx reference to internal repo
ccioflan Mar 18, 2024
77e8929
Merge branch 'ne16support' into 'master'
ccioflan Mar 18, 2024
7b77bff
Updated .gitignore
ccioflan Mar 18, 2024
0e38d0c
Set github upstream for pulp-nnx following version bump
ccioflan Mar 19, 2024
6d835ec
Bump pulp-nnx to github version
ccioflan Mar 19, 2024
602f5dc
Manual fixes for gitub alignment
ccioflan Mar 19, 2024
aa14311
Moved layer selection for deployment from backend to frontend
ccioflan Mar 20, 2024
efb0977
Added L1 memory restrictions to enable TrainLib. Added patch to enabl…
ccioflan Mar 21, 2024
e43bd7c
PATCH: L1-only DSCNNL in Trainlib. Commented out for now.
ccioflan Mar 21, 2024
d53a7df
Removed hardcoded value
ccioflan Mar 21, 2024
171ec53
Updated quantlab parser to include trainable layers excluded from Dor…
ccioflan Apr 5, 2024
de0ccb9
GAP9 Templates: Fix network not passing all the arguments to the cluster
Freakness109 Jun 17, 2024
9232e65
Added verbosity flag
ccioflan Jul 11, 2024
115a481
Added trainable/frozen layer division for quantlib
ccioflan Jul 11, 2024
7126f91
Added verbosity flags on print_perf
ccioflan Jul 18, 2024
44df73d
GAP9 template PR alignment
ccioflan Jul 22, 2024
ff5ca88
Merge branch 'fix-gap9-template' into 'master'
ccioflan Jul 22, 2024
2343a34
Merge branch 'master' of iis-git.ee.ethz.ch:kws/dory
ccioflan Jul 22, 2024
3771c72
Lowered Dory L1 to enable Trainlib
ccioflan Jul 22, 2024
4cb20c6
HW_description.json is source of L1 resizing
ccioflan Jul 24, 2024
01dac38
Found configuration for DSCNN L
ccioflan Jul 24, 2024
0a851dd
Removed obsolete l3 buffer
ccioflan Jul 26, 2024
6f8e82b
WIP: Fixing NE16 inference
ccioflan Jul 31, 2024
5b87728
WIP: Fixing NE16 inference, minor cleanup
ccioflan Jul 31, 2024
4bb6e51
Pushing to emphasize the need to manually adjust the file
ccioflan Aug 5, 2024
4523700
Updated gitmodules
ccioflan Aug 5, 2024
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ application
**/gmon.out
.idea
dory.egg-info
dory.egg-info/
dory.egg-info/
DSCNN_DIR_DEST_DORY/
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[submodule "dory_examples"]
path = dory/dory_examples
url = ../../pulp-platform/dory_examples
url = https://github.com/pulp-platform/dory_examples
[submodule "Hardware-targets/GAP8/Backend_Kernels/pulp-nn"]
path = dory/Hardware_targets/PULP/Backend_Kernels/pulp-nn
url = ../../pulp-platform/pulp-nn.git
url = https://github.com/pulp-platform/pulp-nn.git
[submodule "Hardware-targets/Diana/Backend_Kernels/dory-hal"]
path = dory/Hardware_targets/Diana/Backend_Kernels/dory-hal
url = ../../ABurrello/dory-hal.git
url = https://github.com/ABurrello/dory-hal.git
[submodule "dory/Hardware_targets/GAP8/Backend_Kernels/pulp-nn-mixed"]
path = dory/Hardware_targets/PULP/Backend_Kernels/pulp-nn-mixed
url = https://github.com/pulp-platform/pulp-nn-mixed.git
Expand Down
5 changes: 3 additions & 2 deletions dory/Frontend_frameworks/NEMO/Parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
class onnx_manager(Parser_ONNX_to_DORY):
# Used to manage the ONNX files. By now, supported Convolutions (PW and DW), Pooling, Fully Connected and Relu.

def __init__(self, onnx, config_file, net_prefix=""):
def __init__(self, onnx, config_file, net_prefix="", n_trainable_layers=0):
layers_accepted = ['Conv', 'Pad', 'Mul', 'Add', 'Div', 'Constant', 'AveragePool', 'GlobalAveragePool', 'MaxPool', 'Cast', 'Clip', 'Floor', 'Flatten', 'Gemm', 'MatMul', 'Shape', 'Gather', 'Unsqueeze', 'Concat', 'Reshape', 'Sigmoid', 'LogSoftmax']
layers_neglected = ['Cast', 'Floor', 'Flatten', 'Shape', 'Gather', 'Unsqueeze', 'Concat', 'Reshape', 'Sigmoid', 'LogSoftmax']
layers_to_node = ['AveragePool', 'MaxPool', 'Conv', 'Gemm', 'MatMul', 'GlobalAveragePool']
Expand All @@ -45,7 +45,7 @@ def __init__(self, onnx, config_file, net_prefix=""):
self.n_test_inputs = config_file["n_inputs"]
except KeyError:
self.n_test_inputs = 1
super().__init__(onnx, rules, layers_accepted, layers_neglected, layers_to_node, net_prefix)
super().__init__(onnx, rules, layers_accepted, layers_neglected, layers_to_node, net_prefix, n_trainable_layers)

def frontend_mapping_to_DORY_nodes(self):
print("\nNEMO Frontend: Matching patterns from generated ONNX to DORY.")
Expand All @@ -55,6 +55,7 @@ def frontend_mapping_to_DORY_nodes(self):
string_matching, indexes = self.pattern_matching(node, i)
if isinstance(string_matching, str):
self.DORY_Graph = Pattern_rewriter(self.DORY_Graph).execute(string_matching, indexes)

print("\nNEMO Frontend: Updating Add nodes with constants.")
for i, node in enumerate(self.DORY_Graph):
if "Addition" in node.name:
Expand Down
10 changes: 7 additions & 3 deletions dory/Frontend_frameworks/Quantlab/Parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
class onnx_manager(Parser_ONNX_to_DORY):
# Used to manage the ONNX files. By now, supported Convolutions (PW and DW), Pooling, Fully Connected and Relu.

def __init__(self, onnx, config_file, net_prefix=""):
def __init__(self, onnx, config_file, net_prefix="", n_trainable_layers=0):
layers_accepted = ['Conv', 'Pad', 'Mul', 'Add', 'Div', 'Constant', 'AveragePool', 'GlobalAveragePool', 'MaxPool', 'Cast', 'Clip', 'Floor', 'Flatten', 'Gemm', 'MatMul', 'Shape', 'Gather', 'Unsqueeze', 'Squeeze', 'Concat', 'Reshape', 'Sigmoid', 'LogSoftmax']
layers_neglected = ['Cast', 'Floor', 'Flatten', 'Shape', 'Gather', 'Unsqueeze', 'Concat', 'Reshape', 'Sigmoid', 'LogSoftmax', 'Squeeze']
layers_to_node = ['AveragePool', 'MaxPool', 'Conv', 'Gemm', 'MatMul', 'GlobalAveragePool']
Expand All @@ -53,7 +53,7 @@ def __init__(self, onnx, config_file, net_prefix=""):
self.n_test_inputs = config_file["n_inputs"]
except KeyError:
self.n_test_inputs = 1
super().__init__(onnx, rules, layers_accepted, layers_neglected, layers_to_node, net_prefix)
super().__init__(onnx, rules, layers_accepted, layers_neglected, layers_to_node, net_prefix, n_trainable_layers)

def frontend_mapping_to_DORY_nodes(self):
print("\nQuantlab Frontend: Matching patterns from generated ONNX to DORY.")
Expand Down Expand Up @@ -93,7 +93,11 @@ def frontend_mapping_to_DORY_nodes(self):
# input 1 parameters
#### Look at the order of inputs in Onnx. If the lowest index
#is not the first argument, revert the order inmul1 and inmul2
if int(node.input_indexes[0]) > int(node.input_indexes[1]):
def pos_in_schedule(node: str) -> int:
for idx, node_iterating in enumerate(list(self.graph.graph.node)):
if node_iterating.output[0] == node:
return idx
if pos_in_schedule(node.input_indexes[0]) > pos_in_schedule(node.input_indexes[1]):
temp_shift = node.in1_shift
temp_mul = node.in1_mul
temp_add = node.in1_add
Expand Down
2 changes: 1 addition & 1 deletion dory/Hardware_targets/Diana/Backend_Kernels/dory-hal
Submodule dory-hal updated 1 files
+8 −3 src/utils.c
30 changes: 19 additions & 11 deletions dory/Hardware_targets/PULP/Backend_Kernels/BackendKernelsAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,24 +177,32 @@ def _check_valid_node(self, node: HW_node) -> None:
if self.accelerator_name == "ne16":
assert True # TODO

def _get_ne16_src_files(self) -> List[str]:
return ["src/pulp_nnx_ne16.c", "ne16/hal/ne16_hal.c"]
def _get_acc_src_files(self) -> List[str]:
return [
f"{self.accelerator_name}/hal/{self.accelerator_name}.c",
f"{self.accelerator_name}/hal/{self.accelerator_name}_task.c",
f"{self.accelerator_name}/bsp/{self.accelerator_name}_pulp_bsp.c",
f"src/pulp_nnx_{self.accelerator_name}.c",
]

def _get_ne16_inc_files(self) -> List[str]:
def _get_acc_inc_files(self) -> List[str]:
return [
"ne16/gvsoc/ne16_gvsoc_logging.h",
"ne16/hal/ne16_defs.h",
"ne16/hal/ne16_hal.h",
f"{self.accelerator_name}/gvsoc/{self.accelerator_name}_gvsoc.h",
f"{self.accelerator_name}/hal/{self.accelerator_name}_task_defs.h",
f"{self.accelerator_name}/hal/{self.accelerator_name}.h",
f"{self.accelerator_name}/hal/{self.accelerator_name}_task.h",
f"{self.accelerator_name}/bsp/{self.accelerator_name}_pulp_bsp.h",
f"inc/pulp_nnx_{self.accelerator_name}.h",
]

def _get_src_files(self) -> List[str]:
src_files = ["util/pulp_nnx_util.c"]
src_files = ["util/pulp_nnx_util.c", "util/hwpe.c"]
if self.accelerator_name == "ne16":
src_files += self._get_ne16_src_files()
src_files += self._get_acc_src_files()
return [os.path.join(self._root_dir(), file) for file in src_files]

def _get_inc_files(self) -> List[str]:
inc_files = ["inc/pulp_nnx.h", "util/pulp_nnx_util.h"]
inc_files = ["util/pulp_nnx_util.h", "util/hwpe.h"]
if self.accelerator_name == "ne16":
inc_files += self._get_ne16_inc_files()
return [os.path.join(self._root_dir(), file) for file in inc_files]
inc_files += self._get_acc_inc_files()
return [os.path.join(self._root_dir(), file) for file in inc_files]
2 changes: 1 addition & 1 deletion dory/Hardware_targets/PULP/Backend_Kernels/pulp-nnx
Submodule pulp-nnx updated 79 files
+20 −4 .gitlab-ci.yml
+59 −0 CHANGELOG.md
+52 −0 CMakeLists.txt
+61 −46 README.md
+0 −75 inc/pulp_nnx.h
+76 −0 inc/pulp_nnx_ne16.h
+61 −0 inc/pulp_nnx_neureka.h
+36 −0 ne16/README.md
+85 −0 ne16/bsp/ne16_pulp_bsp.c
+81 −0 ne16/bsp/ne16_pulp_bsp.h
+20 −15 ne16/gvsoc/ne16_gvsoc.h
+13 −6 ne16/hal/ne16.c
+15 −10 ne16/hal/ne16.h
+0 −157 ne16/hal/ne16_defs.h
+0 −224 ne16/hal/ne16_hal.c
+0 −197 ne16/hal/ne16_hal.h
+260 −0 ne16/hal/ne16_task.c
+193 −0 ne16/hal/ne16_task.h
+122 −0 ne16/hal/ne16_task_defs.h
+34 −0 neureka/README.md
+78 −0 neureka/bsp/neureka_siracusa_bsp.c
+67 −0 neureka/bsp/neureka_siracusa_bsp.h
+54 −0 neureka/gvsoc/neureka_gvsoc.h
+37 −0 neureka/hal/neureka.c
+15 −5 neureka/hal/neureka.h
+245 −0 neureka/hal/neureka_task.c
+188 −0 neureka/hal/neureka_task.h
+124 −0 neureka/hal/neureka_task_defs.h
+0 −167 neureka/inc/pulp_nnx_defs.h
+0 −217 neureka/inc/pulp_nnx_hal.h
+0 −412 neureka/src/pulp_nnx_hal.c
+68 −170 src/pulp_nnx_ne16.c
+76 −0 src/pulp_nnx_neureka.c
+1 −1 test/.gitignore
+4 −0 test/.isort.cfg
+52 −12 test/HeaderWriter.py
+0 −94 test/Ne16.py
+99 −0 test/Ne16MemoryLayout.py
+117 −0 test/Ne16TestConf.py
+134 −0 test/NeuralEngineFunctionalModel.py
+156 −0 test/NeurekaMemoryLayout.py
+110 −0 test/NeurekaTestConf.py
+160 −225 test/NnxTestClasses.py
+6 −0 test/README.md
+7 −7 test/TestClasses.py
+25 −15 test/app/Makefile
+11 −8 test/app/src/main.c
+190 −62 test/app/src/nnx_layer.c
+8 −5 test/conf.toml
+54 −9 test/conftest.py
+1 −0 test/requirements-dev.txt
+2 −2 test/requirements.txt
+40 −16 test/test.py
+118 −56 test/testgen.py
+29 −0 test/tests/test_100/conf.json
+29 −0 test/tests/test_101/conf.json
+29 −0 test/tests/test_102/conf.json
+29 −0 test/tests/test_103/conf.json
+29 −0 test/tests/test_104/conf.json
+29 −0 test/tests/test_105/conf.json
+29 −0 test/tests/test_106/conf.json
+29 −0 test/tests/test_107/conf.json
+29 −0 test/tests/test_108/conf.json
+29 −0 test/tests/test_109/conf.json
+29 −0 test/tests/test_110/conf.json
+29 −0 test/tests/test_111/conf.json
+29 −0 test/tests/test_112/conf.json
+29 −0 test/tests/test_113/conf.json
+29 −0 test/tests/test_114/conf.json
+29 −0 test/tests/test_115/conf.json
+29 −0 test/tests/test_116/conf.json
+29 −0 test/tests/test_117/conf.json
+29 −0 test/tests/test_118/conf.json
+30 −0 test/tests/test_119/conf.json
+30 −0 test/tests/test_120/conf.json
+85 −0 util/hwpe.c
+43 −0 util/hwpe.h
+7 −5 util/pulp_nnx_util.c
+11 −9 util/pulp_nnx_util.h
4 changes: 2 additions & 2 deletions dory/Hardware_targets/PULP/Common/C_Parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def mapping_layers_to_C_files(self):

if n_memory_levels > 2 and (node.L3_input != 0 or (node.tiling_dimensions["L3"]["output_dimensions"] != node.tiling_dimensions["L2"]["output_dimensions"]) or (node.tiling_dimensions["L3"]["weights_dimensions"] != node.tiling_dimensions["L2"]["weights_dimensions"])):
tk = Layer2D_writer.print_template_layer_L3(node)
TemplateWriter.write(tk, {os.path.join(self.src_dir, node.prefixed_name + ".c"): os.path.join(self.tmpl_dir, "layer_L3_c_template.c"),
os.path.join(self.inc_dir, node.prefixed_name + ".h"): os.path.join(self.tmpl_dir, "layer_L3_h_template.h")})
TemplateWriter.write(tk, {os.path.join(self.src_dir, node.prefixed_name + ".c"): os.path.join(self.layer_tmpl_dir, "layer_L3_c_template.c"),
os.path.join(self.inc_dir, node.prefixed_name + ".h"): os.path.join(self.layer_tmpl_dir, "layer_L3_h_template.h")})
if node.tiling_dimensions["L3"]["input_dimensions"][1] > node.tiling_dimensions["L2"]["input_dimensions"][1]:
node.tiling_dimensions["L2"]["output_dimensions"][1] = int(np.floor((node.tiling_dimensions["L2"]["input_dimensions"][1] - node.kernel_shape[0] + node.strides[0]) / node.strides[0]))
if node.tiling_dimensions["L3"]["output_dimensions"][1] > node.tiling_dimensions["L2"]["output_dimensions"][1]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
* limitations under the License.
*/
#include "${func_name_L3}.h"
#include "${func_name[0]}.h"
% if len(func_name)>1:
#include "${func_name[1]}.h"
#include "${func_name[2]}.h"
%endif
% for name in func_name:
#include "${name}.h"
% endfor
#include "dory_get_tile.h"
#include "pmsis.h"
#include "bsp/fs.h"
Expand Down
3 changes: 2 additions & 1 deletion dory/Hardware_targets/PULP/Common/Templates/main.c.t
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ int main () {
#ifndef TARGET_CHIP_FAMILY_GAP9
PMU_set_voltage(1000, 0);
#else
pi_pmu_voltage_set(PI_PMU_VOLTAGE_DOMAIN_CHIP, PI_PMU_VOLT_800);
pi_pmu_voltage_set(PI_PMU_VOLTAGE_DOMAIN_CHIP, PI_VOLT_800); // GAP9
// pi_pmu_voltage_set(PI_PMU_VOLTAGE_DOMAIN_CHIP, PI_PMU_VOLT_800); // GAP8
#endif
pi_time_wait_us(10000);
pi_freq_set(PI_FREQ_DOMAIN_FC, ${fc_frequency});
Expand Down
17 changes: 13 additions & 4 deletions dory/Hardware_targets/PULP/Common/Templates/network.c.t
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ void ${prefix}network_initialize() {
L3_input = ram_malloc(L3_INPUT_SIZE);
L3_output = ram_malloc(L3_OUTPUT_SIZE);

#ifdef VERBOSE
% if 'Yes' in performance:
printf("\nL3 Buffer alloc initial\t@ %d:\t%s\n", (unsigned int)L3_weights, L3_weights?"Ok":"Failed");
printf("\nL3 Buffer alloc initial\t@ %d:\t%s\n", (unsigned int)L3_input, L3_input?"Ok":"Failed");
printf("\nL3 Buffer alloc initial\t@ %d:\t%s\n", (unsigned int)L3_output, L3_output?"Ok":"Failed");
#endif
% endif

void *w_ptr = L3_weights;
for (int i = 0; i < ${weights_number}; i++) {
Expand Down Expand Up @@ -113,7 +113,7 @@ struct ${prefix}network_run_token ${prefix}network_run_async(void *l2_buffer, si
pi_cluster_conf_init(&conf);
conf.id=0;
<%
n_args = 4 if l3_supported else 5
n_args = 5 if l3_supported else 6
%>\
unsigned int args[${n_args}];
args[0] = (unsigned int) l2_buffer;
Expand Down Expand Up @@ -141,8 +141,10 @@ struct ${prefix}network_run_token ${prefix}network_run_async(void *l2_buffer, si
void ${prefix}network_run_wait(struct ${prefix}network_run_token token)
{
pi_cluster_close(&token.cluster_dev);
% if 'Perf_final' in verbose_level:
% if 'Yes' in performance:
#ifdef VERBOSE
print_perf("Final", ${prefix}cycle_network_execution, ${MACs});
#endif
% endif
}

Expand Down Expand Up @@ -215,6 +217,7 @@ void ${prefix}network_run_cluster(void *args) {
/* -------- SECTION 2 BEGIN --------- */
/* ---------------------------------- */
int weight_l_cnt = 0; // count how many layers with weights we have processed to increment the weights_L3 pointer

for (int i = 0; i < ${len(DORY_HW_graph)}; i++) {
/* MEMORY ALLOCATION
- allocate memory if layer is executed from L3;
Expand All @@ -235,6 +238,7 @@ void ${prefix}network_run_cluster(void *args) {
L2_weights = Weights_name[i];
% endif

% if 'Yes' in performance:
% if 'Check_all' in verbose_level:
#ifdef VERBOSE
% if l3_supported:
Expand All @@ -256,6 +260,7 @@ void ${prefix}network_run_cluster(void *args) {
else
printf("Switching branch, already checked activation\n");
#endif
% endif
% endif

layer_args_t largs = {
Expand Down Expand Up @@ -292,7 +297,9 @@ void ${prefix}network_run_cluster(void *args) {
% endif

% if 'Yes' in performance:
#ifdef VERBOSE
print_perf(Layers_name[i], perf_cyc, NODEs_MACS[i]);
#endif
% endif

// TODO: What error?
Expand All @@ -304,6 +311,7 @@ void ${prefix}network_run_cluster(void *args) {
L3_output = temp;
asm volatile("": : :"memory");

% if 'Yes' in performance:
#ifdef VERBOSE
printf("Layer %s %d ended: \n", Layers_name[i], i);
% if 'Check_all' in verbose_level:
Expand All @@ -323,6 +331,7 @@ void ${prefix}network_run_cluster(void *args) {
checksum("final layer", L2_output, activations_out_size[i], activations_out_checksum[i][exec]);
% endif
#endif
% endif

// Free memory
% if l3_supported:
Expand Down
45 changes: 15 additions & 30 deletions dory/Hardware_targets/PULP/Common/Tiler/tiler_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,62 +91,47 @@ def get_tiling_Add_L2(self):
# return immediatly if the memory fits the L1
if buffer_total <= L1_memory:
return ([], self.HW_node.tiling_dimensions["L2"]["input_dimensions"] , self.HW_node.tiling_dimensions["L2"]["output_dimensions"] )
else:
db = self.double_buffering

db = self.double_buffering

parameters = pywrapcp.Solver.DefaultSolverParameters()
solver = pywrapcp.Solver("simple_CP", parameters)

# integer positive variables.
tile_n = solver.IntVar(1, in_ch, 'tile_n')
tile_h_in = solver.IntVar(ks[0], inp_dim[0], 'tile_h_in')
tile_w_in = solver.IntVar(ks[1], inp_dim[1], 'tile_w_in')
tile_h_out = solver.IntVar(1, out_dim[0], 'tile_h_out')
tile_w_out = solver.IntVar(1, out_dim[1], 'tile_w_out')
assert in_ch == out_ch

# scaling is used to ensure datasize is integer
solver.Add(tile_h_out == tile_h_in)
solver.Add(tile_w_out == tile_w_in)
solver.Add(tile_n == in_ch)
# integer positive variables.
tile_n = in_ch
tile_h = solver.IntVar(1, inp_dim[0], 'tile_h_in')
tile_w = inp_dim[1]

# CONSTRAINTS: managing of correct dimensions (no decimal h_out and any
# type of rounding)
input_tile_dimension = (db * in_ch * tile_h_in * inp_dim[1] * self.HW_node.input_activation_bits + 7 ) // 8 # the 7 is to account for bit precision of 1, which still occupy an entire byte
output_tile_dimension = (db * out_ch * tile_h_out * out_dim[1] * self.HW_node.output_activation_bits + 7 ) // 8 # the 7 is to account for bit precision of 1, which still occupy an entire byte
input_tile_dimension = (db * tile_n * tile_h * tile_w * self.HW_node.input_activation_bits + 7 ) // 8 # the 7 is to account for bit precision of 1, which still occupy an entire byte
output_tile_dimension = (db * tile_n * tile_h * tile_w * self.HW_node.output_activation_bits + 7 ) // 8 # the 7 is to account for bit precision of 1, which still occupy an entire byte
constraint_all = input_tile_dimension * int(np.ceil(1+self.HW_node.second_input_activation_bits/self.HW_node.input_activation_bits)) + output_tile_dimension
solver.Add(constraint_all <= L1_memory)

# objective
obj_expr = solver.IntVar(0, 1000000000000, "obj_expr")
solver.Add(obj_expr == 1000000 * constraint_all
+ 10 * tile_w_in
+ 1 * tile_h_in
+ 1000 * tile_n)
solver.Add(obj_expr == constraint_all)
objective = solver.Maximize(obj_expr, 1)

decision_builder = solver.Phase([tile_n, tile_h_in, tile_w_in, tile_h_out, tile_w_out],
decision_builder = solver.Phase([tile_h],
solver.CHOOSE_FIRST_UNBOUND,
solver.ASSIGN_MIN_VALUE)

# Create a solution collector.
collector = solver.LastSolutionCollector()
# Add the decision variables.
collector.Add(tile_n)
collector.Add(tile_h_in)
collector.Add(tile_w_in)
collector.Add(tile_h_out)
collector.Add(tile_w_out)
collector.Add(tile_h)
# Add the objective.
collector.AddObjective(obj_expr)

solver.Solve(decision_builder, [objective, collector])
if collector.SolutionCount() > 0:
best_solution = collector.SolutionCount() - 1
tile_n = collector.Value(best_solution, tile_n)
tile_h_in = collector.Value(best_solution, tile_h_in)
tile_w_in = collector.Value(best_solution, tile_w_in)
tile_h_out = collector.Value(best_solution, tile_h_out)
tile_w_out = collector.Value(best_solution, tile_w_out)
return ([], [tile_n, tile_h_in, tile_w_in], [tile_n, tile_h_out, tile_w_out])
tile_h = collector.Value(best_solution, tile_h)
return ([], [tile_n, tile_h, tile_w], [tile_n, tile_h, tile_w])
print(" Add ERROR: no tiling found. Exiting...")
os._exit(0)
return None
2 changes: 1 addition & 1 deletion dory/Hardware_targets/PULP/GAP8_L2/HW_description.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"accelerator frequency": 100000000,
"HW specific parameters":{
"accelerator core0 stack": 3500,
"accelerator core1-7 stack": 3400
"accelerator core1-7 stack": 3400
},
"split_ints": true,
"double_buffering": 1
Expand Down
2 changes: 1 addition & 1 deletion dory/Hardware_targets/PULP/GAP9/HW_description.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"memory": {
"levels": 3,
"L1": {
"dimension": 120000,
"dimension": 110000,
"bandwidth": 32,
"latency": 1,
"frequency": 100000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ static void kernel(Layer tile, Layer tile2) {
tile.addr.input,
tile2.addr.input,
tile.addr.output,
${inmul2},
${inmul1},
${inmul2},
${outshift},
tile.input.width,
tile.input.height,
Expand Down
Loading
Loading