Skip to content

[mlir] SCF reverse-mode derivatives #2348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

[mlir] SCF reverse-mode derivatives #2348

wants to merge 1 commit into from

Conversation

pengmai
Copy link
Member

@pengmai pengmai commented Jun 12, 2025

No description provided.

auto term = oBB.getTerminator();

for (auto &&[arg, operand] :
llvm::zip_equal(incomingGradients, term->getOperands())) {
Copy link
Contributor

@Pangoraw Pangoraw Jun 18, 2025

Choose a reason for hiding this comment

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

IIUC, incomingGradients can be smaller than term->getOperands() if at least one result is inactive

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, will fix and add a test

* fix enzyme-to-memref
@pengmai pengmai force-pushed the jmp/scf-reverse branch from 237bbe9 to 36e2e87 Compare July 7, 2025 20:37
MGradientUtilsReverse *gutils) const {
auto ifOp = cast<scf::IfOp>(op);

Operation *newOp = gutils->getNewFromOriginal(op);
Copy link
Member

Choose a reason for hiding this comment

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

Nit but if all the inner operations and resulting values are inactive we can skip storing this

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.

3 participants