Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-platform-gap9-tiled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
select-env:
uses: ./.github/workflows/_select-env.yml
with:
docker_image_deeploy: ${{ github.event.inputs.docker_image_deeploy || github.repository == 'pulp-platform/Deeploy' && 'ghcr.io/pulp-platform/deeploy-gap9:latest'}}
docker_image_deeploy: "ghcr.io/filippocordella/deeploy:gap9"

gap9-kernels-tiled-singlebuffer-L2:
needs: select-env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-platform-gap9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
select-env:
uses: ./.github/workflows/_select-env.yml
with:
docker_image_deeploy: ${{ github.event.inputs.docker_image_deeploy || (github.repository == 'pulp-platform/Deeploy' && 'ghcr.io/pulp-platform/deeploy-gap9:latest') }}
docker_image_deeploy: "ghcr.io/filippocordella/deeploy:gap9"

gap9-kernels:
needs: select-env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/infra-generate-ccache-gap9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
generate-ccache-gap9:
runs-on: ubuntu-latest
container:
image: ${{ github.event.inputs.docker_image_deeploy || 'ghcr.io/pulp-platform/deeploy-gap9:latest' }}
image: ${{ github.event.inputs.docker_image_deeploy || 'ghcr.io/filippocordella/deeploy:gap9' }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ DeeployTest/Tests/**/generateTest.py
DeeployTest/out.txt

CHANGELOG_GEN.md
TargetLibraries/PULPOpen/third_party/pulp-nn-mixed/
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this change. Run git submodule sync git submodule update --init --recursive

TargetLibraries/PULPOpen/third_party/pulp-nnx/
15 changes: 13 additions & 2 deletions Deeploy/Targets/GAP9/Bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
from Deeploy.Targets.GAP9.DMA.MchanDma import GAP9MchanDma
# Import templates from PULPOpen and Generic
from Deeploy.Targets.Generic.Templates import AddTemplate, ConcatTemplate, DequantTemplate, FloatReduceMeanTemplate, \
FloatReduceSumTemplate, GatherTemplate, QuantTemplate, RQSiGELUTemplate, SliceTemplate, iHardswishTemplate
FloatReduceSumTemplate, GatherTemplate, QuantTemplate, RQSiGELUTemplate, RQSILUTemplate, SILUTemplate, \
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, \
SliceChecker, SoftmaxChecker, SoftmaxCrossEntropyLossChecker, TransposeChecker
SILUChecker, SliceChecker, SoftmaxChecker, SoftmaxCrossEntropyLossChecker, TransposeChecker
from Deeploy.Targets.PULPOpen.Bindings import ForkClosure, L3MemoryAwareFunctionCallClosure, \
MemoryAwareForkTransformer, MemoryAwareFunctionCallClosure, TilingCallClosure
from Deeploy.Targets.PULPOpen.CodeTransformationPasses.PULPClusterSynch import PULPSynchCoresPass
Expand Down Expand Up @@ -380,6 +381,16 @@
GELUChecker([PointerClass(float32_t), PointerClass(float32_t)], [PointerClass(float32_t)]),
FloatGELUTemplate.referenceTemplate, GAP9Transformer)

GAP9SILUBindings = [
NodeBinding(SILUChecker([PointerClass(int8_t)], [PointerClass(int32_t)]), SILUTemplate.referenceTemplate,
GAP9Transformer)
]

GAP9RQSILUBindings = [
NodeBinding(SILUChecker([PointerClass(int8_t)], [PointerClass(int8_t)]), RQSILUTemplate.referenceTemplate,
GAP9Transformer)
]

