mirror of
https://github.com/GayPizzaSpecifications/stable-diffusion-rpc.git
synced 2025-08-04 14:01:32 +00:00
Document API, make the implementation match the API, and update the same.
This commit is contained in:
26
Sources/StableDiffusionProtos/Utilities.swift
Normal file
26
Sources/StableDiffusionProtos/Utilities.swift
Normal file
@ -0,0 +1,26 @@
|
||||
import CoreML
|
||||
import Foundation
|
||||
|
||||
public extension SdComputeUnits {
|
||||
func toMlComputeUnits() -> MLComputeUnits {
|
||||
switch self {
|
||||
case .all: return .all
|
||||
case .cpu: return .cpuOnly
|
||||
case .cpuAndGpu: return .cpuAndGPU
|
||||
case .cpuAndNeuralEngine: return .cpuAndNeuralEngine
|
||||
default: return .all
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension MLComputeUnits {
|
||||
func toSdComputeUnits() -> SdComputeUnits {
|
||||
switch self {
|
||||
case .all: return .all
|
||||
case .cpuOnly: return .cpu
|
||||
case .cpuAndGPU: return .cpuAndGpu
|
||||
case .cpuAndNeuralEngine: return .cpuAndNeuralEngine
|
||||
default: return .all
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user