Skip to content

Commit 9210c7e

Browse files
author
aharakal
committed
Fix compile error
1 parent e2169ab commit 9210c7e

3 files changed

Lines changed: 19 additions & 55 deletions

File tree

skainet-apps/skainet-grayscale-cli/src/main/kotlin/sk/ainet/apps/grayscale/ExecutionContextManager.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,7 @@ public class ExecutionContextManager {
3131
verbose = verbose
3232
)
3333

34-
// If there are critical errors and GPU is required, throw an error
35-
if (!validationResult.success && preferGpu) {
36-
val firstError = validationResult.errors.first()
37-
throw firstError
38-
}
39-
40-
// Detect GPU capabilities
34+
// Detect GPU capabilities (validation errors will be used for fallback decisions)
4135
val gpuCapabilities = detectGpuCapabilities(validationResult)
4236

4337
if (verbose) {
@@ -73,11 +67,12 @@ public class ExecutionContextManager {
7367
val validation = validationResult ?: dependencyValidator.validateAllDependencies(requireGpu = false)
7468

7569
return try {
76-
// Use validation results to determine GPU capabilities
77-
val cudaAvailable = !validation.errors.any { error ->
78-
error is GrayscaleCliError.SystemError.MissingDependency &&
70+
// Use both validation errors and actual CUDA detection to determine GPU capabilities
71+
val hasCudaError = validation.errors.any { error ->
72+
error is GrayscaleCliError.SystemError.MissingDependency &&
7973
error.dependency.contains("CUDA", ignoreCase = true)
8074
}
75+
val cudaAvailable = !hasCudaError && detectCudaAvailability()
8176

8277
val memoryMB = if (cudaAvailable) estimateGpuMemory() else 0L
8378
val computeCapability = if (cudaAvailable) detectComputeCapability() else "N/A"

skainet-apps/skainet-grayscale-cli/src/test/kotlin/sk/ainet/apps/grayscale/ImageLoaderTest.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public class ImageLoaderTest {
6565
public fun loadImage_nonExistentFile_throwsException() {
6666
val nonExistentPath = File(tempDir, "nonexistent.jpg").absolutePath
6767

68-
val exception = assertFailsWith<ImageLoadException> {
68+
val exception = assertFailsWith<GrayscaleCliError.ImageLoadError.FileNotFound> {
6969
imageLoader.loadImage(nonExistentPath)
7070
}
71-
72-
assertTrue(exception.message!!.contains("does not exist"))
71+
72+
assertTrue(exception.message!!.contains("not found"))
7373
}
7474

7575
@Test
@@ -78,20 +78,20 @@ public class ImageLoaderTest {
7878
val textFile = File(tempDir, "test.txt")
7979
textFile.writeText("not an image")
8080

81-
val exception = assertFailsWith<ImageLoadException> {
81+
val exception = assertFailsWith<GrayscaleCliError.ImageLoadError.UnsupportedFormat> {
8282
imageLoader.loadImage(textFile.absolutePath)
8383
}
84-
84+
8585
assertTrue(exception.message!!.contains("Unsupported image format"))
8686
}
8787

8888
@Test
8989
public fun loadImage_directoryPath_throwsException() {
90-
val exception = assertFailsWith<ImageLoadException> {
90+
val exception = assertFailsWith<GrayscaleCliError.ImageLoadError.FileNotFound> {
9191
imageLoader.loadImage(tempDir.absolutePath)
9292
}
93-
94-
assertTrue(exception.message!!.contains("not a file"))
93+
94+
assertTrue(exception.message!!.contains("not found"))
9595
}
9696

9797
@Test
@@ -153,11 +153,11 @@ public class ImageLoaderTest {
153153
public fun loadImagesFromDirectory_nonExistentDirectory_throwsException() {
154154
val nonExistentDir = File(tempDir, "nonexistent").absolutePath
155155

156-
val exception = assertFailsWith<ImageLoadException> {
156+
val exception = assertFailsWith<GrayscaleCliError.ImageLoadError.DirectoryNotFound> {
157157
imageLoader.loadImagesFromDirectory(nonExistentDir)
158158
}
159-
160-
assertTrue(exception.message!!.contains("does not exist"))
159+
160+
assertTrue(exception.message!!.contains("not found"))
161161
}
162162

163163
@Test
@@ -166,11 +166,11 @@ public class ImageLoaderTest {
166166
val file = File(tempDir, "notadirectory.txt")
167167
file.writeText("test")
168168

169-
val exception = assertFailsWith<ImageLoadException> {
169+
val exception = assertFailsWith<GrayscaleCliError.ImageLoadError.DirectoryNotFound> {
170170
imageLoader.loadImagesFromDirectory(file.absolutePath)
171171
}
172-
173-
assertTrue(exception.message!!.contains("not a directory"))
172+
173+
assertTrue(exception.message!!.contains("not found"))
174174
}
175175

176176
@Test

skainet-compile/skainet-compile-hlo/src/jvmMain/kotlin/sk/ainet/compile/hlo/generate/ModelRegistry.kt

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package sk.ainet.compile.hlo.generate
22

3-
import sk.ainet.apps.kwhisper.WhisperModelMetadata
4-
import sk.ainet.apps.kwhisper.dsl.WhisperEncoderHloModel
53
import sk.ainet.context.ExecutionContext
64
import sk.ainet.lang.model.Model
75
import sk.ainet.lang.tensor.Shape
@@ -66,35 +64,6 @@ internal object ModelRegistry {
6664
}
6765
))
6866

69-
// Whisper-tiny.en encoder: mel spectrogram → encoder hidden states
70-
put("whisper-encoder", ModelDescriptor(
71-
name = "whisper-encoder",
72-
description = "Whisper-tiny.en encoder (FP32, 4 layers, 384-dim)",
73-
functionName = "whisper_encoder",
74-
createModelAndInput = { ctx, height, width, batch ->
75-
val metadata = WhisperModelMetadata(
76-
nMels = 80,
77-
nAudioCtx = 1500,
78-
nAudioState = 384,
79-
nAudioHead = 6,
80-
nAudioLayer = 4,
81-
nVocab = 51864,
82-
nTextCtx = 448,
83-
nTextState = 384,
84-
nTextHead = 6,
85-
nTextLayer = 4
86-
)
87-
val model = WhisperEncoderHloModel(metadata)
88-
// Mel spectrogram input: [nMels, nFrames] where nFrames = 3000 for 30s audio
89-
val nFrames = 3000
90-
val input = ctx.fromFloatArray<FP32, Float>(
91-
shape = Shape(metadata.nMels, nFrames),
92-
dtype = FP32::class,
93-
data = FloatArray(metadata.nMels * nFrames) { 0.0f }
94-
)
95-
ModelAndInput(model, input)
96-
}
97-
))
9867
}
9968

10069
fun get(name: String): ModelDescriptor? = models[name]

0 commit comments

Comments
 (0)