You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cpu_analyser.py 1.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright 2021 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """The cpu base analyser."""
  16. from mindinsight.profiler.analyser.gpu_analyser import GpuAnalyser
  17. from mindinsight.profiler.common.validator import validate
  18. class CpuOpTypeAnalyser(GpuAnalyser):
  19. """Cpu operation type analyser."""
  20. _col_names = validate.CPU_TYPE_COL
  21. _csv_file_to_analyse = 'cpu_op_type_info_{}.csv'
  22. @staticmethod
  23. def _convert_field_type(row):
  24. """
  25. Convert the field type to the specific type.
  26. Args:
  27. row (list): One row data from parsed data.
  28. Returns:
  29. list, the converted data.
  30. """
  31. return [row[0], int(row[1]), int(row[2]), float(row[3]), float(row[4]), float(row[5])*100]
  32. class CpuOpInfoAnalyser(GpuAnalyser):
  33. """Cpu operation detail info analyser."""
  34. _col_names = validate.CPU_DETAIL_COL
  35. _csv_file_to_analyse = 'cpu_op_detail_info_{}.csv'
  36. @staticmethod
  37. def _convert_field_type(row):
  38. """
  39. Convert the field type to the specific type.
  40. Args:
  41. row (list): One row data from parsed data.
  42. Returns:
  43. list, the converted data.
  44. """
  45. return [row[0], row[1], row[2], row[3], int(row[4]), float(row[5]),
  46. float(row[6]), float(row[7]), row[8]]