Skip to content

Commit

Permalink
Change logic
Browse files Browse the repository at this point in the history
  • Loading branch information
BradenEverson committed Mar 5, 2024
1 parent 23b8a35 commit 1950c60
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/core/graph/consteval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ impl Context {
modifications += 1;
changed = true;
}
modifications += 1;
//Enqueue the dependent nodes to check both of them for constant
//mul/adding

Expand All @@ -254,12 +253,13 @@ impl Context {
self.replace_index(node_id, a)?;
modifications += 1;
changed = true;
} else if let Some(literal) = self.nodes[a].is_const() {
}
if let Some(literal) = self.nodes[a].is_const() {
//Check for mul by 1
let floating_literal: Vec<f32> = literal.convert(xla::PrimitiveType::F32)?.to_vec()?;
let mut all_one = true;
floating_literal.iter().for_each(|elem| {
if elem != &1f32 {
if *elem != 1f32 {
all_one = false;
}
});
Expand All @@ -269,16 +269,18 @@ impl Context {
modifications += 1;
changed = true;
}
} else if self.nodes[b].is_zero()?{
}
if self.nodes[b].is_zero()?{
self.replace_index(node_id, b)?;
modifications += 1;
changed = true;
} else if let Some(literal) = self.nodes[b].is_const() {
}
if let Some(literal) = self.nodes[b].is_const() {
//Check for mul by 1
let floating_literal: Vec<f32> = literal.convert(xla::PrimitiveType::F32)?.to_vec()?;
let mut all_one = true;
floating_literal.iter().for_each(|elem| {
if elem != &1f32 {
if *elem != 1f32 {
all_one = false;
}
});
Expand All @@ -289,7 +291,6 @@ impl Context {
changed = true;
}
}
modifications += 1;
//Enqueue the dependent nodes to check both of them for constant
//mul/adding

Expand Down

0 comments on commit 1950c60

Please sign in to comment.