trt_ops.td 5.5 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
    I32ArrayAttr:$kernel_size,
    I32ArrayAttr:$strides,
    I32ArrayAttr:$paddings,
    StrAttr:$padding_mode,
    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,
    I32Attr:$pool_type,
    I32ArrayAttr:$window_size,
    I32ArrayAttr:$strides,
    I32ArrayAttr:$paddings,
W
Wilber 已提交
104 105 106 107
    I32Attr:$padding_mode,
    BoolAttr:$exclusive,
    BoolAttr:$adaptive,
    StrAttr:$padding_algorithm
W
Wilber 已提交
108 109 110 111 112 113
  );
  let results = (outs
    DenseTensor:$output_tensor
  );
}

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

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

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

W
Wilber 已提交
136
  let results = (outs DenseTensor:$output);
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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
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,
    I32Attr:$mode,
    DenseTensor:$shift,
    DenseTensor:$scale,
    DenseTensor:$power,
    I32Attr:$axis
  );

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

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

    TensorRT IShuffleLayer

  }];
  let arguments = (ins  
    DenseTensor:$input_tensor,
    I32ArrayAttr:$reshape
  );

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