Skip to content

Commit 746f585

Browse files
committed
Merge branch 'upstream-main' into gltf-tutorial
# Conflicts: # REUSE.toml # antora/modules/ROOT/nav.adoc
2 parents 2bceba1 + d404e5d commit 746f585

180 files changed

Lines changed: 40511 additions & 10 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# SPDX-FileCopyrightText: 2026 Holochip Inc.
2+
# SPDX-License-Identifier: CC-BY-4.0
3+
name: ML Inference CI
4+
5+
on:
6+
push:
7+
paths:
8+
- 'attachments/ml_inference/**'
9+
- '.github/workflows/ml_inference_ci.yml'
10+
pull_request:
11+
paths:
12+
- 'attachments/ml_inference/**'
13+
- '.github/workflows/ml_inference_ci.yml'
14+
workflow_dispatch:
15+
16+
jobs:
17+
desktop:
18+
name: Build (ubuntu-latest)
19+
runs-on: ubuntu-latest
20+
21+
defaults:
22+
run:
23+
working-directory: attachments/ml_inference
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Install Clang + Ninja + ccache
30+
shell: bash
31+
run: |
32+
set -euo pipefail
33+
sudo apt-get update
34+
sudo apt-get install -y clang ninja-build ccache
35+
36+
- name: Select Clang toolchain
37+
shell: bash
38+
run: |
39+
echo "CC=clang" >> "$GITHUB_ENV"
40+
echo "CXX=clang++" >> "$GITHUB_ENV"
41+
42+
- name: ccache
43+
uses: actions/cache@v4
44+
with:
45+
path: ~/.cache/ccache
46+
key: ${{ runner.os }}-ml-inference-ccache-${{ github.sha }}
47+
restore-keys: ${{ runner.os }}-ml-inference-ccache-
48+
49+
- name: Cache Vulkan SDK
50+
id: cache-vulkan
51+
uses: actions/cache@v4
52+
with:
53+
path: ${{ runner.temp }}/VulkanSDK
54+
key: ${{ runner.os }}-vulkan-sdk
55+
56+
- name: Install Vulkan SDK
57+
shell: bash
58+
run: |
59+
set -euo pipefail
60+
sudo apt-get update
61+
sudo apt-get install -y curl ca-certificates xz-utils spirv-tools
62+
63+
SDK_DIR="${RUNNER_TEMP}/VulkanSDK"
64+
65+
if [ "${{ steps.cache-vulkan.outputs.cache-hit }}" != "true" ]; then
66+
echo "Downloading Vulkan SDK from LunarG..."
67+
SDK_TGZ="${RUNNER_TEMP}/vulkansdk-linux.tar.xz"
68+
69+
download_ok=0
70+
for url in \
71+
"https://sdk.lunarg.com/sdk/download/latest/linux/vulkan-sdk.tar.xz" \
72+
"https://sdk.lunarg.com/sdk/download/latest/linux/vulkansdk-linux-x86_64.tar.xz" \
73+
"https://sdk.lunarg.com/sdk/download/latest/linux/vulkan-sdk.tar.xz?Human=true" \
74+
"https://sdk.lunarg.com/sdk/download/latest/linux/vulkansdk-linux-x86_64.tar.xz?Human=true"
75+
do
76+
echo "Attempting: $url"
77+
if curl -L --fail -o "$SDK_TGZ" "$url"; then
78+
download_ok=1
79+
break
80+
fi
81+
done
82+
if [ "$download_ok" -ne 1 ]; then
83+
echo "Failed to download Vulkan SDK from LunarG (all endpoints returned non-200)." >&2
84+
exit 1
85+
fi
86+
87+
rm -rf "$SDK_DIR"
88+
mkdir -p "$SDK_DIR"
89+
tar -xJf "$SDK_TGZ" -C "$SDK_DIR"
90+
else
91+
echo "Using cached Vulkan SDK from $SDK_DIR"
92+
fi
93+
94+
VULKAN_SDK_PATH="$(find "$SDK_DIR" -maxdepth 1 -type d -name '1.*' | sort -r | head -n 1)"
95+
if [ -z "${VULKAN_SDK_PATH:-}" ]; then
96+
echo "Failed to locate extracted Vulkan SDK directory under $SDK_DIR" >&2
97+
exit 1
98+
fi
99+
100+
SDK_SYSROOT="$VULKAN_SDK_PATH"
101+
if [ -d "$VULKAN_SDK_PATH/x86_64" ]; then
102+
SDK_SYSROOT="$VULKAN_SDK_PATH/x86_64"
103+
fi
104+
105+
echo "VULKAN_SDK=$VULKAN_SDK_PATH" >> "$GITHUB_ENV"
106+
echo "VULKAN_SDK_SYSROOT=$SDK_SYSROOT" >> "$GITHUB_ENV"
107+
108+
if [ -d "$VULKAN_SDK_PATH/bin" ]; then
109+
echo "$VULKAN_SDK_PATH/bin" >> "$GITHUB_PATH"
110+
fi
111+
if [ -d "$SDK_SYSROOT/bin" ]; then
112+
echo "$SDK_SYSROOT/bin" >> "$GITHUB_PATH"
113+
fi
114+
115+
echo "CMAKE_PREFIX_PATH=$SDK_SYSROOT" >> "$GITHUB_ENV"
116+
echo "Vulkan_INCLUDE_DIR=$SDK_SYSROOT/include" >> "$GITHUB_ENV"
117+
if [ -f "$SDK_SYSROOT/lib/libvulkan.so" ]; then
118+
echo "Vulkan_LIBRARY=$SDK_SYSROOT/lib/libvulkan.so" >> "$GITHUB_ENV"
119+
elif [ -f "$SDK_SYSROOT/lib/libvulkan.so.1" ]; then
120+
echo "Vulkan_LIBRARY=$SDK_SYSROOT/lib/libvulkan.so.1" >> "$GITHUB_ENV"
121+
fi
122+
123+
if command -v slangc >/dev/null 2>&1; then
124+
echo "SLANGC_EXECUTABLE=$(command -v slangc)" >> "$GITHUB_ENV"
125+
fi
126+
127+
compat_dir="${RUNNER_TEMP}/slang-compat"
128+
mkdir -p "$compat_dir"
129+
pthread_path="$(ldconfig -p | awk '/libpthread\.so\.0/{print $NF; exit 0}' || true)"
130+
if [ -n "${pthread_path:-}" ] && [ -f "$pthread_path" ]; then
131+
ln -sf "$pthread_path" "$compat_dir/libpthread.so"
132+
fi
133+
echo "LD_LIBRARY_PATH=$compat_dir:${SDK_SYSROOT}/lib:${VULKAN_SDK_PATH}/lib:${LD_LIBRARY_PATH:-}" >> "$GITHUB_ENV"
134+
135+
- name: Vulkan SDK diagnostics
136+
shell: bash
137+
run: |
138+
echo "VULKAN_SDK=$VULKAN_SDK"
139+
echo "VULKAN_SDK_SYSROOT=${VULKAN_SDK_SYSROOT:-}"
140+
echo "Vulkan_INCLUDE_DIR=${Vulkan_INCLUDE_DIR:-}"
141+
echo "Vulkan_LIBRARY=${Vulkan_LIBRARY:-}"
142+
echo "SLANGC_EXECUTABLE=${SLANGC_EXECUTABLE:-}"
143+
echo "which slangc: $(command -v slangc || echo 'NOT FOUND')"
144+
145+
- name: Install system dependencies
146+
shell: bash
147+
run: |
148+
set -euo pipefail
149+
sudo apt-get update
150+
sudo apt-get install -y \
151+
build-essential cmake git pkg-config \
152+
ca-certificates curl zip unzip \
153+
libglfw3-dev libglm-dev \
154+
libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
155+
156+
- name: Clone NNEF parser
157+
shell: bash
158+
run: |
159+
set -euo pipefail
160+
NNEF_DIR="third_party/nnef-parser"
161+
if [ ! -f "${NNEF_DIR}/src/nnef.cpp" ]; then
162+
WORK="${RUNNER_TEMP}/NNEF-Tools"
163+
git clone --depth 1 https://github.com/KhronosGroup/NNEF-Tools.git "$WORK"
164+
mkdir -p "${NNEF_DIR}/src" "${NNEF_DIR}/include"
165+
cp "$WORK/nnef-pyproject/nnef/cpp/src/nnef.cpp" "${NNEF_DIR}/src/"
166+
cp -r "$WORK/nnef-pyproject/nnef/cpp/include/." "${NNEF_DIR}/include/"
167+
else
168+
echo "NNEF parser already present"
169+
fi
170+
171+
- name: Create placeholder resource directories
172+
shell: bash
173+
run: |
174+
# These directories are not tracked by git but are referenced in post-build
175+
# copy_directory commands. Create them so the build does not fail.
176+
mkdir -p models/mobilenetv2_nnef_optimized data sample_images
177+
touch mnist_model.onnx mnist_model.onnx.data mnist_weights.bin
178+
179+
- name: Configure
180+
shell: bash
181+
run: |
182+
set -euo pipefail
183+
extra_args=()
184+
if [ -n "${Vulkan_INCLUDE_DIR:-}" ]; then
185+
extra_args+=("-DVulkan_INCLUDE_DIR=${Vulkan_INCLUDE_DIR}")
186+
fi
187+
if [ -n "${Vulkan_LIBRARY:-}" ]; then
188+
extra_args+=("-DVulkan_LIBRARY=${Vulkan_LIBRARY}")
189+
fi
190+
if [ -n "${SLANGC_EXECUTABLE:-}" ]; then
191+
extra_args+=("-DSLANGC_EXECUTABLE=${SLANGC_EXECUTABLE}")
192+
fi
193+
194+
cmake -S . -B build -G Ninja \
195+
-DCMAKE_BUILD_TYPE=Release \
196+
-DCMAKE_C_COMPILER=clang \
197+
-DCMAKE_CXX_COMPILER=clang++ \
198+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
199+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
200+
-DCMAKE_PREFIX_PATH="${VULKAN_SDK_SYSROOT}" \
201+
-DML_SETUP_PYTHON_ENV=OFF \
202+
-DML_TRAIN_MODELS=OFF \
203+
"${extra_args[@]}"
204+
205+
- name: Build
206+
shell: bash
207+
run: cmake --build build --parallel 4
208+
209+
- name: ccache stats
210+
shell: bash
211+
run: ccache -s

