caffe2::CommonSubexpressionEliminationTransform Class Reference

Common Subexpression Elimination. More...

`#include <common_subexpression_elimination.h>`

Inheritance diagram for caffe2::CommonSubexpressionEliminationTransform:

## Protected Member Functions | |

bool | PatternRule (const transform::Graph &g, const std::vector< int > &subgraph, int idx) override |

The PatternRule essentially answers: Given the current subgraph (ordered), should we append the new node at idx? | |

bool | ValidatorRule (const transform::Graph &g, const std::vector< int > &subgraph) override |

The ValidatorRule essentially answers: Given a subgraph, can we accept it? | |

bool | ReplaceRule (const std::vector< int > &subgraph, transform::Graph *g_ptr) override |

The ReplaceRule actually mutates the graph, and applies the transformation upon the subgraph. | |

Protected Member Functions inherited from caffe2::Transform | |

void | SetPatternMatchType (PatternMatchType type) |

## Additional Inherited Members | |

Public Types inherited from caffe2::Transform | |

enum | PatternMatchType { CONNECTED_SUBGRAPH,
SORTED_WRT_EXECUTION_ORDER,
GENERAL
} |

Determines the type of subgraphs that PatternMatch will find. More... | |

Public Member Functions inherited from caffe2::Transform | |

NetDef | ApplyTo (const NetDef &orig_net_def) |

Apply a Transform onto a NetDef. More... | |

std::vector< std::vector< int > > | PatternMatch (const transform::Graph &graph) |

Generates all matches (stored as ordered subgraphs) and returns them. More... | |

void | ReplacePattern (const std::vector< std::vector< int >> &matches, transform::Graph *graph) |

Applies the replace rule onto each of the matches found. | |

Common Subexpression Elimination.

This transforms looks for specific operators (denoted by whitelisted_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.

Definition at line 28 of file common_subexpression_elimination.h.

The documentation for this class was generated from the following files:

- caffe2/transforms/common_subexpression_elimination.h
- caffe2/transforms/common_subexpression_elimination.cc

Generated on Thu Apr 19 2018 13:03:58 for Caffe2 - C++ API by 1.8.11