Skip to content

Commit 6351bda

Browse files
authored
Chimera Platform Integration (#96)
* Temporary rename util due to name collision * Proto integration of chimera platform * Basic Chimera platform integration (Deeploy side) * WIP chimera test harness * Add Generic Test Harness for Chimera * Add GVSoC Support for CMake Chimera platform * Chimera install flow + GVSoC support for Chimera * Add Chimera kernel CI tests * Add chimera sdk make command and TARGETPLATFORM arg to the lightweight stage * Install wget and move cmake install after apt install * Install make via apt * Make chimera-sdk path generic * Toogle my docker * Lint * Fix typo * Install make from apt instead of cmake * Use CHIMERA_SDK_HOME symbol * Remove unused function and rename util to utils * Lint C * Apply Philip's comments * Update changelog
1 parent 73542af commit 6351bda

File tree

22 files changed

+607
-12
lines changed

22 files changed

+607
-12
lines changed

.github/workflows/CI.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ jobs:
158158
simpleRegression
159159
WaveFormer
160160
161+
162+
### Chimera Tests ###
163+
chimera-kernels:
164+
uses: ./.github/workflows/TestRunnerChimera.yml
165+
needs: select-docker-image-and-runner
166+
with:
167+
runner: ${{ needs.select-docker-image-and-runner.outputs.runner }}
168+
docker-image: ${{ needs.select-docker-image-and-runner.outputs.image }}
169+
test-names: |
170+
Adder
171+
simulators: |
172+
gvsoc
173+
174+
161175
### Snitch Tests ###
162176
snitch-kernels:
163177
uses: ./.github/workflows/TestRunnerSnitch.yml
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: TestRunnerChimera
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
runner:
7+
required: true
8+
type: string
9+
docker-image:
10+
required: true
11+
type: string
12+
test-names:
13+
required: true
14+
type: string
15+
simulators:
16+
required: true
17+
type: string
18+
19+
jobs:
20+
test-runner-chimera:
21+
runs-on: ${{ inputs.runner }}
22+
container:
23+
image: ${{ inputs.docker-image }}
24+
steps:
25+
- name: Checkout Repo
26+
uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
29+
- name: Build Deeploy
30+
run: pip install -e .
31+
- name: Cache ccache
32+
uses: actions/cache/restore@v4
33+
with:
34+
path: /app/.ccache
35+
key: ccache-ci
36+
- name: Run Test
37+
run: |
38+
testNames="${{ inputs.test-names }}"
39+
simulators="${{inputs.simulators}}"
40+
cd DeeployTest
41+
mkdir -p /app/.ccache
42+
export CCACHE_DIR=/app/.ccache
43+
export CHIMERA_SDK_HOME=/app/install/chimera-sdk
44+
echo "$simulators" | while IFS= read -r simulator; do
45+
if [[ -n "$simulator" ]]; then
46+
echo "$testNames" | while IFS= read -r testName; do
47+
if [[ -n "$testName" ]]; then
48+
echo "Running test $testName using $simulator"
49+
python testRunner_chimera.py -t Tests/$testName --simulator=$simulator
50+
fi
51+
done
52+
fi
53+
done
54+
shell: bash

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This file contains the changelog for the Deeploy project. The changelog is divid
55
This release containing major architectural changes, new platform support, enhanced simulation workflows, floating-point kernel support, training infrastructure for CCT models, memory allocation strategies, and documentation improvements.
66

77
### List of Pull Requests
8+
- Chimera Platform Integration [#96](https://github.com/pulp-platform/Deeploy/pull/96)
89
- Add Tutorial and Refactor README [#97](https://github.com/pulp-platform/Deeploy/pull/97)
910
- Reduce Mean Float Template [#92](https://github.com/pulp-platform/Deeploy/pull/92)
1011
- Reshape Memory Freeing and Generic Float GEMM Fixes [#91](https://github.com/pulp-platform/Deeploy/pull/91)
@@ -67,6 +68,12 @@ This release containing major architectural changes, new platform support, enhan
6768

6869

6970
### Added
71+
- ChimeraDeployer, currently mainly a placeholder
72+
- Allocate templates for Chimera
73+
- ChimeraPlatform, using appropriate allocation templates and using the generic Parser + Binding for the Add node
74+
- Adder CI test for Chimera
75+
- Install flow for chimera-sdk via Makefile
76+
- DeeployChimeraMath library
7077
- Generic FP32 reduce mean bindings, parser, and template
7178
- New alias list parameter for buffer objects
7279
- New test, also included in the CI pipeline, for the reshape and skip connection situation
@@ -194,6 +201,9 @@ This release containing major architectural changes, new platform support, enhan
194201
- `dev-requirements.txt` tracking the dependencies of the build system, linting, documentation, and QOL.
195202

196203
### Changed
204+
- Bump the CMake version to 3.24 as required for the chimera-sdk
205+
- Bump GVSoC's version and add chimera simulation target
206+
- Rename the generic source util to utils to avoid name collision with chimera-sdk
197207
- Moved PULP SDK from Victor-Jung/pulp-sdk branch deeploy to pulp-platform/pulp-sdk branch main.
198208
- Memory arena buffers are now declared at the beginning of the `InitNetwork` function
199209
- Tiling profiling is now an ON/OFF version where you get the I/O DMA time for each DMA call
@@ -279,9 +289,10 @@ This release containing major architectural changes, new platform support, enhan
279289
- Input offset height and width calculation for tiled PULPOpen convolution kernels
280290

281291
### Removed
292+
- Removed commented code from generic allocation templates
282293
- Remove the link to the precompiled LLVM 12 in the `testRunner` for Snitch and in the CI.
283294
- Remove the sourcing of the cursed PULP SDK script.
284295
- Commented IPython breakpoints.
285296

286297
## Release v0.1.0 (2024-08-08)
287-
This release contains the first version of Deeploy, which includes the initial implementation of the Deeploy framework, support for various platforms, and basic functionality for deploying deep learning models on PULP-based systems.
298+
This release contains the first version of Deeploy, which includes the initial implementation of the Deeploy framework, support for various platforms, and basic functionality for deploying deep learning models on PULP-based systems.

CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ elseif(platform STREQUAL Snitch)
3434
message(STATUS "Building for platform 'Snitch'")
3535
elseif(platform STREQUAL SoftHier)
3636
message(STATUS "Building for platform 'SoftHier'")
37+
elseif(platform STREQUAL Chimera)
38+
message(STATUS "Building for platform 'Chimera'")
3739
else()
3840
message(FATAL_ERROR "Invalid platform '${platform}' specified!")
3941
endif()
@@ -233,5 +235,33 @@ if(platform STREQUAL Snitch)
233235

234236
endif()
235237

238+
if(platform STREQUAL Chimera)
239+
240+
# JUNGVI: Currently only LLVM is supported by the Chimera SDK
241+
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/cmake/chimera/toolchain_llvm.cmake)
242+
243+
include(${CMAKE_CURRENT_LIST_DIR}/cmake/chimera/chimera-sdk.cmake)
244+
245+
project(deeploy LANGUAGES C ASM)
246+
247+
set(TARGET_PLATFORM "chimera-open")
248+
set(TEST_MODE "none")
249+
250+
message(STATUS "============================= ${platform} Configuration ============================")
251+
message(STATUS "[cMake ] TARGET_PLATFORM = " ${TARGET_PLATFORM})
252+
message(STATUS "[cMake ] ISA = " ${ISA})
253+
message(STATUS "[cMake ] TEST_MODE = " ${TEST_MODE})
254+
message(STATUS "====================================================================================")
255+
message(STATUS "")
256+
257+
add_subdirectory(TargetLibraries/Generic)
258+
add_subdirectory(TargetLibraries/Chimera)
259+
target_include_directories(deeploychimera PUBLIC TargetLibraries/Generic/inc)
260+
261+
add_subdirectory(DeeployTest)
262+
target_link_libraries(deeploylib INTERFACE deeploybasic deeploychimera)
263+
264+
endif()
265+
236266

237267
print_simulation_config()

Container/Dockerfile.deeploy

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN apt-get upgrade && \
2828

2929
RUN --mount=type=cache,target=/ccache \
3030
ccache -z && \
31-
make pulp-sdk qemu mempool banshee xtensor && \
31+
make pulp-sdk chimera-sdk qemu mempool banshee xtensor && \
3232
make gvsoc && \
3333
cp -r /app/toolchain/gvsoc/core/requirements.txt /app/core-requirements.txt && \
3434
cp -r /app/toolchain/gvsoc/gapy/requirements.txt /app/gapy-requirements.txt && \
@@ -60,14 +60,16 @@ RUN rm -rf toolchain
6060
########## Stage 2: Lightweight image with precompiled toolchain and emulators ##########
6161
FROM ubuntu:22.04 AS deeploy
6262

63+
ARG TARGETPLATFORM
6364
ARG DEBIAN_FRONTEND=noninteractive
6465
ENV TZ=Etc/UTC
6566

6667
# Export symbols necessary for Deeploy's build flow
6768
ENV CMAKE=/usr/bin/cmake
6869
ENV PULP_SDK_HOME=/app/install/pulp-sdk
69-
ENV LLVM_INSTALL_DIR=/app/install/llvm
7070
ENV SNITCH_HOME=/app/install/snitch_cluster
71+
ENV CHIMERA_SDK_HOME=/app/install/chimera-sdk
72+
ENV LLVM_INSTALL_DIR=/app/install/llvm
7173
ENV GVSOC_INSTALL_DIR=/app/install/gvsoc
7274
ENV SOFTHIER_INSTALL_DIR=/app/install/softhier
7375
ENV MINIMALLOC_INSTALL_DIR=/app/install/minimalloc
@@ -82,8 +84,9 @@ COPY pyproject.toml ./
8284
RUN mkdir -p /root/.cargo/bin/ && \
8385
apt-get update && \
8486
apt-get install -y git-lfs \
85-
cmake \
87+
wget \
8688
ccache \
89+
make \
8790
curl \
8891
libpixman-1-dev \
8992
libsdl2-dev \
@@ -98,6 +101,17 @@ RUN mkdir -p /root/.cargo/bin/ && \
98101
toml-to-req --toml-file pyproject.toml && \
99102
pip install -r requirements.txt
100103

104+
# Install CMake
105+
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
106+
wget https://github.com/Kitware/CMake/releases/download/v3.24.0/cmake-3.24.0-linux-x86_64.sh && \
107+
chmod +x cmake-3.24.0-linux-x86_64.sh && \
108+
./cmake-3.24.0-linux-x86_64.sh --prefix=/usr --skip-license; \
109+
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
110+
wget https://github.com/Kitware/CMake/releases/download/v3.24.0/cmake-3.24.0-linux-aarch64.sh && \
111+
chmod +x ./cmake-3.24.0-linux-aarch64.sh && \
112+
./cmake-3.24.0-linux-aarch64.sh --prefix=/usr --skip-license; \
113+
fi
114+
101115
COPY --from=toolchain /app/core-requirements.txt ./core-requirements.txt
102116
COPY --from=toolchain /app/gapy-requirements.txt ./gapy-requirements.txt
103117
COPY --from=toolchain /app/requirements-dev.txt ./
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# ----------------------------------------------------------------------
2+
#
3+
# File: Deployer.py
4+
#
5+
# Last edited: 16.06.2025
6+
#
7+
# Copyright (C) 2025, ETH Zurich and University of Bologna.
8+
#
9+
# Author:
10+
# - Victor Jung, jungvi@iis.ee.ethz.ch, ETH Zurich
11+
#
12+
# ----------------------------------------------------------------------
13+
# SPDX-License-Identifier: Apache-2.0
14+
#
15+
# Licensed under the Apache License, Version 2.0 (the License); you may
16+
# not use this file except in compliance with the License.
17+
# You may obtain a copy of the License at
18+
#
19+
#
20+
# Unless required by applicable law or agreed to in writing, software
21+
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
22+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
# See the License for the specific language governing permissions and
24+
# limitations under the License.
25+
26+
from typing import Callable, Dict, Type
27+
28+
import onnx_graphsurgeon as gs
29+
30+
from Deeploy.AbstractDataTypes import Pointer
31+
from Deeploy.CommonExtensions.NetworkDeployers.SignPropDeployer import SignPropDeployer
32+
from Deeploy.DeeployTypes import DeploymentPlatform, TopologyOptimizer
33+
34+
35+
class ChimeraDeployer(SignPropDeployer):
36+
37+
def __init__(self,
38+
graph: gs.Graph,
39+
deploymentPlatform: DeploymentPlatform,
40+
inputTypes: Dict[str, Type[Pointer]],
41+
loweringOptimizer: TopologyOptimizer,
42+
scheduler: Callable = lambda x: x,
43+
name: str = 'DeeployNetwork',
44+
default_channels_first = False,
45+
deeployStateDir: str = "DeeployStateDir",
46+
inputOffsets = {}):
47+
super().__init__(graph,
48+
deploymentPlatform,
49+
inputTypes,
50+
loweringOptimizer,
51+
scheduler,
52+
name,
53+
default_channels_first = default_channels_first,
54+
deeployStateDir = deeployStateDir,
55+
inputOffsets = inputOffsets)
56+
57+
self.loweringOptimizer.passes += []
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# ----------------------------------------------------------------------
2+
#
3+
# File: Platform.py
4+
#
5+
# Last edited: 16.06.2025
6+
#
7+
# Copyright (C) 2025, ETH Zurich and University of Bologna.
8+
#
9+
# Author:
10+
# - Victor Jung, jungvi@iis.ee.ethz.ch, ETH Zurich
11+
#
12+
# ----------------------------------------------------------------------
13+
# SPDX-License-Identifier: Apache-2.0
14+
#
15+
# Licensed under the Apache License, Version 2.0 (the License); you may
16+
# not use this file except in compliance with the License.
17+
# You may obtain a copy of the License at
18+
#
19+
#
20+
# Unless required by applicable law or agreed to in writing, software
21+
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
22+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
# See the License for the specific language governing permissions and
24+
# limitations under the License.
25+
26+
from typing import List
27+
28+
from Deeploy.DeeployTypes import ConstantBuffer, DeploymentEngine, DeploymentPlatform, NodeMapper, NodeTemplate, \
29+
StructBuffer, TopologyOptimizer, TransientBuffer, VariableBuffer
30+
from Deeploy.Targets.Chimera.Templates import AllocateTemplate as ChimeraAllocateTemplate
31+
from Deeploy.Targets.Generic.Bindings import BasicAddBindings
32+
from Deeploy.Targets.Generic.Layers import AddLayer
33+
from Deeploy.Targets.Generic.Parsers import AddParser
34+
from Deeploy.Targets.Generic.Templates import AllocateTemplate as BasicAllocateTemplate
35+
36+
AddMapper = NodeMapper(AddParser(), BasicAddBindings)
37+
38+
ChimeraMapping = {
39+
'Add': AddLayer([AddMapper]),
40+
}
41+
42+
43+
class ChimeraVariableBuffer(VariableBuffer):
44+
45+
initTemplate = BasicAllocateTemplate.referenceInitTemplate
46+
allocTemplate = ChimeraAllocateTemplate.memoryIslandAllocateTemplate
47+
deallocTemplate = ChimeraAllocateTemplate.memoryIslandFreeTemplate
48+
49+
50+
class ChimeraTransientBuffer(TransientBuffer):
51+
52+
initTemplate = BasicAllocateTemplate.referenceInitTemplate
53+
allocTemplate = ChimeraAllocateTemplate.memoryIslandAllocateTemplate
54+
deallocTemplate = ChimeraAllocateTemplate.memoryIslandFreeTemplate
55+
56+
57+
class ChimeraConstantBuffer(ConstantBuffer):
58+
59+
initTemplate = BasicAllocateTemplate.referenceGlobalInitTemplate
60+
allocTemplate = BasicAllocateTemplate.referenceGlobalInitTemplate
61+
deallocTemplate = NodeTemplate("")
62+
63+
64+
class ChimeraStructBuffer(StructBuffer):
65+
66+
initTemplate = BasicAllocateTemplate.referenceStructInitTemplate
67+
allocTemplate = BasicAllocateTemplate.referenceStructAllocateTemplate
68+
deallocTemplate = NodeTemplate("")
69+
70+
71+
ChimeraOptimizer = TopologyOptimizer([
72+
# JUNGVI: Nothing for now
73+
])
74+
75+
_includeList = [
76+
"uart.h",
77+
"DeeployChimeraMath.h",
78+
]
79+
80+
81+
class ChimeraHostEngine(DeploymentEngine):
82+
83+
def __init__(self, name: str, Mapping = ChimeraMapping, initCode = "", includeList = _includeList) -> None:
84+
super().__init__(name, Mapping, initCode, includeList)
85+
86+
87+
class ChimeraPlatform(DeploymentPlatform):
88+
89+
def __init__(self,
90+
engines = [ChimeraHostEngine("ChimeraHost")],
91+
variableBuffer = ChimeraVariableBuffer,
92+
constantBuffer = ChimeraConstantBuffer,
93+
structBuffer = ChimeraStructBuffer,
94+
transientBuffer = ChimeraTransientBuffer,
95+
includeList: List[str] = _includeList):
96+
super().__init__(engines, variableBuffer, constantBuffer, structBuffer, transientBuffer)

0 commit comments

Comments
 (0)