trt_ops.td 5.6 KB
Newer Older
1 2 3 4 5 6 7 8 9
#ifndef TRT_OPS
#define TRT_OPS

include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/LoopLikeInterface.td"
include "mlir/Interfaces/CallInterfaces.td"
include "mlir/IR/OpBase.td"
include "paddle/infrt/dialect/tensorrt/trt_op_base.td"

W
Wilber 已提交
10 11
include "paddle/infrt/dialect/infrt/ir/infrt_base.td"
include "paddle/infrt/dialect/phi/ir/infrt_phi_base.td"
12
include "paddle/infrt/dialect/pd/ir/pd_op_base.td"
S
Shang Zhizhou 已提交
13 14 15

def TRT_CreateEngineOp : TRT_Op<"create_engine", [SingleBlockImplicitTerminator<"::infrt::ReturnOp">]> {
  let summary = "trt CreateEngine Op";
16 17 18 19
  let description = [{
    Describe a tensorrt subgraph.
  }];
  let regions = (region SizedRegion<1>:$body);
20
  let arguments = (ins Variadic<PD_Tensor>:$inputs, DefaultValuedAttr<BoolAttr, "true">:$run_once);
W
Wilber 已提交
21
  let results = (outs TRT_EngineType:$engine);
S
Shang Zhizhou 已提交
22 23
}

W
Wilber 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
def TRT_EngineComputeOp : TRT_Op<"compute", [NoSideEffect]> {
  let summary = "trt compute engine";
  let description = [{
    execute engine
  }];
  let arguments = (ins TRT_EngineType:$engine, Context:$context);
  let results = (outs DenseTensorList:$outputs);
}

def TRT_InspectEngineOp : TRT_Op<"inspect_engine", [NoSideEffect]> {
  let summary = "trt inspect engine";
  let description = [{
    Show engine
  }];
  let arguments = (ins TRT_EngineType:$engine);
39
}
40 41 42 43 44 45 46 47

def TRT_ActivationOp : TRT_Op<"Activation", [NoSideEffect]> {
  let summary = "TensorRT IActivationLayer";
  let description = [{
    
    TensorRT IActivationLayer.
    
  }];
W
Wilber 已提交
48
  let arguments = (ins  DenseTensor:$input, SI32Attr:$activation_type,
49 50 51
                        DefaultValuedAttr<F32Attr, "0.0">:$alpha,
                        DefaultValuedAttr<F32Attr, "0.0">:$beta);

W
Wilber 已提交
52
  let results = (outs DenseTensor:$output);
53 54
}

W
Wilber 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
def TRT_FullyConnectedOp : TRT_Op<"FullyConnected", [NoSideEffect]> {
  let summary = "TensorRT IFullyConnectedLayer";
  let description = [{
    TensorRT IFullyConnectedLayer
  }];
  let arguments = (ins
    DenseTensor:$input_tensor,
    DenseTensor:$kernel_weights,
    DenseTensor:$bias_weights,
    SI32Attr:$out_channel_num
  );
  let results = (outs
    DenseTensor:$output_tensor
  );
}

def TRT_ConvolutionOp : TRT_Op<"Convolution", [NoSideEffect]> {
  let summary = "TensorRT IConvolutionLayer";
  let description = [{
    TensorRT IConvolutionLayer
  }];
  let arguments = (ins
    DenseTensor:$input_tensor,
    DenseTensor:$kernel_weights,
79
    Optional<DenseTensor>:$bias_weights,
W
Wilber 已提交
80
    SI32Attr:$out_channel_num,
81 82 83
    I32ArrayAttr:$kernel_size,
    I32ArrayAttr:$strides,
    I32ArrayAttr:$paddings,
84 85 86
    I32ArrayAttr:$pre_paddings,
    I32ArrayAttr:$post_paddings,
    DefaultValuedAttr<SI32Attr, "0">:$padding_mode, //kEXPLICIT_ROUND_DOWN
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    SI32Attr:$groups,
    I32ArrayAttr:$dilations
  );
  let results = (outs
    DenseTensor:$output_tensor
  );
}

