Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit b1a45f0

Browse files
committed
Adapt to removal of TS backend
1 parent 8849744 commit b1a45f0

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

cpp/src/examples/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ add_library(babyllama_handler SHARED ${BABYLLAMA_SOURCE_FILES})
1414
target_include_directories(babyllama_handler PUBLIC ${BABYLLAMA_SRC_DIR})
1515
target_link_libraries(babyllama_handler PRIVATE ts_backends_core ts_utils ${TORCH_LIBRARIES})
1616
target_compile_options(babyllama_handler PRIVATE -Wall -Wextra -Ofast)
17-
target_link_libraries(mnist_handler PRIVATE ts_backends_torch_scripted ts_utils ${TORCH_LIBRARIES})
1817

1918
set(LLM_SRC_DIR "${torchserve_cpp_SOURCE_DIR}/src/examples/llamacpp")
2019
set(LLAMACPP_SRC_DIR "/home/ubuntu/llama.cpp")
@@ -23,7 +22,7 @@ list(APPEND LLM_SOURCE_FILES ${LLM_SRC_DIR}/llamacpp_handler.cc)
2322
add_library(llamacpp_handler SHARED ${LLM_SOURCE_FILES})
2423
target_include_directories(llamacpp_handler PUBLIC ${LLM_SRC_DIR})
2524
target_include_directories(llamacpp_handler PUBLIC ${LLAMACPP_SRC_DIR})
26-
target_link_libraries(llamacpp_handler PRIVATE ts_backends_torch_scripted ts_utils ${TORCH_LIBRARIES})
25+
target_link_libraries(llamacpp_handler PRIVATE ts_backends_core ts_utils ${TORCH_LIBRARIES})
2726

2827

2928
set(MY_OBJECT_FILES

cpp/src/examples/llamacpp/llamacpp_handler.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ void LlamacppHandler::initialize_context() {
1717
}
1818
}
1919

20-
std::pair<std::shared_ptr<torch::jit::script::Module>,
21-
std::shared_ptr<torch::Device>>
20+
std::pair<std::shared_ptr<void>, std::shared_ptr<torch::Device>>
2221
LlamacppHandler::LoadModel(
2322
std::shared_ptr<torchserve::LoadModelRequest>& load_model_request) {
2423
try {
@@ -156,8 +155,7 @@ std::vector<torch::jit::IValue> LlamacppHandler::Preprocess(
156155
}
157156

158157
torch::Tensor LlamacppHandler::Inference(
159-
std::shared_ptr<torch::jit::script::Module> model,
160-
std::vector<torch::jit::IValue>& inputs,
158+
std::shared_ptr<void> model, std::vector<torch::jit::IValue>& inputs,
161159
std::shared_ptr<torch::Device>& device,
162160
std::pair<std::string&, std::map<uint8_t, std::string>&>& idx_to_req_id,
163161
std::shared_ptr<torchserve::InferenceResponseBatch>& response_batch) {
@@ -290,11 +288,11 @@ LlamacppHandler::~LlamacppHandler() noexcept {
290288

291289
#if defined(__linux__) || defined(__APPLE__)
292290
extern "C" {
293-
torchserve::torchscripted::BaseHandler* allocatorLlamacppHandler() {
291+
torchserve::BaseHandler* allocatorLlamacppHandler() {
294292
return new llm::LlamacppHandler();
295293
}
296294

297-
void deleterLlamacppHandler(torchserve::torchscripted::BaseHandler* p) {
295+
void deleterLlamacppHandler(torchserve::BaseHandler* p) {
298296
if (p != nullptr) {
299297
delete static_cast<llm::LlamacppHandler*>(p);
300298
}

cpp/src/examples/llamacpp/llamacpp_handler.hh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#include "common/common.h"
88
#include "ggml.h"
99
#include "llama.h"
10-
#include "src/backends/torch_scripted/handler/base_handler.hh"
10+
#include "src/backends/handler/base_handler.hh"
1111

1212
namespace llm {
13-
class LlamacppHandler : public torchserve::torchscripted::BaseHandler {
13+
class LlamacppHandler : public torchserve::BaseHandler {
1414
private:
1515
gpt_params params;
1616
llama_model_params model_params;
@@ -27,8 +27,7 @@ class LlamacppHandler : public torchserve::torchscripted::BaseHandler {
2727

2828
void initialize_context();
2929

30-
virtual std::pair<std::shared_ptr<torch::jit::script::Module>,
31-
std::shared_ptr<torch::Device>>
30+
virtual std::pair<std::shared_ptr<void>, std::shared_ptr<torch::Device>>
3231
LoadModel(std::shared_ptr<torchserve::LoadModelRequest>& load_model_request);
3332

3433
std::vector<torch::jit::IValue> Preprocess(
@@ -39,8 +38,7 @@ class LlamacppHandler : public torchserve::torchscripted::BaseHandler {
3938
override;
4039

4140
torch::Tensor Inference(
42-
std::shared_ptr<torch::jit::script::Module> model,
43-
std::vector<torch::jit::IValue>& inputs,
41+
std::shared_ptr<void> model, std::vector<torch::jit::IValue>& inputs,
4442
std::shared_ptr<torch::Device>& device,
4543
std::pair<std::string&, std::map<uint8_t, std::string>&>& idx_to_req_id,
4644
std::shared_ptr<torchserve::InferenceResponseBatch>& response_batch)

0 commit comments

Comments
 (0)