-
Notifications
You must be signed in to change notification settings - Fork 365
Expand file tree
/
Copy pathadaptor_base_wrapper.hpp
More file actions
37 lines (28 loc) · 941 Bytes
/
adaptor_base_wrapper.hpp
File metadata and controls
37 lines (28 loc) · 941 Bytes
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
#pragma once
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include <pybind11/pybind11.h>
#include "adaptor_base.hpp"
namespace lazyllm {
class LAZYLLM_HIDDEN AdaptorBaseWrapper : public AdaptorBase {
pybind11::object _py_obj;
public:
AdaptorBaseWrapper(const pybind11::object &obj) : _py_obj(obj) {}
virtual ~AdaptorBaseWrapper() = default;
std::any call(
const std::string& func_name,
const std::unordered_map<std::string, std::any>& args) const override final
{
pybind11::gil_scoped_acquire gil;
pybind11::object func = pybind11::getattr(_py_obj, func_name.c_str(), pybind11::none());
return call_impl(func_name, func, args);
}
virtual std::any call_impl(
const std::string& func_name,
const pybind11::object& func,
const std::unordered_map<std::string, std::any>& args) const = 0;
};
}