Skip to content

Commit 3ccfe0c

Browse files
committed
llama.cpp integration
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
1 parent 2feb804 commit 3ccfe0c

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@
4646
[submodule "backends/arm/third-party/ethos-u-core-driver"]
4747
path = backends/arm/third-party/ethos-u-core-driver
4848
url = https://git.mlplatform.org/ml/ethos-u/ethos-u-core-driver.git
49+
[submodule "examples/third-party/llama_cpp"]
50+
path = examples/third-party/llama_cpp
51+
url = https://github.com/ggerganov/llama.cpp.git

examples/llama_cpp/CMakeLists.txt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
#
8+
# Simple CMake build system for selective build demo.
9+
#
10+
# ### Editing this file ###
11+
#
12+
# This file should be formatted with
13+
# ~~~
14+
# cmake-format --first-comment-is-literal=True CMakeLists.txt
15+
# ~~~
16+
# It should also be cmake-lint clean.
17+
#
18+
19+
cmake_minimum_required(VERSION 3.19)
20+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
21+
set(TORCH_ROOT ${EXECUTORCH_ROOT}/third-party/pytorch)
22+
include(${EXECUTORCH_ROOT}/build/Utils.cmake)
23+
include(${EXECUTORCH_ROOT}/build/Codegen.cmake)
24+
25+
#
26+
# select_build_lib: C++ library to register selected ops in custom kernel
27+
# library
28+
#
29+
set(_kernel_lib)
30+
if(EXECUTORCH_SELECT_OPS_YAML)
31+
set(_custom_ops_yaml
32+
${EXECUTORCH_ROOT}/examples/portable/custom_ops/custom_ops.yaml)
33+
gen_selected_ops("${_custom_ops_yaml}" "" "")
34+
set(kernel_sources
35+
${EXECUTORCH_ROOT}/examples/portable/custom_ops/custom_ops_1_out.cpp
36+
${EXECUTORCH_ROOT}/examples/portable/custom_ops/custom_ops_2_out.cpp)
37+
#
38+
# custom_kernels: C++ kernel implementations of custom ops
39+
#
40+
add_library(custom_kernels ${kernel_sources})
41+
target_link_libraries(custom_kernels PRIVATE executorch)
42+
target_compile_options(custom_kernels PUBLIC ${_common_compile_options})
43+
44+
list(APPEND _kernel_lib custom_kernels)
45+
else()
46+
list(APPEND _kernel_lib portable_kernels)
47+
endif()
48+
49+
gen_selected_ops(
50+
"${_custom_ops_yaml}"
51+
"${EXECUTORCH_SELECT_OPS_LIST}"
52+
"${EXECUTORCH_SELECT_ALL_OPS}")
53+
54+
generate_bindings_for_kernels(${EXECUTORCH_ROOT}/kernels/portable/functions.yaml
55+
"${_custom_ops_yaml}")
56+
gen_operators_lib("select_build_lib" ${_kernel_lib} executorch)
57+
58+
set(_updated__srcs)
59+
foreach(_src ${_executor_runner__srcs})
60+
list(APPEND _updated__srcs "${EXECUTORCH_ROOT}/${_src}")
61+
endforeach()
62+
63+
#
64+
# selective_build_test: test binary to allow different operator libraries to
65+
# link to
66+
#
67+
add_executable(selective_build_test ${_updated__srcs})
68+
if(CMAKE_BUILD_TYPE EQUAL "RELEASE")
69+
target_link_options(selective_build_test PRIVATE "LINKER:--gc-sections")
70+
endif()
71+
target_link_libraries(selective_build_test executorch gflags select_build_lib)
72+
target_compile_options(selective_build_test PUBLIC ${_common_compile_options})
73+
74+
# Print all summary
75+
executorch_print_configuration_summary()

examples/third-party/llama_cpp

Submodule llama_cpp added at f3b25e4

0 commit comments

Comments
 (0)