Skip to content

Commit 2389a27

Browse files
committed
init
1 parent 4341e83 commit 2389a27

File tree

5 files changed

+114
-8
lines changed

5 files changed

+114
-8
lines changed

.github/workflows/compile.yml

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,16 @@ jobs:
162162
include:
163163
- build: 'noavx'
164164
defines: '-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF'
165+
arch: 'x64'
165166
- build: 'avx2'
166167
defines: ''
168+
arch: 'x64'
167169
- build: 'avx'
168170
defines: '-DGGML_AVX2=OFF'
171+
arch: 'x64'
169172
- build: 'avx512'
170173
defines: '-DGGML_AVX512=ON -DGGML_AVX512_VBMI=ON -DGGML_AVX512_VNNI=ON'
174+
arch: 'x64'
171175
runs-on: windows-latest
172176
steps:
173177
- uses: actions/checkout@v4
@@ -189,32 +193,90 @@ jobs:
189193
uses: actions/upload-artifact@v4
190194
with:
191195
path: .\build\bin\Release\llama.dll
192-
name: llama-bin-win-${{ matrix.build }}-x64.dll
196+
name: llama-bin-win-${{ matrix.build }}-${{ matrix.arch }}.dll
193197
if-no-files-found: error
194198
- name: Upload artifacts (ggml)
195199
uses: actions/upload-artifact@v4
196200
with:
197201
path: .\build\bin\Release\ggml.dll
198-
name: ggml-bin-win-${{ matrix.build }}-x64.dll
202+
name: ggml-bin-win-${{ matrix.build }}-${{ matrix.arch }}.dll
199203
if-no-files-found: error
200204
- name: Upload artifacts (ggml-base)
201205
uses: actions/upload-artifact@v4
202206
with:
203207
path: .\build\bin\Release\ggml-base.dll
204-
name: ggml-base-bin-win-${{ matrix.build }}-x64.dll
208+
name: ggml-base-bin-win-${{ matrix.build }}-${{ matrix.arch }}.dll
205209
if-no-files-found: error
206210
- name: Upload artifacts (ggml-cpu)
207211
uses: actions/upload-artifact@v4
208212
with:
209213
path: .\build\bin\Release\ggml-cpu.dll
210-
name: ggml-cpu-bin-win-${{ matrix.build }}-x64.dll
214+
name: ggml-cpu-bin-win-${{ matrix.build }}-${{ matrix.arch }}.dll
211215
if-no-files-found: error
212216

213217
- name: Upload artifacts (llava)
214218
uses: actions/upload-artifact@v4
215219
with:
216220
path: .\build\bin\Release\llava_shared.dll
217-
name: llava-bin-win-${{ matrix.build }}-x64.dll
221+
name: llava-bin-win-${{ matrix.build }}-${{ matrix.arch }}.dll
222+
if-no-files-found: error
223+
224+
compile-windows-arm64:
225+
name: Compile (Windows ARM64)
226+
strategy:
227+
fail-fast: true
228+
matrix:
229+
include:
230+
- build: 'arm64'
231+
defines: '-DCMAKE_GENERATOR_PLATFORM=ARM64 -DGGML_NATIVE=OFF -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF'
232+
arch: 'arm64'
233+
runs-on: windows-latest
234+
steps:
235+
- uses: actions/checkout@v4
236+
with:
237+
repository: ggerganov/llama.cpp
238+
fetch-depth: 0
239+
ref: '${{ github.event.inputs.llama_cpp_commit }}'
240+
241+
- name: Build
242+
id: cmake_build
243+
run: |
244+
mkdir build
245+
cd build
246+
cmake .. ${{ env.COMMON_DEFINE }} ${{ matrix.defines }}
247+
cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
248+
tree /f
249+
250+
- name: Upload artifacts (llama)
251+
uses: actions/upload-artifact@v4
252+
with:
253+
path: .\build\bin\Release\llama.dll
254+
name: llama-bin-win-${{ matrix.build }}-${{ matrix.arch }}.dll
255+
if-no-files-found: error
256+
- name: Upload artifacts (ggml)
257+
uses: actions/upload-artifact@v4
258+
with:
259+
path: .\build\bin\Release\ggml.dll
260+
name: ggml-bin-win-${{ matrix.build }}-${{ matrix.arch }}.dll
261+
if-no-files-found: error
262+
- name: Upload artifacts (ggml-base)
263+
uses: actions/upload-artifact@v4
264+
with:
265+
path: .\build\bin\Release\ggml-base.dll
266+
name: ggml-base-bin-win-${{ matrix.build }}-${{ matrix.arch }}.dll
267+
if-no-files-found: error
268+
- name: Upload artifacts (ggml-cpu)
269+
uses: actions/upload-artifact@v4
270+
with:
271+
path: .\build\bin\Release\ggml-cpu.dll
272+
name: ggml-cpu-bin-win-${{ matrix.build }}-${{ matrix.arch }}.dll
273+
if-no-files-found: error
274+
275+
- name: Upload artifacts (llava)
276+
uses: actions/upload-artifact@v4
277+
with:
278+
path: .\build\bin\Release\llava_shared.dll
279+
name: llava-bin-win-${{ matrix.build }}-${{ matrix.arch }}.dll
218280
if-no-files-found: error
219281

