pd_ops.td 5.7 KB
Newer Older
Y
Yan Chunwei 已提交
1 2 3 4 5 6 7 8
#ifndef PD_OPS
#define PD_OPS

include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/LoopLikeInterface.td"
include "mlir/IR/OpBase.td"
include "paddle/infrt/dialect/pd_op_base.td"

9
def PD_FeedOp : PD_Op<"feed", [NoSideEffect]> {
Y
Yan Chunwei 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23
  let summary = "Feed Op";

  let description = [{
    Feed a tensor into the model.
  }];

  let arguments = (ins);
  let results = (outs PD_Tensor:$out);

  let assemblyFormat = [{
      `(` `)` attr-dict `:` type($out)
  }];
}

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
def PD_FetchOp : PD_Op<"fetch", [Terminator]> {
  let summary = "fetch Op";

  let description = [{
    Fetch tensor from the graph.
  }];

  let arguments = (ins Variadic<PD_Tensor>:$inputs);
}

def PD_GraphOp : PD_Op<"graph", [SingleBlockImplicitTerminator<"FetchOp">]> {
  let summary = "paddle graph Op";
  let description = [{
    Describe a paddle graph or subgraph.
  }];
  let regions = (region SizedRegion<1>:$body);
  let arguments = (ins Variadic<PD_Tensor>:$inputs);
  let results = (outs Variadic<PD_Tensor>:$outputs);
}

44
def PD_ConstantOp : PD_Op<"constant", [NoSideEffect, ConstantLike, DeclareOpInterfaceMethods<InferTypeOpInterface>, AllTypesMatch<["value", "output"]>]> {
Y
Yan Chunwei 已提交
45 46 47 48 49 50 51 52 53 54 55 56
  let summary = "constant Op";
  let description = [{}];

  let arguments = (ins ElementsAttr:$value);
  let results = (outs PD_Tensor:$output);
  let hasFolder = 1;

  let builders = [
    OpBuilder<"OpBuilder &builder, OperationState &state, Attribute value">,
  ];
}

57
def PD_AbsOp : PD_Op<"abs", [NoSideEffect, SameOperandsAndResultType]> {
Y
Yan Chunwei 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
  let summary = "Computes the absolute value of a tensor";

  let description = [{
  }];

  let arguments = (ins PD_Tensor:$x);
  let results = (outs PD_Tensor:$y);
}

def PD_SqrtOp : PD_Op<"sqrt", [NoSideEffect, SameOperandsAndResultType]> {
  let summary = "Computes the sqrt value of a tensor";

  let description = [{
  }];

  let arguments = (ins PD_Tensor:$x);
  let results = (outs PD_Tensor:$y);
}

77
def PD_ReluOp : PD_Op<"relu", [NoSideEffect, SameOperandsAndResultType]> {
Y
Yan Chunwei 已提交
78 79 80 81 82 83 84 85 86 87
  let summary = "Computes the Relu of a tensor";

  let description = [{
  }];

  let arguments = (ins PD_Tensor:$x);
  let results = (outs PD_Tensor:$y);
  let hasCanonicalizer = 1;
}

88
def PD_Relu6Op : PD_Op<"relu6", [NoSideEffect, SameOperandsAndResultType]> {
Y
Yan Chunwei 已提交
89 90 91 92 93 94 95 96 97
  let summary = "Computes the Relu6 of a tensor";

  let description = [{
  }];

  let arguments = (ins PD_Tensor:$x);
  let results = (outs PD_Tensor:$y);
}

98
def PD_ElementwiseAdd : PD_Op<"elementwise_add", [NoSideEffect, Commutative, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
Y
Yan Chunwei 已提交
99 100 101 102 103 104 105 106 107 108
  let summary = "ElementwiseAdd Op";
  let description = [{
  }];

  let arguments = (ins PD_Tensor:$x, PD_Tensor:$y, DefaultValuedAttr<I32Attr, "-1">:$axis);
  let results = (outs PD_Tensor:$out);
  let hasCanonicalizer = 1;
  let hasFolder = 1;
}