REUSE.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ SPDX-License-Identifier = "BSD-3-Clause"
6868
[[annotations]]
6969
path = [
7070
"attachments/simple_engine/**",
71+
"attachments/ml_inference/**",
7172
"attachments/advanced_gltf/**",
7273
"en/Synchronization/**",
74+
"en/ML_Inference/**",
7375
"en/Advanced_glTF/**",
7476
"scripts/**",
7577
]

antora/Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,22 @@ EXCLUDE = 'index.adoc'
1515
setup: setup_tutorial
1616

1717
setup_tutorial:
18-
# In order to keep the image links we need to have the image folder inside the image folder (due to how Antora works)
18+
# In order to keep the image links we need to have the image folder inside the image folder (due to how Antora works)
1919
mkdir -p $(ROOT)/images/images
2020
rsync -a --delete ../images $(ROOT)/images
21-
rsync -a --delete ../attachments $(ROOT)
21+
# Exclude large and generated build artifacts from attachments to keep Antora fast and avoid glob recursion
22+
rsync -a --delete \
23+
--exclude '*/.git/' \
24+
--exclude '*/.cxx/' \
25+
--exclude '*/build/' \
26+
--exclude '*/cmake-build-*' \
27+
--exclude '*/venv/' \
28+
--exclude '*/node_modules/' \
29+
--exclude '*/__pycache__/' \
30+
../attachments $(ROOT)
2231
mkdir -p $(ROOT)/pages
2332
rsync -a --delete --exclude ${EXCLUDE} ../en/ $(ROOT)/pages
33+
cp ../en/Building_a_Simple_Engine/GUI/index.adoc $(ROOT)/pages/Building_a_Simple_Engine/GUI/index.adoc
2434
# Use a python script to automat some file content changes that are necessary due to differences between Antora and github
2535
python3 make_helper.py
2636