220282
compile-vulkan:
@@ -606,6 +668,7 @@ jobs:
606668
"compile-linux",
607669
"compile-musl",
608670
"compile-windows",
671+
"compile-windows-arm64",
609672
"compile-vulkan",
610673
"compile-cublas",
611674
"compile-macos",
@@ -620,7 +683,7 @@ jobs:
620683
- name: Rearrange Files
621684
run: |
622685
# Make all directories at once
623-
mkdir --parents deps/{noavx,avx,avx2,avx512,linux-arm64,musl-noavx,musl-avx,musl-avx2,musl-avx512,osx-arm64,osx-x64,osx-x64-rosetta2,cu11.7.1,cu12.2.0,vulkan,android-arm64-v8a,android-x86,android-x86_64}
686+
mkdir --parents deps/{noavx,avx,avx2,avx512,linux-arm64,musl-noavx,musl-avx,musl-avx2,musl-avx512,osx-arm64,osx-x64,osx-x64-rosetta2,cu11.7.1,cu12.2.0,vulkan,android-arm64-v8a,android-x86,android-x86_64,win-arm64}
624687
625688
# Linux
626689
cp artifacts/ggml-bin-linux-noavx-x64.so/libggml.so deps/noavx/libggml.so
@@ -704,6 +767,13 @@ jobs:
704767
cp artifacts/llama-bin-win-avx512-x64.dll/llama.dll deps/avx512/llama.dll
705768
cp artifacts/llava-bin-win-avx512-x64.dll/llava_shared.dll deps/avx512/llava_shared.dll
706769
770+
# Windows ARM64
771+
cp artifacts/ggml-bin-win-arm64-arm64.dll/ggml.dll deps/win-arm64/ggml.dll
772+
cp artifacts/ggml-base-bin-win-arm64-arm64.dll/ggml-base.dll deps/win-arm64/ggml-base.dll
773+
cp artifacts/ggml-cpu-bin-win-arm64-arm64.dll/ggml-cpu.dll deps/win-arm64/ggml-cpu.dll
774+
cp artifacts/llama-bin-win-arm64-arm64.dll/llama.dll deps/win-arm64/llama.dll
775+
cp artifacts/llava-bin-win-arm64-arm64.dll/llava_shared.dll deps/win-arm64/llava_shared.dll
776+
707777
# MacOS
708778
cp artifacts/ggml-bin-osx-arm64.dylib/libggml.dylib deps/osx-arm64/libggml.dylib
709779
cp artifacts/ggml-base-bin-osx-arm64.dylib/libggml-base.dylib deps/osx-arm64/libggml-base.dylib

LLama/LLamaSharp.Runtime.targets

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,29 @@
112112
</None>
113113

114114

