cleanupgood first issue
仓库指标
- Star
- (392 star)
- PR 合并指标
- (PR 指标待抓取)
描述
We currently have the following methods available in a Fusion object:
deque<Val*> IrContainer::deterministic_vals(): returnsVals in insertion order, not in topological order and not just those leading to outputs (sinceIrContainerdoesn't track inputs or outputs)deque<Expr*> IrContainer::deterministic_exprs(): similar to above but forExprs.const std::unordered_set<Expr*>& IrContainer::unordered_exprs(): return allExprs in no particular order. Again this gives all expressions regardless of outputs.const std::unordered_set<Val*>& IrContainer::vals(): same as above but forVal. Note the name is inconsistentstd::vector<Expr*> Fusion::exprs(): returns a vector of topologically sorted expressions leading to outputs.std::vector<Val*> Fusion::inputsOf(Val* val): comment says this will "Return a vector of fusion inputs that feed this Val", but what it really returns is all producerVals that don't themselves have definitions.val->isFusionInput()is not checked, so this could be a method ofIrContainerinstead..std::vector<Val*> Fusion::usedMathVals(): return all outputs andVals leading to outputs, and all siblings of any of thoseVals (sibling means another output from the same multi-output expression).std::vector<Val*> Fusion::terminatingMathVals(): filterusedMathVals()to find vals that have definitions but no uses (i.e. whether they are outputs or not, no other output consumes them).
I came to this because I was confused thinking fusion->vals() would behave similarly to fusion->exprs(), which it does not. I think we should do at least the following cleanups:
- Fix the comment of
Fusion::inputsOfto accurately reflect what it does. - Move
Fusion::inputsOftoIrContainer. - Rename
IrContainer::vals()toIrContainer::unordered_vals(). - Rename
Fusion::exprs()toFusion::usedExprs()to reflect that these are only theExprs that lead to outputs unlike those returned byunordered_exprs(). - Change snake_case method names like
deterministic_valsto camelCase. - Consider renaming
usedMathVals()to something likeproducedMathVals(). The interesting thing about this method that it actually returns unused siblings of all the liveVals in the fusion so the name should not suggest that they are all used.
There are probably some other ways to clarify this part of the code that I've missed.