Spaces:
Running
Running
File size: 13,833 Bytes
5f923cd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | # Copyright 2026 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(PKG_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(constrained_decoding)
add_subdirectory(embedding_lookup)
add_subdirectory(preprocessor)
add_subdirectory(tool_use)
# ==============================================================================
# 1. Tokenizer Interface
# ==============================================================================
add_litertlm_library(runtime_components_tokenizer INTERFACE)
add_library(LiteRTLM::Runtime::Components::Tokenizer::Interface ALIAS runtime_components_tokenizer)
target_include_directories(runtime_components_tokenizer
INTERFACE
${GENERATED_SRC_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_tokenizer
INTERFACE
runtime_util_convert_tensor_buffer
LITERTLM_DEPS
)
# ==============================================================================
# 2. HuggingFace Tokenizer
# ==============================================================================
add_litertlm_library(runtime_components_huggingface_tokenizer STATIC
huggingface_tokenizer.cc
)
add_library(LiteRTLM::Runtime::Components::Tokenizer::HuggingFace ALIAS runtime_components_huggingface_tokenizer)
target_compile_definitions(runtime_components_huggingface_tokenizer
PUBLIC ENABLE_HUGGINGFACE_TOKENIZER
)
target_include_directories(runtime_components_huggingface_tokenizer
PRIVATE
${GENERATED_SRC_DIR}
${CMAKE_BINARY_DIR}
${LITERT_INCLUDE_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_huggingface_tokenizer
PUBLIC
LiteRTLM::Runtime::Components::Tokenizer::Interface
runtime_util_litert_status_util
runtime_util_memory_mapped_file
LITERTLM_DEPS
)
# ==============================================================================
# 3. SentencePiece Tokenizer
# ==============================================================================
add_litertlm_library(runtime_components_sentencepiece_tokenizer STATIC
sentencepiece_tokenizer.cc
)
add_library(LiteRTLM::Runtime::Components::Tokenizer::SentencePiece ALIAS runtime_components_sentencepiece_tokenizer)
target_compile_definitions(runtime_components_sentencepiece_tokenizer
PUBLIC ENABLE_SENTENCEPIECE_TOKENIZER
)
target_include_directories(runtime_components_sentencepiece_tokenizer
PRIVATE
${GENERATED_SRC_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_sentencepiece_tokenizer
PUBLIC
LiteRTLM::Runtime::Components::Tokenizer::Interface
PRIVATE
LITERTLM_DEPS
)
# ==============================================================================
# 4. Prompt Template
# ==============================================================================
add_litertlm_library(runtime_components_prompt_template STATIC
prompt_template.cc
)
add_library(LiteRTLM::Runtime::Components::PromptTemplate ALIAS runtime_components_prompt_template)
target_include_directories(runtime_components_prompt_template
PRIVATE
${LITERTLM_INCLUDE_PATHS}
${THIRD_PARTY_DIR}/json/include
)
target_link_libraries(runtime_components_prompt_template
PUBLIC
runtime_util_litert_status_util
LITERTLM_DEPS
)
# ==============================================================================
# 5. LoRA
# ==============================================================================
add_litertlm_library(runtime_components_lora STATIC
lora.cc
)
add_library(LiteRTLM::Runtime::Components::LoRA ALIAS runtime_components_lora)
target_include_directories(runtime_components_lora
PRIVATE
${GENERATED_SRC_DIR}
${CMAKE_BINARY_DIR}
${LITERTLM_INCLUDE_PATHS}
${THIRD_PARTY_DIR}/litert/src/litert_external-build/include
)
target_link_libraries(runtime_components_lora
PUBLIC
runtime_util_litert_status_util
runtime_util_lora_data
runtime_util_lora_util
LITERTLM_DEPS
)
# ==============================================================================
# 6. LoRA Manager
# ==============================================================================
add_litertlm_library(runtime_components_lora_manager STATIC
lora_manager.cc
)
add_library(LiteRTLM::Runtime::Components::LoRAManager ALIAS runtime_components_lora_manager)
target_include_directories(runtime_components_lora_manager
PRIVATE
${GENERATED_SRC_DIR}
${CMAKE_BINARY_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_lora_manager
PUBLIC
LiteRTLM::Runtime::Components::LoRA
runtime_util_litert_status_util
runtime_util_lora_data
runtime_executor_executor_settings_base
LITERTLM_DEPS
)
# ==============================================================================
# 7. Model Resources Interface
# ==============================================================================
add_litertlm_library(runtime_components_model_resources INTERFACE)
add_library(LiteRTLM::Runtime::Components::ModelResources::Interface ALIAS runtime_components_model_resources)
target_include_directories(runtime_components_model_resources
INTERFACE
${GENERATED_SRC_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_model_resources
INTERFACE
LiteRTLM::Runtime::Components::Tokenizer::Interface
LITERTLM_DEPS
)
# ==============================================================================
# 8. Model Resources LiteRT LM
# ==============================================================================
add_litertlm_library(runtime_components_model_resources_litert_lm STATIC
model_resources_litert_lm.cc
)
add_library(LiteRTLM::Runtime::Components::ModelResources::LiteRTLM ALIAS runtime_components_model_resources_litert_lm)
target_include_directories(runtime_components_model_resources_litert_lm
PRIVATE
${GENERATED_SRC_DIR}
${CMAKE_BINARY_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_model_resources_litert_lm
PUBLIC
LiteRTLM::Runtime::Components::ModelResources::Interface
runtime_util_litert_lm_loader
runtime_util_litert_status_util
LiteRTLM::Runtime::Components::Tokenizer::HuggingFace
LiteRTLM::Runtime::Components::Tokenizer::SentencePiece
LiteRTLM::Runtime::Components::Tokenizer::Interface
LiteRTLM::Schema::Core
LITERTLM_DEPS
)
# ==============================================================================
# 9. Model Resources Task
# ==============================================================================
add_litertlm_library(runtime_components_model_resources_task STATIC
model_resources_task.cc
)
add_library(LiteRTLM::Runtime::Components::ModelResources::Task ALIAS runtime_components_model_resources_task)
target_include_directories(runtime_components_model_resources_task
PRIVATE
${GENERATED_SRC_DIR}
${CMAKE_BINARY_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_model_resources_task
PUBLIC
LiteRTLM::Runtime::Components::ModelResources::Interface
runtime_util_model_asset_bundle_resources
runtime_util_litert_status_util
runtime_util_metadata_util
LiteRTLM::Runtime::Components::Tokenizer::SentencePiece
LiteRTLM::Runtime::Components::Tokenizer::Interface
LITERTLM_DEPS
)
# ==============================================================================
# 10. Sampler Interface
# ==============================================================================
add_litertlm_library(runtime_components_sampler INTERFACE)
add_library(LiteRTLM::Runtime::Components::Sampler::Interface ALIAS runtime_components_sampler)
target_include_directories(runtime_components_sampler
INTERFACE
${GENERATED_SRC_DIR}
${CMAKE_BINARY_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_sampler
INTERFACE
LITERTLM_DEPS # absl::status
)
# ==============================================================================
# 11. Sampler Factory
# ==============================================================================
add_litertlm_library(runtime_components_sampler_factory STATIC
sampler_factory.cc
)
add_library(LiteRTLM::Runtime::Components::Sampler::Factory ALIAS runtime_components_sampler_factory)
target_include_directories(runtime_components_sampler_factory
PRIVATE
${GENERATED_SRC_DIR}
${CMAKE_BINARY_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_sampler_factory
PUBLIC
runtime_executor_executor_settings_base
runtime_executor_llm_executor_settings
runtime_util_litert_status_util
LiteRTLM::Runtime::Components::Sampler::Interface
LiteRTLM::Runtime::Components::Sampler::TopP
LITERTLM_DEPS
)
# ==============================================================================
# 12. Sampling CPU Util
# ==============================================================================
add_litertlm_library(runtime_components_sampling_cpu_util STATIC
sampling_cpu_util.cc
)
add_library(LiteRTLM::Runtime::Components::SamplingCpuUtil ALIAS runtime_components_sampling_cpu_util)
target_include_directories(runtime_components_sampling_cpu_util
PRIVATE
${LITERTLM_INCLUDE_PATHS}
${GENERATED_SRC_DIR}
${CMAKE_BINARY_DIR}
)
target_link_libraries(runtime_components_sampling_cpu_util
PUBLIC
LITERTLM_DEPS
)
# ==============================================================================
# 13. Scoring CPU Util
# ==============================================================================
add_litertlm_library(runtime_components_scoring_cpu_util STATIC
scoring_cpu_util.cc
)
add_library(LiteRTLM::Runtime::Components::ScoringCpuUtil ALIAS runtime_components_scoring_cpu_util)
target_include_directories(runtime_components_scoring_cpu_util
PUBLIC
${LITERTLM_INCLUDE_PATHS}
${GENERATED_SRC_DIR}
${CMAKE_BINARY_DIR}
)
target_link_libraries(runtime_components_scoring_cpu_util
PUBLIC
LiteRTLM::Runtime::Components::SamplingCpuUtil
runtime_util_litert_status_util
LITERTLM_DEPS
)
# ==============================================================================
# 14. Stop Token Detector
# ==============================================================================
add_litertlm_library(runtime_components_stop_token_detector STATIC
stop_token_detector.cc
)
add_library(LiteRTLM::Runtime::Components::StopTokenDetector ALIAS runtime_components_stop_token_detector)
target_include_directories(runtime_components_stop_token_detector
PRIVATE
${GENERATED_SRC_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_stop_token_detector
PUBLIC
LITERTLM_DEPS
)
# ==============================================================================
# 15. Token ID Util
# ==============================================================================
add_litertlm_library(runtime_components_token_id_util STATIC
token_id_util.cc
)
add_library(LiteRTLM::Runtime::Components::TokenIdUtil ALIAS runtime_components_token_id_util)
target_include_directories(runtime_components_token_id_util
PRIVATE
${GENERATED_SRC_DIR}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_token_id_util
PUBLIC
LITERTLM_DEPS
)
# ==============================================================================
# 16. Top P CPU Sampler
# ==============================================================================
add_litertlm_library(runtime_components_top_p_cpu_sampler STATIC
top_p_cpu_sampler.cc
)
add_library(LiteRTLM::Runtime::Components::Sampler::TopP ALIAS runtime_components_top_p_cpu_sampler)
target_include_directories(runtime_components_top_p_cpu_sampler
PUBLIC
${PKG_ROOT}
${LITERTLM_INCLUDE_PATHS}
)
target_link_libraries(runtime_components_top_p_cpu_sampler
PUBLIC
LiteRTLM::Runtime::Components::Sampler::Interface
LiteRTLM::Runtime::Components::SamplingCpuUtil
runtime_util_convert_tensor_buffer
runtime_util_tensor_buffer_util
LITERTLM_DEPS
)
# ==============================================================================
# 17. Folder Facade
# ==============================================================================
add_library(runtime_components_libs INTERFACE)
add_library(LiteRTLM::Runtime::Components ALIAS runtime_components_libs)
target_link_libraries(runtime_components_libs INTERFACE
LiteRTLM::Runtime::Components::ConstrainedDecoding
LiteRTLM::Runtime::Components::EmbeddingLookup
LiteRTLM::Runtime::Components::Preprocessor
LiteRTLM::Runtime::Components::ToolUse
LiteRTLM::Runtime::Components::Tokenizer::HuggingFace
LiteRTLM::Runtime::Components::LoRA
LiteRTLM::Runtime::Components::LoRAManager
LiteRTLM::Runtime::Components::ModelResources::Interface
LiteRTLM::Runtime::Components::ModelResources::LiteRTLM
LiteRTLM::Runtime::Components::ModelResources::Task
LiteRTLM::Runtime::Components::PromptTemplate
LiteRTLM::Runtime::Components::Sampler::Interface
LiteRTLM::Runtime::Components::Sampler::Factory
LiteRTLM::Runtime::Components::SamplingCpuUtil
LiteRTLM::Runtime::Components::ScoringCpuUtil
LiteRTLM::Runtime::Components::Tokenizer::SentencePiece
LiteRTLM::Runtime::Components::StopTokenDetector
LiteRTLM::Runtime::Components::TokenIdUtil
LiteRTLM::Runtime::Components::Tokenizer::Interface
LiteRTLM::Runtime::Components::Sampler::TopP
) |