GAP9GatherBindings = [
NodeBinding(GatherChecker([PointerClass(float32_t), PointerClass(type)], [PointerClass(float32_t)]),
GatherTemplate.referenceTemplate, GAP9Transformer) for type in IntegerDataTypes
Expand Down
24 changes: 15 additions & 9 deletions Deeploy/Targets/GAP9/Platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@
GAP9LayernormTilingReadyBindings, GAP9MatMulTilingReadyBindings, GAP9MaxPool2DTilingReadyBindings, \
GAP9MulTilingReadyBindings, GAP9ReduceSumTilingReadyBindings, GAP9ReluTilingReadyBindings, \
GAP9RQAddTilingReadyBindings, GAP9RQSConv2DTilingReadyBindings, GAP9RQSDWConv2DTilingReadyBindings, \
GAP9RQSGEMMTilingReadyBindings, GAP9RQSiHardswishTilingReadyBindings, GAP9RQSMatrixVecTilingReadyBindings, \
GAP9RQSTallGEMMTilingReadyBindings, GAP9RQSTilingReadyBindings, GAP9SGDTilingReadyBindings, \
GAP9SoftmaxCrossEntropyGradTilingReadyBindings, GAP9SoftmaxCrossEntropyTilingReadyBindings, \
GAP9SoftmaxGradTilingReadyBindings, GAP9SoftmaxTilingReadyBindings, GAP9TransposeTilingReadyBindings, \
GAP9UniformRQSTilingReadyBindings
GAP9RQSGEMMTilingReadyBindings, GAP9RQSiHardswishTilingReadyBindings, GAP9RQSILUTilingReadyBindings, \
GAP9RQSMatrixVecTilingReadyBindings, GAP9RQSTallGEMMTilingReadyBindings, GAP9RQSTilingReadyBindings, \
GAP9SGDTilingReadyBindings, GAP9SILUTilingReadyBindings, GAP9SoftmaxCrossEntropyGradTilingReadyBindings, \
GAP9SoftmaxCrossEntropyTilingReadyBindings, GAP9SoftmaxGradTilingReadyBindings, GAP9SoftmaxTilingReadyBindings, \
GAP9TransposeTilingReadyBindings, GAP9UniformRQSTilingReadyBindings
from Deeploy.Targets.Generic.Bindings import BasicGEMMBindings, BasicPad1DBindings, BasicPad2DBindings, \
BasicRQIntegerDivBinding
from Deeploy.Targets.Generic.Layers import AddLayer, ConcatLayer, ConvLayer, GatherLayer, GELULayer, GEMMLayer, \
LayerNormLayer, MatMulLayer, MaxPoolLayer, MulLayer, PadLayer, QuantLayer, ReduceMeanLayer, ReduceSumLayer, \
ReluLayer, RequantShiftLayer, ReshapeLayer, RQIntegerDivLayer, RQSiGELULayer, RQSiHardswishLayer, SGDLayer, \
SliceLayer, SoftmaxCrossEntropyLossGradLayer, SoftmaxCrossEntropyLossLayer, SoftmaxGradLayer, SoftmaxLayer, \
TransposeLayer, iHardswishLayer, iRMSNormLayer
ReluLayer, RequantShiftLayer, ReshapeLayer, RQIntegerDivLayer, RQSiGELULayer, RQSiHardswishLayer, RQSILULayer, \
SGDLayer, SILULayer, SliceLayer, SoftmaxCrossEntropyLossGradLayer, SoftmaxCrossEntropyLossLayer, SoftmaxGradLayer, \
SoftmaxLayer, TransposeLayer, iHardswishLayer, iRMSNormLayer
from Deeploy.Targets.Generic.Parsers import AddParser, ConcatParser, DequantParser, FlattenParser, GatherParser, \
GELUParser, GEMMParser, LayerNormParser, MatMulParser, MaxPool2DParser, MulParser, Pad1DParser, Pad2DParser, \
QuantParser, ReduceMeanParser, ReduceSumParser, ReluParser, RequantShiftParser, ReshapeParser, RQAddParser, \
RQIntegerDivParser, RQSiGELUParser, RQSiHardswishParser, SGDParser, SliceParser, \
RQIntegerDivParser, RQSiGELUParser, RQSiHardswishParser, SGDParser, SILUParser, SliceParser, \
SoftmaxCrossEntropyLossGradParser, SoftmaxCrossEntropyLossParser, SoftmaxGradParser, SoftmaxParser, \
TransposeParser, UniformRequantShiftParser, UnsqueezeParser, iHardswishParser, iRMSNormParser, iSoftmaxParser
from Deeploy.Targets.Generic.Templates import AllocateTemplate as BasicAllocateTemplate
Expand All @@ -49,6 +49,8 @@
GAP9_AddMapper = NodeMapper(AddParser(), GAP9AddTilingReadyBindings)
GAP9_FlattenMapper = NodeMapper(FlattenParser(), GAP9FlattenTilingReadyBindings)
GAP9_GELUMapper = NodeMapper(GELUParser(), GAP9FPGELUTilingReadyBindings)
GAP9_SILUMapper = NodeMapper(SILUParser(), GAP9SILUTilingReadyBindings)
GAP9_RQSILUMapper = NodeMapper(SILUParser(), GAP9RQSILUTilingReadyBindings)
GAP9_GatherMapper = NodeMapper(GatherParser(), GAP9GatherTilingReadyBindings)
GAP9_MulMapper = NodeMapper(MulParser(), GAP9MulTilingReadyBindings)
GAP9_Pad1DMapper = NodeMapper(Pad1DParser(), BasicPad1DBindings)
Expand Down Expand Up @@ -106,6 +108,10 @@
GEMMLayer([GAP9_FloatGEMMMapper, GAP9_GEMMDequantMapper]),
'Gelu':
GELULayer([GAP9_GELUMapper]),
'SILU':
SILULayer([GAP9_SILUMapper]),
'RQSILU':
RQSILULayer([GAP9_RQSILUMapper]),
'LayerNormalization':
LayerNormLayer([GAP9_LayerNormMapper]),
'MaxPool':
Expand Down
13 changes: 10 additions & 3 deletions Deeploy/Targets/GAP9/Tiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
GAP9iHardswishBindings, GAP9iRMSNormBindings, GAP9iRQSGELUBindings, GAP9LayernormBinding, GAP9MatMulBindings, \
GAP9MaxPool2DBindings, GAP9MulBindings, GAP9ReduceSumBindings, GAP9ReluBinding, GAP9ReshapeBindings, \
GAP9RQAddBindings, GAP9RQSBindings, GAP9RQSConv2DBindings, GAP9RQSDWConv2DBindings, GAP9RQSGEMMBindings, \
GAP9RQSiHardswishBindings, GAP9RQSMatrixVecBindings, GAP9RQSTallGEMMBindings, GAP9SGDBindings, \
GAP9SoftmaxBindings, GAP9SoftmaxCrossEntropyLossBindings, GAP9SoftmaxCrossEntropyLossGradBindings, \
GAP9SoftmaxGradBindings, GAP9TransposeBindings, GAP9UniformRQSBindings
GAP9RQSiHardswishBindings, GAP9RQSILUBindings, GAP9RQSMatrixVecBindings, GAP9RQSTallGEMMBindings, GAP9SGDBindings, \
GAP9SILUBindings, GAP9SoftmaxBindings, GAP9SoftmaxCrossEntropyLossBindings, \
GAP9SoftmaxCrossEntropyLossGradBindings, GAP9SoftmaxGradBindings, GAP9TransposeBindings, GAP9UniformRQSBindings
from Deeploy.Targets.Generic.TileConstraints.AddTileConstraint import AddTileConstraint
from Deeploy.Targets.Generic.TileConstraints.ConcatTileConstraint import ConcatTileConstraint
from Deeploy.Targets.Generic.TileConstraints.iHardswishTileConstraint import iHardswishTileConstraint
Expand All @@ -26,6 +26,7 @@
from Deeploy.Targets.Generic.TileConstraints.NOPTileConstraint import NOPTileConstraint
from Deeploy.Targets.Generic.TileConstraints.RQSiGELUTileConstraint import RQSiGELUTileConstraint
from Deeploy.Targets.Generic.TileConstraints.RQSiHardswishTileConstraint import RQSiHardswishTileConstraint
from Deeploy.Targets.Generic.TileConstraints.SILUTileConstraint import SILUTileConstraint
from Deeploy.Targets.Generic.TileConstraints.TransposeTileConstraint import TransposeTileConstraint
from Deeploy.Targets.Generic.TileConstraints.UnaryTileConstraint import UnaryTileConstraint
from Deeploy.Targets.Generic.TileConstraints.UntiledTileConstraint import UntiledTileConstraint
Expand Down Expand Up @@ -142,3 +143,9 @@

GAP9SGDTilingReadyBindings = TilingReadyNodeBindings(nodeBindings = GAP9SGDBindings,
tileConstraint = SGDTileConstraint())

GAP9SILUTilingReadyBindings = TilingReadyNodeBindings(nodeBindings = GAP9SILUBindings,
tileConstraint = SILUTileConstraint())

GAP9RQSILUTilingReadyBindings = TilingReadyNodeBindings(nodeBindings = GAP9RQSILUBindings,
tileConstraint = SILUTileConstraint())
18 changes: 14 additions & 4 deletions Deeploy/Targets/Generic/Bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
FloatPowTemplate, FloatReduceMeanTemplate, FloatReluTemplate, FloatSoftmaxTemplate, FloatSqrtTemplate, \
GatherTemplate, GemmTemplate, IntegerDivTemplate, ITAMaxTemplate, ITAPartialMaxTemplate, MatMulTemplate, \
MaxPoolTemplate, MulTemplate, PadTemplate, QuantTemplate, ReduceMeanTemplate, ReduceSumTemplate, \
RequantShiftTemplate, ReshapeTemplate, RQIntegerDivTemplate, RQSiGELUTemplate, SliceTemplate, TransposeTemplate, \
iGELUTemplate, iLayernormTemplate, iRMSNormTemplate, iSoftmaxTemplate
RequantShiftTemplate, ReshapeTemplate, RQIntegerDivTemplate, RQSiGELUTemplate, RQSILUTemplate, SILUTemplate, \
SliceTemplate, TransposeTemplate, iGELUTemplate, iLayernormTemplate, iRMSNormTemplate, iSoftmaxTemplate
from Deeploy.Targets.Generic.TypeCheckers import AddChecker, BatchNormChecker, ConcatChecker, ConvChecker, \
DebugPrintChecker, DequantChecker, DivChecker, DummyChecker, GatherChecker, GELUChecker, GEMMChecker, \
LayerNormChecker, MatMulChecker, MaxPoolChecker, MulChecker, PadChecker, QuantChecker, ReduceMeanChecker, \
ReduceSumChecker, ReluChecker, RequantShiftChecker, ReshapeChecker, RQIntegerDivChecker, SliceChecker, \
SoftmaxChecker, TransposeChecker
ReduceSumChecker, ReluChecker, RequantShiftChecker, ReshapeChecker, RQIntegerDivChecker, SILUChecker, \
SliceChecker, SoftmaxChecker, TransposeChecker

BasicTransformer = CodeTransformation([ArgumentStructGeneration(), MemoryManagementGeneration(), FutureGeneration()])

Expand Down Expand Up @@ -327,3 +327,13 @@
ConvTransposeTemplate.referenceTemplate,
BasicTransformer) for type in FloatDataTypes
]

