示例#1
0
 def set_quantization_dataset_path(self, dataset_path: str) -> None:
     """Update dataset path in quantization config."""
     if dataset_path == "no_dataset_location":
         return
     if (self.quantization and self.quantization.calibration
             and self.quantization.calibration.dataloader
             and self.quantization.calibration.dataloader.dataset):
         self.quantization.calibration.dataloader.dataset.params.update(
             {"root": dataset_path}, )
     else:
         log.warning("Could not set quantization dataset path.")
示例#2
0
 def set_quantization_dataloader(self, dataloader: dict) -> None:
     """Udpate dataloader in quantization config."""
     if (self.quantization and self.quantization.calibration
             and self.quantization.calibration.dataloader):
         calib_dataloader = {
             dataloader.get("name", "Unknown"):
             dataloader.get("params", {}),
         }
         self.quantization.calibration.dataloader.set_dataset(
             calib_dataloader)
     else:
         log.warning("Could not set performance dataloader.")
示例#3
0
    def set_evaluation_dataloader(self, dataloader: dict) -> None:
        """Udpate dataloader in evaluation config."""
        dataset = {
            dataloader.get("name", "Unknown"): dataloader.get("params", {}),
        }
        if self.evaluation and self.evaluation.accuracy and self.evaluation.accuracy.dataloader:
            self.evaluation.accuracy.dataloader.set_dataset(deepcopy(dataset))
        else:
            log.warning("Could not set accuracy dataloader.")

        if (self.evaluation and self.evaluation.performance
                and self.evaluation.performance.dataloader):
            self.evaluation.performance.dataloader.set_dataset(
                deepcopy(dataset))
        else:
            log.warning("Could not set performance dataloader.")
示例#4
0
 def set_evaluation_dataset_path(self, dataset_path: str) -> None:
     """Update dataset path in evaluation config."""
     if dataset_path == "no_dataset_location":
         return
     if (self.evaluation and self.evaluation.accuracy
             and self.evaluation.accuracy.dataloader
             and self.evaluation.accuracy.dataloader.dataset):
         self.evaluation.accuracy.dataloader.dataset.params.update(
             {"root": dataset_path}, )
     else:
         log.warning("Could not set accuracy dataset path.")
     if (self.evaluation and self.evaluation.performance
             and self.evaluation.performance.dataloader
             and self.evaluation.performance.dataloader.dataset):
         self.evaluation.performance.dataloader.dataset.params.update(
             {"root": dataset_path}, )
     else:
         log.warning("Could not set performance dataset path.")
示例#5
0
文件: hw_info.py 项目: vuiseng9/lpot
 def __init__(self) -> None:
     """Initialize HW Info class and gather information platform hardware."""
     cpu_info = cpuinfo.get_cpu_info()
     self.sockets: int = get_number_of_sockets()
     self.cores: int = psutil.cpu_count(logical=False)
     self.cores_per_socket: int = int(
         psutil.cpu_count(logical=False) / self.sockets)
     self.threads_per_socket: int = int(
         psutil.cpu_count(logical=True) / self.sockets)
     self.total_memory: str = f"{psutil.virtual_memory().total / (1024 ** 3):.3f}GB"
     self.system: str = get_distribution()
     self.ip = determine_ip()
     if cpu_info.get("brand"):
         self.platform = cpu_info.get("brand")
     elif cpu_info.get("brand_raw"):
         self.platform = cpu_info.get("brand_raw")
     else:
         self.platform = ""
     self.hyperthreading_enabled: bool = psutil.cpu_count(
         logical=False) != psutil.cpu_count(logical=True, )
     self.turboboost_enabled = is_turbo_boost_enabled()
     self.bios_version = get_bios_version()
     self.kernel: str = get_kernel_version()
     try:
         min_cpu_freq = int(psutil.cpu_freq(percpu=False).min)
         max_cpu_freq = int(psutil.cpu_freq(percpu=False).max)
     except Exception:
         log.warning("Cannot collect cpu frequency information.")
         min_cpu_freq = 0
         max_cpu_freq = 0
     finally:
         if min_cpu_freq == 0:
             self.min_cpu_freq = "n/a"
         else:
             self.min_cpu_freq = f"{min_cpu_freq}Hz"
         if max_cpu_freq == 0:
             self.max_cpu_freq = "n/a"
         else:
             self.max_cpu_freq = f"{max_cpu_freq}Hz"
示例#6
0
    def serialize(
        self,
        serialization_type: str = "default",
    ) -> Union[Dict[str, Any], List[Dict[str, Any]]]:
        """
        Serialize class to dict.

        :param serialization_type: serialization type, defaults to "default"
        :type serialization_type: str, optional
        :return: serialized class
        :rtype: Union[dict, List[dict]]
        """
        result = {}
        for key, value in self.__dict__.items():
            if key in self._skip:
                continue
            if value is None:
                continue

            variable_name = re.sub(r"^_", "", key)
            getter_value = value
            try:
                getter_value = getattr(self, variable_name)
            except AttributeError:
                log.warning(
                    f"Found f{key} attribute without {variable_name} getter.")

            serialized_value = self._serialize_value(
                getter_value,
                serialization_type,
            )

            if serialized_value is not None:
                result[variable_name] = serialized_value

        return result
示例#7
0
 def report_deprecated(*args: str, **kwargs: str) -> Any:
     log.warning(f"Call to deprecated function {func.__name__}.")
     return func(*args, **kwargs)