Skip to content

Commit

Permalink
Merge pull request #40 from hiventive/master
Browse files Browse the repository at this point in the history
support cublas build type
  • Loading branch information
mudler authored Jul 14, 2023
2 parents 3fec197 + 6bd18b8 commit ffb09d7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
INCLUDE_PATH := $(abspath ./)
LIBRARY_PATH := $(abspath ./)
CMAKEFLAGS=${TRANSFORMERS_CMAKEFLAGS}
CMAKE_ARGS=${TRANSFORMERS_CMAKE_ARGS}
EXTRA_OBJS =

ifndef UNAME_S
UNAME_S := $(shell uname -s)
Expand Down Expand Up @@ -122,6 +123,11 @@ ifneq ($(filter armv8%,$(UNAME_M)),)
CFLAGS += -mfp16-format=ieee -mno-unaligned-access
endif

ifeq ($(BUILD_TYPE),cublas)
CMAKE_ARGS += -DGGML_CUBLAS=ON
EXTRA_OBJS += ggml-cuda.o
endif

#
# Print build information
#
Expand All @@ -133,15 +139,18 @@ $(info I UNAME_M: $(UNAME_M))
$(info I CFLAGS: $(CFLAGS))
$(info I CXXFLAGS: $(CXXFLAGS))
$(info I LDFLAGS: $(LDFLAGS))
$(info I CMAKEFLAGS: $(CMAKEFLAGS))
$(info I CMAKE_ARGS: $(CMAKE_ARGS))
$(info I CC: $(CCV))
$(info I CXX: $(CXXV))
$(info )


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

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

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
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
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}

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

0 comments on commit ffb09d7

Please sign in to comment.