コード例 #1
0
    def create_mock_input_pipeline(self):
        ipa = input_pipeline_pb2.InputPipelineAnalysisResult()
        ipa.hardware_type = "CPU_ONLY"
        ipa.step_time_summary.CopyFrom(self.create_mock_step_summary(10))
        ipa.input_percent_summary.CopyFrom(self.create_mock_step_summary(20))

        # Add 3 rows
        for _ in range(0, 3):
            step_details = input_pipeline_pb2.PerGenericStepDetails()
            step_details.step_number = int(MockValues.STEP_NUMBER)
            step_details.step_time_ms = int(MockValues.STEP_TIME_MS)
            step_details.unknown_time_ms = int(MockValues.UNKNOWN_TIME_MS)
            step_details.host_wait_input_ms = int(
                MockValues.HOST_WAIT_INPUT_MS)
            step_details.host_to_device_ms = int(MockValues.HOST_TO_DEVICE_MS)
            step_details.output_ms = int(MockValues.OUTPUT_MS)
            step_details.device_compute_ms = int(MockValues.DEVICE_COMPUTE_MS)
            step_details.device_to_device_ms = int(
                MockValues.DEVICE_TO_DEVICE_MS)
            step_details.device_collectives_ms = int(
                MockValues.DEVICE_COLLECTIVES_MS)
            step_details.host_compute_ms = int(MockValues.HOST_COMPUTE_MS)
            step_details.host_prepare_ms = int(MockValues.HOST_PREPARE_MS)
            step_details.host_compile_ms = int(MockValues.HOST_COMPILE_MS)

            step_details_any = Any()
            step_details_any.Pack(step_details)
            ipa.step_details.append(step_details_any)

        input_time_breakdown = input_pipeline_pb2.InputTimeBreakdown()
        input_time_breakdown.demanded_file_read_us = 1
        input_time_breakdown.advanced_file_read_us = 2
        input_time_breakdown.preprocessing_us = 3
        input_time_breakdown.enqueue_us = 4
        input_time_breakdown.unclassified_non_enqueue_us = 5
        ipa.input_time_breakdown.CopyFrom(input_time_breakdown)

        for _ in range(0, 3):
            input_op_details = input_pipeline_pb2.InputOpDetails()
            input_op_details.op_name = str(1)
            input_op_details.count = 2
            input_op_details.time_in_ms = 3
            input_op_details.time_in_percent = 4
            input_op_details.self_time_in_ms = 5
            input_op_details.self_time_in_percent = 6
            input_op_details.category = str(7)
            ipa.input_op_details.append(input_op_details)

        recommendation = input_pipeline_pb2.InputPipelineAnalysisRecommendation(
        )
        for ss in ["a", "b", "c", "d", "e"]:
            recommendation.details.append(ss)
        ipa.recommendation.CopyFrom(recommendation)

        step_time_breakdown = input_pipeline_pb2.GenericStepTimeBreakdown()
        step_time_breakdown.unknown_time_ms_summary.CopyFrom(
            self.create_mock_step_summary(1))
        step_time_breakdown.host_wait_input_ms_summary.CopyFrom(
            self.create_mock_step_summary(9))
        step_time_breakdown.host_to_device_ms_summary.CopyFrom(
            self.create_mock_step_summary(10))
        step_time_breakdown.input_ms_summary.CopyFrom(
            self.create_mock_step_summary(11))
        step_time_breakdown.output_ms_summary.CopyFrom(
            self.create_mock_step_summary(3))
        step_time_breakdown.device_compute_ms_summary.CopyFrom(
            self.create_mock_step_summary(4))
        step_time_breakdown.device_to_device_ms_summary.CopyFrom(
            self.create_mock_step_summary(5))
        step_time_breakdown.device_collectives_ms_summary.CopyFrom(
            self.create_mock_step_summary(12))
        step_time_breakdown.host_compute_ms_summary.CopyFrom(
            self.create_mock_step_summary(6))
        step_time_breakdown.host_prepare_ms_summary.CopyFrom(
            self.create_mock_step_summary(7))
        step_time_breakdown.host_compile_ms_summary.CopyFrom(
            self.create_mock_step_summary(8))

        step_time_breakdown_any = Any()
        step_time_breakdown_any.Pack(step_time_breakdown)
        ipa.step_time_breakdown.CopyFrom(step_time_breakdown_any)

        return ipa
