aih1013 commited on
Commit
1fe6df0
·
unverified ·
1 Parent(s): 84c1cc7

cmake : build with any BLAS compatible library (#927)

Browse files

* Build with any BLAS library

* ci: Removed explicit CUDA nvcc path

Files changed (2) hide show
  1. .gitignore +46 -46
  2. CMakeLists.txt +23 -11
.gitignore CHANGED
@@ -1,46 +1,46 @@
1
- *.o
2
- *.a
3
- .cache/
4
- .coreml/
5
- .test/
6
- .vs/
7
- .vscode/
8
- .DS_Store
9
-
10
- build/
11
- build-em/
12
- build-debug/
13
- build-release/
14
- build-static/
15
- build-cublas/
16
- build-no-accel/
17
- build-sanitize-addr/
18
- build-sanitize-thread/
19
-
20
- /main
21
- /stream
22
- /command
23
- /talk
24
- /talk-llama
25
- /bench
26
- /quantize
27
-
28
- arm_neon.h
29
- sync.sh
30
- libwhisper.a
31
- libwhisper.so
32
- compile_commands.json
33
-
34
- examples/arm_neon.h
35
- examples/whisper.objc/whisper.objc.xcodeproj/xcshareddata
36
- examples/whisper.objc/whisper.objc.xcodeproj/xcuserdata/
37
- examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/xcuserdata
38
-
39
- extra/bench-gg.txt
40
-
41
- models/*.mlmodel
42
- models/*.mlmodelc
43
- models/*.mlpackage
44
- bindings/java/.gradle/
45
- bindings/java/.idea/
46
- .idea/
 
1
+ *.o
2
+ *.a
3
+ .cache/
4
+ .coreml/
5
+ .test/
6
+ .vs/
7
+ .vscode/
8
+ .DS_Store
9
+
10
+ build/
11
+ build-em/
12
+ build-debug/
13
+ build-release/
14
+ build-static/
15
+ build-cublas/
16
+ build-no-accel/
17
+ build-sanitize-addr/
18
+ build-sanitize-thread/
19
+
20
+ /main
21
+ /stream
22
+ /command
23
+ /talk
24
+ /talk-llama
25
+ /bench
26
+ /quantize
27
+
28
+ arm_neon.h
29
+ sync.sh
30
+ libwhisper.a
31
+ libwhisper.so
32
+ compile_commands.json
33
+
34
+ examples/arm_neon.h
35
+ examples/whisper.objc/whisper.objc.xcodeproj/xcshareddata
36
+ examples/whisper.objc/whisper.objc.xcodeproj/xcuserdata/
37
+ examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/xcuserdata
38
+
39
+ extra/bench-gg.txt
40
+
41
+ models/*.mlmodel
42
+ models/*.mlmodelc
43
+ models/*.mlpackage
44
+ bindings/java/.gradle/
45
+ bindings/java/.idea/
46
+ .idea/
CMakeLists.txt CHANGED
@@ -59,9 +59,11 @@ if (APPLE)
59
  option(WHISPER_COREML "whisper: enable Core ML framework" OFF)
60
  option(WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback" OFF)
61
  else()
62
- option(WHISPER_OPENBLAS "whisper: support for OpenBLAS" OFF)
63
- option(WHISPER_CUBLAS "whisper: support for cuBLAS" OFF)
64
- option(WHISPER_CLBLAST "whisper: use CLBlast" OFF)
 
 
65
  endif()
66
 
67
  option(WHISPER_PERF "whisper: enable perf timings" OFF)
@@ -127,18 +129,28 @@ if (APPLE)
127
  endif()
128
 
129
  if (WHISPER_OPENBLAS)
130
- find_library(OPENBLAS_LIB
131
- NAMES openblas libopenblas
132
- )
133
- if (OPENBLAS_LIB)
134
- message(STATUS "OpenBLAS found")
 
 
 
 
 
135
 
136
- set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${OPENBLAS_LIB})
 
 
137
  set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS)
 
 
 
138
  else()
139
- message(WARNING "OpenBLAS not found")
140
  endif()
141
- endif()
142
 
143
  if (WHISPER_CUBLAS)
144
  cmake_minimum_required(VERSION 3.17)
 
59
  option(WHISPER_COREML "whisper: enable Core ML framework" OFF)
60
  option(WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback" OFF)
61
  else()
62
+ option(WHISPER_BLAS "whisper: use BLAS libraries" OFF)
63
+ option(WHISPER_BLAS_VENDOR "whisper: BLAS library vendor" Generic)
64
+ option(WHISPER_OPENBLAS "whisper: prefer OpenBLAS" OFF)
65
+ option(WHISPER_CUBLAS "whisper: support for cuBLAS" OFF)
66
+ option(WHISPER_CLBLAST "whisper: use CLBlast" OFF)
67
  endif()
68
 
69
  option(WHISPER_PERF "whisper: enable perf timings" OFF)
 
129
  endif()
130
 
131
  if (WHISPER_OPENBLAS)
132
+ set(WHISPER_BLAS_VENDOR "OpenBLAS")
133
+ set(WHISPER_BLAS ON)
134
+ endif()
135
+
136
+ if (WHISPER_BLAS)
137
+ set(BLA_STATIC 1)
138
+ set(BLA_VENDOR ${WHISPER_BLAS_VENDOR})
139
+ # set(BLA_PREFER_PKGCONFIG 1)
140
+ set(BLA_SIZEOF_INTEGER 8)
141
+ find_package(BLAS)
142
 
143
+ if(BLAS_FOUND)
144
+ message(STATUS "BLAS compatible library found")
145
+ message(STATUS "Libraries ${BLAS_LIBRARIES}")
146
  set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS)
147
+
148
+ include_directories(${BLAS_INCLUDE_DIRS})
149
+ set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${BLAS_LIBRARIES})
150
  else()
151
+ message(WARNING "BLAS library was not found")
152
  endif()
153
+ endif ()
154
 
155
  if (WHISPER_CUBLAS)
156
  cmake_minimum_required(VERSION 3.17)