Skip to content

Commit

Permalink
[examples] Add optimizations and mimalloc to LLaMA example.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghb97 committed Oct 31, 2023
1 parent 719e7de commit 3f1ccf5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 13 additions & 1 deletion examples/BuddyLlama/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ add_custom_command(
-eliminate-empty-tensors
-empty-tensor-to-alloc-tensor
-linalg-bufferize
-matmul-paralell-vectorization-optimize
-batchmatmul-optimize
-convert-linalg-to-affine-loops
-affine-loop-fusion
-affine-parallelize
Expand Down Expand Up @@ -61,4 +63,14 @@ SET_TARGET_PROPERTIES(

add_executable(buddy-llama-run llama-main.cpp)
target_link_directories(buddy-llama-run PRIVATE ${LLVM_MLIR_LIBRARY_DIR})
target_link_libraries(buddy-llama-run LLAMA mlir_c_runner_utils omp)

set(BUDDY_LLAMA_LIBS
LLAMA
mlir_c_runner_utils
omp
)
if(BUDDY_MLIR_USE_MIMALLOC)
list(APPEND BUDDY_LLAMA_LIBS mimalloc)
endif()

target_link_libraries(buddy-llama-run ${BUDDY_LLAMA_LIBS})
3 changes: 3 additions & 0 deletions examples/BuddyLlama/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ $ cd bin
$ ./buddy-llama-run
```
This build will spend a few minutes. We recommend you to use better cpu such as server-level cpu to run buddy-llama-run.

If you wish to utilize `mimalloc` as a memory allocator, you need to set `BUDDY_MLIR_USE_MIMALLOC` and `MIMALLOC_BUILD_DIR`.
For more details, please see [here](../../thirdparty/README.md#the-mimalloc-allocator).

0 comments on commit 3f1ccf5

Please sign in to comment.