fetch_op.h 2.3 KB
Newer Older
L
liuruilong 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* 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

17
#include <string>
L
liuruilong 已提交
18
#include "framework/operator.h"
Z
zhaojiaying01 已提交
19
#include "operators/kernel/fetch_kernel.h"
L
liuruilong 已提交
20 21 22 23
#include "operators/op_param.h"

namespace paddle_mobile {
namespace operators {
24
using std::string;
L
liuruilong 已提交
25 26

template <typename DeviceType, typename T>
27
#ifdef PADDLE_MOBILE_CL
Z
zhaojiaying01 已提交
28 29 30
class FetchOp
    : public framework::OperatorWithKernel<DeviceType, FetchParam<DeviceType>,
                                           FetchKernel<DeviceType, T>> {
L
liuruilong 已提交
31
 public:
32
  FetchOp(const string &type, const VariableNameMap &inputs,
L
liuruilong 已提交
33 34
          const VariableNameMap &outputs, const framework::AttributeMap attrs,
          std::shared_ptr<framework::Scope> scope)
Z
zhaojiaying01 已提交
35 36 37
      : framework::OperatorWithKernel<DeviceType, FetchParam<DeviceType>,
                                      FetchKernel<DeviceType, T>>(
            type, inputs, outputs, attrs, scope) {}
38 39 40 41 42 43 44 45 46
#else
class FetchOp : public framework::OperatorBase<DeviceType> {
 public:
  FetchOp(const string &type, const VariableNameMap &inputs,
          const VariableNameMap &outputs, const framework::AttributeMap attrs,
          std::shared_ptr<framework::Scope> scope)
      : framework::OperatorBase<DeviceType>(type, inputs, outputs, attrs,
                                            scope),
        param_(inputs, outputs, attrs, *scope) {}
L
liuruilong 已提交
47

48 49
  void Init() {}
#endif
Z
zhaojiaying01 已提交
50
  void InferShape() const override;
L
liuruilong 已提交
51

Z
zhaojiaying01 已提交
52
  void RunImpl() override;
L
liuruilong 已提交
53 54

 protected:
55 56 57
#ifndef PADDLE_MOBILE_CL
  FetchParam<DeviceType> param_;
#endif
L
liuruilong 已提交
58 59
};

60 61 62
}  // namespace operators
}  // namespace paddle_mobile

L
for  
liuruilong 已提交
63 64 65 66
#ifdef PADDLE_MOBILE_CPU
USE_OP_CPU(fetch);
#endif
#ifdef PADDLE_MOBILE_MALI_GPU
E
eclipsess 已提交
67
USE_OP_MALI_GPU(fetch);
L
for  
liuruilong 已提交
68 69
#endif
#ifdef PADDLE_MOBILE_FPGA
Z
zhangyang 已提交
70
USE_OP_FPGA(fetch);
L
for  
liuruilong 已提交
71
#endif
Y
yangfei 已提交
72 73 74
#ifdef PADDLE_MOBILE_CL
USE_OP_CL(fetch);
#endif