forked from google-research/dex-lang
-
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.
Implement constant folding for casts to floating-point types.
Caveat: Did not check that they agree bit-for-bit with the runtime behavior, but any discrepancies should be small. Benefit: - This ends up constant-folding the cast from the literal zero to the relevant floating-point type in the `Add` instance for floats. - Therefore, that zero ends up being an `Atom` and not an expression when we build the `BaseMonoid` for adding floats, and so is inlined therein. - Therefore, that zero is, in effect, rematerialized when doing AD. - Therefore, an n by m by k tensor of those zeros is not stored by linearize of matmul, so the jvp-matmul benchmark runs some 30% faster. Of course, it is still storing two other tensors it shouldn't store, but that's for another time.
- Loading branch information
Showing
2 changed files
with
29 additions
and
6 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
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