diff --git a/.github/workflows/backends.yml b/.github/workflows/backends.yml
index 13b4b0a..f18f253 100644
--- a/.github/workflows/backends.yml
+++ b/.github/workflows/backends.yml
@@ -101,6 +101,51 @@ jobs:
uses: actions/upload-artifact@v4.3.1
with:
name: windows-${{ matrix.build }}
+ path: .\build\bin\stable-diffusion.dll
+
+ windows-sycl:
+ runs-on: windows-latest
+
+ defaults:
+ run:
+ shell: bash
+
+ env:
+ WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/7dff44ba-e3af-4448-841c-0d616c8da6e7/w_BaseKit_p_2024.1.0.595_offline.exe
+ WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
+
+ steps:
+ - name: Checkout
+ id: checkout
+ uses: actions/checkout@v4.1.2
+ with:
+ repository: 'leejet/stable-diffusion.cpp'
+ ref: '${{ github.event.inputs.commit }}'
+ submodules: recursive
+
+ - name: Checkout Install Script
+ id: checkoutInstallScript
+ uses: actions/checkout@v4.1.2
+ with:
+ path: scripts
+ sparse-checkout: |
+ Backends/install-oneapi.bat
+ Backends/win-build-sycl.bat
+ sparse-checkout-cone-mode: false
+
+ - name: Install Sycl tools
+ id: installSyclCompiler
+ run: scripts/Backends/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
+
+ - name: Build
+ id: cmake_build
+ run: scripts/Backends/win-build-sycl.bat
+
+ - name: Upload artifact
+ id: upload_artifact
+ uses: actions/upload-artifact@v4.3.1
+ with:
+ name: windows-sycl
path: .\build\bin\stable-diffusion.dll
linux:
@@ -119,7 +164,9 @@ jobs:
- build: 'cuda11'
defines: '-DSD_CUBLAS=ON -DSD_BUILD_SHARED_LIBS=ON'
- build: 'cuda12'
- defines: '-DSD_CUBLAS=ON -DSD_BUILD_SHARED_LIBS=ON'
+ defines: '-DSD_CUBLAS=ON -DSD_BUILD_SHARED_LIBS=ON'
+ - build: 'sycl'
+ defines: '-DSD_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DSD_BUILD_SHARED_LIBS=ON'
steps:
- name: Checkout
@@ -150,8 +197,32 @@ jobs:
use-github-cache: false
use-local-cache: false
+ - name: Install Sycl tools
+ id: installSyclCompiler
+ if: ${{ matrix.build == 'sycl' }}
+ shell: bash
+ run: |
+ cd /tmp
+ wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
+ sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
+ rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
+ sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
+ sudo apt update
+ sudo apt install intel-oneapi-compiler-dpcpp-cpp intel-oneapi-mkl-devel
+
+ - name: Build
+ id: cmake_build_sycl
+ if: ${{ matrix.build == 'sycl' }}
+ run: |
+ source /opt/intel/oneapi/setvars.sh
+ mkdir build
+ cd build
+ cmake .. ${{ matrix.defines }}
+ cmake --build . --config Release
+
- name: Build
id: cmake_build
+ if: ${{ matrix.build != 'sycl' }}
run: |
mkdir build
cd build
@@ -244,6 +315,7 @@ jobs:
needs:
- windows
+ - windows-sycl
- linux
- linux-hip
- osx
@@ -276,6 +348,7 @@ jobs:
nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda12.Linux.nuspec -version ${{ github.event.inputs.version }}
nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda.nuspec -version ${{ github.event.inputs.version }}
nuget pack ./Backends/StableDiffusion.NET.Backend.Rocm.nuspec -version ${{ github.event.inputs.version }}
+ nuget pack ./Backends/StableDiffusion.NET.Backend.Sycl.nuspec -version ${{ github.event.inputs.version }}
- name: Upload artifacts
id: upload_artifacts
diff --git a/Backends/StableDiffusion.NET.Backend.Sycl.nuspec b/Backends/StableDiffusion.NET.Backend.Sycl.nuspec
new file mode 100644
index 0000000..639baaa
--- /dev/null
+++ b/Backends/StableDiffusion.NET.Backend.Sycl.nuspec
@@ -0,0 +1,30 @@
+
+
+
+ StableDiffusion.NET.Backend.Sycl
+ $version$
+ StableDiffusion.NET.Backend.Sycl
+ Darth Affe & stable-diffusion.cpp Authors
+ false
+ MIT
+ sd_net_sycl.png
+ https://github.com/DarthAffe/StableDiffusion.NET
+ SYCL-Backend for StableDiffusion.NET.
+
+ Copyright © Darth Affe 2024
+ readme.md
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Backends/install-oneapi.bat b/Backends/install-oneapi.bat
new file mode 100644
index 0000000..e99bef1
--- /dev/null
+++ b/Backends/install-oneapi.bat
@@ -0,0 +1,19 @@
+:: MIT license
+:: Copyright (C) 2024 Intel Corporation
+:: SPDX-License-Identifier: MIT
+
+
+set URL=%1
+set COMPONENTS=%2
+
+curl.exe --output %TEMP%\webimage.exe --url %URL% --retry 5 --retry-delay 5
+start /b /wait %TEMP%\webimage.exe -s -x -f webimage_extracted --log extract.log
+del %TEMP%\webimage.exe
+if "%COMPONENTS%"=="" (
+ webimage_extracted\bootstrapper.exe -s --action install --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=.
+) else (
+ webimage_extracted\bootstrapper.exe -s --action install --components=%COMPONENTS% --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=.
+)
+set installer_exit_code=%ERRORLEVEL%
+rd /s/q "webimage_extracted"
+exit /b %installer_exit_code%
diff --git a/Backends/sd_net_sycl.png b/Backends/sd_net_sycl.png
new file mode 100644
index 0000000..850b4d2
Binary files /dev/null and b/Backends/sd_net_sycl.png differ
diff --git a/Backends/win-build-sycl.bat b/Backends/win-build-sycl.bat
new file mode 100644
index 0000000..286a470
--- /dev/null
+++ b/Backends/win-build-sycl.bat
@@ -0,0 +1,24 @@
+:: MIT license
+:: Copyright (C) 2024 Intel Corporation
+:: SPDX-License-Identifier: MIT
+
+
+IF not exist build (mkdir build)
+cd build
+if %errorlevel% neq 0 goto ERROR
+
+@call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 --force
+if %errorlevel% neq 0 goto ERROR
+
+cmake -G "Ninja" .. -DGGML_SYCL=ON -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=icx -DSD_BUILD_SHARED_LIBS=ON
+if %errorlevel% neq 0 goto ERROR
+
+cmake --build . -j --config Release
+if %errorlevel% neq 0 goto ERROR
+
+cd ..
+exit /B 0
+
+:ERROR
+echo comomand error: %errorlevel%
+exit /B %errorlevel%
diff --git a/Examples/ImageCreationUI/MainWindowViewModel.cs b/Examples/ImageCreationUI/MainWindowViewModel.cs
index f31afb7..be6fae4 100644
--- a/Examples/ImageCreationUI/MainWindowViewModel.cs
+++ b/Examples/ImageCreationUI/MainWindowViewModel.cs
@@ -175,7 +175,7 @@ public class MainWindowViewModel : INotifyPropertyChanged
}
catch (Exception ex)
{
- LogLine($"Failed to load stable-diffussion.cpp libraries!{Environment.NewLine}{ex.Message}");
+ LogLine($"Failed to load stable-diffusion.cpp libraries!{Environment.NewLine}{ex.Message}");
}
}
diff --git a/Resources/sd_net_icon.xcf b/Resources/sd_net_icon.xcf
index 0ab00ce..a7d9992 100644
Binary files a/Resources/sd_net_icon.xcf and b/Resources/sd_net_icon.xcf differ
diff --git a/StableDiffusion.NET/Backends/Backends.cs b/StableDiffusion.NET/Backends/Backends.cs
index 150befb..2ce6607 100644
--- a/StableDiffusion.NET/Backends/Backends.cs
+++ b/StableDiffusion.NET/Backends/Backends.cs
@@ -14,11 +14,12 @@ public static class Backends
public static CpuBackend CpuBackend { get; } = new();
public static CudaBackend CudaBackend { get; } = new();
public static RocmBackend RocmBackend { get; } = new();
+ public static SyclBackend SyclBackend { get; } = new();
private static readonly List CUSTOM_BACKENDS = [];
public static IReadOnlyList CustomBackends => CUSTOM_BACKENDS.AsReadOnly();
- public static IEnumerable RegisteredBackends => [CpuBackend, CudaBackend, RocmBackend, .. CUSTOM_BACKENDS];
+ public static IEnumerable RegisteredBackends => [CpuBackend, CudaBackend, RocmBackend, SyclBackend, .. CUSTOM_BACKENDS];
public static IEnumerable AvailableBackends => RegisteredBackends.Where(x => x.IsAvailable);
public static IEnumerable ActiveBackends => AvailableBackends.Where(x => x.IsEnabled);
@@ -36,7 +37,7 @@ public static class Backends
public static bool RegisterBackend(IBackend backend)
{
- if (backend is NET.CpuBackend or NET.CudaBackend or NET.RocmBackend)
+ if (backend is NET.CpuBackend or NET.CudaBackend or NET.RocmBackend or NET.SyclBackend)
throw new ArgumentException("Default backends can't be registered again.");
if (CUSTOM_BACKENDS.Contains(backend))
diff --git a/StableDiffusion.NET/Backends/SyclBackend.cs b/StableDiffusion.NET/Backends/SyclBackend.cs
new file mode 100644
index 0000000..80e0b5b
--- /dev/null
+++ b/StableDiffusion.NET/Backends/SyclBackend.cs
@@ -0,0 +1,30 @@
+using System.Runtime.InteropServices;
+using JetBrains.Annotations;
+
+namespace StableDiffusion.NET;
+
+[PublicAPI]
+public class SyclBackend : IBackend
+{
+ #region Properties & Fields
+
+ //TODO DarthAffe 10.08.2024: tbh I'm not really sure how to detect a sycl-compatible system so for now it's disabled by default
+ public bool IsEnabled { get; set; } = false;
+
+ public int Priority => 5;
+
+ public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
+ || RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ && (RuntimeInformation.OSArchitecture == Architecture.X64);
+
+ public string PathPart => "sycl";
+
+ #endregion
+
+ #region Constructors
+
+ internal SyclBackend()
+ { }
+
+ #endregion
+}
\ No newline at end of file