infrt_phi_tensor.td 1.9 KB
Newer Older
1
#ifdef PHI_TENSOR
2
#else
3
#define PHI_TENSOR
4

5
include "paddle/infrt/dialect/phi/ir/infrt_phi_base.td"
6 7
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/IR/OpBase.td"
8
include "paddle/infrt/dialect/infrt/ir/infrt_base.td"
9

10 11
def PHI_DenseTensorDialect : Dialect {
  let name = "phi_dt";
12 13

  let description = [{
14
    The PHI DenseTensor dialect.
15 16
  }];

17
  let cppNamespace = "::infrt::phi";
18 19
}

20
// PHI DenseTensor related Op.
21 22
class PDT_Op<string mnemonic, list<OpTrait> traits = []> : Op<PHI_DenseTensorDialect,
  mnemonic, !listconcat(traits, [PhiOpTrait, IsolatedFromAbove])> {}
23

24 25 26 27
class CreateDenseTensorOp 
      : PDT_Op<"create_dense_tensor", [NoSideEffect]> {
  let arguments = (ins Context:$context, I64ArrayAttr:$dims, 
    LayoutAttr:$layout, I64ArrayAttr:$lod, PrecisionAttr:$precision);
28
  let results = (outs DenseTensor:$output);
29 30
}

31 32
class FillDenseTensorOp<Attr attr_type, string dtype> :
      PDT_Op<"fill_dense_tensor." # dtype> {
33
  let arguments = (ins
34
      DenseTensor:$input,
35 36 37
      attr_type:$value
  );
  let results = (outs);
38 39 40 41 42 43 44 45
  let assemblyFormat = "`(` $input `:` type($input) `)` attr-dict";
}

class PrintDenseTensorOp:
      PDT_Op<"print_tensor"> {
  let arguments = (ins DenseTensor:$input);
  let results = (outs);
  let assemblyFormat = "`(` $input `:` type($input) `)` attr-dict";
46 47
}

48 49
class CreateContextOp<string target>
      : PDT_Op<"create_context." # target, [NoSideEffect]> {
50
  let arguments = (ins);
51
  let results = (outs Context:$output);
52 53
}

54
def PDT_CreateDenseTensorOp : CreateDenseTensorOp;
55
def PDT_FillDenseTensorOp_f32 : FillDenseTensorOp<F32ArrayAttr, "f32">;
56 57
def PDT_CreateCPUContextOp : CreateContextOp<"cpu">;
def PDT_PrintDenseTensor : PrintDenseTensorOp;
58

59
def FakeKernelOp : PDT_Op<"fake_phi_kernel"> {
60
  let arguments = (ins Context:$dev_ctx, DenseTensor:$x, DenseTensor:$y, BoolAttr:$transpose_x, BoolAttr:$transpose_y);
61 62 63
  let results = (outs DenseTensor:$output);
}

64
#endif