Merged
Conversation
MaxSagebaum
referenced
this pull request
Feb 7, 2025
…mple The test @autodiff function can now handle the "r = a + b;" case. This code: test: @autodiff @print type = { // A simple first function would be: // func: (a: double, b: double) -> double = { return a + b; } func: (a: double, b: double) -> (r: double) = { r = a + b; } // The generated autodiff forward transformation would be: // func_diff: (a: double, a_d: double, b: double, b_d: double) -> (r: double, r_d: double) = { // r_d = a * b_d + b * a_d; // r = a * b; // } } Generates the following, as reported by @print in the cppfront compile output: test:/* @autodiff @print */ type = { func:( in a: double, in b: double, ) -> (out r: double, ) = { r = a + b; return; } func_diff:( in a: double, in a_d: double, in b: double, in b_d: double, ) -> ( out r: double = 1, out r_d: double = 1, ) = { r_d = a * b_d + b * a_d; r = a * b; return; } } And a bug fix: When a file that contains Cpp2 code begins with Cpp1 #includes, preserve their position at the top of the generated file too. This allows a Cpp2 type's template parameter list to use types a from Cpp1 header file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additional steps for making autodiff work.