-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
pub class AD T { | ||
type D | ||
} | ||
|
||
instance AD () { | ||
type D = () | ||
} | ||
|
||
instance AD bool { | ||
type D = bool | ||
} | ||
|
||
instance AD i32 { | ||
type D = i32 | ||
} | ||
|
||
instance AD u32 { | ||
type D = u32 | ||
} | ||
|
||
instance AD i64 { | ||
type D = i64 | ||
} | ||
|
||
instance AD u64 { | ||
type D = u64 | ||
} | ||
|
||
instance AD f32 { | ||
type D = (f32, f32) | ||
} | ||
|
||
instance AD f64 { | ||
type D = (f64, f64) | ||
} | ||
|
||
instance T (AD T) => AD []T { | ||
type D = []((AD T).D) | ||
} | ||
|
||
instance A B (AD A) (AD B) => AD (A, B) { | ||
type D = ((AD A).D, (AD B).D) | ||
} | ||
|
||
instance A B (AD A) (AD B) => AD (A | B) { | ||
type D = (AD A).D | (AD B).D | ||
} | ||
|
||
pub val A B (AD A) (AD B) => linearize : (A -> B) -> (AD A).D -> (AD B).D | ||
|
||
pub val A B (AD A) (AD B) => | ||
transpose : ((AD A).D -> (AD B).D) -> (AD A).D -> ((AD B).D, () -> ()) |