Skip to content
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

Incorrect differentiation of loop conditions in reverse mode #746

Closed
parth-07 opened this issue Feb 2, 2024 · 11 comments · Fixed by #818
Closed

Incorrect differentiation of loop conditions in reverse mode #746

parth-07 opened this issue Feb 2, 2024 · 11 comments · Fixed by #818

Comments

@parth-07
Copy link
Collaborator

parth-07 commented Feb 2, 2024

Loop conditions are incorrectly differentiated in the reverse mode.

Reproducible example:

#include "clad/Differentiator/Differentiator.h"
#include <iostream>
#define show(x) std::cout << #x << ": " << x << "\n";

double fn(double i, double j) {
    double res = 0;
    for (int c = 0; res = i * j; ++c) {
        if (c == 1)
            break;
    }
    return res;
}

int main() {
    auto fn_grad = clad::gradient(fn);
    double i = 3, j = 5;
    double di = 0, dj = 0;
    fn_grad.execute(i, j, &di, &dj);
    show(di);
    show(dj);
}

Output:
di: 0
dj: 0

Expected output:
di: 5
dj: 3

@KronoCode
Copy link

Hello, I would like to take this issue as it seem to be a simple one for a first contribution 🙂

@vgvassilev
Copy link
Owner

Please go ahead!

@KronoCode
Copy link

I could not run Clad on my machine as it crashed when building the project.. As for the issue, I looked into the code and I had a few questions about the topic :

  • Is the derived function generated by the constructor of the CladFunction class?

  • From my understanding, this issue is due to the generation of an incorrect derivate function OR MAYBE the function is not taken into account from the execute method and returns 0.

@wymux
Copy link

wymux commented Feb 9, 2024

Clang-17 fails to compile provided code:

DeclRefExpr for Decl not entered in LocalDeclMap?
UNREACHABLE executed at /var/tmp/paludis/build/dev-lang-clang-17.0.6/work/llvm-project/clang/lib/CodeGen/CGExpr.cpp:2867!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/clang-17 -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name 01.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/wymux/Internet/Git/Exherbo/ExMux -resource-dir /usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/clang/17 -internal-isystem /usr/host/bin/../lib64/gcc/x86_64-pc-linux-gnu/13/../../../../../x86_64-pc-linux-gnu/include/c++/13 -internal-isystem /usr/host/bin/../lib64/gcc/x86_64-pc-linux-gnu/13/../../../../../x86_64-pc-linux-gnu/include/c++/13/x86_64-pc-linux-gnu -internal-isystem /usr/host/bin/../lib64/gcc/x86_64-pc-linux-gnu/13/../../../../../x86_64-pc-linux-gnu/include/c++/13/backward -internal-isystem /usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/clang/17/include -internal-isystem /usr/x86_64-pc-linux-gnu/include -internal-isystem /usr/local/include -internal-isystem /usr/host/bin/../lib64/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir=/home/wymux/Internet/Git/Exherbo/ExMux -ferror-limit 19 -fmessage-length=95 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -load /usr/lib/clad.so -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/01-55ca06.o -x c++ 01.cpp
1.      <eof> parser at end of file
2.      LLVM IR generation of declaration 'fn_grad'
3.      Generating code for declaration 'fn_grad'
4.      LLVM IR generation of compound statement ('{}')
 #0 0x00007ff17f3ab64e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libLLVM-17.so+0x142664e)
 #1 0x00007ff17f3a86fb llvm::sys::RunSignalHandlers() (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libLLVM-17.so+0x14236fb)
 #2 0x00007ff17f3a8825 (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libLLVM-17.so+0x1423825)
 #3 0x00007ff17db42be0 (/usr/x86_64-pc-linux-gnu/lib/libc.so.6+0x3dbe0)
 #4 0x00007ff17db9216c (/usr/x86_64-pc-linux-gnu/lib/libc.so.6+0x8d16c)
 #5 0x00007ff17db42b36 gsignal (/usr/x86_64-pc-linux-gnu/lib/libc.so.6+0x3db36)
 #6 0x00007ff17db2b835 abort (/usr/x86_64-pc-linux-gnu/lib/libc.so.6+0x26835)
 #7 0x00007ff17f2c2ada (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libLLVM-17.so+0x133dada)
 #8 0x00007ff18aa19ead clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x24dfead)
 #9 0x00007ff18aa15531 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x24db531)
