trt_ops.td 5.1 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 104
    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,
    StrAttr:$padding_mode
W
Wilber 已提交
105 106 107 108 109 110
  );
  let results = (outs
    DenseTensor:$output_tensor
  );
}

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

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

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

W
Wilber 已提交
133
  let results = (outs DenseTensor:$output);
134 135
}

136 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
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);
}
204
#endif  // TRT_OPS