Skip to content

Commit 507a658

Browse files
committed
fix Neureka DW weight encoding and parsing
1 parent d9f5707 commit 507a658

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

Deeploy/Targets/Neureka/Engine.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131
ConvLayer([NeurekaPWConv2DMapper, NeurekaDWConv2DMapper, NeurekaDenseConv2DMapper]),
3232
}
3333

34-
_includeList = ["pulp_nnx_neureka.h", "pulp_nnx_util.h", "neureka_siracusa_bsp.h", "neureka.h", "neureka_task.h", "neureka_gvsoc.h"]
34+
_includeList = [
35+
"pulp_nnx_neureka.h", "pulp_nnx_util.h", "neureka_siracusa_bsp.h", "neureka.h", "neureka_task.h", "neureka_gvsoc.h"
36+
]
3537

3638
_neurekaInitCode = r"""
3739
neureka_siracusa_conf_t conf = {.max_stall = 8};
3840
neureka_nnx_init(neureka_siracusa_get_dev(), &conf);
39-
neureka_gvsoc_log_activate(neureka_siracusa_get_dev(), NEUREKA_GVSOC_LOG_LEVEL_ALL, NEUREKA_GVSOC_LOG_FORMAT_DECIMAL);
41+
neureka_gvsoc_log_activate(neureka_siracusa_get_dev(), NEUREKA_GVSOC_LOG_LEVEL_ALL, NEUREKA_GVSOC_LOG_FORMAT_HEXADECIMAL);
4042
"""
4143

4244

Deeploy/Targets/Neureka/Parsers.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,19 @@ def parseNode(self, node: gs.Node) -> bool:
8787
if not super().parseNode(node):
8888
return False
8989

90-
ch_im_out = node.inputs[1].shape[0]
91-
ch_im_in = node.inputs[1].shape[1]
92-
90+
weights = node.inputs[1]
91+
92+
# weigths reshaped by the weigths encoder into
93+
# (cout, cinMajor, bits, weightBandwidthBytes)
94+
# where:
95+
# - cout: 1 by definition (it is cin from ONNX)
96+
# - cinMajor: number of tiles over the channels
97+
# - bits: weight bit width (only 8 is supported)
98+
# - weightBandwidthBytes: which is 32 in Siracusa
9399
if not all([
94100
self.operatorRepresentation['kernel_shape'] == [3, 3],
95-
self.operatorRepresentation['group'] == ch_im_out,
96-
ch_im_in == 1,
101+
len(weights.shape) == 4,
102+
weights.shape[0] == 1, # ch_im_out
97103
]):
98104
return False
99105

Deeploy/Targets/Neureka/TopologyOptimizationPasses/Passes.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ def _weightEncode(weight: npt.NDArray[np.uint8], bits: int, depthwise: bool = Fa
3434
_NEUREKA_CIN_SUBTILE_1x1 = 32
3535
_NEUREKA_CIN_SUBTILE_3x3 = 28
3636

37-
if depthwise:
38-
weight = weight.transpose(1, 0, 2, 3) # Swap cout and cin
39-
4037
cout, cin, height, width = weight.shape
4138
cinSubtile = (_NEUREKA_CIN_SUBTILE_3x3 if height == 3 else _NEUREKA_CIN_SUBTILE_1x1)
4239

0 commit comments

Comments
 (0)