mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +00:00
Compare commits
3 Commits
ec4d85c0d6
...
c78f96dd57
| Author | SHA1 | Date | |
|---|---|---|---|
| c78f96dd57 | |||
| bb71986ce7 | |||
| 7fbbb70f90 |
1
.github/workflows/backends.yml
vendored
1
.github/workflows/backends.yml
vendored
@ -363,6 +363,7 @@ 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
|
||||
|
||||
@ -15,11 +15,12 @@ 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, .. CUSTOM_BACKENDS];
|
||||
public static IEnumerable<IBackend> RegisteredBackends => [CpuBackend, CudaBackend, RocmBackend, SyclBackend, VulkanBackend, .. CUSTOM_BACKENDS];
|
||||
public static IEnumerable<IBackend> AvailableBackends => RegisteredBackends.Where(x => x.IsAvailable);
|
||||
public static IEnumerable<IBackend> ActiveBackends => AvailableBackends.Where(x => x.IsEnabled);
|
||||
|
||||
@ -37,7 +38,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)
|
||||
if (backend is NET.CpuBackend or NET.CudaBackend or NET.RocmBackend or NET.SyclBackend or NET.VulkanBackend)
|
||||
throw new ArgumentException("Default backends can't be registered again.");
|
||||
|
||||
if (CUSTOM_BACKENDS.Contains(backend))
|
||||
|
||||
@ -13,7 +13,7 @@ public class CpuBackend : IBackend
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
public int Priority => 0;
|
||||
public int Priority { get; set; } = 0;
|
||||
|
||||
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
|
||||
|
||||
@ -22,7 +22,7 @@ public partial class CudaBackend : IBackend
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
public int Priority => 10;
|
||||
public int Priority { get; set; } = 10;
|
||||
|
||||
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
|
||||
@ -6,7 +6,7 @@ namespace StableDiffusion.NET;
|
||||
public interface IBackend
|
||||
{
|
||||
bool IsEnabled { get; set; }
|
||||
public int Priority { get; }
|
||||
public int Priority { get; set; }
|
||||
bool IsAvailable { get; }
|
||||
string PathPart { get; }
|
||||
}
|
||||
@ -12,7 +12,7 @@ public partial class RocmBackend : IBackend
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
public int Priority => 10;
|
||||
public int Priority { get; set; } = 10;
|
||||
|
||||
public bool IsAvailable => ((RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||
&& RocmVersion is 5)
|
||||
|
||||
@ -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 => 5;
|
||||
public int Priority { get; set; } = 5;
|
||||
|
||||
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
|
||||
29
StableDiffusion.NET/Backends/VulkanBackend.cs
Normal file
29
StableDiffusion.NET/Backends/VulkanBackend.cs
Normal file
@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user