How can I create a custom class with member variables in c++ and use the variables in python?
Now i construct this cpp code.
class Loader : public torch::CustomClassHolder{
public:
Loader(const std::string& path);
std::vector<int64_t> get_config(const std::string& filename);
std::vector<int64_t> meta_json;
};
# ------------------
TORCH_LIBRARY(name, ops) {
ops.class_<Loader>("Loader")
.def(torch::init<const std::string>())
.def("get_config", &Loader::get_config);
}
but i can’t use “Loader().meta_json” in python
model = torch.classes.name.Loader("xxx.path")
print(model.meta_json) # error with "meta_json" not found.
So, how can i register the class member in python?
Thanks for your help~