@@ -32,4 +42,4 @@ setup_tutorial:
3242
# $(ROOT)/images
3343

3444
# clean:
35-
# $(RMRF) $(ANTORA_GENERATED)
45+
# $(RMRF) $(ANTORA_GENERATED)

antora/modules/ROOT/nav.adoc

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,82 @@
161161
** Appendix
162162
*** xref:Building_a_Simple_Engine/Appendix/appendix.adoc[Appendix]
163163
164+
* Machine Learning Inference
165+
** xref:ML_Inference/introduction.adoc[Introduction]
166+
** ML Inference Pipeline
167+
*** xref:ML_Inference/ML_Inference_Pipeline/01_introduction.adoc[Introduction]
168+
*** xref:ML_Inference/ML_Inference_Pipeline/02_what_is_machine_learning.adoc[What is Machine Learning]
169+
*** xref:ML_Inference/ML_Inference_Pipeline/03_neural_networks_fundamentals.adoc[Neural Networks Fundamentals]
170+
*** xref:ML_Inference/ML_Inference_Pipeline/04_inference_explained.adoc[Inference Explained]
171+
*** xref:ML_Inference/ML_Inference_Pipeline/05_transfer_learning.adoc[Transfer Learning]
172+
*** xref:ML_Inference/ML_Inference_Pipeline/06_model_formats.adoc[Model Formats]
173+
*** xref:ML_Inference/ML_Inference_Pipeline/07_mental_model_gpu_execution.adoc[Mental Model: GPU Execution]
174+
** Integrating Third-Party ML Libraries
175+
*** xref:ML_Inference/Third_Party_Libraries/01_introduction.adoc[Introduction]
176+
*** xref:ML_Inference/Third_Party_Libraries/02_onnx_runtime.adoc[ONNX Runtime]
177+
*** xref:ML_Inference/Third_Party_Libraries/03_tensorflow_lite.adoc[TensorFlow Lite]
178+
*** xref:ML_Inference/Third_Party_Libraries/04_pytorch_mobile.adoc[PyTorch Mobile]
179+
*** xref:ML_Inference/Third_Party_Libraries/05_directml.adoc[DirectML]
180+
*** xref:ML_Inference/Third_Party_Libraries/06_integration_patterns.adoc[Integration Patterns]
181+
*** xref:ML_Inference/Third_Party_Libraries/07_gpu_resource_sharing.adoc[GPU Resource Sharing]
182+
*** xref:ML_Inference/Third_Party_Libraries/08_data_transfer_optimization.adoc[Data Transfer Optimization]
183+
*** xref:ML_Inference/Third_Party_Libraries/09_practical_examples.adoc[Practical Examples]
184+
*** xref:ML_Inference/Third_Party_Libraries/10_choosing_library.adoc[Choosing the Right Library]
185+
*** xref:ML_Inference/Third_Party_Libraries/11_ML_Compilers.adoc[ML Compilers Overview]
186+
*** xref:ML_Inference/Third_Party_Libraries/12_iree.adoc[IREE]
187+
*** xref:ML_Inference/Third_Party_Libraries/13_apache_tvm.adoc[Apache TVM]
188+
*** xref:ML_Inference/Third_Party_Libraries/14_mojo_max.adoc[Mojo / MAX]
189+
*** xref:ML_Inference/Third_Party_Libraries/15_openxla.adoc[OpenXLA]
190+
*** xref:ML_Inference/Third_Party_Libraries/16_choosing_compiler.adoc[Choosing the Right ML Compiler]
191+
** Vulkan Compute for ML
192+
*** xref:ML_Inference/Vulkan_Compute_for_ML/01_introduction.adoc[Introduction]
193+
*** xref:ML_Inference/Vulkan_Compute_for_ML/02_compute_pipeline_review.adoc[Compute Pipeline Review]
194+
*** xref:ML_Inference/Vulkan_Compute_for_ML/03_element_wise_operations.adoc[Element-wise Operations]
195+
*** xref:ML_Inference/Vulkan_Compute_for_ML/04_matrix_operations.adoc[Matrix Operations]
196+
*** xref:ML_Inference/Vulkan_Compute_for_ML/05_data_management.adoc[Data Management]
197+
*** xref:ML_Inference/Vulkan_Compute_for_ML/06_synchronization.adoc[Synchronization]
198+
*** xref:ML_Inference/Vulkan_Compute_for_ML/07_vector_addition_example.adoc[Vector Addition Example]
199+
** Building the Inference Engine
200+
*** xref:ML_Inference/Building_the_Inference_Engine/01_introduction.adoc[Introduction]
201+
*** xref:ML_Inference/Building_the_Inference_Engine/02_hardcoded_forward_prop.adoc[Hardcoded Forward Prop]
202+
*** xref:ML_Inference/Building_the_Inference_Engine/03_from_hardcoded_to_flexible.adoc[From Hardcoded to Flexible]
203+
*** xref:ML_Inference/Building_the_Inference_Engine/04_model_representation.adoc[Model Representation]
204+
*** xref:ML_Inference/Building_the_Inference_Engine/05_model_formats_as_input.adoc[Model Formats as Input]
205+
*** xref:ML_Inference/Building_the_Inference_Engine/06_nnef_introduction.adoc[NNEF Introduction]
206+
*** xref:ML_Inference/Building_the_Inference_Engine/07_putting_it_together.adoc[Putting it Together]
207+
** Debugging and Performance
208+
*** xref:ML_Inference/Debugging_and_Performance/01_introduction.adoc[Introduction]
209+
*** xref:ML_Inference/Debugging_and_Performance/02_debugging_vulkan_compute.adoc[Debugging Vulkan Compute]
210+
*** xref:ML_Inference/Debugging_and_Performance/03_verifying_correctness.adoc[Verifying Correctness]
211+
*** xref:ML_Inference/Debugging_and_Performance/04_performance_profiling.adoc[Performance Profiling]
212+
*** xref:ML_Inference/Debugging_and_Performance/05_optimization_techniques.adoc[Optimization Techniques]
213+
** Desktop Applications
214+
*** xref:ML_Inference/Desktop_Applications/01_introduction.adoc[Introduction]
215+
*** xref:ML_Inference/Desktop_Applications/02_image_classification.adoc[Image Classification]
216+
*** xref:ML_Inference/Desktop_Applications/03_practical_implementation.adoc[Practical Implementation]
217+
*** xref:ML_Inference/Desktop_Applications/04_ci_render_validation.adoc[CI/CD Render Validation]
218+
*** xref:ML_Inference/Desktop_Applications/05_real_time_camera.adoc[Real-time Camera]
219+
*** xref:ML_Inference/Desktop_Applications/06_rl_automated_exploration.adoc[RL Automated Exploration]
220+
*** xref:ML_Inference/Desktop_Applications/07_ray_tracing_optimization.adoc[Ray Tracing Optimization]
221+
*** xref:ML_Inference/Desktop_Applications/08_future_directions.adoc[Future Directions]
222+
** Advanced Topics
223+
*** xref:ML_Inference/Advanced_Topics/01_introduction.adoc[Introduction]
224+
*** xref:ML_Inference/Advanced_Topics/02_quantization_strategies.adoc[Quantization Strategies]
225+
*** xref:ML_Inference/Advanced_Topics/03_vendor_optimizations.adoc[Vendor Optimizations]
226+
*** xref:ML_Inference/Advanced_Topics/04_memory_management.adoc[Memory Management]
227+
*** xref:ML_Inference/Advanced_Topics/05_model_optimization.adoc[Model Optimization]
228+
** Embedded Applications
229+
*** xref:ML_Inference/Embedded_Applications/01_introduction.adoc[Introduction]
230+
*** xref:ML_Inference/Embedded_Applications/02_cross_compilation.adoc[Cross Compilation]
231+
*** xref:ML_Inference/Embedded_Applications/03_camera_integration.adoc[Camera Integration]
232+
*** xref:ML_Inference/Embedded_Applications/04_power_optimization.adoc[Power Optimization]
233+
*** xref:ML_Inference/Embedded_Applications/05_complete_example.adoc[Complete Example]
234+
*** xref:ML_Inference/Embedded_Applications/06_scene_understanding_openxr.adoc[Scene Understanding with OpenXR]
235+
*** xref:ML_Inference/Embedded_Applications/07_ml_compiler.adoc[ML Compilers on Embedded Devices]
236+
*** xref:ML_Inference/Embedded_Applications/08_nnef_example.adoc[NNEF on Embedded: Example]
237+
*** xref:ML_Inference/Embedded_Applications/09_conclusion.adoc[Conclusion]
238+
** xref:ML_Inference/glossary.adoc[Glossary]
239+
164240
* Advanced glTF: High-Performance Character Pipelines
165241
** xref:Advanced_glTF/introduction.adoc[Introduction]
166242
** Scene Graph & Transform Hierarchy

0 commit comments

Comments
 (0)