opencompl / mlir-fuzz

A enumerator for MLIR, relying on the information given by IRDL.
15 stars 4 forks source link

function isValidReturnType added #2

Closed Hatsunespica closed 1 year ago

Hatsunespica commented 1 year ago

Check if the given OperationOp can use specified type as a valid return type. bool isValidReturnType(GeneratorInfo &info, irdl::OperationOp op, mlir::Type type)

For each constraint variable, we try to assign the constraint with the provided type. Otherwise use random one from all satisfied types.

Hatsunespica commented 1 year ago

Hi Mathieu,

Thanks for your reviewing! I’ll update my code like you suggested 0w0.

All the best, Yuyou On Thu, Oct 20, 2022 at 13:23 Fehr Mathieu @.***> wrote:

@.**** commented on this pull request.

In mlir-enumerate/mlir-enumerate.cpp https://github.com/opencompl/mlir-fuzz/pull/2#discussion_r1001029540:

  • if (constraintOp) {
  • for (auto namedConstraintAttr : constraintOp->getParams()) {
  • auto namedConstraint =
  • namedConstraintAttr.cast();
  • auto constraint =
  • namedConstraint.getConstraint()
  • .cast()
  • .getTypeConstraint(info.irdlContext, namedConstraintVars);
  • // TODO(fehr) Currently a hack, will be fixed later once I update
  • // the IRDL API.
  • auto constraint2 =
  • namedConstraint.getConstraint()
  • .cast()
  • .getTypeConstraint(info.irdlContext, namedConstraintVars);
  • if (constraint.get()

You do not actually need to assign any type on the constraints here. This should be done automatically when you check that the result types are satisfying the constraints. So when you check something like Vector with the type Vector for instance, T will be set to i32 in the verifyType function.

So for here, you can actually just check the result constraints, without dealing manually with the constraint variables. You still though have to fill namedConstraintVars, varConstraints, and vars. But you should just set each Type to Type() in vars if I recall correctly.

— Reply to this email directly, view it on GitHub https://github.com/opencompl/mlir-fuzz/pull/2#pullrequestreview-1149845250, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2SKR6Z3OUSU2ZKA4UIWF3WEGL2NANCNFSM6AAAAAARIS3TCE . You are receiving this because you modified the open/close state.Message ID: @.***>

Hatsunespica commented 1 year ago

Hi Mathieu,

I updated the branch with what you said! Does it look good? 0w0

math-fehr commented 1 year ago

Perfect, thanks a lot!