Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3rdparty/tvm
Submodule tvm updated 558 files
4 changes: 2 additions & 2 deletions cpp/json_ffi/json_ffi_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ class JSONFFIEngineImpl : public JSONFFIEngine, public ffi::ModuleObj {
}
};

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef().def("mlc.json_ffi.CreateJSONFFIEngine",
[]() { return ffi::Module(tvm::ffi::make_object<JSONFFIEngineImpl>()); });
});
}

} // namespace json_ffi
} // namespace llm
Expand Down
4 changes: 2 additions & 2 deletions cpp/multi_gpu/builtin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ ObjectRef SendFromLastGroupToWorker0(Tensor send, Optional<Tensor> recv, Shape s
return recv;
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def("mlc.multi_gpu.DispatchFunctionByGroup", DispatchFunctionByGroup)
.def("mlc.multi_gpu.SendFromLastGroupToWorker0", SendFromLastGroupToWorker0);
});
}

} // namespace multi_gpu
} // namespace llm
Expand Down
4 changes: 2 additions & 2 deletions cpp/multi_gpu/multi_gpu_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,12 @@ Array<Optional<Tensor>> LoadMultiGPUPresharded(const std::string& model_path, Mo
return params;
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def("mlc.multi_gpu.LoadMultiGPU", LoadMultiGPU)
.def("mlc.multi_gpu.LoadMultiGPUPresharded", LoadMultiGPUPresharded);
});
}

} // namespace multi_gpu
} // namespace llm
Expand Down
16 changes: 8 additions & 8 deletions cpp/serve/data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ ObjectRef TextDataNode::GetEmbedding(Model model, ObjectRef* dst, int offset) co
"Please tokenize the text and construct a TokenData object.";
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def("mlc.serve.TextData", [](String text) { return TextData(std::move(text)); })
.def("mlc.serve.TextDataGetTextString", [](TextData data) { return data->text; });
});
}

/****************** TokenData ******************/

Expand All @@ -99,7 +99,7 @@ ObjectRef TokenDataNode::GetEmbedding(Model model, ObjectRef* dst, int offset) c
return model->TokenEmbed(token_ids, dst, offset);
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def_packed("mlc.serve.TokenData",
Expand All @@ -112,7 +112,7 @@ TVM_FFI_STATIC_INIT_BLOCK({
*rv = TokenData(std::move(token_ids));
})
.def("mlc.serve.TokenDataGetTokenIds", [](TokenData data) { return data->token_ids; });
});
}

/****************** ImageData ******************/

Expand All @@ -129,13 +129,13 @@ ObjectRef ImageDataNode::GetEmbedding(Model model, ObjectRef* dst, int offset) c
return model->ImageEmbed(image, dst, offset);
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def("mlc.serve.ImageData",
[](Tensor image, int embed_size) { return ImageData(std::move(image), embed_size); })
.def("mlc.serve.ImageDataGetImage", [](ImageData data) { return data->image; });
});
}

/****************** SampleResult ******************/