#10 0x00007ff18aa20850 clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x24e6850)
#11 0x00007ff18aa798a7 (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x253f8a7)
#12 0x00007ff18aa744fa (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x253a4fa)
#13 0x00007ff18aa76bab (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x253cbab)
#14 0x00007ff18aa744fa (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x253a4fa)
#15 0x00007ff18aa7ca95 clang::CodeGen::CodeGenFunction::EmitPromotedScalarExpr(clang::Expr const*, clang::QualType) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x2542a95)
#16 0x00007ff18aa7d2ec (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x25432ec)
#17 0x00007ff18aa72d77 (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x2538d77)
#18 0x00007ff18aa744fa (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x253a4fa)
#19 0x00007ff18aa7ddc5 (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x2543dc5)
#20 0x00007ff18aa7e501 clang::CodeGen::CodeGenFunction::EmitCompoundAssignmentLValue(clang::CompoundAssignOperator const*) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x2544501)
#21 0x00007ff18aa156d6 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x24db6d6)
#22 0x00007ff18aa14648 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x24da648)
#23 0x00007ff18abb5deb clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x267bdeb)
#24 0x00007ff18abbbacc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x2681acc)
#25 0x00007ff18abbbee9 clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x2681ee9)
#26 0x00007ff18abbc288 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x2682288)
#27 0x00007ff18abb5301 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x267b301)
#28 0x00007ff18abbbacc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x2681acc)
#29 0x00007ff18ac26d38 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x26ecd38)
#30 0x00007ff18ac3a75f clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x270075f)
#31 0x00007ff18ac9341c clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x275941c)
#32 0x00007ff18ac8e7dc clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x27547dc)
#33 0x00007ff18ac8ef1b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x2754f1b)
#34 0x00007ff18ac985d2 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x275e5d2)
#35 0x00007ff18ad22d44 (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x27e8d44)
#36 0x00007ff18ac184ef clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x26de4ef)
#37 0x00007ff18b7559e0 clang::MultiplexConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x321b9e0)
#38 0x00007ff17b200612 clad::plugin::CladPlugin::ProcessDiffRequest(clad::DiffRequest&) (/usr/lib/clad.so+0x7e612)
#39 0x00007ff17b200d9b clad::plugin::CladPlugin::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/lib/clad.so+0x7ed9b)
#40 0x00007ff18b7559e0 clang::MultiplexConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x321b9e0)
#41 0x00007ff18931e69c clang::ParseAST(clang::Sema&, bool, bool) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0xde469c)
#42 0x00007ff18b71dd29 clang::FrontendAction::Execute() (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x31e3d29)
#43 0x00007ff18b69ed8f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x3164d8f)
#44 0x00007ff18b7b0447 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/../lib/libclang-cpp.so.17+0x3276447)
#45 0x0000561001ac2fa7 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/clang-17+0x1bfa7)
#46 0x0000561001abb395 (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/clang-17+0x14395)
#47 0x0000561001abf2bc clang_main(int, char**, llvm::ToolContext const&) (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/clang-17+0x182bc)
#48 0x0000561001ab9791 main (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/clang-17+0x12791)
#49 0x00007ff17db2d25e (/usr/x86_64-pc-linux-gnu/lib/libc.so.6+0x2825e)
#50 0x00007ff17db2d319 __libc_start_main (/usr/x86_64-pc-linux-gnu/lib/libc.so.6+0x28319)
#51 0x0000561001ab97c5 _start (/usr/x86_64-pc-linux-gnu/lib/llvm/17/bin/clang-17+0x127c5)
clang++-17: error: unable to execute command: Aborted
clang++-17: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 17.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/host/bin
clang++-17: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++-17: note: diagnostic msg: /tmp/01-521472.cpp
clang++-17: note: diagnostic msg: /tmp/01-521472.sh
clang++-17: note: diagnostic msg: 

********************

@wymux
Copy link

wymux commented Feb 9, 2024

How would the error: DeclRefExpr for Decl not entered in LocalDeclMap? be circumvented?

@AlphaGotReal
Copy link

@wymux
try using clang++-11 with the -std=c++11
here is the full command I used to compile my program

clang++-11 -std=c++11 -I /path/to/clad/include -fplugin=/path/to/build/lib/clad.so <your source code>.cpp

@Dsantra92
Copy link
Contributor

Hey @KronoCode are you still working on this issue?

@kchristin22
Copy link
Collaborator

kchristin22 commented Mar 7, 2024

Hi @parth-07!
By:

for (int c = 0; res = i * j; ++c) {
        if (c == 1)
            break;
    }

Do you mean:

for (int c = 0;; ++c) {
       if (c == 1)
           break;
       res = i * j;
   }

If yes, I tested the example locally and it run as expected when I compiled with clang-17. clang-14 and 15 failed to compile the code correctly. So maybe we should focus on the differences between these versions and the internal compilation errors? I am curious to know if this is indeed a problem or only occurred to me.

@parth-07
Copy link
Collaborator Author

parth-07 commented Mar 8, 2024

Hi @kchristin22

I meant the first snippet only -- that is mentioned in the issue description.

clang-14 and 15 failed to compile the code correctly.

Just to clarify, do you mean clang-14 and clang-15 failed to differentiate the code in the 2nd snippet? If so, can you please open an issue for this?

@kchristin22
Copy link
Collaborator

It was actually a false alarm, clang-15 did fine, sorry for that. The 1st snippet (the one denoted in the issue description) fails at these lines which seem to be in reverse order and should not compile:

* _d_j += i * _r_d0;
* _d_i += _r_d0 * j;
 _d_res -= _r_d0;
double _r_d0 = _d_res;
res = clad::pop(_t1);

I'm not familiar with how the AST nodes are being handled though to give extra input : (
Do you have any idea why is that happening? I could investigate it further if it's not too low level.

