pub struct CommonSubexpressionEliminationTransform { /* private fields */ }
Expand description
| Common Subexpression Elimination | | This transforms looks for specific operators | (denoted by allowed_ops_), and removes | unnecessary repetition of that operator. | | Consider some operator of X, that reads from | blob b_ written to by W. X_a and X_b read the | output of X. However, another operator Y, is | the same type as X, has the same arguments as | X, and reads from the same input b_, written to | by W. It’s output is the same as X. Y_a, Y_b, | and Y_c read from Y. | | Then, we can eliminate the common | subexpressions X and Y, and merge them to Z, | where X_a, X_b, Y_a, Y_b, and Y_c all read from | Z. | | | TODO(benz): Fix the error to not match nodes | that write to external output.
Implementations§
source§impl CommonSubexpressionEliminationTransform
impl CommonSubexpressionEliminationTransform
pub fn is_allowed(&mut self, op_type: String) -> bool
pub fn pattern_rule(&mut self, g: &Graph, subgraph: &Vec<i32>, idx: i32) -> bool
sourcepub fn validator_rule(&mut self, g: &Graph, subgraph: &Vec<i32>) -> bool
pub fn validator_rule(&mut self, g: &Graph, subgraph: &Vec<i32>) -> bool
| As long as we have matched more than 2 | ops, it is worth eliminating. |
pub fn replace_rule(&mut self, subgraph: &Vec<i32>, g_ptr: *mut Graph) -> bool
Trait Implementations§
source§impl Transform for CommonSubexpressionEliminationTransform
impl Transform for CommonSubexpressionEliminationTransform
source§fn pattern_match(&mut self, graph: &Graph) -> Vec<Vec<i32>>
fn pattern_match(&mut self, graph: &Graph) -> Vec<Vec<i32>>
source§fn try_neighbors(
&mut self,
graph: &Graph,
neighbors: &HashMap<i32, Vec<String>>,
matched: &Vec<bool>,
subgraph_ptr: *mut Vec<i32>,
best_subgraph_ptr: *mut Vec<i32>
)
fn try_neighbors( &mut self, graph: &Graph, neighbors: &HashMap<i32, Vec<String>>, matched: &Vec<bool>, subgraph_ptr: *mut Vec<i32>, best_subgraph_ptr: *mut Vec<i32> )
source§fn pattern_match_helper(
&mut self,
graph: &Graph,
matched: &Vec<bool>,
subgraph_ptr: *mut Vec<i32>,
best_subgraph_ptr: *mut Vec<i32>
)
fn pattern_match_helper( &mut self, graph: &Graph, matched: &Vec<bool>, subgraph_ptr: *mut Vec<i32>, best_subgraph_ptr: *mut Vec<i32> )
source§fn pattern_rule(&mut self, g: &Graph, subgraph: &Vec<i32>, idx: i32) -> bool
fn pattern_rule(&mut self, g: &Graph, subgraph: &Vec<i32>, idx: i32) -> bool
source§fn validator_rule(&mut self, g: &Graph, subgraph: &Vec<i32>) -> bool
fn validator_rule(&mut self, g: &Graph, subgraph: &Vec<i32>) -> bool
source§fn replace_rule(&mut self, subgraph: &Vec<i32>, g_ptr: *mut Graph) -> bool
fn replace_rule(&mut self, subgraph: &Vec<i32>, g_ptr: *mut Graph) -> bool
fn set_pattern_match_type(&mut self, ty: PatternMatchType)
Auto Trait Implementations§
impl RefUnwindSafe for CommonSubexpressionEliminationTransform
impl Send for CommonSubexpressionEliminationTransform
impl Sync for CommonSubexpressionEliminationTransform
impl Unpin for CommonSubexpressionEliminationTransform
impl UnwindSafe for CommonSubexpressionEliminationTransform
Blanket Implementations§
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.