XName.cpp 4.41 KB
Newer Older
xiaotong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/* NiuTrans.Tensor - an open-source tensor library
 * Copyright (C) 2018, Natural Language Processing Lab, Northestern University.
 * 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.
 */

/*
 * $Created by: XIAO Tong (xiaotong@mail.neu.edu.cn) 2018-07-05
 */

22
#include "XName.h"
xiaotong committed
23 24 25 26 27 28

namespace nts { // namespace nts(NiuTrans.Tensor)
    
/* get operator name */
const char * GetOPName(int type)
{
29 30
    if ((type & MATH_BASE) != 0){
        if (type == MATH_ABSOLUTE)
31
            return "M_ABSOLUTE";
32 33 34 35 36 37 38 39 40 41
        else if (type == MATH_EXP)
            return "M_EXP";
        else if (type == MATH_LOG)
            return "M_LOG";
        else if (type == MATH_SIN)
            return "M_SIN";
        else if (type == MATH_COS)
            return "M_COS";
        else if (type == MATH_TAN)
            return "M_TAN";
42 43 44 45 46 47
        else if (type == MATH_ROUND)
            return "M_ROUND";
        else if (type == MATH_CLIP)
            return "M_CLIP";
        else if (type == MATH_DIV)
            return "M_DIV";
48 49
        else if (type == MATH_DIVDIM)
            return "M_DIVDIM";
50
        else if (type == MATH_MATRIXMUL)
51
            return "M_MATRIXMUL";
52
        else if (type == MATH_MATRIXMULBATCHED)
53
            return "M_MATRIXMULBATCHED";
54
        else if (type == MATH_MULTIPLY)
xiaotong committed
55
            return "M_MULTIPLY";
56 57
        else if (type == MATH_MULTIPLYDIM)
            return "M_MULTIPLYDIM";
58
        else if (type == MATH_NEGATE)
59
            return "M_NEGATE";
60 61 62 63 64 65
        else if (type == MATH_NORMALIZE)
            return "M_NORMALIZE";
        else if (type == MATH_POWER)
            return "M_POWER";
        else if (type == MATH_SCALEANDSHIFT)
            return "M_SCALEANDSHIFT";
66
        else if (type == MATH_SIGN)
67
            return "M_SIGN";
68 69
        else if (type == MATH_SUB)
            return "M_SUB";
70 71 72 73
        else if (type == MATH_SUBDIM)
            return "M_SUBDIM";
        else if (type == MATH_SUM)
            return "M_SUM";
74 75
        else if (type == MATH_SUMDIM)
            return "M_SUMDIM";
76
        else if (type == REDUCE_REDUCEMAX)
77
            return "R_REDUCEMAX";
78
        else if (type == REDUCE_REDUCEMEAN)
79
            return "R_REDUCEMEAN";
80
        else if (type == REDUCE_REDUCESUM)
81
            return "R_REDUCESUM";
82
        else if (type == REDUCE_REDUCESUMSQUARED)
83
            return "R_REDUCESUMSQUARED";
84
        else if (type == REDUCE_REDUCEVARIANCE)
85
            return "R_REDUCEVARIANCE";
86 87 88 89 90 91 92 93 94
    }
    else if ((type & DATA_BASE) != 0){
        if (type == GETANDSET_SELECT)
            return "G_SELECT";
        else if (type == MOVEMENT_COPYINDEXED)
            return "M_COPYINDEXED";
        else if (type == MOVEMENT_COPYVALUES)
            return "M_COPYVALUES";
        else if (type == SHAPE_CONCATENATE)
95
            return "S_CONCATENATE";
96
        else if (type == SHAPE_MERGE)
97
            return "S_MERGE";
98 99 100
        else if (type == SHAPE_MERGE_LIST)
            return "S_MERGE_LIST";
        else if (type == SHAPE_PERMUTE)
101
            return "S_PERMUTE";
102
        else if (type == SHAPE_SPLIT)
103
            return "S_SPLIT";
104 105 106
        else if (type == SHAPE_SPLIT_LIST)
            return "S_SPLIT_LIST";
        else if (type == SHAPE_TRANSPOSE)
107
            return "S_TRANSPOSE";
108
        else if (type == SHAPE_UNSQUEEZE)
109
            return "S_UNSQUEEZE";
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
        else if (type == SORT_SORT)
            return "S_SORT";
        else if (type == SORT_TOPK)
            return "S_TOPK";
    }
    else if ((type & FUNCTION_BASE) != 0){
        if (type == FUNC_HARDTANH)
            return "F_HARDTANH";
        else if (type == FUNC_IDENTITY)
            return "F_IDENTITY";
        else if (type == FUNC_LOGSOFTMAX)
            return "F_LOGSOFTMAX";
        else if (type == FUNC_RECTIFY)
            return "F_RECTIFY";
        else if (type == FUNC_SIGMOID)
            return "F_SIGMOID";
        else if (type == FUNC_SOFTMAX)
            return "F_SOFTMAX";
xiaotong committed
128 129 130 131 132 133 134
    }
    
    return "NULL";
}
    
} // namespace nts(NiuTrans.Tensor)