Skip to content

Commit 152dd65

Browse files
Add Availability Annotations (#18)
1 parent a4238a3 commit 152dd65

15 files changed

+26
-4
lines changed

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import PackageDescription
66
let package = Package(
77
name: "stable-diffusion",
88
platforms: [
9-
.macOS(.v13),
10-
.iOS(.v16),
11-
],
9+
.macOS(.v11),
10+
.iOS(.v14),
11+
],
1212
products: [
1313
.library(
1414
name: "StableDiffusion",

swift/StableDiffusion/pipeline/Decoder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import CoreML
66
import Accelerate
77

88
/// A decoder model which produces RGB images from latent samples
9+
@available(iOS 16.2, macOS 13.1, *)
910
public struct Decoder: ResourceManaging {
1011

1112
/// VAE decoder model

swift/StableDiffusion/pipeline/ManagedMLModel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import CoreML
77
///
88
/// It will automatically load a model into memory when needed or requested
99
/// It allows one to request to unload the model from memory
10+
@available(iOS 16.2, macOS 13.1, *)
1011
public final class ManagedMLModel: ResourceManaging {
1112

1213
/// The location of the model

swift/StableDiffusion/pipeline/Random.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import CoreML
99
/// This implementation matches:
1010
/// [NumPy's older randomkit.c](https://github.com/numpy/numpy/blob/v1.0/numpy/random/mtrand/randomkit.c)
1111
///
12+
@available(iOS 16.2, macOS 13.1, *)
1213
struct NumPyRandomSource: RandomNumberGenerator {
1314

1415
struct State {

swift/StableDiffusion/pipeline/SafetyChecker.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import CoreML
66
import Accelerate
77

88
/// Image safety checking model
9+
@available(iOS 16.2, macOS 13.1, *)
910
public struct SafetyChecker: ResourceManaging {
1011

1112
/// Safety checking Core ML model

swift/StableDiffusion/pipeline/SampleTimer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Foundation
1818
/// print(String(format: "mean: %.2f, var: %.2f",
1919
/// timer.mean, timer.variance))
2020
/// ```
21+
@available(iOS 16.2, macOS 13.1, *)
2122
public final class SampleTimer: Codable {
2223
var startTime: CFAbsoluteTime?
2324
var sum: Double = 0.0

swift/StableDiffusion/pipeline/Scheduler.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import CoreML
99
/// [Hugging Face Diffusers PNDMScheduler](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_pndm.py)
1010
///
1111
/// It uses the pseudo linear multi-step (PLMS) method only, skipping pseudo Runge-Kutta (PRK) steps
12+
@available(iOS 16.2, macOS 13.1, *)
1213
public final class Scheduler {
1314
/// Number of diffusion steps performed during training
1415
public let trainStepCount: Int
@@ -224,6 +225,7 @@ public final class Scheduler {
224225
}
225226
}
226227

228+
@available(iOS 16.2, macOS 13.1, *)
227229
extension Scheduler {
228230
/// How to map a beta range to a sequence of betas to step over
229231
public enum BetaSchedule {

swift/StableDiffusion/pipeline/StableDiffusionPipeline+Resources.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import Foundation
55
import CoreML
66

7+
@available(iOS 16.2, macOS 13.1, *)
78
public extension StableDiffusionPipeline {
89

910
struct ResourceURLs {

swift/StableDiffusion/pipeline/StableDiffusionPipeline.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import CoreGraphics
1010
///
1111
/// This implementation matches:
1212
/// [Hugging Face Diffusers Pipeline](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py)
13+
@available(iOS 16.2, macOS 13.1, *)
1314
public struct StableDiffusionPipeline: ResourceManaging {
1415

1516
/// Model to generate embeddings for tokenized input text
@@ -271,6 +272,7 @@ public struct StableDiffusionPipeline: ResourceManaging {
271272

272273
}
273274

275+
@available(iOS 16.2, macOS 13.1, *)
274276
extension StableDiffusionPipeline {
275277
/// Sampling progress details
276278
public struct Progress {

swift/StableDiffusion/pipeline/TextEncoder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Foundation
55
import CoreML
66

77
/// A model for encoding text
8+
@available(iOS 16.2, macOS 13.1, *)
89
public struct TextEncoder: ResourceManaging {
910

1011
/// Text tokenizer

0 commit comments

Comments
 (0)