Home | History | Annotate | Download | only in grappler
      1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
      2 
      3 Licensed under the Apache License, Version 2.0 (the "License");
      4 you may not use this file except in compliance with the License.
      5 You may obtain a copy of the License at
      6 
      7     http://www.apache.org/licenses/LICENSE-2.0
      8 
      9 Unless required by applicable law or agreed to in writing, software
     10 distributed under the License is distributed on an "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 See the License for the specific language governing permissions and
     13 limitations under the License.
     14 ==============================================================================*/
     15 
     16 #ifndef TENSORFLOW_GRAPPLER_OP_TYPES_H_
     17 #define TENSORFLOW_GRAPPLER_OP_TYPES_H_
     18 
     19 #include "tensorflow/core/framework/node_def.pb.h"
     20 #include "tensorflow/core/lib/core/status.h"
     21 
     22 namespace tensorflow {
     23 namespace grappler {
     24 
     25 bool IsAdd(const NodeDef& node);
     26 bool IsAddN(const NodeDef& node);
     27 bool IsAll(const NodeDef& node);
     28 bool IsAngle(const NodeDef& node);
     29 bool IsAny(const NodeDef& node);
     30 bool IsAnyDiv(const NodeDef& node);
     31 bool IsApproximateEqual(const NodeDef& node);
     32 bool IsAvgPoolGrad(const NodeDef& node);
     33 bool IsAssert(const NodeDef& node);
     34 bool IsAtan2(const NodeDef& node);
     35 bool IsBetainc(const NodeDef& node);
     36 bool IsBiasAdd(const NodeDef& node);
     37 bool IsBiasAddGrad(const NodeDef& node);
     38 bool IsBitcast(const NodeDef& node);
     39 bool IsCast(const NodeDef& node);
     40 bool IsComplex(const NodeDef& node);
     41 bool IsComplexAbs(const NodeDef& node);
     42 bool IsConj(const NodeDef& node);
     43 bool IsConcatOffset(const NodeDef& node);
     44 bool IsConstant(const NodeDef& node);
     45 bool IsConv2D(const NodeDef& node);
     46 bool IsConv2DBackpropFilter(const NodeDef& node);
     47 bool IsConv2DBackpropInput(const NodeDef& node);
     48 bool IsDepthwiseConv2dNative(const NodeDef& node);
     49 bool IsDepthwiseConv2dNativeBackpropFilter(const NodeDef& node);
     50 bool IsDepthwiseConv2dNativeBackpropInput(const NodeDef& node);
     51 bool IsDequeueOp(const NodeDef& node);
     52 bool IsDiv(const NodeDef& node);
     53 bool IsEluGrad(const NodeDef& node);
     54 bool IsEnter(const NodeDef& node);
     55 bool IsEqual(const NodeDef& node);
     56 bool IsExit(const NodeDef& node);
     57 bool IsFill(const NodeDef& node);
     58 bool IsFloorDiv(const NodeDef& node);
     59 bool IsFloorMod(const NodeDef& node);
     60 bool IsFusedBatchNormGrad(const NodeDef& node);
     61 bool IsGreater(const NodeDef& node);
     62 bool IsGreaterEqual(const NodeDef& node);
     63 bool IsHistogramSummary(const NodeDef& node);
     64 bool IsIdentity(const NodeDef& node);
     65 bool IsIdentityN(const NodeDef& node);
     66 bool IsIgamma(const NodeDef& node);
     67 bool IsIgammac(const NodeDef& node);
     68 bool IsImag(const NodeDef& node);
     69 bool IsInvGrad(const NodeDef& node);
     70 bool IsLess(const NodeDef& node);
     71 bool IsLessEqual(const NodeDef& node);
     72 bool IsLogicalAnd(const NodeDef& node);
     73 bool IsLogicalNot(const NodeDef& node);
     74 bool IsLogicalOr(const NodeDef& node);
     75 bool IsMax(const NodeDef& node);
     76 bool IsMaximum(const NodeDef& node);
     77 bool IsMean(const NodeDef& node);
     78 bool IsMerge(const NodeDef& node);
     79 bool IsMin(const NodeDef& node);
     80 bool IsMinimum(const NodeDef& node);
     81 bool IsMirrorPad(const NodeDef& node);
     82 bool IsMirrorPadGrad(const NodeDef& node);
     83 bool IsMod(const NodeDef& node);
     84 bool IsMul(const NodeDef& node);
     85 bool IsMatMul(const NodeDef& node);
     86 bool IsNextIteration(const NodeDef& node);
     87 bool IsPad(const NodeDef& node);
     88 bool IsNoOp(const NodeDef& node);
     89 bool IsNotEqual(const NodeDef& node);
     90 bool IsPlaceholder(const NodeDef& node);
     91 bool IsPolygamma(const NodeDef& node);
     92 bool IsProd(const NodeDef& node);
     93 bool IsPow(const NodeDef& node);
     94 bool IsReal(const NodeDef& node);
     95 bool IsRealDiv(const NodeDef& node);
     96 bool IsRelu6Grad(const NodeDef& node);
     97 bool IsReluGrad(const NodeDef& node);
     98 bool IsReciprocalGrad(const NodeDef& node);
     99 bool IsRecv(const NodeDef& node);
    100 bool IsReduction(const NodeDef& node);
    101 bool IsReshape(const NodeDef& node);
    102 bool IsRestore(const NodeDef& node);
    103 bool IsReverseV2(const NodeDef& node);
    104 bool IsRsqrtGrad(const NodeDef& node);
    105 bool IsSelect(const NodeDef& node);
    106 bool IsSeluGrad(const NodeDef& node);
    107 bool IsSend(const NodeDef& node);
    108 bool IsSlice(const NodeDef& node);
    109 bool IsShape(const NodeDef& node);
    110 bool IsShapeN(const NodeDef& node);
    111 bool IsSigmoidGrad(const NodeDef& node);
    112 bool IsSoftplusGrad(const NodeDef& node);
    113 bool IsSoftsignGrad(const NodeDef& node);
    114 bool IsSplit(const NodeDef& node);
    115 bool IsSplitV(const NodeDef& node);
    116 bool IsSqrtGrad(const NodeDef& node);
    117 bool IsSquaredDifference(const NodeDef& node);
    118 bool IsSqueeze(const NodeDef& node);
    119 bool IsStopGradient(const NodeDef& node);
    120 bool IsStridedSlice(const NodeDef& node);
    121 bool IsStridedSliceGrad(const NodeDef& node);
    122 bool IsSub(const NodeDef& node);
    123 bool IsSum(const NodeDef& node);
    124 bool IsSwitch(const NodeDef& node);
    125 bool IsTanhGrad(const NodeDef& node);
    126 bool IsTile(const NodeDef& node);
    127 bool IsTranspose(const NodeDef& node);
    128 bool IsTruncateDiv(const NodeDef& node);
    129 bool IsTruncateMod(const NodeDef& node);
    130 bool IsVariable(const NodeDef& node);
    131 bool IsZeta(const NodeDef& node);
    132 
    133 // Return true if the op is an aggregation (e.g. Add, AddN).
    134 // Returns false if it could not be determined to be so.
    135 bool IsAggregate(const NodeDef& node);
    136 
    137 // Return true if the op is commutative (e.g. Mul, Add).
    138 // Returns false if it could not be determined to be so.
    139 bool IsCommutative(const NodeDef& node);
    140 
    141 // Returns true if the node is known to use persistent memory to store its
    142 // value.
    143 bool IsPersistent(const NodeDef& node);
    144 
    145 bool IsFreeOfSideEffect(const NodeDef& node);
    146 bool ModifiesFrameInfo(const NodeDef& node);
    147 
    148 // Returns true if the op is an element-wise involution, i.e. if it is its
    149 // own inverse such that f(f(x)) == x.
    150 bool IsInvolution(const NodeDef& node);
    151 
    152 // Returns true if the op in node only rearranges the order of elements in its
    153 // first input tensor and possible changes its shape. More precisely, this
    154 // function returns true if the op commutes with all element-wise operations.
    155 bool IsValuePreserving(const NodeDef& node);
    156 
    157 // Returns true if we can find an opdef corresponding to the op of the node.
    158 bool HasOpDef(const NodeDef& node);
    159 
    160 }  // end namespace grappler
    161 }  // end namespace tensorflow
    162 
    163 #endif  // TENSORFLOW_GRAPPLER_OP_TYPES_H_
    164