115+
<!-- Windows ARM64 -->
116+
<None Include="$(MSBuildThisFileDirectory)runtimes/deps/win-arm64/llama.dll">
117+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
118+
<Link>runtimes/win-arm64/native/llama.dll</Link>
119+
</None>
120+
<None Include="$(MSBuildThisFileDirectory)runtimes/deps/win-arm64/ggml.dll">
121+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
122+
<Link>runtimes/win-arm64/native/ggml.dll</Link>
123+
</None>
124+
<None Include="$(MSBuildThisFileDirectory)runtimes/deps/win-arm64/ggml-base.dll">
125+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
126+
<Link>runtimes/win-arm64/native/ggml-base.dll</Link>
127+
</None>
128+
<None Include="$(MSBuildThisFileDirectory)runtimes/deps/win-arm64/ggml-cpu.dll">
129+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
130+
<Link>runtimes/win-arm64/native/ggml-cpu.dll</Link>
131+
</None>
132+
<None Include="$(MSBuildThisFileDirectory)runtimes/deps/win-arm64/llava_shared.dll">
133+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
134+
<Link>runtimes/win-arm64/native/llava_shared.dll</Link>
135+
</None>
136+
137+
115138
<None Include="$(MSBuildThisFileDirectory)runtimes/deps/noavx/libllama.so">
116139
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
117140
<Link>runtimes/linux-x64/native/noavx/libllama.so</Link>
@@ -418,6 +441,10 @@
418441
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
419442
<Link>runtimes/win-x64/native/vulkan/libmtmd.dll</Link>
420443
</None>
444+
<None Include="$(MSBuildThisFileDirectory)runtimes/deps/win-arm64/mtmd.dll">
445+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
446+
<Link>runtimes/win-arm64/native/libmtmd.dll</Link>
447+
</None>
421448

422449
<None Include="$(MSBuildThisFileDirectory)runtimes/deps/noavx/libmtmd.so">
423450
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

LLama/Native/Load/NativeLibraryUtils.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ public static void GetPlatformPathParts(OSPlatform platform, out string os, out
219219
{
220220
if (platform == OSPlatform.Windows)
221221
{
222-
os = "win-x64";
222+
os = System.Runtime.Intrinsics.Arm.ArmBase.Arm64.IsSupported
223+
? "win-arm64"
224+
: "win-x64";
223225
fileExtension = ".dll";
224226
libPrefix = "";
225227
return;

LLama/Native/Load/NativeLibraryWithAvx.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public IEnumerable<string> Prepare(SystemInfo systemInfo, NativeLogConfig.LLamaL
5050
private string? GetAvxPath(SystemInfo systemInfo, AvxLevel avxLevel, NativeLogConfig.LLamaLogCallback? logCallback)
5151
{
5252
NativeLibraryUtils.GetPlatformPathParts(systemInfo.OSPlatform, out var os, out var fileExtension, out var libPrefix);
53-
if (os != "linux-arm64"){
53+
if (os != "linux-arm64" && os != "win-arm64"){
5454
var avxStr = NativeLibraryConfig.AvxLevelToString(avxLevel);
5555
if (!string.IsNullOrEmpty(avxStr))
5656
avxStr += "/";

LLama/runtimes/build/LLamaSharp.Backend.Cpu.nuspec

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
<file src="runtimes/deps/avx512/llama.dll" target="runtimes\win-x64\native\avx512\llama.dll" />
4343
<file src="runtimes/deps/avx512/llava_shared.dll" target="runtimes\win-x64\native\avx512\llava_shared.dll" />
4444

45+
<!-- Windows ARM64 -->
46+
<file src="runtimes/deps/win-arm64/ggml.dll" target="runtimes\win-arm64\native\ggml.dll" />
47+
<file src="runtimes/deps/win-arm64/ggml-base.dll" target="runtimes\win-arm64\native\ggml-base.dll" />
48+
<file src="runtimes/deps/win-arm64/ggml-cpu.dll" target="runtimes\win-arm64\native\ggml-cpu.dll" />
49+
<file src="runtimes/deps/win-arm64/llama.dll" target="runtimes\win-arm64\native\llama.dll" />
50+
<file src="runtimes/deps/win-arm64/llava_shared.dll" target="runtimes\win-arm64\native\llava_shared.dll" />
51+
4552
<file src="runtimes/deps/noavx/libggml.so" target="runtimes\linux-x64\native\noavx\libggml.so" />
4653
<file src="runtimes/deps/noavx/libggml-base.so" target="runtimes\linux-x64\native\noavx\libggml-base.so" />
4754
<file src="runtimes/deps/noavx/libggml-cpu.so" target="runtimes\linux-x64\native\noavx\libggml-cpu.so" />

0 commit comments

Comments
 (0)