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

Implement Const Folding for Mul, Add and Sub #42

Merged
merged 25 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0b77119
Begin constant folding
BradenEverson Feb 25, 2024
a676479
Zero testing for most data types implemented
BradenEverson Feb 26, 2024
0ca77df
is_const returns inner Literal
BradenEverson Feb 26, 2024
8df9cb8
Fixed refs for const checking
BradenEverson Feb 26, 2024
8f2e419
Mapped adding
BradenEverson Feb 27, 2024
c9a3cca
Stubbed out new traversal method that looks nicer
BradenEverson Feb 27, 2024
16272cb
Only add nonconstants and nonparameters to queue
BradenEverson Feb 27, 2024
968bd74
Change derr of constant to be scalar 0
BradenEverson Feb 27, 2024
b1d5db5
Merge pull request #38 from BradenEverson/master
BradenEverson Feb 29, 2024
7f3666a
Merge branch 'const_fold' into merge_cnflct_autodiff
BradenEverson Mar 1, 2024
e5704e6
Merge pull request #41 from BradenEverson/merge_cnflct_autodiff
BradenEverson Mar 1, 2024
682738b
Add const_fold for new Operations
BradenEverson Mar 1, 2024
1e1b0d0
Begin appending deps and removing deps
BradenEverson Mar 1, 2024
cea1851
Add replace fn for swapping nodes
BradenEverson Mar 2, 2024
77fbf58
Add folding works!
BradenEverson Mar 4, 2024
a8c6409
Mul by zero folds
BradenEverson Mar 4, 2024
253bc2b
Scalar mul folding works
BradenEverson Mar 4, 2024
93539f6
Removed outer match branch
BradenEverson Mar 4, 2024
bb2d085
Removed all of those .into()s
BradenEverson Mar 4, 2024
3b28b3e
Match when a == b in input(still need to fix up the nested matching)
BradenEverson Mar 4, 2024
23b8a35
Removed outer match for replace and created a == b situation
BradenEverson Mar 5, 2024
1950c60
Change logic
BradenEverson Mar 5, 2024
4d9a1e7
Add fold to test
BradenEverson Mar 5, 2024
18ac492
Fully branch out const traversal
BradenEverson Mar 5, 2024
562c5d6
Neg just adds to the queue as well for now
BradenEverson Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/core/graph/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ impl Context {
self.nodes[with_respect_to].callsite.clone(),
));
}

if node == with_respect_to {
return self.scalar(1, wrt_dtype);
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/graph/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ pub enum CompileError {
}

impl Context {
pub fn compile<A: Into<NodeIdentifier> + Copy, const N: usize>(
pub fn compile<const N: usize>(
&mut self,
name: &str,
returns: [A; N],
returns: [NodeIdentifier; N],
client: &xla::PjRtClient,
) -> Result<xla::PjRtLoadedExecutable> {
// TODO: gate debug mode behind a feature flag
Expand All @@ -33,7 +33,7 @@ impl Context {
}

for a in returns.iter() {
self.foldconsts(*a, usize::MAX)?;
self.fold_consts(*a, usize::MAX)?;
}
//while self.foldconsts(a, 1)? {
// println!("{}", self.to_string(a));
Expand Down
Loading
Loading