From 9c503a43ab02ca9f9d29690965cc1c5947e36ee6 Mon Sep 17 00:00:00 2001 From: Alex Marchioni Date: Mon, 30 Nov 2026 19:09:09 +0100 Subject: [PATCH] REFACTOR: break PULPOpen <-> GAP9 cycle and core -> Generic import --- CHANGELOG.md | 4 ++++ .../BindingsOptimizationPasses/bindingUtils.py | 2 +- Deeploy/Targets/GAP9/Platform.py | 10 +++++----- Deeploy/Targets/GAP9/Tiler.py | 2 +- Deeploy/Targets/PULPOpen/Deployer.py | 3 +-- Deeploy/Targets/PULPOpen/Tiler.py | 2 +- .../UntiledTileConstraint.py | 0 7 files changed, 13 insertions(+), 10 deletions(-) rename Deeploy/{Targets/Generic/TileConstraints => TilingExtension}/UntiledTileConstraint.py (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0df577542..2fbd03edc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ This file contains the changelog for the Deeploy project. The changelog is divid - Match GAP9 SDK MLPerf Tiny Performance with Specialised Depthwise and Pointwise Kernels [#206](https://github.com/pulp-platform/Deeploy/pull/206) - Add support for the X-HEEP platform [#200](https://github.com/pulp-platform/Deeploy/pull/200) - Add support for Operators for Generic target needed in MAGIA (again) [#195]( https://github.com/pulp-platform/Deeploy/pull/195) +- REFACTOR: Break PULPOpen ↔ GAP9 cycle and core → Generic import [#224](https://github.com/pulp-platform/Deeploy/pull/224) ### Added - tests for Regular and DW Conv2D with 3x3 kernel @@ -93,6 +94,8 @@ This file contains the changelog for the Deeploy project. The changelog is divid - The test runner passes `--cores` to the generator for tiled runs - Siracusa/PULPOpen float output comparison uses a combined absolute + relative tolerance - Add `pre-commit` to `requirements-dev.txt` and run the reuse hook serially +- `GAP9ClusterEngine` now subclasses `PULPClusterEngine`, so `PULPDeployer` no longer imports from the GAP9 target (removes the PULPOpen ↔ GAP9 import cycle) +- Move `UntiledTileConstraint` from `Deeploy.Targets.Generic.TileConstraints` to `Deeploy.TilingExtension`, so core no longer imports from `Deeploy.Targets` ### Fixed - Reject non-finite outputs in the PULPOpen/Siracusa floating-point test comparison. @@ -124,6 +127,7 @@ This file contains the changelog for the Deeploy project. The changelog is divid - Fix GAP9 board tests with `--defaultMemLevel L3` reading garbage inputs: place all gapy `--flash-property` options before the positional subcommand and use `image flash run` so the readfs partition (input hex files) is flashed to the device - Fix Deeploy 101 tutorial errors: `--profileTiling` usage and the moved intrinsics inventory path - Fix `ConvTranspose` layer: output buffer shape computation. +- `--cores` is now applied to GAP9 cluster engines (previously GAP9 always used the default 8 cores) ### Removed - removed experimental `enable3x3` flag, from Neureka Engine. Now, 3x3 mode is enabled by default. diff --git a/Deeploy/CommonExtensions/OptimizationPasses/BindingsOptimizationPasses/bindingUtils.py b/Deeploy/CommonExtensions/OptimizationPasses/BindingsOptimizationPasses/bindingUtils.py index 4737a6bd5d..7085ab89d4 100644 --- a/Deeploy/CommonExtensions/OptimizationPasses/BindingsOptimizationPasses/bindingUtils.py +++ b/Deeploy/CommonExtensions/OptimizationPasses/BindingsOptimizationPasses/bindingUtils.py @@ -11,7 +11,7 @@ from Deeploy.CommonExtensions.CodeTransformationPasses.MemoryAllocation import MemoryManagementGeneration, \ MemoryPassthroughGeneration from Deeploy.DeeployTypes import CodeTransformation, NetworkContext, NodeTemplate, ONNXLayer -from Deeploy.Targets.Generic.TileConstraints.UntiledTileConstraint import UntiledTileConstraint +from Deeploy.TilingExtension.UntiledTileConstraint import UntiledTileConstraint _bypassNodeTemplate = NodeTemplate(""" // BYPASSED (Name: ${nodeName}, Op: ${nodeOp}) diff --git a/Deeploy/Targets/GAP9/Platform.py b/Deeploy/Targets/GAP9/Platform.py index 6d68a36352..c5849a33a3 100644 --- a/Deeploy/Targets/GAP9/Platform.py +++ b/Deeploy/Targets/GAP9/Platform.py @@ -5,8 +5,8 @@ import numpy as np import onnx_graphsurgeon as gs -from Deeploy.DeeployTypes import ConstantBuffer, DeploymentEngine, DeploymentPlatform, NetworkContext, NodeMapper, \ - NodeTemplate, StructBuffer, TransientBuffer, VariableBuffer +from Deeploy.DeeployTypes import ConstantBuffer, DeploymentPlatform, NetworkContext, NodeMapper, NodeTemplate, \ + StructBuffer, TransientBuffer, VariableBuffer from Deeploy.MemoryLevelExtension.MemoryLevels import MemoryHierarchy, MemoryLevel from Deeploy.MemoryLevelExtension.NetworkDeployers.MemoryLevelDeployer import MemoryPlatform, MemoryPlatformWrapper from Deeploy.Targets.GAP9.Templates import AllocateTemplate, FreeTemplate @@ -43,6 +43,7 @@ from Deeploy.Targets.PULPOpen.Parsers import PULPConv1DParser, PULPConv2DParser, PULPDWConv1DParser, \ PULPDWConv2DParser, PULPFPConv2DParser, PULPFPDWConv2DParser, PULPGEMMParser, PULPMatrixVecParser, \ PULPPWConv2DParser, PULPStemConv2DParser, PULPTallGEMMParser +from Deeploy.Targets.PULPOpen.Platform import PULPClusterEngine # Create GAP9-specific NodeMappers GAP9_RQAddMapper = NodeMapper(RQAddParser(), GAP9RQAddTilingReadyBindings) @@ -253,7 +254,7 @@ class GAP9StructBuffer(StructBuffer): _includeList = ["pmsis.h", "DeeployGAP9Math.h", "pulp_nn_kernels.h", "DeeployMchan.h"] -class GAP9ClusterEngine(DeploymentEngine): +class GAP9ClusterEngine(PULPClusterEngine): def __init__(self, name: str, @@ -261,8 +262,7 @@ def __init__(self, initCode = "", includeList = _includeList, n_cores: int = 8) -> None: - super().__init__(name, Mapping, initCode, includeList) - self.n_cores = n_cores + super().__init__(name, Mapping, initCode, includeList, n_cores) class GAP9Platform(DeploymentPlatform): diff --git a/Deeploy/Targets/GAP9/Tiler.py b/Deeploy/Targets/GAP9/Tiler.py index 3c70554e0f..ad36217e73 100644 --- a/Deeploy/Targets/GAP9/Tiler.py +++ b/Deeploy/Targets/GAP9/Tiler.py @@ -28,7 +28,6 @@ from Deeploy.Targets.Generic.TileConstraints.RQSiHardswishTileConstraint import RQSiHardswishTileConstraint from Deeploy.Targets.Generic.TileConstraints.TransposeTileConstraint import TransposeTileConstraint from Deeploy.Targets.Generic.TileConstraints.UnaryTileConstraint import UnaryTileConstraint -from Deeploy.Targets.Generic.TileConstraints.UntiledTileConstraint import UntiledTileConstraint from Deeploy.Targets.PULPOpen.TileConstraints.ConvTileConstraint import Conv2DTileConstraint, RQConv2DTileConstraint from Deeploy.Targets.PULPOpen.TileConstraints.DWConvTileConstraint import DWConv2DTileConstraint, \ RQDWConv2DTileConstraint @@ -45,6 +44,7 @@ SoftmaxCrossEntropyGradTileConstraint, SoftmaxCrossEntropyTileConstraint from Deeploy.Targets.PULPOpen.TileConstraints.StemConvTileConstraint import RQStemConv2DTileConstraint from Deeploy.TilingExtension.TilerExtension import TilingReadyNodeBindings +from Deeploy.TilingExtension.UntiledTileConstraint import UntiledTileConstraint # GAP9-specific tiling ready bindings using ClDma GAP9RQSConv2DTilingReadyBindings = TilingReadyNodeBindings(nodeBindings = GAP9RQSConv2DBindings, diff --git a/Deeploy/Targets/PULPOpen/Deployer.py b/Deeploy/Targets/PULPOpen/Deployer.py index 0828cb392e..bceea01f4d 100644 --- a/Deeploy/Targets/PULPOpen/Deployer.py +++ b/Deeploy/Targets/PULPOpen/Deployer.py @@ -13,7 +13,6 @@ from Deeploy.CommonExtensions.OptimizationPasses.TopologyOptimizationPasses.LoweringOptimizationPasses import \ PULPNCHWtoNHWCPass, RemoveGlobalOutputReshapePass, TransposeMatmulInputsPass from Deeploy.DeeployTypes import ConstantBuffer, DeploymentPlatform, NodeTemplate, TopologyOptimizer, VariableBuffer -from Deeploy.Targets.GAP9.Platform import GAP9ClusterEngine from Deeploy.Targets.Generic.TopologyOptimizationPasses.Passes import ReshapeConstOptPass, TransposeConstOptPass, \ TransposeMergePass, TransposeNoPermOptPass, TransposeSplitPass from Deeploy.Targets.PULPOpen.Platform import PULPClusterEngine @@ -70,7 +69,7 @@ def annotateNCores(self) -> None: node = layer.node engine = self._selectEngine(node) opRepr = layer.mapper.parser.operatorRepresentation - if isinstance(engine, (PULPClusterEngine, GAP9ClusterEngine)): + if isinstance(engine, PULPClusterEngine): opRepr["n_cores"] = engine.n_cores def bind(self) -> bool: diff --git a/Deeploy/Targets/PULPOpen/Tiler.py b/Deeploy/Targets/PULPOpen/Tiler.py index 88c32d0546..a0510c0488 100644 --- a/Deeploy/Targets/PULPOpen/Tiler.py +++ b/Deeploy/Targets/PULPOpen/Tiler.py @@ -14,7 +14,6 @@ from Deeploy.Targets.Generic.TileConstraints.RQSiHardswishTileConstraint import RQSiHardswishTileConstraint from Deeploy.Targets.Generic.TileConstraints.TransposeTileConstraint import TransposeTileConstraint from Deeploy.Targets.Generic.TileConstraints.UnaryTileConstraint import UnaryTileConstraint -from Deeploy.Targets.Generic.TileConstraints.UntiledTileConstraint import UntiledTileConstraint from Deeploy.Targets.PULPOpen.Bindings import PULPAddBindings, PULPBatchNormBindings, PULPConcatBindings, \ PULPFloatConv2DBindings, PULPFloatConvTranspose2DBindings, PULPFloatDWConv2DBindings, PULPFloatGELUBinding, \ PULPFloatGELUGradBinding, PULPFloatGEMMBindings, PULPGatherBindings, PULPiHardswishBindings, PULPiRMSNormBindings, \ @@ -51,6 +50,7 @@ SoftmaxCrossEntropyGradTileConstraint, SoftmaxCrossEntropyTileConstraint from Deeploy.Targets.PULPOpen.TileConstraints.StemConvTileConstraint import RQStemConv2DTileConstraint from Deeploy.TilingExtension.TilerExtension import TilingReadyNodeBindings +from Deeploy.TilingExtension.UntiledTileConstraint import UntiledTileConstraint PULPRQSConv1DTilingReadyBindings = TilingReadyNodeBindings(nodeBindings = PULPRQSConv1DBindings, tileConstraint = RQConv1DTileConstraint()) diff --git a/Deeploy/Targets/Generic/TileConstraints/UntiledTileConstraint.py b/Deeploy/TilingExtension/UntiledTileConstraint.py similarity index 100% rename from Deeploy/Targets/Generic/TileConstraints/UntiledTileConstraint.py rename to Deeploy/TilingExtension/UntiledTileConstraint.py