Expand Down Expand Up @@ -223,7 +223,7 @@ RequestStreamOutput RequestStreamOutput::Usage(String request_id,
return RequestStreamOutput(n);
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef().def("mlc.serve.RequestStreamOutputUnpack", [](RequestStreamOutput output) {
CHECK(!output->unpacked) << "One RequestStreamOutput can be unpacked for at most once.";
Expand All @@ -250,7 +250,7 @@ TVM_FFI_STATIC_INIT_BLOCK({
output->unpacked = true;
return ret;
});
});
}

} // namespace serve
} // namespace llm
Expand Down
4 changes: 2 additions & 2 deletions cpp/serve/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1087,10 +1087,10 @@ class EngineModule : public ffi::ModuleObj {
GenerationConfig default_generation_config_;
};

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef().def("mlc.serve.create_engine", EngineModule::Create);
});
}

} // namespace serve
} // namespace llm
Expand Down
4 changes: 2 additions & 2 deletions cpp/serve/event_trace_recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ EventTraceRecorder EventTraceRecorder::Create() {
return EventTraceRecorder(tvm::ffi::make_object<EventTraceRecorderImpl>());
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def("mlc.serve.EventTraceRecorder", []() { return EventTraceRecorder::Create(); })
.def("mlc.serve.EventTraceRecorderAddEvent",
[](const EventTraceRecorder& trace_recorder, const String& request_id,
const std::string& event) { trace_recorder->AddEvent(request_id, event); })
.def_method("mlc.serve.EventTraceRecorderDumpJSON", &EventTraceRecorderObj::DumpJSON);
});
}

} // namespace serve
} // namespace llm
Expand Down
4 changes: 2 additions & 2 deletions cpp/serve/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ class ModelImpl : public ModelObj {
std::unordered_set<int64_t> prefilled_seq_ids_;
};

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef().def(
"mlc.copy_embedding_to_offset", [](Tensor embedding, Tensor dst, int offset) {
Expand All @@ -1132,7 +1132,7 @@ TVM_FFI_STATIC_INIT_BLOCK({
((embedding->dtype.bits * embedding->dtype.lanes + 7) / 8);
Tensor::CopyFromTo(&copy_src, &copy_dst);
});
});
}

} // namespace serve
} // namespace llm
Expand Down
4 changes: 2 additions & 2 deletions cpp/serve/radix_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ PagedRadixTree PagedRadixTree::Create() {
return PagedRadixTree(tvm::ffi::make_object<PagedRadixTreeImpl>());
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def("mlc.serve.PagedRadixTree", []() { return PagedRadixTree::Create(); })
Expand Down Expand Up @@ -836,7 +836,7 @@ TVM_FFI_STATIC_INIT_BLOCK({
.def("mlc.serve.PagedRadixTreeFreeCapacity", [](PagedRadixTree paged_radix_tree) {
return static_cast<int64_t>(paged_radix_tree->FreeCapacity());
});
});
}

} // namespace serve
} // namespace llm
Expand Down
4 changes: 2 additions & 2 deletions cpp/serve/request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ Request Request::FromUntokenized(const Request& request, const Tokenizer& tokeni
}
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def("mlc.serve.RequestGetInputs", [](Request request) { return request->inputs; })
.def("mlc.serve.RequestGetGenerationConfigJSON", [](Request request) {
return picojson::value(request->generation_cfg->AsJSON()).serialize();
});
});
}

} // namespace serve
} // namespace llm
Expand Down
4 changes: 2 additions & 2 deletions cpp/serve/threaded_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,11 @@ class ThreadedEngineModule : public ThreadedEngineImpl, public ffi::ModuleObj {
TVM_MODULE_VTABLE_END();
};

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef().def("mlc.serve.create_threaded_engine",
[]() { return Module(tvm::ffi::make_object<ThreadedEngineModule>()); });
});
}

std::unique_ptr<ThreadedEngine> ThreadedEngine::Create() {
std::unique_ptr<ThreadedEngineImpl> threaded_engine = std::make_unique<ThreadedEngineImpl>();
Expand Down
8 changes: 4 additions & 4 deletions cpp/tokenizers/streamer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ std::string TextStreamerObj::Finish() {
}
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def("mlc.tokenizers.TextStreamer",
Expand All @@ -149,7 +149,7 @@ TVM_FFI_STATIC_INIT_BLOCK({
{delta_tokens->data, delta_tokens->data + delta_tokens->size});
})
.def_method("mlc.tokenizers.TextStreamerFinish", &TextStreamerObj::Finish);
});
}

/****************** StopStrHandler ******************/

Expand Down Expand Up @@ -261,7 +261,7 @@ StopStrHandler::StopStrHandler(Array<String> stop_strs,
data_ = tvm::ffi::make_object<StopStrHandlerObj>(std::move(stop_strs), token_table);
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def("mlc.tokenizers.StopStrHandler",
Expand All @@ -281,7 +281,7 @@ TVM_FFI_STATIC_INIT_BLOCK({
return IntTuple(std::move(remaining_token_ids));
})
.def_method("mlc.tokenizers.StopStrHandlerStopTriggered", &StopStrHandlerObj::StopTriggered);
});
}

} // namespace llm
} // namespace mlc
8 changes: 4 additions & 4 deletions cpp/tokenizers/tokenizers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ const std::vector<std::string>& TokenizerObj::PostProcessedTokenTable() {
return post_processed_token_table_;
}

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def("mlc.tokenizers.Tokenizer", [](const String& path) { return Tokenizer::FromPath(path); })
Expand All @@ -478,11 +478,11 @@ TVM_FFI_STATIC_INIT_BLOCK({
})
.def("mlc.tokenizers.DetectTokenizerInfo",
[](const String& path) { return Tokenizer::DetectTokenizerInfo(path)->AsJSONString(); });
});
}

#endif

TVM_FFI_STATIC_INIT_BLOCK({
TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::GlobalDef()
.def_packed("mlc.tokenizers.PostProcessTokenTable",
Expand All @@ -507,7 +507,7 @@ TVM_FFI_STATIC_INIT_BLOCK({
[](const String& token, const String& token_postproc_method) {
return PostProcessToken(token, token_postproc_method);
});
});
}

} // namespace llm
} // namespace mlc
Loading