BasicSILUBindings = [
NodeBinding(SILUChecker([PointerClass(int8_t)], [PointerClass(int32_t)]), SILUTemplate.referenceTemplate,
BasicTransformer)
]

BasicRQSILUBindings = [
NodeBinding(SILUChecker([PointerClass(int8_t), PointerClass(int8_t)], [PointerClass(int8_t)]),
RQSILUTemplate.referenceTemplate, BasicTransformer)
]
12 changes: 12 additions & 0 deletions Deeploy/Targets/Generic/Layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,3 +709,15 @@ def computeOps(self):
numPx = opRep['dim_im_out_x']

return numPx * opsPerPx


class SILULayer(ONNXLayer):

def __init__(self, maps: List[NodeMapper]):
super().__init__(maps)


class RQSILULayer(SILULayer):

def __init__(self, maps: List[NodeMapper]):
super().__init__(maps)
25 changes: 25 additions & 0 deletions Deeploy/Targets/Generic/Parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2886,3 +2886,28 @@ def parseNodeCtxt(self,
self.operatorRepresentation['size'] = int(np.prod(data_in.shape))

return ctxt, True


class SILUParser(NodeParser):

def __init__(self):
super().__init__()

def parseNode(self, node: gs.Node) -> bool:

ret = all([len(node.inputs) >= 1, len(node.outputs) == 1])

return ret

def parseNodeCtxt(self,
ctxt: NetworkContext,
node: gs.Node,
channels_first: bool = True) -> Tuple[NetworkContext, bool]:

data_in = ctxt.lookup(node.inputs[0].name)
data_out = ctxt.lookup(node.outputs[0].name)
self.operatorRepresentation['data_in'] = data_in.name
self.operatorRepresentation['data_out'] = data_out.name
self.operatorRepresentation['size'] = np.prod(data_in.shape)

return ctxt, True
19 changes: 12 additions & 7 deletions Deeploy/Targets/Generic/Platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
BasicLayerNormBindings, BasicMatMulBindings, BasicMaxPool1DBindings, BasicMaxPool2DBindings, BasicMulBindings, \
BasicPad1DBindings, BasicPad2DBindings, BasicPowBindings, BasicQuantBindings, BasicReduceMeanBindings, \
BasicReduceSumBindings, BasicReluBinding, BasicReshapeBindings, BasicRQIntegerDivBinding, BasicRQSBindings, \
BasicRQSGELUBinding, BasicSliceBindings, BasicSoftmaxBindings, BasicSqrtBindings, BasicTransposeBindings, \
DummyBinding
BasicRQSGELUBinding, BasicRQSILUBindings, BasicSILUBindings, BasicSliceBindings, BasicSoftmaxBindings, \
BasicSqrtBindings, BasicTransposeBindings, DummyBinding
from Deeploy.Targets.Generic.Layers import AddLayer, BatchNormalizationLayer, ConcatLayer, ConvLayer, \
ConvTransposeLayer, DebugPrintLayer, DequantLayer, DivLayer, GatherLayer, GELULayer, GEMMLayer, ITAMaxLayer, \
LayerNormLayer, MatMulLayer, MaxPoolLayer, MulLayer, PadLayer, PowLayer, QuantLayer, ReduceMeanLayer, \
ReduceSumLayer, ReluLayer, RequantShiftLayer, ReshapeLayer, RQIntegerDivLayer, RQSiGELULayer, SliceLayer, \
SoftmaxLayer, SqrtLayer, TransposeLayer
ReduceSumLayer, ReluLayer, RequantShiftLayer, ReshapeLayer, RQIntegerDivLayer, RQSiGELULayer, RQSILULayer, \
SILULayer, SliceLayer, SoftmaxLayer, SqrtLayer, TransposeLayer
from Deeploy.Targets.Generic.Parsers import AddParser, BatchNormParser, ConcatParser, ConvTranspose1DParser, \
DebugParser, DequantParser, DivParser, DummyParser, FlattenParser, GatherParser, GELUParser, GenericConv1DParser, \
GenericConv2DParser, GenericDWConv1DParser, GenericDWConv2DParser, GenericGEMMParser, GenericMaxPool2DParser, \
IntegerDivParser, ITAMaxParser, ITAPartialMaxParser, LayerNormParser, MatMulParser, MaxPool1DParser, MulParser, \
Pad1DParser, Pad2DParser, PowParser, QuantParser, ReduceMeanParser, ReduceSumParser, ReluParser, \
RequantShiftParser, ReshapeParser, RQIntegerDivParser, RQSiGELUParser, SliceParser, SoftmaxParser, SqrtParser, \
TransposeParser, UnsqueezeParser, iLayerNormParser, iSoftmaxParser
RequantShiftParser, ReshapeParser, RQIntegerDivParser, RQSiGELUParser, SILUParser, SliceParser, SoftmaxParser, \
SqrtParser, TransposeParser, UnsqueezeParser, iLayerNormParser, iSoftmaxParser
from Deeploy.Targets.Generic.Templates import AllocateTemplate, FreeTemplate
from Deeploy.Targets.Generic.TopologyOptimizationPasses.Passes import DequantPatternPass, ExtractPaddingFromConvPass, \
ExtractPaddingFromPoolPass, MatMulAddMergePass, MergeConstAddAndRequantPass, QuantPatternPass, \
Expand Down Expand Up @@ -73,6 +73,8 @@
BatchNormalizationMapper = NodeMapper(BatchNormParser(), BasicBatchNormBindings)
ConvTransposeMapper = NodeMapper(ConvTranspose1DParser(), BasicConvTransposeBindings)
SliceMapper = NodeMapper(SliceParser(), BasicSliceBindings)
SILUMapper = NodeMapper(SILUParser(), BasicSILUBindings)
RQSILUMapper = NodeMapper(SILUParser(), BasicRQSILUBindings)

# Dummy nodes are intended for development purposes only!
# They should always generate compiler errors to not accidentally end up in production code
Expand Down Expand Up @@ -118,7 +120,10 @@
'Quant': QuantLayer([QuantMapper]),
'Dequant': DequantLayer([DequantMapper]),
'BatchNormalization': BatchNormalizationLayer([BatchNormalizationMapper]),
'ConvTranspose': ConvTransposeLayer([ConvTransposeMapper])
'ConvTranspose': ConvTransposeLayer([ConvTransposeMapper]),
'SILU': SILULayer([SILUMapper]),
'RQSILU': RQSILULayer([RQSILUMapper]),

# # For example, you can use the DummpyMapper, in case you want to test
# # deployment or optimizations with GlobalAveragePool nodes but did not yet
# # implement the corresponding kernel
Expand Down
33 changes: 33 additions & 0 deletions Deeploy/Targets/Generic/Templates/RQSILUTemplate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2024 ETH Zurich and University of Bologna
#
# SPDX-License-Identifier: Apache-2.0

from typing import Dict, List, Tuple

from Deeploy.DeeployTypes import NetworkContext, NodeTemplate, OperatorRepresentation


class _SILUTemplate(NodeTemplate):

def __init__(self, templateStr):
super().__init__(templateStr)

def alignToContext(self, ctxt: NetworkContext,
operatorRepresentation: OperatorRepresentation) -> Tuple[NetworkContext, Dict, List[str]]:

data_in = ctxt.lookup(operatorRepresentation['data_in'])
data_out = ctxt.lookup(operatorRepresentation['data_out'])
operatorRepresentation['input_offset'] = 0
if hasattr(data_in, "_signed") and hasattr(data_in, "nLevels"):
operatorRepresentation['input_offset'] = (data_in._signed == 0) * int(data_in.nLevels / 2)
operatorRepresentation['output_offset'] = 0
if hasattr(data_out, "_signed") and hasattr(data_out, "nLevels"):
operatorRepresentation['output_offset'] = -(data_out._signed == 0) * int(data_out.nLevels / 2)

return ctxt, operatorRepresentation, []


referenceTemplate = _SILUTemplate("""
// RQSILU (Name: ${nodeName}, Op: ${nodeOp})
SINGLE_CORE RQSILU_s${data_in_type.referencedType.typeWidth}_s${data_out_type.referencedType.typeWidth}(${data_in}, ${data_out}, ${size}, ${input_offset});
""")
33 changes: 33 additions & 0 deletions Deeploy/Targets/Generic/Templates/SILUTemplate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2024 ETH Zurich and University of Bologna
#
# SPDX-License-Identifier: Apache-2.0

from typing import Dict, List, Tuple

from Deeploy.DeeployTypes import NetworkContext, NodeTemplate, OperatorRepresentation


class _SILUTemplate(NodeTemplate):

def __init__(self, templateStr):
super().__init__(templateStr)

def alignToContext(self, ctxt: NetworkContext,
operatorRepresentation: OperatorRepresentation) -> Tuple[NetworkContext, Dict, List[str]]:

data_in = ctxt.lookup(operatorRepresentation['data_in'])
data_out = ctxt.lookup(operatorRepresentation['data_out'])
operatorRepresentation['input_offset'] = 0
if hasattr(data_in, "_signed") and hasattr(data_in, "nLevels"):
operatorRepresentation['input_offset'] = (data_in._signed == 0) * int(data_in.nLevels / 2)
operatorRepresentation['output_offset'] = 0
if hasattr(data_out, "_signed") and hasattr(data_out, "nLevels"):
operatorRepresentation['output_offset'] = -(data_out._signed == 0) * int(data_out.nLevels / 2)

return ctxt, operatorRepresentation, []


referenceTemplate = _SILUTemplate("""
// SILU (Name: ${nodeName}, Op: ${nodeOp})
SINGLE_CORE SILU_s${data_in_type.referencedType.typeWidth}_s${data_out_type.referencedType.typeWidth}(${data_in}, ${data_out}, ${size}, ${input_offset});
Copy link
Contributor

Choose a reason for hiding this comment

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

For the PULP platform, you should add a multicore template.

""")
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2024 ETH Zurich and University of Bologna
#
# SPDX-License-Identifier: Apache-2.0

from Deeploy.Targets.Generic.TileConstraints.UnaryTileConstraint import UnaryTileConstraint


class SILUTileConstraint(UnaryTileConstraint):
pass
Loading
Loading