18 #ifndef TENSORFLOW_COMPILER_XLA_SERVICE_HLO_ORDERING_H_ 19 #define TENSORFLOW_COMPILER_XLA_SERVICE_HLO_ORDERING_H_ 25 #include "tensorflow/compiler/xla/service/call_graph.h" 26 #include "tensorflow/compiler/xla/service/hlo.pb.h" 27 #include "tensorflow/compiler/xla/service/hlo_dataflow_analysis.h" 30 #include "tensorflow/compiler/xla/service/hlo_value.h" 31 #include "tensorflow/compiler/xla/types.h" 32 #include "tensorflow/core/lib/gtl/flatmap.h" 44 : module_(module), call_graph_(CallGraph::Build(module)) {}
53 bool IsDefinedBefore(
const HloValue& a,
const HloValue& b)
const;
57 bool UseIsBeforeValueDefinition(
const HloUse& use,
const HloValue& value,
58 const HloDataflowAnalysis& dataflow)
const;
61 bool MayInterfere(
const HloValue& a,
const HloValue& b,
62 const HloDataflowAnalysis& dataflow)
const;
66 bool LiveRangeStrictlyBefore(
const HloValue& a,
const HloValue& b,
67 const HloDataflowAnalysis& dataflow)
const;
71 virtual const std::vector<const HloInstruction*>* SequentialOrder(
75 const CallGraph& call_graph()
const {
return *call_graph_; }
77 virtual string ToString()
const = 0;
81 HloOrderingProto ToProto()
const;
91 virtual bool ExecutesBeforeInSameComputation(
96 std::unique_ptr<CallGraph> call_graph_;
104 class PredecessorHloOrdering :
public HloOrdering {
106 ~PredecessorHloOrdering()
override =
default;
110 const std::vector<const HloInstruction*>* SequentialOrder(
115 HloReachabilityMap& reachability_map(
const HloComputation* computation) {
116 return *predecessors_.at(computation);
118 const HloReachabilityMap& reachability_map(
119 const HloComputation* computation)
const {
120 return *predecessors_.at(computation);
124 explicit PredecessorHloOrdering(
const HloModule* module);
125 string ToStringHelper(
const string& name)
const;
127 bool ExecutesBeforeInSameComputation(
const HloInstruction* a,
128 const HloInstruction* b)
const override;
134 tensorflow::gtl::FlatMap<
const HloComputation*,
135 std::unique_ptr<HloReachabilityMap>>
163 class DependencyHloOrdering :
public PredecessorHloOrdering {
165 explicit DependencyHloOrdering(
const HloModule* module);
166 ~DependencyHloOrdering()
override =
default;
168 string ToString()
const override;
208 std::vector<const HloInstruction*>>;
215 const std::vector<const HloInstruction*>* SequentialOrder(
218 string ToString()
const override;
232 tensorflow::gtl::FlatMap<const HloInstruction*, int> order_position_;
235 std::ostream& operator<<(
241 #endif // TENSORFLOW_COMPILER_XLA_SERVICE_HLO_ORDERING_H_ Definition: hlo_ordering.h:203
Definition: hlo_computation.h:60
Definition: hlo_instruction.h:165
namespace for xla
Definition: client_library.cc:26
tensorflow::gtl::FlatMap< const HloComputation *, std::vector< const HloInstruction * > > HloModuleSequence
Definition: hlo_ordering.h:208
Definition: hlo_module.h:52
Definition: hlo_ordering.h:41