mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +00:00
Added sycl backend
This commit is contained in:
parent
5c31ce725e
commit
ecac81dd8b
@ -14,11 +14,12 @@ public static class Backends
|
|||||||
public static CpuBackend CpuBackend { get; } = new();
|
public static CpuBackend CpuBackend { get; } = new();
|
||||||
public static CudaBackend CudaBackend { get; } = new();
|
public static CudaBackend CudaBackend { get; } = new();
|
||||||
public static RocmBackend RocmBackend { get; } = new();
|
public static RocmBackend RocmBackend { get; } = new();
|
||||||
|
public static SyclBackend SyclBackend { get; } = new();
|
||||||
|
|
||||||
private static readonly List<IBackend> CUSTOM_BACKENDS = [];
|
private static readonly List<IBackend> CUSTOM_BACKENDS = [];
|
||||||
public static IReadOnlyList<IBackend> CustomBackends => CUSTOM_BACKENDS.AsReadOnly();
|
public static IReadOnlyList<IBackend> CustomBackends => CUSTOM_BACKENDS.AsReadOnly();
|
||||||
|
|
||||||
public static IEnumerable<IBackend> RegisteredBackends => [CpuBackend, CudaBackend, RocmBackend, .. CUSTOM_BACKENDS];
|
public static IEnumerable<IBackend> RegisteredBackends => [CpuBackend, CudaBackend, RocmBackend, SyclBackend, .. CUSTOM_BACKENDS];
|
||||||
public static IEnumerable<IBackend> AvailableBackends => RegisteredBackends.Where(x => x.IsAvailable);
|
public static IEnumerable<IBackend> AvailableBackends => RegisteredBackends.Where(x => x.IsAvailable);
|
||||||
public static IEnumerable<IBackend> ActiveBackends => AvailableBackends.Where(x => x.IsEnabled);
|
public static IEnumerable<IBackend> ActiveBackends => AvailableBackends.Where(x => x.IsEnabled);
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ public static class Backends
|
|||||||
|
|
||||||
public static bool RegisterBackend(IBackend backend)
|
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.");
|
throw new ArgumentException("Default backends can't be registered again.");
|
||||||
|
|
||||||
if (CUSTOM_BACKENDS.Contains(backend))
|
if (CUSTOM_BACKENDS.Contains(backend))
|
||||||
|
|||||||
30
StableDiffusion.NET/Backends/SyclBackend.cs
Normal file
30
StableDiffusion.NET/Backends/SyclBackend.cs
Normal file
@ -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
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user