Skip to content
Open
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c59f625
Conv2D Bias Adaptation
diaconuccalin Jul 29, 2025
8edf0c2
Adde PULPOpen support for Conv2D and partially working DW Conv2D. Fix…
diaconuccalin Aug 7, 2025
b26d8ef
DW 2D Float Conv for PULPOpen platform now working. Updated im2col bu…
diaconuccalin Sep 18, 2025
ec749d5
Optimized the PULPOpen DW 2D fp32 Convolution and fixed the bias vers…
diaconuccalin Sep 19, 2025
b2ade51
Updated float reshape with skip connection test to a smaller one
diaconuccalin Sep 19, 2025
e58fa66
Fixed generic platform alias_of bug
diaconuccalin Sep 22, 2025
41cb270
Fixed the PULPOpen FloatGemmTemplate (identical issue to the generic …
diaconuccalin Sep 22, 2025
6cbf247
Working TinyViT Demo test. Added it to the CI pipeline. Added float s…
diaconuccalin Sep 22, 2025
afe1761
Added GEMM batched fix to MatMul template
diaconuccalin Sep 23, 2025
8ebe0aa
Fixed formatting
diaconuccalin Sep 23, 2025
c413255
Fixes to avoid warnings
diaconuccalin Sep 23, 2025
f0e469c
Fix formatting
diaconuccalin Sep 23, 2025
a198973
Merge fix
diaconuccalin Sep 23, 2025
545e5f4
Dynamic buffer calculation fix. Other fixes
diaconuccalin Sep 24, 2025
cadc0e8
Reformat
diaconuccalin Sep 24, 2025
f12e117
Added back CI tests removed by merge
diaconuccalin Sep 24, 2025
35dd7ad
Updated changelog file
diaconuccalin Sep 24, 2025
db23d69
Applied fixes suggested in the PR review
diaconuccalin Sep 24, 2025
adba733
Post-merge fixes
diaconuccalin Oct 13, 2025
884b8f2
Quickfix
diaconuccalin Oct 13, 2025
7bcb512
PR fixes
diaconuccalin Oct 17, 2025
ebc02cf
Addressed PR review. Minor fix for aliasing in reshape parser
diaconuccalin Oct 21, 2025
73dec31
Minor fix based on PR review
diaconuccalin Oct 21, 2025
a1aecff
Post-rebase fixes
diaconuccalin Oct 27, 2025
f320760
More post-rebase fixes
diaconuccalin Oct 27, 2025
7c2e410
Quickfix
diaconuccalin Oct 27, 2025
01c767c
Fix aliases parameter issues
diaconuccalin Oct 27, 2025
aa48ced
Bring alias changes to PULP reshape
diaconuccalin Oct 27, 2025
c28d79b
Alias quickfix
diaconuccalin Oct 27, 2025
082db01
Fixes based on CodeRabbit PR Reviews
diaconuccalin Oct 27, 2025
c17c13a
Removed alias leftovers
diaconuccalin Oct 28, 2025
6aaed14
Reduced code duplication in PULP Conv2D parsers
diaconuccalin Oct 28, 2025
992bb83
Remove duplicate code in the PULPOpen reshape template
diaconuccalin Oct 29, 2025
c915c16
Restrained n_cores usage to PULP
diaconuccalin Oct 30, 2025
0c3cdce
Quickfix
diaconuccalin Oct 30, 2025
43544e9
Fix based on CodeRabbit review
diaconuccalin Oct 30, 2025
cf7a23f
Make IntegerDataTypes a tuple
lukamac Oct 31, 2025
f493257
Change _mapNode to _selectEngine
lukamac Oct 31, 2025
ac0ddb5
Revert removal of PULPReshapeBindings
lukamac Oct 31, 2025
6730204
Add n_cores to PULPClusterEngine and a hacky way to annotate the oper…
lukamac Oct 31, 2025
b41cce1
Remove n_cores annotation from context and parser
lukamac Oct 31, 2025
db1f488
Trailing whitespace fixes
lukamac Oct 31, 2025
ba665dc
Revert unnecessary changes
lukamac Oct 31, 2025
fe9cdb4
Rename --n_cores flag to --cores to align with the preexisting siracu…
lukamac Oct 31, 2025
4acb449
Use parsed args instead of an extra argument to testRunner
lukamac Nov 1, 2025
49cd3b1
Revert removal of header guard and addition of full license in the he…
lukamac Nov 1, 2025
dd40418
Fix missing space between `--cores` argument and previous args
lukamac Nov 1, 2025
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
10 changes: 10 additions & 0 deletions .github/workflows/ci-platform-siracusa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ jobs:
testBacktracking
testFloatAdder
testFloatGEMM

testFloat2DConvolution
testFloat2DConvolutionBias
testFloat2DConvolutionZeroBias

testFloat2DDWConvolution
testFloat2DDWConvolutionBias
testFloat2DDWConvolutionZeroBias

testFloatLayerNorm
testFloatRelu
testFloatMaxPool
Expand All @@ -64,6 +72,7 @@ jobs:
Quant
Dequant
testFloatReduceSum
testFloatReshapeWithSkipConnection
testFloatSoftmaxGrad
testFloatSoftmaxCrossEntropy
testFloatSoftmaxCrossEntropyGrad
Expand All @@ -87,4 +96,5 @@ jobs:
CCT/CCT_1_16_16_8
CCT/CCT_2_32_32_128_Opset20
testTrainCCT/CCT1_Classifier_Training/CCT_1_16_16_8
testFloatDemoTinyViT
num-cores: 8
20 changes: 16 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This file contains the changelog for the Deeploy project. The changelog is divid
## Unreleased (Planned Release Target: v0.2.1)

### List of Pull Requests
- TinyViT on non-tiled Siracusa [#117](https://github.com/pulp-platform/Deeploy/pull/117)
- Disallow shape inference [#128](https://github.com/pulp-platform/Deeploy/pull/128)
- Remove memory-aware node bindings [#123](https://github.com/pulp-platform/Deeploy/pull/123)
- Fix missing const's layout transformation and refactor NCHWtoNHWC passes [#122](https://github.com/pulp-platform/Deeploy/pull/122)
Expand All @@ -23,6 +24,13 @@ This file contains the changelog for the Deeploy project. The changelog is divid
- Fix bias hoisting in generic GEMM with no bias [#126](https://github.com/pulp-platform/Deeploy/pull/126)

### Added
- PULP 2D FP DW conv Im2Col template and kernel, with bias support.
- Bias support for PULP 2D FP regular conv Im2Col in template & kernel.
- PULP FP DW conv 2D parser.
- FP conv 2D (simple & DW), reshape & skip connection, and TinyViT demo tests to the non-tiled Siracusa CI pipeline.
- FP bindings and mappings for PULP slice, DW conv 2D, and reduce mean operations.
- FP PULP DW conv lowering optimization pass similar to the existent one for integer version.
- RemoveEmptyConvBiasPass to the PULP optimizer.
- Add manual type inference feature (CLI: `--input-type-map`/`--input-offset-map`) to resolve ambiguities when test inputs are not representative enough
- Added a `testTypeInferenceDifferentTypes` test case to validate type inference for different input types
- Added `_mangleNodeNames` function to avoid duplicate node mappings
Expand Down Expand Up @@ -57,6 +65,7 @@ This file contains the changelog for the Deeploy project. The changelog is divid
- Added testFloatGEMMnobias

### Changed
- Reduced size of reshape & skip connection test, for non-tiled Siracusa memory compatibility.
- Replaced platform-specific tags (`*-amd64`, `*-arm64`) with direct digest references in `Noelware/docker-manifest-action`.
- mchan HAL is now reduced to bare-bones
- refactor of the IntrospectiveCodeTransformation to work on the Mako template
Expand Down Expand Up @@ -93,6 +102,9 @@ This file contains the changelog for the Deeploy project. The changelog is divid
- Added missing shape annotation to the testTypeInferenceDifferentTypes

### Fixed
- Fixed bug for non-batched elements in the PULPOpen FP GEMM and matmul templates.
- Added underscore to the beginning of closure names to avoid naming issues when they start with unsupported first characters (like numbers).
- Data types in the PULPOpen FP add and mul templates.
Comment on lines +105 to +107
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix sentence fragment in Fixed section.

Line 107 is missing the verb "Fixed," creating a sentence fragment that's inconsistent with the other entries in this section.

Apply this diff to correct it:

- Fixed bug for non-batched elements in the PULPOpen FP GEMM and matmul templates.
- Added underscore to the beginning of closure names to avoid naming issues when they start with unsupported first characters (like numbers).
- Data types in the PULPOpen FP add and mul templates.
+ Fixed bug for non-batched elements in the PULPOpen FP GEMM and matmul templates.
+ Added underscore to the beginning of closure names to avoid naming issues when they start with unsupported first characters (like numbers).
+ Fixed data types in the PULPOpen FP add and mul templates.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Fixed bug for non-batched elements in the PULPOpen FP GEMM and matmul templates.
- Added underscore to the beginning of closure names to avoid naming issues when they start with unsupported first characters (like numbers).
- Data types in the PULPOpen FP add and mul templates.
- Fixed bug for non-batched elements in the PULPOpen FP GEMM and matmul templates.
- Added underscore to the beginning of closure names to avoid naming issues when they start with unsupported first characters (like numbers).
- Fixed data types in the PULPOpen FP add and mul templates.
🤖 Prompt for AI Agents
In CHANGELOG.md around lines 105 to 107, the third bullet (line 107) is a
sentence fragment missing the leading verb "Fixed"; update that line to start
with "Fixed" so it matches the style of the other entries (e.g., "Fixed data
types in the PULPOpen FP add and mul templates.").

- Prevent node duplication for graphs generated via GraphSurgeon
- Resolved issue with missing `id` in the `Build Cache for Docker` step, used in the `Inject build-cache` step.
- Fix license CI check and prevent potential issues with `jq` installation
Expand Down Expand Up @@ -180,9 +192,9 @@ This release containing major architectural changes, new platform support, enhan


### Added
- BatchNorm kernel
- ConvTranspose kernel
- MaxPool1D kernel
- BatchNorm kernel
- ConvTranspose kernel
- MaxPool1D kernel
- Template for 1D Convolution
- Support for float32 data type in the previous kernels
- Float binding for Pad1D kernel
Expand Down Expand Up @@ -321,7 +333,7 @@ This release containing major architectural changes, new platform support, enhan

### Changed
- FloatConvTemplate file
- Platform.py file
- Platform.py file
- Bump the CMake version to 3.24 as required for the chimera-sdk
- Bump GVSoC's version and add chimera simulation target
- Rename the generic source util to utils to avoid name collision with chimera-sdk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def apply(self,
executionBlock: ExecutionBlock,
name: str,
verbose: CodeGenVerbosity = _NoVerbosity) -> Tuple[NetworkContext, ExecutionBlock]:
self.closureName = name + self.closureSuffix
# Prepend underscore to avoid name issues when beginning with problematic characters (like numbers)
self.closureName = "_" + name + self.closureSuffix
self.functionCall = executionBlock.generate(ctxt)
self._generateClosureStruct(ctxt, executionBlock)
ctxt = self._generateClosureCtxt(ctxt, name)
Expand Down
10 changes: 5 additions & 5 deletions Deeploy/CommonExtensions/DataTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ class float64_t(FloatImmediate):

SignedIntegerDataTypes: Tuple[Type[IntegerImmediate], ...] = (int8_t, int16_t, int32_t, int64_t)
UnsignedIntegerDataTypes: Tuple[Type[IntegerImmediate], ...] = (uint8_t, uint16_t, uint32_t, uint64_t)
IntegerDataTypes: Tuple[Type[IntegerImmediate], ...] = (sorted((
*SignedIntegerDataTypes,
*UnsignedIntegerDataTypes,
),
key = lambda _type: _type.typeWidth))
IntegerDataTypes: Tuple[Type[IntegerImmediate], ...] = tuple(
sorted((
*SignedIntegerDataTypes,
*UnsignedIntegerDataTypes,
), key = lambda _type: _type.typeWidth))
FloatDataTypes: Tuple[Type[FloatImmediate], ...] = (bfloat16_t, float16_t, float32_t, float64_t)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
#
# SPDX-License-Identifier: Apache-2.0

from typing import Any, Union

import onnx_graphsurgeon as gs

from Deeploy.DeeployTypes import CodeGenVerbosity, NetworkContext, NetworkDeployer, ONNXLayer, _NoVerbosity
from Deeploy.DeeployTypes import CodeGenVerbosity, DeploymentEngine, NetworkContext, NetworkDeployer, _NoVerbosity


class NetworkDeployerWrapper(NetworkDeployer):
Expand Down Expand Up @@ -68,8 +66,8 @@ def generateBufferAllocationCode(self) -> str:
return self._innerObject.generateBufferAllocationCode()

# MultiEngineDeployer augment
def _mapNode(self, node: gs.Node) -> Union[ONNXLayer, Any]:
return self._innerObject._mapNode(node)
def _selectEngine(self, node: gs.Node) -> DeploymentEngine:
return self._innerObject._selectEngine(node)

def _printMemorySummary(self):
return self._innerObject._printMemorySummary()
Expand Down
11 changes: 6 additions & 5 deletions Deeploy/DeeployTypes.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that you will have to revert 99% of your changes to DeeployTypes.py

Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,15 @@ def fromNode(cls, node: gs.Node):
return (cls(name = node.name, shape = node.shape if not isinstance(node, gs.Constant) else node.values.shape))

def has_live_aliases(self, ctxt: NetworkContext) -> bool:
"""Checks whether this VariableBuffer has any live ancestors, i.e. buffers that are still live and are aliased by this buffer.
"""Checks whether this VariableBuffer has any live aliases, i.e. buffers that are still live and are aliased by this buffer.
Parameters
----------
ctxt : NetworkContext
Current NetworkContext
Returns
-------
bool
True if this VariableBuffer has any live ancestors, False otherwise
True if this VariableBuffer has any live aliases, False otherwise
"""
# Do a breadth-first search across the aliasing double-linked list
live = self._live
Expand Down Expand Up @@ -2562,10 +2562,10 @@ def codeTransform(self, verbose: CodeGenVerbosity = _NoVerbosity):
self.ctxt = layer.codeTransform(self.ctxt, verbose)
self.transformed = True

def _mapNode(self, node: gs.Node) -> Union[ONNXLayer, Any]:
def _selectEngine(self, node: gs.Node) -> DeploymentEngine:
for engine in self.Platform.engines:
if node.op in engine.Mapping:
return engine.Mapping[node.op](node)
return engine
raise RuntimeError(f"No mapping found for node {node.name} with op type {node.op}")

def _bindLayers(self):
Expand All @@ -2582,7 +2582,8 @@ def _bindLayers(self):
flatSchedule += subGraph

for node in flatSchedule:
layer = self._mapNode(node)
engine = self._selectEngine(node)
layer = engine.Mapping[node.op](node)
if isinstance(layer, ONNXLayer):
log.debug(f" {SUCCESS_MARK} Bind {node.name} to layer {layer.__class__.__name__}")
self.layerBinding[layer.node.name] = layer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#
# SPDX-License-Identifier: Apache-2.0

from typing import Any, Callable, Dict, Type, Union
from typing import Callable, Dict, Type

import onnx_graphsurgeon as gs

from Deeploy.AbstractDataTypes import Pointer
from Deeploy.CommonExtensions.NetworkDeployers.NetworkDeployerWrapper import NetworkDeployerWrapper
from Deeploy.DeeployTypes import DeploymentPlatform, NetworkDeployer, ONNXLayer, Schedule, TopologyOptimizer
from Deeploy.DeeployTypes import DeploymentEngine, DeploymentPlatform, NetworkDeployer, Schedule, TopologyOptimizer
from Deeploy.EngineExtension.OptimizationPasses.TopologyOptimizationPasses.EngineColoringPasses import \
EngineColoringPass, EngineMapper

Expand Down Expand Up @@ -48,14 +48,14 @@ def lower(self, graph: gs.Graph) -> gs.Graph:
) == 0, f"Missing engine color for nodes {[node.name for node in uncoloredNodes]} with operations {uncoloredOperations}"
return graph

def _mapNode(self, node: gs.Node) -> Union[ONNXLayer, Any]:
def _selectEngine(self, node: gs.Node) -> DeploymentEngine:
assert "engine" in node.attrs, f"Node {node.name} doesn't have an engine color."
engineName = node.attrs["engine"]
assert isinstance(engineName, str) and engineName in self.engineDict, \
f"Node {node.name} has an invalid engine {engineName} assigned."
engine = self.engineDict[engineName]
assert node.op in engine.Mapping, f"No mapping found for {node.op} in engine {engine.name}"
return engine.Mapping[node.op](node)
return engine


class EngineColoringDeployerWrapper(EngineColoringDeployer, NetworkDeployerWrapper):
Expand Down
51 changes: 36 additions & 15 deletions Deeploy/Targets/PULPOpen/Bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from Deeploy.CommonExtensions.CodeTransformationPasses.Closure import ClosureGeneration, MemoryAwareClosureGeneration
from Deeploy.CommonExtensions.CodeTransformationPasses.MemoryAllocation import ArgumentStructGeneration, \
MemoryManagementGeneration, MemoryPassthroughGeneration
from Deeploy.CommonExtensions.DataTypes import IntegerDataTypes, SignedIntegerDataTypes, float32_t, int8_t, int32_t, \
uint8_t
from Deeploy.CommonExtensions.DataTypes import FloatDataTypes, IntegerDataTypes, SignedIntegerDataTypes, float32_t, \
int8_t, int32_t, int64_t, uint8_t
from Deeploy.DeeployTypes import CodeTransformation, NodeBinding, NodeTemplate
from Deeploy.FutureExtension.Bindings.AutoFutureBinding import AutoFutureBinding
from Deeploy.FutureExtension.CodeTransformationPasses.FutureCodeTransformation import FutureGeneration
from Deeploy.Targets.Generic.Templates import AddTemplate, ConcatTemplate, DequantTemplate, FloatReduceSumTemplate, \
GatherTemplate, QuantTemplate, RQSiGELUTemplate, iHardswishTemplate
from Deeploy.Targets.Generic.Templates import AddTemplate, ConcatTemplate, DequantTemplate, FloatReduceMeanTemplate, \
FloatReduceSumTemplate, GatherTemplate, QuantTemplate, RQSiGELUTemplate, SliceTemplate, iHardswishTemplate
from Deeploy.Targets.Generic.TypeCheckers import AddChecker, ConcatChecker, ConvChecker, DequantChecker, \
GatherChecker, GELUChecker, GEMMChecker, HardswishChecker, LayerNormChecker, MatMulChecker, MulChecker, \
QuantChecker, ReduceMeanChecker, ReluChecker, ReshapeChecker, RQAddChecker, RQHardswishChecker, SGDChecker, \
Expand All @@ -27,11 +27,11 @@
from Deeploy.Targets.PULPOpen.DataTypes import PULPDMAFuture
from Deeploy.Targets.PULPOpen.DMA.L3Dma import l3DmaHack
from Deeploy.Targets.PULPOpen.DMA.MchanDma import MchanDma
from Deeploy.Targets.PULPOpen.Templates import ConvTemplate, FloatAddTemplate, FloatConvTemplate, FloatGELUTemplate, \
FloatGemmTemplate, FloatLayernormTemplate, FloatMatMulTemplate, FloatMaxPoolTemplate, FloatMulTemplate, \
FloatReluTemplate, FloatSoftmaxTemplate, GEMMTemplate, MatrixVectorTemplate, MaxPool2DTemplate, MulTemplate, \
ReduceMeanTemplate, RequantShiftTemplate, ReshapeTemplate, RQAddTemplate, RQSiHardswishTemplate, SGDTemplate, \
SliceTemplate, SoftmaxCrossEntropyLossTemplate, TallGEMMTemplate, TransposeTemplate, UniformRequantShiftTemplate, \
from Deeploy.Targets.PULPOpen.Templates import ConvTemplate, DMASliceTemplate, FloatAddTemplate, FloatConvTemplate, \
FloatGELUTemplate, FloatGemmTemplate, FloatLayernormTemplate, FloatMatMulTemplate, FloatMaxPoolTemplate, \
FloatMulTemplate, FloatReluTemplate, FloatSoftmaxTemplate, GEMMTemplate, MatrixVectorTemplate, MaxPool2DTemplate, \
MulTemplate, ReduceMeanTemplate, RequantShiftTemplate, ReshapeTemplate, RQAddTemplate, RQSiHardswishTemplate, \
SGDTemplate, SoftmaxCrossEntropyLossTemplate, TallGEMMTemplate, TransposeTemplate, UniformRequantShiftTemplate, \
iRMSNormTemplate, iSoftmaxTemplate
from Deeploy.Targets.PULPOpen.TypeCheckers import PULPConvChecker, PULPLinearChecker, PULPMaxPoolChecker, \
PULPRequantShiftChecker
Expand Down Expand Up @@ -148,16 +148,24 @@
PointerClass(uint8_t),
PointerClass(uint8_t),
PointerClass(uint8_t)
], [PULPDMAFuture(underlyingType = type)]), SliceTemplate.referenceTemplate, MemoryAwareForkTransformer)
], [PULPDMAFuture(underlyingType = type)]), DMASliceTemplate.referenceTemplate, MemoryAwareForkTransformer)
for type in IntegerDataTypes
]

PULPSliceBindings = [
NodeBinding(
SliceChecker([
PointerClass(type),
PointerClass(uint8_t),
PointerClass(uint8_t),
PointerClass(uint8_t),
PointerClass(uint8_t)
], [PointerClass(type)]), SliceTemplate.referenceTemplate, ForkTransformer) for type in FloatDataTypes
]

PULPReshapeBindings = [
NodeBinding(ReshapeChecker([PointerClass(type), PointerClass(int32_t)], [PointerClass(type)]),
ReshapeTemplate.referenceTemplate, SkipTransformer) for type in IntegerDataTypes
] + [
NodeBinding(ReshapeChecker([PointerClass(float32_t), PointerClass(type)], [PointerClass(float32_t)]),
ReshapeTemplate.referenceTemplate, SkipTransformer) for type in IntegerDataTypes
NodeBinding(ReshapeChecker([PointerClass(type), PointerClass(int64_t)], [PointerClass(type)]),
ReshapeTemplate.referenceTemplate, SkipTransformer) for type in IntegerDataTypes + FloatDataTypes
]

PULPRQAddBindings = [
Expand Down Expand Up @@ -225,6 +233,14 @@
ForkTransformer)
]

PULPFloatDWConv2DBindings = [
NodeBinding(
ConvChecker(
[PointerClass(float_type), PointerClass(float_type),
PointerClass(float_type)], [PointerClass(float_type)]), FloatConvTemplate.referenceDW2DIm2ColTemplate,
ForkTransformer) for float_type in FloatDataTypes
]

PULPRQSMatrixVecBindings = [
NodeBinding(
PULPLinearChecker([PointerClass(type1),
Expand Down Expand Up @@ -276,6 +292,11 @@
PULPReduceMeanBindings = [
NodeBinding(ReduceMeanChecker([PointerClass(type)], [PointerClass(type)]), ReduceMeanTemplate.referenceTemplate,
ClusterTransformer) for type in IntegerDataTypes
] + [
NodeBinding(ReduceMeanChecker([PointerClass(float_type), PointerClass(integer_type)], [PointerClass(float_type)]),
FloatReduceMeanTemplate.referenceTemplate, ClusterTransformer)
for integer_type in SignedIntegerDataTypes
for float_type in FloatDataTypes
]

PULPReduceSumBindings = [
Expand Down
24 changes: 19 additions & 5 deletions Deeploy/Targets/PULPOpen/Deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from Deeploy.DeeployTypes import ConstantBuffer, DeploymentPlatform, NodeTemplate, TopologyOptimizer, VariableBuffer
from Deeploy.Targets.Generic.TopologyOptimizationPasses.Passes import ReshapeConstOptPass, TransposeConstOptPass, \
TransposeMergePass, TransposeNoPermOptPass, TransposeSplitPass
from Deeploy.Targets.PULPOpen.Platform import PULPClusterEngine
from Deeploy.Targets.PULPOpen.TopologyOptimizationPasses.Passes import RQAddTransposeSquashPass

_L3AllocTemplate = NodeTemplate("""
Expand Down Expand Up @@ -63,19 +64,32 @@ def __init__(self,

self.extNameCount = 0

def bind(self):
def annotateNCores(self) -> None:
for layer in self.layerBinding.values():
node = layer.node
engine = self._selectEngine(node)
opRepr = layer.mapper.parser.operatorRepresentation
if isinstance(engine, PULPClusterEngine):
opRepr["n_cores"] = engine.n_cores

def bind(self) -> bool:
# SCHEREMO: THIS IS A STOP GAP SOLUTION. DONT REUSE. I MEAN IT. I WILL FIND YOU.
# SCHEREMO: The BindingOptimizationPass system is fairly fragile;
# it was designed this way because implementing further topology optimizations after
# parsing is very involved. If there are further use-cases, we should consider making this effort,
# but if there is only very few cases, this solution is okay.
autoTransposePass = AutoTransposeMergePass()
#self.ctxt, self.layerBinding = autoTransposePass.apply(self.ctxt, self.graph, self.layerBinding)

# LMACAN: THIS IS A STOP GAP SOLUTION. DONT REUSE. I MEAN IT. I WILL FIND YOU.
self.annotateNCores()

# SCHEREMO: THIS IS A STOP GAP SOLUTION. DONT REUSE. I MEAN IT. I WILL FIND YOU.
ret = super().bind()
if ret:
self.ctxt.hoistGlobalDefinition("cluster_dev", "extern struct pi_device cluster_dev;")
return ret
if not super().bind():
return False

self.ctxt.hoistGlobalDefinition("cluster_dev", "extern struct pi_device cluster_dev;")
return True

def _l3ConstBuffer(self) -> List[VariableBuffer]:
return [
Expand Down
Loading
Loading