tensorflow/core/profiler/utils/step_intersection.cc
// If the subordinate steps and the chief steps are aligned at the given anchor
// points (i.e. at the subordinate_anchor step on the subordinate sequence, at
// the chief_anchor step on the chief sequence), returns the corresponding
// AlignmentInfo.
If the subordinate steps and the chief steps are aligned at the given anchor
points , returns the corresponding
AlignmentInfo.
If the subordinate steps and the chief steps are aligned at the given anchor points returns the corresponding AlignmentInfo .
AlignmentInfo ComputeAlignmentInfo(const StepDatabaseResult& subordinate,
                                   uint32 subordinate_anchor,
                                   const StepDatabaseResult& chief,
                                   uint32 chief_anchor) {
  uint32 pre_anchor_steps = std::min(subordinate_anchor, chief_anchor);
  uint32 post_anchor_steps =
      std::min(subordinate.step_sequence_size() - subordinate_anchor,
               chief.step_sequence_size() - chief_anchor);
  uint32 alignment_steps = pre_anchor_steps + post_anchor_steps;
  double similarity = 0;
  uint32 begin_subordinate_idx = subordinate_anchor - pre_anchor_steps;
  uint32 begin_chief_idx = chief_anchor - pre_anchor_steps;
  for (uint32 i = 0; i < alignment_steps; i++) {
    similarity +=
        StepSimilarity(subordinate.step_sequence(begin_subordinate_idx + i),
                       chief.step_sequence(begin_chief_idx + i));
  }
  StepsAlignment alignment = {begin_subordinate_idx, begin_chief_idx,
                              alignment_steps};
  return {alignment, similarity};
}
AlignmentInfo ComputeAlignmentInfo ( const StepDatabaseResult & subordinate , uint32 subordinate_anchor , const StepDatabaseResult & chief , uint32 chief_anchor ) { uint32 pre_anchor_steps = std :: min ( subordinate_anchor , chief_anchor ) ; uint32 post_anchor_steps = std :: min ( subordinate . step_sequence_size ( ) - subordinate_anchor , chief . step_sequence_size ( ) - chief_anchor ) ; uint32 alignment_steps = pre_anchor_steps + post_anchor_steps ; double similarity = 0 ; uint32 begin_subordinate_idx = subordinate_anchor - pre_anchor_steps ; uint32 begin_chief_idx = chief_anchor - pre_anchor_steps ; for ( uint32 i = 0 ; i < alignment_steps ; i ++ ) { similarity += StepSimilarity ( subordinate . step_sequence ( begin_subordinate_idx + i ) , chief . step_sequence ( begin_chief_idx + i ) ) ; } StepsAlignment alignment = { begin_subordinate_idx , begin_chief_idx , alignment_steps } ; return { alignment , similarity } ; }
If the subordinate steps and the chief steps are aligned at the given anchor
points (i.e.
If the subordinate steps and the chief steps are aligned at the given anchor points ( i . e .
// Assumes that the step at subordinate_anchor on the subordinate sequence is // aligned with the step at the chief_anchor on the chief sequence. Then the // number of steps before the anchor is the minimum of the number of steps // before the anchor in the subordinate and that before the anchor in the // chief. Similarly, the number of steps after the anchor is the minimum of // the number of steps after the anchor in the subordinate and that after the // anchor in the chief. // total number of steps aligned = pre_anchor_steps + post_anchor_steps. // Where the aligned steps begin on the subordinate sequence. // Where the aligned steps begin on the chief sequence. // Accumulates the similarity at each step.