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

D
dolphin8 已提交
15
#pragma once
朔-望's avatar
朔-望 已提交
16

L
liuruilong 已提交
17 18
#include <string>
#include <unordered_map>
19
#include <utility>
D
dolphin8 已提交
20
#include <vector>
L
liuruilong 已提交
21

朔-望's avatar
朔-望 已提交
22
namespace paddle_mobile {
H
hanbuhe 已提交
23 24 25
enum class Precision : int { FP32 = 0, FP16 = 1 };

typedef int16_t half;
朔-望's avatar
朔-望 已提交
26

L
liuruilong 已提交
27
template <Precision p>
L
liuruilong 已提交
28
struct PrecisionTrait {
L
liuruilong 已提交
29 30 31 32
  typedef void ptype;
};

template <>
L
liuruilong 已提交
33
struct PrecisionTrait<Precision::FP32> {
L
liuruilong 已提交
34 35
  typedef float ptype;
};
H
hanbuhe 已提交
36 37 38 39
template <>
struct PrecisionTrait<Precision::FP16> {
  typedef half ptype;
};
L
liuruilong 已提交
40

朔-望's avatar
朔-望 已提交
41
//! device type
42 43 44 45 46 47 48
enum DeviceTypeEnum {
  kINVALID = -1,
  kCPU = 0,
  kFPGA = 1,
  kGPU_MALI = 2,
  kGPU_CL = 3
};
朔-望's avatar
朔-望 已提交
49

朔-望's avatar
朔-望 已提交
50 51
template <DeviceTypeEnum T>
struct DeviceType {};
朔-望's avatar
朔-望 已提交
52

朔-望's avatar
朔-望 已提交
53 54 55
typedef DeviceType<kCPU> CPU;
typedef DeviceType<kFPGA> FPGA;
typedef DeviceType<kGPU_MALI> GPU_MALI;
L
liuruilong 已提交
56
typedef DeviceType<kGPU_CL> GPU_CL;
朔-望's avatar
朔-望 已提交
57

朔-望's avatar
朔-望 已提交
58 59
//! data type
enum DataType {
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
  PM_INVALID = -1,
  PM_HALF = 0,
  PM_FLOAT = 1,
  PM_DOUBLE = 2,
  PM_INT8 = 3,
  PM_INT16 = 4,
  PM_INT32 = 5,
  PM_INT64 = 6,
  PM_UINT8 = 7,
  PM_UINT16 = 8,
  PM_UINT32 = 9,
  PM_STRING = 10,
  PM_BOOL = 11,
  PM_SHAPE = 12,
  PM_TENSOR = 13
朔-望's avatar
朔-望 已提交
75 76 77
};
//!
enum PMStatus {
78 79 80 81 82 83 84 85 86
  PMSuccess = 0xFF,        /*!< No errors */
  PMNotInitialized = 0x01, /*!< Data not initialized. */
  PMInvalidValue = 0x02,   /*!< Incorrect variable value. */
  PMMemAllocFailed = 0x03, /*!< Memory allocation error. */
  PMUnKownError = 0x04,    /*!< Unknown error. */
  PMOutOfAuthority = 0x05, /*!< Try to modified data not your own*/
  PMOutOfMem = 0x06,       /*!< OOM error*/
  PMUnImplError = 0x07,    /*!< Unimplement error. */
  PMWrongDevice = 0x08     /*!< un-correct device. */
朔-望's avatar
朔-望 已提交
87
};
L
liuruilong 已提交
88

89
enum RoundType {
90 91 92 93 94 95 96 97 98 99 100 101 102
  ROUND_NEAREST_AWAY_ZERO = 0,
  ROUND_NEAREST_TOWARDS_ZERO = 1,
  ROUND_NEAREST_TO_EVEN = 2,
};

enum ActivationType {
  Linear = 0,
  Relu = 1,
  Relu6 = 2,
  PRelu = 3,
  LeakyRelu = 4,
  Tanh = 5,
  Sigmoid = 6,
103 104
};

105 106 107 108 109 110
extern const char *G_OP_TYPE_CONV;
extern const char *G_OP_TYPE_BATCHNORM;
extern const char *G_OP_TYPE_BOX_CODER;
extern const char *G_OP_TYPE_CONCAT;
extern const char *G_OP_TYPE_ELEMENTWISE_ADD;
extern const char *G_OP_TYPE_FUSION_CONV_ADD_RELU;
111
extern const char *G_OP_TYPE_FUSION_CONV_ADD_RELU_INT8;
112 113
extern const char *G_OP_TYPE_FUSION_CONV_ADD_PRELU;
extern const char *G_OP_TYPE_FUSION_CONV_ADD_ADD_PRELU;
114
extern const char *G_OP_TYPE_FC;
Z
ZhenWang 已提交
115
extern const char *G_OP_TYPE_FC_INT8;
116 117
extern const char *G_OP_TYPE_FUSION_CONV_ADD;
extern const char *G_OP_TYPE_FUSION_CONV_ADD_BN_RELU;
118
extern const char *G_OP_TYPE_FUSION_CONV_BN_ADD_RELU;
119 120 121 122 123 124 125 126 127
extern const char *G_OP_TYPE_FUSION_DWCONV_BN_RELU;
extern const char *G_OP_TYPE_FUSION_CONV_BN_RELU;

extern const char *G_OP_TYPE_LRN;
extern const char *G_OP_TYPE_MUL;
extern const char *G_OP_TYPE_MULTICLASS_NMS;
extern const char *G_OP_TYPE_POOL2D;
extern const char *G_OP_TYPE_PRIOR_BOX;
extern const char *G_OP_TYPE_RELU;
128
extern const char *G_OP_TYPE_RELU6;
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
extern const char *G_OP_TYPE_RESHAPE;
extern const char *G_OP_TYPE_SIGMOID;
extern const char *G_OP_TYPE_SOFTMAX;
extern const char *G_OP_TYPE_TRANSPOSE;
extern const char *G_OP_TYPE_SPLIT;
extern const char *G_OP_TYPE_FEED;
extern const char *G_OP_TYPE_FETCH;
extern const char *G_OP_TYPE_DEPTHWISE_CONV;
extern const char *G_OP_TYPE_IM2SEQUENCE;
extern const char *G_OP_TYPE_DROPOUT;

extern const char *G_OP_TYPE_FUSION_CONV_ADD_BN;
extern const char *G_OP_TYPE_FUSION_POOL_BN;
extern const char *G_OP_TYPE_FUSION_ELEMENTWISE_ADD_RELU;
extern const char *G_OP_TYPE_FUSION_FC_RELU;
extern const char *G_OP_TYPE_REGION;
qnqinan's avatar
qnqinan 已提交
145
extern const char *G_OP_TYPE_FUSION_CONV_BN;
146 147
extern const char *G_OP_TYPE_CONV_TRANSPOSE;
extern const char *G_OP_TYPE_PRELU;
E
eclipsess 已提交
148 149
extern const char *G_OP_TYPE_SUM;
extern const char *G_OP_TYPE_ELEMENTWISE_MUL;
Z
zhangyang 已提交
150

151 152
extern const char *G_OP_TYPE_QUANTIZE;
extern const char *G_OP_TYPE_DEQUANTIZE;
153
extern const char *G_OP_TYPE_FUSION_DEQUANT_BN;
154 155
extern const char *G_OP_TYPE_FUSION_DEQUANT_ADD_BN;
extern const char *G_OP_TYPE_FUSION_DEQUANT_BN_RELU;
H
hjchen2 已提交
156
extern const char *G_OP_TYPE_FUSION_DEQUANT_ADD_BN_RELU;
157 158
extern const char *G_OP_TYPE_FUSION_DEQUANT_ADD_BN_QUANT;
extern const char *G_OP_TYPE_FUSION_DEQUANT_ADD_BN_RELU_QUANT;
159

Z
zhangyang 已提交
160 161 162
extern const char *G_OP_TYPE_TANH;
extern const char *G_OP_TYPE_FUSION_DECONV_RELU;

qnqinan's avatar
qnqinan 已提交
163 164 165
extern const char *G_OP_TYPE_FUSION_DECONV_ADD;
extern const char *G_OP_TYPE_FUSION_DECONV_ADD_RELU;

L
liuruilong 已提交
166
extern std::unordered_map<
L
liuruilong 已提交
167
    std::string, std::pair<std::vector<std::string>, std::vector<std::string>>>
L
liuruilong 已提交
168 169
    op_input_output_key;

朔-望's avatar
朔-望 已提交
170
}  // namespace paddle_mobile