def TRT_PoolingOp : TRT_Op<"Pooling", [NoSideEffect]> {
  let summary = "TensorRT IPoolingLayer ";
  let description = [{
    TensorRT IPoolingLayer
  }];
  let arguments = (ins
    DenseTensor:$input_tensor,
102
    SI32Attr:$pool_type,
103 104 105
    I32ArrayAttr:$window_size,
    I32ArrayAttr:$strides,
    I32ArrayAttr:$paddings,
106
    SI32Attr:$padding_mode,
W
Wilber 已提交
107 108 109
    BoolAttr:$exclusive,
    BoolAttr:$adaptive,
    StrAttr:$padding_algorithm
W
Wilber 已提交
110 111 112 113 114 115
  );
  let results = (outs
    DenseTensor:$output_tensor
  );
}

116 117 118 119 120 121 122
def TRT_ElementWiseOp : TRT_Op<"ElementWise", [NoSideEffect]> {
  let summary = "TensorRT IElementWiseLayer";
  let description = [{
    
    TensorRT IElementWiseLayer.
    
  }];
W
Wilber 已提交
123
  let arguments = (ins  DenseTensor:$input1, DenseTensor:$input2, SI32Attr:$elementwise_operation);
124

W
Wilber 已提交
125
  let results = (outs DenseTensor:$output);
126 127 128 129 130 131 132 133 134
}

def TRT_MatrixMultiplyOp : TRT_Op<"MatrixMultiply", [NoSideEffect]> {
  let summary = "TensorRT IMatrixMultiplyLayer";
  let description = [{
    
    TensorRT IMatrixMultiplyLayer.
    
  }];
W
Wilber 已提交
135 136
  let arguments = (ins  DenseTensor:$input1, BoolAttr:$transpose1,
                        DenseTensor:$input2, BoolAttr:$transpose2);
137

W
Wilber 已提交
138
  let results = (outs DenseTensor:$output);
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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
def TRT_ScaleOp : TRT_Op<"scale", [NoSideEffect]> {
  let summary = "TensorRT IScaleLayer";
  let description = [{

    TensorRT IScaleLayer

  }];
  let arguments = (ins  
    DenseTensor:$input_tensor,
    DefaultValuedAttr<I32Attr, "0">:$mode, 
    DenseTensor:$shift,
    DenseTensor:$scale,
    DenseTensor:$power
  );

  let results = (outs DenseTensor:$Out);
}

def TRT_MatrixMultiplOp : TRT_Op<"MatrixMultiplOp", [NoSideEffect]> {
  let summary = "TensorRT IMatrixMultiplyLayer";
  let description = [{

    TensorRT IMatrixMultiplyLayer

  }];
  let arguments = (ins  
    DenseTensor:$input1,
    DefaultValuedAttr<I32Attr, "0">:$matrix_operation1, 
    DenseTensor:$input2,
    DefaultValuedAttr<I32Attr, "0">:$matrix_operation2
  );

  let results = (outs DenseTensor:$Out);
}

def TRT_SoftMaxOp : TRT_Op<"SoftMaxOp", [NoSideEffect]> {
  let summary = "TensorRT ISoftMaxLayer";
  let description = [{

    TensorRT ISoftMaxLayer

  }];
  let arguments = (ins  
    DenseTensor:$input_tensor,
    SI32Attr:$axis
  );

  let results = (outs DenseTensor:$Out);
}

def TRT_ScaleNdOp : TRT_Op<"ScaleNd", [NoSideEffect]> {
  let summary = "TensorRT IScaleLayer";
  let description = [{

    TensorRT IScaleLayer

  }];
  let arguments = (ins  
    DenseTensor:$input_tensor,
    DenseTensor:$shift,
    DenseTensor:$scale,
202
    Optional<DenseTensor>:$power
203 204 205 206
  );

  let results = (outs DenseTensor:$Out);
}
207 208 209 210 211 212 213 214 215 216

def TRT_ShuffleOp : TRT_Op<"Shuffle", [NoSideEffect]> {
  let summary = "TensorRT IShuffleLayer";
  let description = [{

    TensorRT IShuffleLayer

  }];
  let arguments = (ins  
    DenseTensor:$input_tensor,
217 218
    DefaultValuedAttr<SI32Attr, "1">:$start_axis,
    DefaultValuedAttr<SI32Attr, "1">:$stop_axis
219 220 221 222
  );

  let results = (outs DenseTensor:$Out);
}
223
#endif  // TRT_OPS