@vgvassilev
Copy link
Owner

It was actually a false alarm, clang-15 did fine, sorry for that. The 1st snippet (the one denoted in the issue description) fails at these lines which seem to be in reverse order and should not compile:

* _d_j += i * _r_d0;
* _d_i += _r_d0 * j;
 _d_res -= _r_d0;
double _r_d0 = _d_res;
res = clad::pop(_t1);

I'm not familiar with how the AST nodes are being handled though to give extra input : ( Do you have any idea why is that happening? I could investigate it further if it's not too low level.

Practically, this is the GSoC project to go at the AST level and sometime even below.

rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Mar 12, 2024
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Mar 12, 2024
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Mar 12, 2024
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Mar 15, 2024
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Mar 15, 2024
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Mar 15, 2024
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Mar 15, 2024
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Mar 23, 2024
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jun 5, 2024
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jun 6, 2024
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 2, 2024
Currently loop conditions are not differentiated in reverse mode.
This change differentiates the loop condition expression.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 2, 2024
Currently loop conditions are not differentiated in reverse mode.
This change differentiates the loop condition expression.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 2, 2024
Currently loop conditions are not differentiated in reverse mode.
This change differentiates the loop condition expression.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 2, 2024
Currently loop conditions are not differentiated in reverse mode.
This change differentiates the loop condition expression.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 3, 2024
Currently loop conditions are not differentiated in reverse mode.
This change differentiates the loop condition expression.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 3, 2024
This change differentiates the loop condition expression.
Additionaly if in forward pass a loop terminates pre-maturely due to break stmt.
The reverse pass should start differentiation with break statment and
not the loop condition differentiation. This change keeps track of whether the break
was called in forward pass and based on that in reverse mode it is decided
whether the loop differentiation is skipped for the first iteration or not.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 3, 2024
This change differentiates the loop condition expression.
Additionaly if in forward pass a loop terminates pre-maturely due to break stmt.
The reverse pass should start differentiation with break statment and
not the loop condition differentiation. This change keeps track of whether the break
was called in forward pass and based on that in reverse mode it is decided
whether the loop differentiation is skipped for the first iteration or not.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 13, 2024
This change differentiates the loop condition expression.
Additionaly if in forward pass a loop terminates pre-maturely due to break stmt.
The reverse pass should start differentiation with break statment and
not the loop condition differentiation. This change keeps track of whether the break
was called in forward pass and based on that in reverse mode it is decided
whether the loop differentiation is skipped for the first iteration or not.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 13, 2024
This change differentiates the loop condition expression.
Additionaly if in forward pass a loop terminates pre-maturely due to break stmt.
The reverse pass should start differentiation with break statment and
not the loop condition differentiation. This change keeps track of whether the break
was called in forward pass and based on that in reverse mode it is decided
whether the loop differentiation is skipped for the first iteration or not.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 13, 2024
This change differentiates the loop condition expression.
Additionaly if in forward pass a loop terminates pre-maturely due to break stmt.
The reverse pass should start differentiation with break statment and
not the loop condition differentiation. This change keeps track of whether the break
was called in forward pass and based on that in reverse mode it is decided
whether the loop differentiation is skipped for the first iteration or not.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 14, 2024
This change differentiates the loop condition expression.
Additionaly if in forward pass a loop terminates pre-maturely due to break stmt.
The reverse pass should start differentiation with break statment and
not the loop condition differentiation. This change keeps track of whether the break
was called in forward pass and based on that in reverse mode it is decided
whether the loop differentiation is skipped for the first iteration or not.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 16, 2024
This change differentiates the loop condition expression.
Additionaly if in forward pass a loop terminates pre-maturely due to break stmt.
The reverse pass should start differentiation with break statment and
not the loop condition differentiation. This change keeps track of whether the break
was called in forward pass and based on that in reverse mode it is decided
whether the loop differentiation is skipped for the first iteration or not.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 16, 2024
This change differentiates the loop condition expression.
Additionaly if in forward pass a loop terminates pre-maturely due to break stmt.
The reverse pass should start differentiation with break statment and
not the loop condition differentiation. This change keeps track of whether the break
was called in forward pass and based on that in reverse mode it is decided
whether the loop differentiation is skipped for the first iteration or not.
rohanjulka19 added a commit to rohanjulka19/clad that referenced this issue Jul 16, 2024
This change differentiates the loop condition expression.
Additionaly if in forward pass a loop terminates pre-maturely due to break stmt.
The reverse pass should start differentiation with break statment and
not the loop condition differentiation. This change keeps track of whether the break
was called in forward pass and based on that in reverse mode it is decided
whether the loop differentiation is skipped for the first iteration or not.
vgvassilev pushed a commit that referenced this issue Jul 18, 2024
This change differentiates the loop condition expression.
Additionaly if in forward pass a loop terminates pre-maturely due to break stmt.
The reverse pass should start differentiation with break statment and
not the loop condition differentiation. This change keeps track of whether the break
was called in forward pass and based on that in reverse mode it is decided
whether the loop differentiation is skipped for the first iteration or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants