Skip to content

Commit

Permalink
implement detect backend
Browse files Browse the repository at this point in the history
  • Loading branch information
CaRoLZhangxy committed Jan 26, 2024
1 parent 0d494b4 commit b1cc754
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/api_cc/src/DeepPot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ void DeepPot::init(const std::string& model,
<< std::endl;
return;
}
// TODO: To implement detect_backend
DPBackend backend = deepmd::DPBackend::TensorFlow;
if (model.length() >= 4 && model.substr(model.length() - 4) == ".pth") {
DPBackend backend = deepmd::DPBackend::PyTorch;
} else if (model.length() >= 3 && model.substr(model.length() - 3) == ".pb") {
DPBackend backend = deepmd::DPBackend::TensorFlow;
else {
throw deepmd::deepmd_exception("Unsupported model file format");
}
if (deepmd::DPBackend::TensorFlow == backend) {
#ifdef BUILD_TENSORFLOW
dp = std::make_shared<deepmd::DeepPotTF>(model, gpu_rank, file_content);
Expand Down

0 comments on commit b1cc754

Please sign in to comment.