api_paddle_mobile.h 1.7 KB
Newer Older
N
nhzlx 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/* 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. */

#pragma once

#include <vector>
#include "common/types.h"
19
#include "io/paddle_inference_api.h"
N
nhzlx 已提交
20 21 22 23
#include "io/paddle_mobile.h"

namespace paddle_mobile {

24
template <typename Device = CPU, typename T = float>
N
nhzlx 已提交
25 26
class PaddleMobilePredictor : public PaddlePredictor {
 public:
L
liuruilong 已提交
27
  PaddleMobilePredictor() = delete;
N
nhzlx 已提交
28 29 30 31 32 33

  explicit PaddleMobilePredictor(const PaddleMobileConfig& config);

  bool Run(const std::vector<PaddleTensor>& inputs,
           std::vector<PaddleTensor>* output_data,
           int batch_size = -1) override;
Z
zhangyang0701 已提交
34 35 36 37
#ifdef PADDLE_MOBILE_FPGA
  bool Run(const std::vector<PaddleTensor>& inputs,
           std::vector<PaddleTensor>* output_data, std::vector<int>* index_data,
           int batch_size = -1) override;
38 39 40
  void FeedData(const std::vector<void*>& inputs) override;
  void GetResults(std::vector<void*>* outputs) override;
  void Predict_From_To(int start = 0, int end = -1) override;
Z
zhangyang0701 已提交
41
#endif
L
liuruilong 已提交
42
  ~PaddleMobilePredictor() override;
N
nhzlx 已提交
43 44

 private:
45
  std::unique_ptr<PaddleMobile<Device, T>> paddle_mobile_;
N
nhzlx 已提交
46 47 48 49 50 51
  bool Init(const PaddleMobileConfig& config);

  PaddleMobileConfig config_;
};

}  // namespace paddle_mobile