/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "io/paddle_mobile.h" namespace paddle_mobile { template bool PaddleMobile::Load(const std::string &dirname, bool optimize, int batch_size) { if (loader_.get() == nullptr) { loader_ = std::make_shared>(); } else { LOG(kLOG_INFO) << "loader inited"; } if (executor_.get() == nullptr) { executor_ = std::make_shared>( loader_->Load(dirname, optimize), batch_size, optimize); } else { LOG(kLOG_INFO) << "executor inited"; } return true; } template bool PaddleMobile::Load(const std::string &model_path, const std::string ¶_path, bool optimize, int batch_size) { if (loader_.get() == nullptr) { loader_ = std::make_shared>(); } else { LOG(kLOG_INFO) << "loader inited"; } if (executor_.get() == nullptr) { executor_ = std::make_shared>( loader_->Load(model_path, para_path, optimize), batch_size, optimize); } else { LOG(kLOG_INFO) << "executor inited"; } return true; } template std::shared_ptr PaddleMobile::Predict( const framework::Tensor &t) { return executor_->Predict(t); } template std::vector::Ptype> PaddleMobile::Predict(const std::vector &input, const std::vector &dims) { return executor_->Predict(input, dims); } template void PaddleMobile::Clear() { executor_ = nullptr; loader_ = nullptr; } template PaddleMobile::~PaddleMobile(){ executor_ = nullptr; loader_ = nullptr; } template class PaddleMobile; template class PaddleMobile; template class PaddleMobile; } // namespace paddle_mobile