Skip to content

Commit

Permalink
Custom Forward Derivative (rust-lang#347)
Browse files Browse the repository at this point in the history
* refactor run on module

* add enzyme_derivative
  • Loading branch information
tgymnich authored Oct 4, 2021
1 parent ced60a9 commit f426b09
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 190 deletions.
6 changes: 4 additions & 2 deletions enzyme/Enzyme/ActivityAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ bool ActivityAnalyzer::isConstantValue(TypeResults &TR, Value *Val) {
// abide by those rules
if (!isCertainPrintMallocOrFree(called) && called->empty() &&
!hasMetadata(called, "enzyme_gradient") &&
!hasMetadata(called, "enzyme_derivative") &&
!isa<IntrinsicInst>(op) && EnzymeEmptyFnInactive) {
InsertConstantValue(TR, Val);
insertConstantsFrom(TR, *UpHypothesis);
Expand Down Expand Up @@ -1666,8 +1667,9 @@ bool ActivityAnalyzer::isInstructionInactiveFromOrigin(TypeResults &TR,
// If requesting empty unknown functions to be considered inactive, abide
// by those rules
if (!isCertainPrintMallocOrFree(called) && called->empty() &&
!hasMetadata(called, "enzyme_gradient") && !isa<IntrinsicInst>(op) &&
EnzymeEmptyFnInactive) {
!hasMetadata(called, "enzyme_gradient") &&
!hasMetadata(called, "enzyme_derivative") &&
!isa<IntrinsicInst>(op) && EnzymeEmptyFnInactive) {
if (EnzymePrintActivity)
llvm::errs() << "constant(" << (int)directions << ") up-emptyconst "
<< *inst << "\n";
Expand Down
Loading

0 comments on commit f426b09

Please sign in to comment.