types.h 4.3 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. */

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

L
liuruilong 已提交
17 18 19
#include <string>
#include <unordered_map>

朔-望's avatar
朔-望 已提交
20
namespace paddle_mobile {
朔-望's avatar
朔-望 已提交
21
enum class Precision : int { FP32 = 0 };
朔-望's avatar
朔-望 已提交
22

L
liuruilong 已提交
23
template <Precision p>
L
liuruilong 已提交
24
struct PrecisionTrait {
L
liuruilong 已提交
25 26 27 28
  typedef void ptype;
};

template <>
L
liuruilong 已提交
29
struct PrecisionTrait<Precision::FP32> {
L
liuruilong 已提交
30 31 32
  typedef float ptype;
};

朔-望's avatar
朔-望 已提交
33 34
//! device type
enum DeviceTypeEnum { kINVALID = -1, kCPU = 0, kFPGA = 1, kGPU_MALI = 2 };
朔-望's avatar
朔-望 已提交
35

朔-望's avatar
朔-望 已提交
36 37
template <DeviceTypeEnum T>
struct DeviceType {};
朔-望's avatar
朔-望 已提交
38

朔-望's avatar
朔-望 已提交
39 40 41
typedef DeviceType<kCPU> CPU;
typedef DeviceType<kFPGA> FPGA;
typedef DeviceType<kGPU_MALI> GPU_MALI;
朔-望's avatar
朔-望 已提交
42

朔-望's avatar
朔-望 已提交
43 44
//! data type
enum DataType {
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
  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
朔-望 已提交
60 61 62
};
//!
enum PMStatus {
63 64 65 66 67 68 69 70 71
  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
朔-望 已提交
72
};
L
liuruilong 已提交
73 74 75 76 77 78

static const std::string G_OP_TYPE_CONV = "conv2d";
static const std::string G_OP_TYPE_BATCHNORM = "batch_norm";
static const std::string G_OP_TYPE_BOX_CODER = "box_coder";
static const std::string G_OP_TYPE_CONCAT = "concat";
static const std::string G_OP_TYPE_ELEMENTWISE_ADD = "elementwise_add";
L
liuruilong 已提交
79 80
static const std::string G_OP_TYPE_FUSION_CONV_ADD_RELU =
    "fusion_conv_add_relu";
L
liuruilong 已提交
81
static const std::string G_OP_TYPE_FC = "fc";
L
liuruilong 已提交
82
static const std::string G_OP_TYPE_CONV_ADD = "conv_add";
L
liuruilong 已提交
83 84 85 86 87 88 89 90 91 92 93 94 95
static const std::string G_OP_TYPE_LRN = "lrn";
static const std::string G_OP_TYPE_MUL = "mul";
static const std::string G_OP_TYPE_MULTICLASS_NMS = "multiclass_nms";
static const std::string G_OP_TYPE_POOL2D = "pool2d";
static const std::string G_OP_TYPE_PRIOR_BOX = "prior_box";
static const std::string G_OP_TYPE_RELU = "relu";
static const std::string G_OP_TYPE_RESHAPE = "reshape";
static const std::string G_OP_TYPE_SIGMOID = "sigmoid";
static const std::string G_OP_TYPE_SOFTMAX = "softmax";
static const std::string G_OP_TYPE_TRANSPOSE = "transpose";
static const std::string G_OP_TYPE_SPLIT = "split";
static const std::string G_OP_TYPE_FEED = "feed";
static const std::string G_OP_TYPE_FETCH = "fetch";
L
liuruilong 已提交
96
static const std::string G_OP_TYPE_DEPTHWISE_CONV = "depthwise_conv2d";
L
liuruilong 已提交
97 98

static std::unordered_map<
L
liuruilong 已提交
99
    std::string, std::pair<std::vector<std::string>, std::vector<std::string>>>
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
    op_input_output_key = {
        {G_OP_TYPE_CONV, {{"Input"}, {"Output"}}},
        {G_OP_TYPE_RELU, {{"X"}, {"Out"}}},
        {G_OP_TYPE_SOFTMAX, {{"X"}, {"Out"}}},
        {G_OP_TYPE_MUL, {{"X"}, {"Out"}}},
        {G_OP_TYPE_ELEMENTWISE_ADD, {{"X", "Y"}, {"Out"}}},
        {G_OP_TYPE_POOL2D, {{"X"}, {"Out"}}},
        {G_OP_TYPE_BATCHNORM, {{"X"}, {"Y"}}},
        {G_OP_TYPE_LRN, {{"X"}, {"Out"}}},
        {G_OP_TYPE_CONCAT, {{"X"}, {"Out"}}},
        {G_OP_TYPE_SPLIT, {{"X"}, {"Out"}}},
        {G_OP_TYPE_FEED, {{"X"}, {"Out"}}},
        {G_OP_TYPE_FETCH, {{"X"}, {"Out"}}},
        {G_OP_TYPE_TRANSPOSE, {{"X"}, {"Out"}}},
        {G_OP_TYPE_BOX_CODER,
         {{"PriorBox", "PriorBoxVar", "TargetBox"}, {"OutputBox"}}},
        {G_OP_TYPE_PRIOR_BOX, {{"Image", "Input"}, {"Boxes", "Variances"}}},
        {G_OP_TYPE_MULTICLASS_NMS, {{"BBoxes", "Scores"}, {"Out"}}},
E
eclipsess 已提交
118
        {G_OP_TYPE_FC, {{"X", "Y", "Z"}, {"Out"}}},
L
liuruilong 已提交
119
        {G_OP_TYPE_RESHAPE, {{"X"}, {"Out"}}},
L
liuruilong 已提交
120
        {G_OP_TYPE_DEPTHWISE_CONV, {{"Input"}, {"Output"}}}};
朔-望's avatar
朔-望 已提交
121
}  // namespace paddle_mobile