In this document, we summarize the guidelines for implementing and reviewing an op for the interpreter. We have intentionally included a few auxiliary action items related to verifier and type inference, with the idea of making progress on those fronts alongside the interpreter implementation.
While implementing the op:
After implementing the op:
In StablehloOps.td:
Make sure that the summary
in the op's ODS follows the standard format. (related ticket)
Add comments referencing constraint labels (e.g. Cn
or In
) from the spec in the format xyz_cn
or xyz_in
, for op XyzOp
, to identify the correspondence between constraints in ODS and the specification. The following example shows how to add the constraint labels as comments alongside mlir Traits
and TypeConstraints
. Note xyz_c4
refers to constraints defined in StableHLO_FooOp
class (e.g. StableHLO_ShapedInterfaceOp
, StableHLO_UnaryElementwiseOp
, StableHLO_Op
, etc.).
def StableHLO_XyzOp: StableHLO_FooOp<"xyz", [Trait1, Trait2 /*xyz_c1, xyz_c2*/, InferTensorType /*xyz_c3*/]> { /*xyz_c4*/ ... let summary = "Xyz operation"; let arguments = (ins 1DTensorOf<[HLO_Float]>:$a, /*xyz_c5, xyz_i1*/ HLO_Tensor:$b, /*xyz_i2*/ .... ); );
In TypeInference.cpp and StablehloOps.cpp:
Cn
or In
) from the spec in the format xyz_cn
or xyz_in
, for op XyzOp
, to identify which parts of verifiers and shape functions correspond to which constraints in the specification.xyz_cn...xyz_cm, xyz_in...xyz_jn
.interpret_<op_mnemonic>.mlir
.In the testdata directory:
RUN-DISABLED
to RUN
.RUN-DISABLED(#1278)
(if it's not already done).CHECK-LABEL
lit macro.xyz_cn_im_...
for a function testing constraints Cn
, Im
, etc. for op XyzOp
. In cases when the proposed format does not apply, keep the existing name.In spec.md:
interpret_<op_mnemonic>.mlir
to the “Examples” section (e.g. More Examples).In status.md:
yes
.