Skip to content

Commit

Permalink
Convert std::path to std::string before passingt to torch::jit::load
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Salzmann committed Feb 22, 2024
1 parent 48fe098 commit 584e751
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libl4casadi/src/l4casadi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ class L4CasADi::L4CasADiImpl
void load_model_from_disk() {
std::filesystem::path dir (this->model_path);
std::filesystem::path forward_model_file (this->model_prefix + "_forward.pt");
this->forward_model = torch::jit::load(dir / forward_model_file);
this->forward_model = torch::jit::load((dir / forward_model_file).generic_string());
this->forward_model.to(this->device);
this->forward_model.eval();
this->forward_model = torch::jit::optimize_for_inference(this->forward_model);

if (this->has_jac) {
std::filesystem::path jac_model_file (this->model_prefix + "_jacrev.pt");
this->jac_model = torch::jit::load(dir / jac_model_file);
this->jac_model = torch::jit::load((dir / jac_model_file).generic_string());
this->jac_model.to(this->device);
this->jac_model.eval();
this->jac_model = torch::jit::optimize_for_inference(this->jac_model);
}

if (this->has_hess) {
std::filesystem::path hess_model_file (this->model_prefix + "_hess.pt");
this->hess_model = torch::jit::load(dir / hess_model_file);
this->hess_model = torch::jit::load((dir / hess_model_file).generic_string());
this->hess_model.to(this->device);
this->hess_model.eval();
this->hess_model = torch::jit::optimize_for_inference(this->hess_model);
Expand Down

0 comments on commit 584e751

Please sign in to comment.