class_docstr: Hexagon Profiler
docstr: Configure HexagonProfiler
docstr_tok: ["Configure","HexagonProfiler"]
code: def __init__(
      self,
      dso_binary: str,
      module: typing.Union[ExecutorFactoryModule, OperatorModule],
      hexagon_server_process,
      enable_debug,
  ):
      """Configure HexagonProfiler"""
      # Save test .so to process profiling data
      self._temp_dir = utils.tempdir(keep_for_debug=enable_debug)
      self._dso_binary_path = self._temp_dir.relpath(dso_binary)
      if isinstance(module, OperatorModule):
          module.save(self._dso_binary_path)
      else:
          module.get_lib().save(self._dso_binary_path)
  
      self._android_serial_number = os.environ.get(
          "ANDROID_SERIAL_NUMBER"
      )
      self._remote_path = ""
      self._logcat_path = ""
  
      self._profiling_mode = None
      config = PassContext.current().config
      if self._android_serial_number is None:
          raise RuntimeError(
              "ANDROID_SERIAL_NUMBER must be set for profiling"
          )
  
      if ("tir.instrument_lwp", True) in config.items():
          # Set profiling mode
          self._profiling_mode = "lwp"
  
          if self._android_serial_number != "simulator":
              # Clear the logcat buffer and create a child process to redirect logcat output
              # into a file.
              launcher = hexagon_server_process["launcher"]
              subprocess.check_call(
                  launcher._adb_device_sub_cmd + ["logcat", "-c"]
              )
              self._logcat_path = self._temp_dir.relpath("logcat.log")
              self._fo = open(self._logcat_path, "w")
              self._proc = subprocess.Popen(
                  launcher._adb_device_sub_cmd + ["logcat"],
                  stdout=self._fo,
              )
  
              # Get the remote workspace on the device from where the lwp data needs to be copied.
              self._remote_path = launcher._workspace
  
      if self._profiling_mode is None:
          raise RuntimeError(
              "Profiling mode was not set or was not a valid one."
          )
  
file_path: tvm/python/tvm/contrib/hexagon/hexagon_profiler.py
imports: import os
  import subprocess
  import typing
  from tvm.ir.transform import PassContext
  from tvm.contrib.hexagon.profiling.process_lwp_data import process_lwp_output
  from tvm.relay.backend.executor_factory import ExecutorFactoryModule
  from tvm.driver.build_module import OperatorModule
  from tvm.contrib import utils
label_desc: Use image node_id 1 to create a new HexagonProfiler object  with example: obj = HexagonProfiler(dso_binary, module, hexagon_server_process, enable_debug)