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

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

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 21
// PHI DenseTensor related Op.
class PDT_Op<string mnemonic, list<OpTrait> traits = []> : Op<PHI_DenseTensorDialect, mnemonic, !listconcat(traits, [IsolatedFromAbove])> {
22 23
}

24 25 26
class CreateDenseTensorOp<string place, string dtype, string layout> 
      : PDT_Op<"create_dense_tensor." # place # "." # dtype # "." # layout, [NoSideEffect]> {
  let arguments = (ins CPU_Allocator:$allocator, I64ArrayAttr:$dims, I64ArrayAttr:$lod);
27
  let results = (outs DenseTensor:$output);
28 29
}

30 31
class FillDenseTensorOp<Attr attr_type, string dtype> :
      PDT_Op<"fill_dense_tensor." # dtype> {
32
  let arguments = (ins
33
      DenseTensor:$input,
34 35 36 37 38
      attr_type:$value
  );
  let results = (outs);
}

39 40 41 42
class CreateCPUAllocatorOp
      : PDT_Op<"create_allocator." # "cpu", [NoSideEffect]> {
  let arguments = (ins);
  let results = (outs CPU_Allocator:$output);
43 44
}

45 46 47 48
class CreateCPUContextOp
      : PDT_Op<"create_context." # "cpu", [NoSideEffect]> {
  let arguments = (ins);
  let results = (outs CPU_Context:$output);
49 50
}

51 52 53 54
def PDT_CreateDenseTensorOp_cpu_f32_nchw : CreateDenseTensorOp<"cpu", "f32", "nchw">;
def PDT_FillDenseTensorOp_f32 : FillDenseTensorOp<F32ArrayAttr, "f32">;
def PDT_CreateAllocatorOp_cpu : CreateCPUAllocatorOp;
def PDT_CreateContextOp_cpu : CreateCPUContextOp;
55 56

#endif