Skip to content

Conversation

@wzyyy-lab
Copy link
Collaborator

add conversion code about arith.cmpf to neura.fcmp in ArithToNeuraPass.app.
Add the test in arith2neura,with the name of cmpf.mlir.

Comment on lines 216 to 246
switch (arith_cmp_type) {
case arith::CmpIPredicate::eq:
cmp_type = "eq"; // ==
break;
case arith::CmpIPredicate::ne:
cmp_type = "ne"; // !=
break;
case arith::CmpIPredicate::slt:
cmp_type = "slt"; // <
break;
case arith::CmpIPredicate::sle:
cmp_type = "sle"; // <=
break;
case arith::CmpIPredicate::sgt:
cmp_type = "sgt"; // >
break;
case arith::CmpIPredicate::sge:
cmp_type = "sge"; // >=
break;
case arith::CmpIPredicate::ult:
cmp_type = "ult"; // unsigned <
break;
case arith::CmpIPredicate::ule:
cmp_type = "ule"; // unsigned <=
break;
case arith::CmpIPredicate::ugt:
cmp_type = "ugt"; // unsigned >
break;
case arith::CmpIPredicate::uge:
cmp_type = "uge"; // unsigned >=
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz help refactor these via the same way as you used for floating-point cmp, i.e.,

StringRef predicate_str = arith::stringifyCmpFPredicate(predicate_enum);
StringAttr predicate_attr = rewriter.getStringAttr(predicate_str);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs fix?

@tancheng tancheng linked an issue Oct 21, 2025 that may be closed by this pull request
@tancheng
Copy link
Contributor

Can you also check the neura-interpreter.cpp and fmax.mlir in
https://github.com/coredac/dataflow/pull/166/files#diff-fd11449b9be503db82690ed31d05c792978b4b5b9d209cc31e49a97891fd64efR913

to see how to support interpreter for the fcmp? It basically verify the functionality by emulating the execution of newly added operations. Plz let me know if anything is unclear to you. Thanks~!

Added missing newline at the end of the file and restored previous comments.
@wzyyy-lab
Copy link
Collaborator Author

Can you also check the and in https://github.com/coredac/dataflow/pull/166/files#diff-fd11449b9be503db82690ed31d05c792978b4b5b9d209cc31e49a97891fd64efR913`neura-interpreter.cpp``fmax.mlir`

to see how to support interpreter for the fcmp? It basically verify the functionality by emulating the execution of newly added operations. Plz let me know if anything is unclear to you. Thanks~!

I apologize for the delay caused by some matters recently. I have now resubmitted it.

StringRef predicate_str = arith::stringifyCmpFPredicate(predicate_enum);

StringAttr predicate_attr = rewriter.getStringAttr(predicate_str);
// Converts arith CmpFOp to Neura FCmpOp.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment also needs indent.

Comment on lines 216 to 246
switch (arith_cmp_type) {
case arith::CmpIPredicate::eq:
cmp_type = "eq"; // ==
break;
case arith::CmpIPredicate::ne:
cmp_type = "ne"; // !=
break;
case arith::CmpIPredicate::slt:
cmp_type = "slt"; // <
break;
case arith::CmpIPredicate::sle:
cmp_type = "sle"; // <=
break;
case arith::CmpIPredicate::sgt:
cmp_type = "sgt"; // >
break;
case arith::CmpIPredicate::sge:
cmp_type = "sge"; // >=
break;
case arith::CmpIPredicate::ult:
cmp_type = "ult"; // unsigned <
break;
case arith::CmpIPredicate::ule:
cmp_type = "ule"; // unsigned <=
break;
case arith::CmpIPredicate::ugt:
cmp_type = "ugt"; // unsigned >
break;
case arith::CmpIPredicate::uge:
cmp_type = "uge"; // unsigned >=
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] Missing conversion from arith.cmpf to neura.fcmp

2 participants