109
def PD_ElementwiseSub : PD_Op<"elementwise_sub", [NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
Y
Yan Chunwei 已提交
110 111 112 113 114 115 116 117
  let summary = "ElementwiseSub Op";
  let description = [{
  }];

  let arguments = (ins PD_Tensor:$x, PD_Tensor:$y, DefaultValuedAttr<I32Attr, "-1">:$axis);
  let results = (outs PD_Tensor:$out);
}

118
def PD_ElementwiseMul : PD_Op<"elementwise_mul", [NoSideEffect, Commutative, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
Y
Yan Chunwei 已提交
119 120 121 122 123 124 125 126
  let summary = "ElementwiseMul Op";
  let description = [{
  }];

  let arguments = (ins PD_Tensor:$x, PD_Tensor:$y, DefaultValuedAttr<I32Attr, "-1">:$axis);
  let results = (outs PD_Tensor:$out);
}

127
def PD_ElementwiseDiv : PD_Op<"elementwise_div", [NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
Y
Yan Chunwei 已提交
128 129 130 131 132 133 134 135
  let summary = "ElementwiseDiv Op";
  let description = [{
  }];

  let arguments = (ins PD_Tensor:$x, PD_Tensor:$y, DefaultValuedAttr<I32Attr, "-1">:$axis);
  let results = (outs PD_Tensor:$out);
}

136
def PD_MatmulOp : PD_Op<"matmul", [NoSideEffect]> {
Y
Yan Chunwei 已提交
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
  let summary = "Computes the matrix mulplication result of two tensors";
  let description = [{
  }];

  let arguments = (ins PD_Tensor:$x, PD_Tensor:$y,
                  DefaultValuedAttr<BoolAttr, "false">:$transpose_x,
                  DefaultValuedAttr<BoolAttr, "false">:$transpose_y,
                  DefaultValuedAttr<F32Attr, "1.0">:$alpha);
  let results = (outs PD_Tensor:$out);

  //let hasCanonicalizer = 1;
}

def PD_MulOp : PD_Op<"mul", [NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
  let summary = "paddle mul op";
  let description = [{}];

  let arguments = (ins PD_Tensor:$x, PD_Tensor:$y);
  let results = (outs PD_Tensor:$out);

  //let hasCanonicalizer = 1;
}

def PD_Conv2dOp : PD_Op<"conv2d", [NoSideEffect]> {
  let summary = "paddle conv2d operation";
  let description = [{
  }];

  let arguments = (ins PD_Tensor:$Input, PD_Tensor:$Filter, PD_Tensor:$Bias);
  let results = (outs PD_Tensor:$Output);

  //let hasCanonicalizer = 1;
}

def PD_BatchNormOp : PD_Op<"batch_norm", [NoSideEffect]> {
  let summary = "paddle batch_norm operation";
  let description = [{
  }];

  let arguments = (ins PD_Tensor:$X, PD_Tensor:$Scale, PD_Tensor:$Bias,
                   PD_Tensor:$Mean, PD_Tensor:$Variance,
                   DefaultValuedAttr<F32Attr, "1e-05">:$epsilon);
  let results = (outs PD_Tensor:$Y);

  let hasCanonicalizer = 1;
}

184
def PD_FusedFC : PD_Op<"fc", [NoSideEffect]> {
Y
Yan Chunwei 已提交
185 186 187 188 189 190 191 192
    let summary = "Computes the Fully Connected result of two tensors";
    let description = [{
    }];

    let arguments = (ins PD_Tensor:$input, PD_Tensor:$w, PD_Tensor:$bias, DefaultValuedAttr<I32Attr, "1">:$in_num_col_dims);
    let results = (outs PD_Tensor:$out);
}

193
def PD_FusedRepeatedFCRelu : PD_Op<"fusion_repeated_fc_relu", [SameVariadicOperandSize, NoSideEffect]> {
Y
Yan Chunwei 已提交
194 195 196 197 198 199 200 201 202
    let summary = "";
    let description = [{ }];

    let arguments = (ins PD_Tensor:$input, Variadic<PD_Tensor>:$w, Variadic<PD_Tensor>:$bias);
    let results = (outs PD_Tensor:$out);
    let hasCanonicalizer = 1;
}

#endif  // PD_OPS