Skip to content

Commit c8adea3

Browse files
committed
fix: ios cmake error
1 parent e26cfae commit c8adea3

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

composeApp/src/iosSimulatorArm64Main/kotlin/org/onion/diffusion/native/DiffusionLoader.iosSimulatorArm64.kt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ actual class DiffusionLoader actual constructor() {
117117
genParams.height = height
118118
genParams.seed = seed
119119
genParams.batch_count = 1
120-
120+
121121
// LoRA Handling
122122
val loraCStrs = mutableListOf<CValues<ByteVar>>()
123123
if (loraPaths != null && loraStrengths != null && loraPaths.isNotEmpty()) {
@@ -141,7 +141,7 @@ actual class DiffusionLoader actual constructor() {
141141
return null
142142
}
143143

144-
// data mapped to uint8_t* in C, which is usually UByteVar in Kotlin/Native
144+
// ... (rest is unchanged)
145145
val pngData = encodeImageToPng(
146146
image.data!!.reinterpret(), image.width.toInt(), image.height.toInt(), image.channel.toInt()
147147
)
@@ -161,7 +161,9 @@ actual class DiffusionLoader actual constructor() {
161161
steps: Int,
162162
cfg: Float,
163163
seed: Long,
164-
sampleMethod: Int
164+
sampleMethod: Int,
165+
loraPaths: Array<String>?,
166+
loraStrengths: FloatArray?
165167
): List<ByteArray>? {
166168
val sdCtx = ctx ?: return null
167169

@@ -176,6 +178,21 @@ actual class DiffusionLoader actual constructor() {
176178
genParams.video_frames = videoFrames
177179
genParams.seed = seed
178180

181+
// LoRA Handling
182+
val loraCStrs = mutableListOf<CValues<ByteVar>>()
183+
if (loraPaths != null && loraStrengths != null && loraPaths.isNotEmpty()) {
184+
val count = loraPaths.size
185+
val loras = allocArray<sd_lora_t>(count)
186+
for (i in 0 until count) {
187+
val cstr = loraPaths[i].cstr
188+
loraCStrs.add(cstr)
189+
loras[i].path = cstr.ptr
190+
loras[i].multiplier = loraStrengths[i]
191+
}
192+
genParams.loras = loras
193+
genParams.lora_count = count.toUInt()
194+
}
195+
179196
// 初始化内嵌的采样参数
180197
sd_sample_params_init(genParams.sample_params.ptr)
181198
if (steps > 0) genParams.sample_params.sample_steps = steps

0 commit comments

Comments
 (0)