Compare commits

..

No commits in common. "c78f96dd57b0b394f06b60bb87c508c542ef1b75" and "ec4d85c0d6cd1985d89ac9720d30abd3e0ba5801" have entirely different histories.

8 changed files with 7 additions and 38 deletions

View File

@ -363,7 +363,6 @@ jobs:
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 }}
nuget pack ./Backends/StableDiffusion.NET.Backend.Vulkan.nuspec -version ${{ github.event.inputs.version }}
- name: Upload artifacts
id: upload_artifacts

View File

@ -15,12 +15,11 @@ public static class Backends
public static CudaBackend CudaBackend { get; } = new();
public static RocmBackend RocmBackend { get; } = new();
public static SyclBackend SyclBackend { get; } = new();
public static VulkanBackend VulkanBackend { get; } = new();
private static readonly List<IBackend> CUSTOM_BACKENDS = [];
public static IReadOnlyList<IBackend> CustomBackends => CUSTOM_BACKENDS.AsReadOnly();
public static IEnumerable<IBackend> RegisteredBackends => [CpuBackend, CudaBackend, RocmBackend, SyclBackend, VulkanBackend, .. 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> ActiveBackends => AvailableBackends.Where(x => x.IsEnabled);
@ -38,7 +37,7 @@ public static class Backends
public static bool RegisterBackend(IBackend backend)
{
if (backend is NET.CpuBackend or NET.CudaBackend or NET.RocmBackend or NET.SyclBackend or NET.VulkanBackend)
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))

View File

@ -13,7 +13,7 @@ public class CpuBackend : IBackend
public bool IsEnabled { get; set; } = true;
public int Priority { get; set; } = 0;
public int Priority => 0;
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux)

View File

@ -22,7 +22,7 @@ public partial class CudaBackend : IBackend
public bool IsEnabled { get; set; } = true;
public int Priority { get; set; } = 10;
public int Priority => 10;
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux))

View File

@ -6,7 +6,7 @@ namespace StableDiffusion.NET;
public interface IBackend
{
bool IsEnabled { get; set; }
public int Priority { get; set; }
public int Priority { get; }
bool IsAvailable { get; }
string PathPart { get; }
}

View File

@ -12,7 +12,7 @@ public partial class RocmBackend : IBackend
public bool IsEnabled { get; set; } = true;
public int Priority { get; set; } = 10;
public int Priority => 10;
public bool IsAvailable => ((RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
&& RocmVersion is 5)

View File

@ -11,7 +11,7 @@ public class SyclBackend : IBackend
//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 { get; set; } = 5;
public int Priority => 5;
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux))

View File

@ -1,29 +0,0 @@
using System.Runtime.InteropServices;
using JetBrains.Annotations;
namespace StableDiffusion.NET;
[PublicAPI]
public class VulkanBackend : IBackend
{
#region Properties & Fields
//TODO DarthAffe 28.08.2024: Find a way to detect vulkan compatibility
public bool IsEnabled { get; set; } = false;
public int Priority { get; set; } = 5;
public bool IsAvailable => RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
&& (RuntimeInformation.OSArchitecture == Architecture.X64);
public string PathPart => "vulkan";
#endregion
#region Constructors
internal VulkanBackend()
{ }
#endregion
}