v2: add EmbeddingKernels to Metal compilation pipeline
This commit is contained in:
@@ -109,6 +109,21 @@ public enum MetalKernels {
|
||||
.replacingOccurrences(of: "using namespace metal;\n", with: "")
|
||||
result += "\n" + fusedStripped
|
||||
|
||||
// Strip preamble from embedding kernels source
|
||||
let embStripped = embeddingKernelsSource
|
||||
.replacingOccurrences(of: "#include <metal_stdlib>\n", with: "")
|
||||
.replacingOccurrences(of: "using namespace metal;\n", with: "")
|
||||
result += "\n" + embStripped
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/// Embedding kernel source for EmbeddingGemma.
|
||||
/// Includes RoPE, bidirectional sliding window attention, Q/K norm, and GELU.
|
||||
public static var embeddingKernelsSource: String {
|
||||
let url = URL(fileURLWithPath: #filePath)
|
||||
.deletingLastPathComponent()
|
||||
.appendingPathComponent("Metal/EmbeddingKernels.metal")
|
||||
return try! String(contentsOf: url, encoding: .utf8)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user