Example #1
0
 def parse_benchmark(self, cmd_res):
     logger.info("==== {} ====".format(self.parse_benchmark.__name__))
     output_lines = cmd_res
     logger.debug(output_lines)
     framework_name = self.config["framework_name"]
     benchmark = dict()
     if framework_name == "tnn" or framework_name == "mnn":
         if framework_name == "tnn":
             bench_res_keyword = "time cost"
         elif framework_name == "mnn":
             bench_res_keyword = "max ="
         output_lines = filter(  # noqa
             lambda line: bench_res_keyword in line, output_lines)
         output_lines = list(output_lines)
         assert len(output_lines) == 1
         line = output_lines[0].split()
         logger.debug(line)
         line = "".join(line)
         logger.debug(line)
         benchmark["min"] = pattern_match(line, "min=", "ms", False)
         benchmark["max"] = pattern_match(line, "max=", "ms", False)
         benchmark["avg"] = pattern_match(line, "avg=", "ms", False)
         benchmark["std_dev"] = pattern_match(line, "std_dev=", "ms", False)
     elif framework_name == "ncnn":
         is_no_vulkan = list(
             filter(lambda line: "no vulkan device" in line, output_lines))
         is_no_vulkan = len(is_no_vulkan) > 0
         if is_no_vulkan:
             benchmark["min"] = 0.0
             benchmark["max"] = 0.0
             benchmark["avg"] = 0.0
             benchmark["std_dev"] = 0.0
         else:
             output_lines = filter(lambda line: "min = " in line,
                                   output_lines)  # noqa
             output_lines = list(output_lines)
             logger.debug("output_lines:\n{}".format(output_lines))
             assert len(output_lines) == 1
             line = output_lines[0]
             line = line.split()
             logger.debug(line)
             line = "".join(line) + "END"
             benchmark["min"] = pattern_match(line, "min=", "max", False)
             benchmark["max"] = pattern_match(line, "max=", "avg", False)
             benchmark["avg"] = pattern_match(line, "avg=", "std_dev",
                                              False)  # noqa
             benchmark["std_dev"] = pattern_match(line, "std_dev=", "END",
                                                  False)  # noqa
     else:
         logger.fatal("Unsupported framework {}".format(  # noqa
             self.config["framework_name"]  # noqa
         )  # noqa
                      )
         exit(1)
     logger.info("benchmark:{}".format(benchmark))
     assert len(benchmark) != 0
     return benchmark
Example #2
0
def get_imei(serial_num):
    lookup_imei_cmd = "adb -s {} shell service call iphonesubinfo 1".format(  # noqa
        serial_num)
    imei_list = run_cmd(lookup_imei_cmd)
    imei_list = list(filter(lambda l: "." in l, imei_list))
    assert 0 < len(imei_list)
    imei_list = list(
        map(lambda l: pattern_match(l, "'", "'", False), imei_list))  # noqa
    logger.debug("imei_list:{}".format(imei_list))
    imei_list = map(lambda l: l.replace(".", ""), imei_list)
    imei = "".join(imei_list)
    imei = imei.replace(" ", "")
    logger.debug("imei:{}".format(imei))
    return imei
Example #3
0
 def parse_benchmark(self, cmd_res):
     logger.info("==== {} ====".format(self.parse_benchmark.__name__))
     output_lines = cmd_res
     logger.debug(output_lines)
     framework_name = self.config["framework_name"]
     benchmark = dict()
     benchmark["min"] = 0.0
     benchmark["max"] = 0.0
     benchmark["avg"] = 0.0
     benchmark["std_dev"] = 0.0
     if cmd_res is None:
         return benchmark
     elif (framework_name == "tnn" or framework_name == "mnn"
           or framework_name == "tflite"):
         if framework_name == "tnn" or framework_name == "tflite":
             bench_res_keyword = "time cost"
         elif framework_name == "mnn":
             bench_res_keyword = "max ="
         output_lines_str = "".join(output_lines)
         output_lines = filter(  # noqa
             lambda line: bench_res_keyword in line, output_lines)
         if (framework_name == "mnn"
                 and "Floating point exception" in output_lines_str):
             return benchmark
         elif (framework_name == "tflite" and
               'Error: dlopen failed: library "libhexagon_interface.so" not found'  # noqa
               in output_lines_str):
             return benchmark
         output_lines = list(output_lines)
         assert len(output_lines) == 1
         line = output_lines[0].split()
         logger.debug(line)
         line = "".join(line)
         logger.debug(line)
         benchmark["min"] = pattern_match(line, "min=", "ms", False)
         benchmark["max"] = pattern_match(line, "max=", "ms", False)
         benchmark["avg"] = pattern_match(line, "avg=", "ms", False)
         benchmark["std_dev"] = pattern_match(line, "std_dev=", "ms", False)
     elif framework_name == "ncnn":
         is_no_vulkan = list(
             filter(
                 lambda line: "no vulkan device" in line or
                 '"libvulkan.so" not found' in line,
                 output_lines,
             ))
         is_no_vulkan = len(is_no_vulkan) > 0
         if is_no_vulkan:
             return benchmark
         else:
             output_lines = filter(lambda line: "min = " in line,
                                   output_lines)  # noqa
             output_lines = list(output_lines)
             logger.debug("output_lines:\n{}".format(output_lines))
             assert len(output_lines) == 1
             line = output_lines[0]
             line = line.split()
             logger.debug(line)
             line = "".join(line) + "END"
             benchmark["min"] = pattern_match(line, "min=", "max", False)
             benchmark["max"] = pattern_match(line, "max=", "avg", False)
             benchmark["avg"] = pattern_match(line, "avg=", "std_dev",
                                              False)  # noqa
             benchmark["std_dev"] = pattern_match(line, "std_dev=", "END",
                                                  False)  # noqa
     else:
         logger.fatal("Unsupported framework {}".format(  # noqa
             self.config["framework_name"]  # noqa
         )  # noqa
                      )
         exit(1)
     logger.info("benchmark:{}".format(benchmark))
     assert len(benchmark) != 0
     return benchmark