Skip to content

Commit ffb09d7

Browse files
authored
Merge pull request #40 from hiventive/master
support cublas build type
2 parents 3fec197 + 6bd18b8 commit ffb09d7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
INCLUDE_PATH := $(abspath ./)
22
LIBRARY_PATH := $(abspath ./)
3-
CMAKEFLAGS=${TRANSFORMERS_CMAKEFLAGS}
3+
CMAKE_ARGS=${TRANSFORMERS_CMAKE_ARGS}
4+
EXTRA_OBJS =
45

56
ifndef UNAME_S
67
UNAME_S := $(shell uname -s)
@@ -122,6 +123,11 @@ ifneq ($(filter armv8%,$(UNAME_M)),)
122123
CFLAGS += -mfp16-format=ieee -mno-unaligned-access
123124
endif
124125

126+
ifeq ($(BUILD_TYPE),cublas)
127+
CMAKE_ARGS += -DGGML_CUBLAS=ON
128+
EXTRA_OBJS += ggml-cuda.o
129+
endif
130+
125131
#
126132
# Print build information
127133
#
@@ -133,15 +139,18 @@ $(info I UNAME_M: $(UNAME_M))
133139
$(info I CFLAGS: $(CFLAGS))
134140
$(info I CXXFLAGS: $(CXXFLAGS))
135141
$(info I LDFLAGS: $(LDFLAGS))
136-
$(info I CMAKEFLAGS: $(CMAKEFLAGS))
142+
$(info I CMAKE_ARGS: $(CMAKE_ARGS))
137143
$(info I CC: $(CCV))
138144
$(info I CXX: $(CXXV))
139145
$(info )
140146

141147

142148
ggml.o:
143149
mkdir build
144-
cd build && cmake ../ggml.cpp $(CMAKEFLAGS) && make VERBOSE=1 ggml && cp -rf src/CMakeFiles/ggml.dir/ggml.c.o ../ggml.o
150+
cd build && cmake ../ggml.cpp $(CMAKE_ARGS) && make VERBOSE=1 ggml && cp -rf src/CMakeFiles/ggml.dir/ggml.c.o ../ggml.o
151+
@if [ "$(BUILD_TYPE)" = "cublas" ]; then \
152+
cp -rf build/src/CMakeFiles/ggml.dir/ggml-cuda.cu.o ggml-cuda.o ;\
153+
fi
145154

146155
generic-ggml.o:
147156
$(CC) $(CFLAGS) -c ggml.cpp/src/ggml.c -o ggml.o
@@ -194,7 +203,7 @@ prepare:
194203
@find ./ggml.cpp/examples/starcoder -type f -name "*.cpp" -exec sed -i'' -e 's/int main/int main_starcoder/g' {} +
195204

196205
libtransformers.a: prepare starcoder.o falcon.o gptj.o mpt.o gpt2.o replit.o gptneox.o ggml.o dolly.o common-ggml.o common.o
197-
ar src libtransformers.a replit.o gptj.o mpt.o gptneox.o starcoder.o gpt2.o dolly.o falcon.o ggml.o common-ggml.o common.o
206+
ar src libtransformers.a replit.o gptj.o mpt.o gptneox.o starcoder.o gpt2.o dolly.o falcon.o ggml.o common-ggml.o common.o ${EXTRA_OBJS}
198207

199208
example:
200209
@C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} go build -o example -x ./examples

0 commit comments

Comments
 (0)