Skip to content

Update GradientUtils.cpp #2234

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions enzyme/Enzyme/GradientUtils.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

@wsmoses With this commit, it resolved the problem. Thanks for the help!

Copy link
Contributor

Choose a reason for hiding this comment

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

@wsmoses add } else if (M.getTargetTriple().find("nvptx") != std::string::npos) { to PreserveNVVM.cpp resolve the custom gradient issue for the cuda.

Copy link
Member Author

Choose a reason for hiding this comment

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

@minansys can you make a PR with?

Copy link
Contributor

@minansys minansys Feb 6, 2025

Choose a reason for hiding this comment

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

@wsmoses I tried to create a PR, however got the following error:

git push origin --set-upstream mixu/cuda-custom-gradient
remote: Permission to EnzymeAD/Enzyme.git denied to minansys.
fatal: unable to access 'https://github.com/EnzymeAD/Enzyme/': The requested URL returned error: 403

It seems I do not have the write right for the repo. I am using https and PAT instead of ssh. Is there any step to grant my write? Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@wsmoses @giordano I have created the PR using a fork. Thanks!

Original file line number Diff line number Diff line change
Expand Up @@ -2480,6 +2480,11 @@ Value *GradientUtils::fixLCSSA(Instruction *inst, BasicBlock *forwardBlock,
// TODO replace forwardBlock with the first block dominated by inst,
// that dominates (or is) forwardBlock to ensuring maximum reuse
IRBuilder<> lcssa(&forwardBlock->front());
#if LLVM_VERSION_MAJOR >= 18
auto It = lcssa.GetInsertPoint();
It.setHeadBit(true);
lcssa.SetInsertPoint(It);
#endif
auto lcssaPHI =
lcssa.CreatePHI(inst->getType(), 1, inst->getName() + "!manual_lcssa");
lcssaFixes[inst][forwardBlock] = lcssaPHI;
Expand Down
Loading