]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
cmake : build with any BLAS compatible library (#927)
authorAlexey Kharlamov <redacted>
Sat, 20 May 2023 18:23:45 +0000 (19:23 +0100)
committerGitHub <redacted>
Sat, 20 May 2023 18:23:45 +0000 (21:23 +0300)
* Build with any BLAS library

* ci: Removed explicit CUDA nvcc path

.gitignore
CMakeLists.txt

index 503a47358af9c43c94d7c32d67b63b2384751546..d24995590688a6c34b447719451094eceaa36cfa 100644 (file)
@@ -1,46 +1,46 @@
-*.o\r
-*.a\r
-.cache/\r
-.coreml/\r
-.test/\r
-.vs/\r
-.vscode/\r
-.DS_Store\r
-\r
-build/\r
-build-em/\r
-build-debug/\r
-build-release/\r
-build-static/\r
-build-cublas/\r
-build-no-accel/\r
-build-sanitize-addr/\r
-build-sanitize-thread/\r
-\r
-/main\r
-/stream\r
-/command\r
-/talk\r
-/talk-llama\r
-/bench\r
-/quantize\r
-\r
-arm_neon.h\r
-sync.sh\r
-libwhisper.a\r
-libwhisper.so\r
-compile_commands.json\r
-\r
-examples/arm_neon.h\r
-examples/whisper.objc/whisper.objc.xcodeproj/xcshareddata\r
-examples/whisper.objc/whisper.objc.xcodeproj/xcuserdata/\r
-examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/xcuserdata\r
-\r
-extra/bench-gg.txt\r
-\r
-models/*.mlmodel\r
-models/*.mlmodelc\r
-models/*.mlpackage\r
-bindings/java/.gradle/\r
-bindings/java/.idea/\r
-.idea/\r
+*.o
+*.a
+.cache/
+.coreml/
+.test/
+.vs/
+.vscode/
+.DS_Store
+
+build/
+build-em/
+build-debug/
+build-release/
+build-static/
+build-cublas/
+build-no-accel/
+build-sanitize-addr/
+build-sanitize-thread/
+
+/main
+/stream
+/command
+/talk
+/talk-llama
+/bench
+/quantize
+
+arm_neon.h
+sync.sh
+libwhisper.a
+libwhisper.so
+compile_commands.json
+
+examples/arm_neon.h
+examples/whisper.objc/whisper.objc.xcodeproj/xcshareddata
+examples/whisper.objc/whisper.objc.xcodeproj/xcuserdata/
+examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/xcuserdata
+
+extra/bench-gg.txt
+
+models/*.mlmodel
+models/*.mlmodelc
+models/*.mlpackage
+bindings/java/.gradle/
+bindings/java/.idea/
+.idea/
index 92b5d0c3f8d1645a43a5f37e3fab1cae9d67c13f..60eb027641e3bf0f68eb463d74f0f069a087f968 100644 (file)
@@ -59,9 +59,11 @@ if (APPLE)
     option(WHISPER_COREML                "whisper: enable Core ML framework"     OFF)
     option(WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback"    OFF)
 else()
-    option(WHISPER_OPENBLAS              "whisper: support for OpenBLAS" OFF)
-    option(WHISPER_CUBLAS                "whisper: support for cuBLAS"   OFF)
-    option(WHISPER_CLBLAST               "whisper: use CLBlast"          OFF)
+    option(WHISPER_BLAS                  "whisper: use BLAS libraries"  OFF)
+    option(WHISPER_BLAS_VENDOR           "whisper: BLAS library vendor" Generic)
+    option(WHISPER_OPENBLAS              "whisper: prefer OpenBLAS"     OFF)
+    option(WHISPER_CUBLAS                "whisper: support for cuBLAS"  OFF)
+    option(WHISPER_CLBLAST               "whisper: use CLBlast"         OFF)
 endif()
 
 option(WHISPER_PERF "whisper: enable perf timings" OFF)
@@ -127,18 +129,28 @@ if (APPLE)
 endif()
 
 if (WHISPER_OPENBLAS)
-    find_library(OPENBLAS_LIB
-        NAMES openblas libopenblas
-        )
-    if (OPENBLAS_LIB)
-        message(STATUS "OpenBLAS found")
+    set(WHISPER_BLAS_VENDOR "OpenBLAS")
+    set(WHISPER_BLAS ON)
+endif()
+
+if (WHISPER_BLAS)
+    set(BLA_STATIC 1)
+    set(BLA_VENDOR ${WHISPER_BLAS_VENDOR})
+#    set(BLA_PREFER_PKGCONFIG 1)
+    set(BLA_SIZEOF_INTEGER 8)
+    find_package(BLAS)
 
-        set(WHISPER_EXTRA_LIBS  ${WHISPER_EXTRA_LIBS}  ${OPENBLAS_LIB})
+    if(BLAS_FOUND)
+        message(STATUS "BLAS compatible library found")
+        message(STATUS "Libraries ${BLAS_LIBRARIES}")
         set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS)
+
+        include_directories(${BLAS_INCLUDE_DIRS})
+        set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${BLAS_LIBRARIES})
     else()
-        message(WARNING "OpenBLAS not found")
+        message(WARNING "BLAS library was not found")
     endif()
-endif()
+endif ()
 
 if (WHISPER_CUBLAS)
     cmake_minimum_required(VERSION 3.17)