TypeTree support in autodiff#144197
Merged
Merged
Conversation
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.
TypeTrees for Autodiff
What are TypeTrees?
Memory layout descriptors for Enzyme. Tell Enzyme exactly how types are structured in memory so it can compute derivatives efficiently.
Structure
Example:
fn compute(x: &f32, data: &[f32]) -> f32Input 0:
x: &f32Input 1:
data: &[f32]Output:
f32Why Needed?
What Enzyme Does With This Information:
Without TypeTrees (current state):
With TypeTrees (our implementation):
TypeTrees - Offset and -1 Explained
Type Structure
Offset Values
Regular Offset (0, 4, 8, etc.)
Specific byte position within a structure
TypeTree for
&Point(internal representation):Generates LLVM:
Offset -1 (Special: "Everywhere")
Means "this pattern repeats for ALL elements"
Example 1: Array
[f32; 100]Instead of listing 100 separate Types with offsets
0,4,8,12...396Example 2: Slice
&[i32]Example 3: Mixed Structure