44
55from typing import Dict , List , Tuple
66
7- import numpy as np
8-
97from Deeploy .DeeployTypes import NetworkContext , OperatorRepresentation , VariableBuffer
108from Deeploy .Targets .Generic .Templates .ReshapeTemplate import _ReshapeTemplate
119
@@ -17,28 +15,20 @@ def alignToContext(self, ctxt: NetworkContext,
1715
1816 ctxt , operatorRepresentation , _ = super ().alignToContext (ctxt , operatorRepresentation )
1917
20- # Calculate size for multi-core parallel copy
2118 bufferIn = ctxt .lookup (operatorRepresentation ['data_in' ])
2219 assert isinstance (bufferIn , VariableBuffer )
23- operatorRepresentation ['size' ] = int (np .prod (bufferIn .shape ))
20+ bufferOut = ctxt .lookup (operatorRepresentation ['data_out' ])
21+ assert isinstance (bufferOut , VariableBuffer )
22+
23+ # Set alias so input and output share the same memory
24+ bufferOut ._alias = bufferIn .name
2425
2526 return ctxt , operatorRepresentation , []
2627
2728
28- # Reshape uses multi-core parallel copy
29- # When aliases work (internal nodes), this copies between same memory (no-op effect)
30- # When aliases don't work (global I/O), this copies data correctly
29+ # Reshape only reinterprets tensor shape without modifying data.
30+ # Uses SkipTransformer (no DMA), consistent with PULPOpen.
3131referenceTemplate = _SnitchReshapeTemplate ("""
3232// Reshape (Name: ${nodeName}, Op: ${nodeOp})
33- {
34- uint32_t core_id = snrt_cluster_core_idx();
35- uint32_t num_cores = snrt_cluster_compute_core_num();
36- uint32_t total = ${size};
37- uint32_t chunk = total / num_cores;
38- uint32_t start = core_id * chunk;
39- uint32_t end = (core_id == num_cores - 1) ? total : start + chunk;
40- for (uint32_t i = start; i < end; i++) {
41- ${data_out}[i] = ${data_in}[i];
42- }
43- }
33+ ${data_out} = ${data_in};
4434""" )
0 commit comments