コード例 #2
0
def get_step_breakdown_table_args(ipa):
  """Creates a step breakdown from an Input Pipeline Analyzer proto.

  Args:
    ipa: An input_pipeline_pb2.InputPipelineAnalysisResult.

  Returns:
    Returns a gviz_api.DataTable
  """

  table_description = [
      ("stepnum", "string", "Step number"),
      ("deviceComputeTimeMs", "number", "Device compute"),
      ("deviceToDeviceTimeMs", "number", "Device to device"),
      ("hostComputeTimeMs", "number", "Host compute"),
      ("kernelLaunchTimeMs", "number", "Kernel launch"),
      ("infeedTimeMs", "number", "Input"),
      ("outfeedTimeMs", "number", "Output"),
      ("compileTimeMs", "number", "Compilation"),
      ("otherTimeMs", "number", "All others"),
      ("tooltip", "string", "tooltip", {
          "role": "tooltip"
      }),
  ]

  # Parameters for input analysis summary.
  total_step_time_ms = 0.0
  total_input_ms = 0.0
  total_output_ms = 0.0
  total_host_compute_ms = 0.0
  total_host_prepare_ms = 0.0
  total_host_compile_ms = 0.0
  total_device_to_device_ms = 0.0
  total_unknown_ms = 0.0

  data = []
  for step_details in ipa.step_details:
    details = input_pipeline_pb2.PerGenericStepDetails()
    step_details.Unpack(details)

    tooltip = ("Step {}, duration: {:.2f} ms\n"
               "-All others: {:.2f} ms\n"
               "-Compilation: {:.2f} ms\n"
               "-Output: {:.2f} ms\n"
               "-Input: {:.2f} ms\n"
               "-Kernel launch: {:.2f} ms\n"
               "-Host compute: {:.2f} ms\n"
               "-Device to device: {:.2f} ms\n"
               "-Device compute: {:.2f} ms").format(
                   details.step_number, details.step_time_ms,
                   details.unknown_time_ms, details.host_compile_ms,
                   details.output_ms,
                   details.host_wait_input_ms + details.host_to_device_ms,
                   details.host_prepare_ms, details.host_compute_ms,
                   details.device_to_device_ms, details.device_compute_ms)

    row = [
        str(details.step_number), details.device_compute_ms,
        details.device_to_device_ms, details.host_compute_ms,
        details.host_prepare_ms,
        details.host_wait_input_ms + details.host_to_device_ms,
        details.output_ms, details.host_compile_ms, details.unknown_time_ms,
        tooltip
    ]
    data.append(row)

    total_step_time_ms += details.step_time_ms
    total_input_ms += details.host_wait_input_ms + details.host_to_device_ms
    total_output_ms += details.output_ms
    total_host_prepare_ms += details.host_prepare_ms
    total_device_to_device_ms += details.device_to_device_ms
    total_host_compute_ms += details.host_compute_ms
    total_host_compile_ms += details.host_compile_ms
    total_unknown_ms += details.unknown_time_ms

  bottleneck_analysis = input_pipeline_pb2.BottleneckAnalysis()
  ipa.recommendation.bottleneck_analysis.Unpack(bottleneck_analysis)
  kernel_launch_classification = \
      bottleneck_analysis.kernel_launch_classification
  kernel_launch_statement = bottleneck_analysis.kernel_launch_statement
  all_other_classification = bottleneck_analysis.all_other_classification
  all_other_statement = bottleneck_analysis.all_other_statement
  input_conclusion = bottleneck_analysis.input_statement
  summary_next_step = ipa.recommendation.summary_next_step

  # Add step time summary
  steptime_ms_average = "{:.1f}".format(ipa.step_time_summary.average)
  steptime_ms_standard_deviation = "{:.1f}".format(
      ipa.step_time_summary.standard_deviation)
  steptime_ms_minimum = "{:.1f}".format(ipa.step_time_summary.minimum)
  steptime_ms_maximum = "{:.1f}".format(ipa.step_time_summary.maximum)

  # Add step time breakdown
  breakdown = input_pipeline_pb2.GenericStepTimeBreakdown()
  ipa.step_time_breakdown.Unpack(breakdown)
  device_compute_time_ms_avg = "{:.1f}".format(
      breakdown.device_compute_ms_summary.average)
  device_compute_time_ms_sdv = "{:.1f}".format(
      breakdown.device_compute_ms_summary.standard_deviation)
  device_to_device_time_ms_avg = "{:.1f}".format(
      breakdown.device_to_device_ms_summary.average)
  device_to_device_time_ms_sdv = "{:.1f}".format(
      breakdown.device_to_device_ms_summary.standard_deviation)
  infeed_time_ms_avg = "{:.1f}".format(breakdown.input_ms_summary.average)
  infeed_time_ms_sdv = "{:.1f}".format(
      breakdown.input_ms_summary.standard_deviation)
  outfeed_time_ms_avg = "{:.1f}".format(breakdown.output_ms_summary.average)
  outfeed_time_ms_sdv = "{:.1f}".format(
      breakdown.output_ms_summary.standard_deviation)
  host_compute_time_ms_avg = "{:.1f}".format(
      breakdown.host_compute_ms_summary.average)
  host_compute_time_ms_sdv = "{:.1f}".format(
      breakdown.host_compute_ms_summary.standard_deviation)
  kernel_launch_time_ms_avg = "{:.1f}".format(
      breakdown.host_prepare_ms_summary.average)
  kernel_launch_time_ms_sdv = "{:.1f}".format(
      breakdown.host_prepare_ms_summary.standard_deviation)
  compile_time_ms_avg = "{:.1f}".format(
      breakdown.host_compile_ms_summary.average)
  compile_time_ms_sdv = "{:.1f}".format(
      breakdown.host_compile_ms_summary.standard_deviation)
  other_time_ms_avg = "{:.1f}".format(breakdown.unknown_time_ms_summary.average)
  other_time_ms_sdv = "{:.1f}".format(
      breakdown.unknown_time_ms_summary.standard_deviation)

  custom_properties = {
      "hardware_type": ipa.hardware_type,
      # Step time summary
      "steptime_ms_average": steptime_ms_average,
      "steptime_ms_standard_deviation": steptime_ms_standard_deviation,
      "steptime_ms_minimum": steptime_ms_minimum,
      "steptime_ms_maximum": steptime_ms_maximum,
      # Step time breakdown
      "device_compute_time_ms_avg": device_compute_time_ms_avg,
      "device_compute_time_ms_sdv": device_compute_time_ms_sdv,
      "device_to_device_time_ms_avg": device_to_device_time_ms_avg,
      "device_to_device_time_ms_sdv": device_to_device_time_ms_sdv,
      "infeed_time_ms_avg": infeed_time_ms_avg,
      "infeed_time_ms_sdv": infeed_time_ms_sdv,
      "outfeed_time_ms_avg": outfeed_time_ms_avg,
      "outfeed_time_ms_sdv": outfeed_time_ms_sdv,
      "host_compute_time_ms_avg": host_compute_time_ms_avg,
      "host_compute_time_ms_sdv": host_compute_time_ms_sdv,
      "kernel_launch_time_ms_avg": kernel_launch_time_ms_avg,
      "kernel_launch_time_ms_sdv": kernel_launch_time_ms_sdv,
      "compile_time_ms_avg": compile_time_ms_avg,
      "compile_time_ms_sdv": compile_time_ms_sdv,
      "other_time_ms_avg": other_time_ms_avg,
      "other_time_ms_sdv": other_time_ms_sdv,
      # Input analysis summary
      "input_conclusion": input_conclusion,
      "summary_nextstep": summary_next_step,
      # Generic recommendation
      "kernel_launch_bottleneck": kernel_launch_classification,
      "kernel_launch_statement": kernel_launch_statement,
      "all_other_bottleneck": all_other_classification,
      "all_other_statement": all_other_statement,
  }

  return (table_description, data, custom_properties)