(ffi) add template specialization to catch and convert to Rust Result<T, tensorrt_llm::common::TllmException>

This commit is contained in:
Morgan Funtowicz 2024-08-02 22:18:18 +00:00 committed by Morgan Funtowicz
parent 33c962ef41
commit 5f7c0b67c3

View File

@ -14,6 +14,18 @@ namespace huggingface::tgi::backends {
class TensorRtLlmBackendImpl; class TensorRtLlmBackendImpl;
} }
// Template to support returning error from TllmException back to Rust in a Result<>
#include <tensorrt_llm/common/tllmException.h>
namespace rust::behavior {
template<typename Try, typename Fail>
static void trycatch(Try &&func, Fail &&fail) noexcept try {
func();
} catch (tensorrt_llm::common::TllmException &e) {
fail(e.what());
}
}
#include "backends/trtllm/src/lib.rs.h" #include "backends/trtllm/src/lib.rs.h"
namespace huggingface::tgi::backends { namespace huggingface::tgi::backends {