Caffe2 - C++ API
A deep learning, cross platform ML framework
dead_code_elimination.h
1 #pragma once
2 
3 #include <torch/csrc/jit/ir.h>
4 
5 namespace torch {
6 namespace jit {
7 
8 // If given a top-level graph, DCE will construct do alias analysis that allows
9 // for "smarter" dead code elimination (we will eliminate mutable ops if we can
10 // prove the mutated values are not used). Otherwise, we will not allow DCE to
11 // eliminate mutable ops.
12 //
13 // So, prefer to use the graph version if you can.
14 TORCH_API void EliminateDeadCode(const std::shared_ptr<Graph>& graph);
15 TORCH_API void EliminateDeadCode(Block* block, bool recurse = true);
16 
17 // Invoke the user-provided callback on all live values before deleting anything
18 TORCH_API void EliminateDeadCode(
19  Block* block,
20  std::function<void(const std::unordered_set<const Value*>&)> cb);
21 } // namespace jit
22 } // namespace torch
Definition: jit_type.h:17