Exemplo n.º 1
0
class LoadPerformance(object):
    """
    init
    """
    def __init__(self, db_name, model, batch_size):
        """
        init
        """
        # init mysql
        self.mysql = LoadCommon(db_name)
        self.batch_size = batch_size
        self.model = model

    def make_excel_result(self):
        """
        analysis the excel data
        1. Net_name 
        2. Batch_size
        3. Library: RT
        4. tensorRT Latency (ms)
        5. RT Memory (MB)
        6. Library: Anakin2
        7. anakin2 Latency (ms)
        8. RT Memory (MB)
        9. anakin/tensorrt latency
        10. anakin/tensorrt memory
        """
        # 1.Net_name
        net_name = model
        # 2. Batch_size
        batch_size = self.batch_size
        # 3. Library: RT
        Library_RT = "RT"
        # 6. Library: Anakin2
        Library_anakin2 = "Anakin2"

        # 4. tensorRT Latency (ms)
        tensorRT_latency_p4 = self.mysql.select_tensorRT_latency("p4")
        tensorRT_latency_k1200 = self.mysql.select_tensorRT_latency("k1200")
        print "tensorRT_latency_p4: %s" % tensorRT_latency_p4
        print "tensorRT_latency_k1200: %s" % tensorRT_latency_k1200
        # 5. RT Memory (MB)
        tensorRT_memory_p4 = self.mysql.select_tensorRT_memory("p4")
        tensorRT_memory_k1200 = self.mysql.select_tensorRT_memory("k1200")
        print "tensorRT_memory_p4: %s" % tensorRT_memory_p4
        print "tensorRT_memory_k1200: %s" % tensorRT_memory_k1200
        # 7. anakin2 Latency (ms)
        anakin2_latency_p4 = self.mysql.select_anakin2_latency("p4")
        anakin2_latency_k1200 = self.mysql.select_anakin2_latency("k1200")
        print "anakin2_latency_p4: %s" % anakin2_latency_p4
        print "anakin2_latency_k1200: %s" % anakin2_latency_k1200
        # 8. RT Memory (MB)
        anakin2_memory_p4 = self.mysql.select_anakin2_memory("p4")
        anakin2_memory_k1200 = self.mysql.select_anakin2_memory("k1200")
        print "anakin2_memory_p4: %s" % anakin2_memory_p4
        print "anakin2_memory_k1200: %s" % anakin2_memory_k1200

        # 9. anakin/tensorrt latency
        if tensorRT_latency_p4 and anakin2_latency_p4:
            #ratio_latency_p4 = string((float(anakin2_latency_p4) / float(tensorRT_latency_p4)) * 100)
            ratio_latency_p4 = str(
                int((float(anakin2_latency_p4) / float(tensorRT_latency_p4)) *
                    100)) + "%"
        else:
            ratio_latency_p4 = None
        if tensorRT_latency_k1200 and anakin2_latency_k1200:
            ratio_latency_k1200 = str(
                int((float(anakin2_latency_k1200) /
                     float(tensorRT_latency_k1200)) * 100)) + "%"
        else:
            ratio_latency_k1200 = None
        print "ratio_latency_p4: %s" % ratio_latency_p4
        print "ratio_latency_k1200: %s" % ratio_latency_k1200

        # 10. anakin/tensorrt memory
        if tensorRT_memory_p4 and anakin2_memory_p4:
            ratio_memory_p4 = str(
                int((float(anakin2_memory_p4) / float(tensorRT_memory_p4)) *
                    100)) + "%"
        else:
            ratio_memory_p4 = None

        if tensorRT_memory_k1200 and anakin2_memory_k1200:
            ratio_memory_k1200 = str(
                int((float(anakin2_memory_k1200) /
                     float(tensorRT_memory_k1200)) * 100)) + "%"
        else:
            ratio_memory_k1200 = None
        print "ratio_memory_p4: %s" % ratio_memory_p4
        print "ratio_memory_k1200: %s" % ratio_memory_k1200

        line_data_p4 = {}
        line_data_p4["net_name"] = net_name
        line_data_p4["batch_size"] = batch_size
        line_data_p4["Library_RT"] = Library_RT
        line_data_p4["tensorRT_latency_p4"] = tensorRT_latency_p4
        line_data_p4["tensorRT_memory_p4"] = tensorRT_memory_p4
        line_data_p4["Library_anakin2"] = Library_anakin2
        line_data_p4["anakin2_latency_p4"] = anakin2_latency_p4
        line_data_p4["anakin2_memory_p4"] = anakin2_memory_p4
        line_data_p4["ratio_latency_p4"] = ratio_latency_p4
        line_data_p4["ratio_memory_p4"] = ratio_memory_p4

        line_data_k1200 = {}
        line_data_k1200["net_name"] = net_name
        line_data_k1200["batch_size"] = batch_size
        line_data_k1200["Library_RT"] = Library_RT
        line_data_k1200["tensorRT_latency_k1200"] = tensorRT_latency_k1200
        line_data_k1200["tensorRT_memory_k1200"] = tensorRT_memory_k1200
        line_data_k1200["Library_anakin2"] = Library_anakin2
        line_data_k1200["anakin2_latency_k1200"] = anakin2_latency_k1200
        line_data_k1200["anakin2_memory_k1200"] = anakin2_memory_k1200
        line_data_k1200["ratio_latency_k1200"] = ratio_latency_k1200
        line_data_k1200["ratio_memory_k1200"] = ratio_memory_k1200

        return line_data_p4, line_data_k1200
Exemplo n.º 2
0
class LoadPerformance(object):
    """
    init
    """
    def __init__(self, db_name, model, thread_size):
        """
        init
        """
        # init mysql
        self.mysql = LoadCommon(db_name)
        self.thread_size = thread_size
        self.model = model

    def make_excel_result(self):
        """
        analysis the excel data
        1. Net_name 
        2. thread_size
        3. Library: Anakin2
        4. Anakin2 Latency (ms)
        5. Anakin2 QPS (ms)
        6. Anakin2 ratio (%)
        7. Anakin2 mem (%)
        8. Library: Paddle
        9. Paddle Latency (ms)
        10. Paddle QPS (ms)
        11. Paddle ratio (%)
        12. Paddle mem (%)
        13. anakin/paddle latency
        14. anakin/paddle qps
        15. accuracy rate
        """
        # 1.Net_name
        net_name = self.model
        # 2. thread_size
        thread_size = self.thread_size
        # 3. Library: Anakin2
        Library_anakin = "Anakin2"
        # 8. Library: paddle
        Library_paddle = "Paddle"
        Library_lego = "Lego"

        # 4. anakin2 Latency (ms)
        anakin_latency_5117 = self.mysql.select_anakin2_latency("5117")
        anakin_latency_v3 = self.mysql.select_anakin2_latency("v3")
        anakin_latency_v4 = self.mysql.select_anakin2_latency("v4")
        print "anakin_latency_5117: %s" % anakin_latency_5117
        print "anakin_latency_v3: %s" % anakin_latency_v3
        print "anakin_latency_v4: %s" % anakin_latency_v4
        # 5. anakin2 QPS (ms)
        anakin_qps_5117 = self.mysql.select_anakin2_qps("5117")
        anakin_qps_v3 = self.mysql.select_anakin2_qps("v3")
        anakin_qps_v4 = self.mysql.select_anakin2_qps("v4")
        print "anakin_qps_5117: %s" % anakin_qps_5117
        print "anakin_qps_v3: %s" % anakin_qps_v3
        print "anakin_qps_v4: %s" % anakin_qps_v4
        # 6. anakin2 ratio (ms)
        anakin_ratio_5117 = self.mysql.select_anakin2_ratio("5117")
        anakin_ratio_v3 = self.mysql.select_anakin2_ratio("v3")
        anakin_ratio_v4 = self.mysql.select_anakin2_ratio("v4")
        print "anakin_ratio_5117: %s" % anakin_ratio_5117
        print "anakin_ratio_v3: %s" % anakin_ratio_v3
        print "anakin_ratio_v4: %s" % anakin_ratio_v4
        # 7. anakin2 Mem (MB)
        anakin_memory_5117  = self.mysql.select_anakin2_memory("5117")
        anakin_memory_v3  = self.mysql.select_anakin2_memory("v3")
        anakin_memory_v4  = self.mysql.select_anakin2_memory("v4")
        print "anakin_memory_5117: %s" % anakin_memory_5117
        print "anakin_memory_v3: %s" % anakin_memory_v3
        print "anakin_memory_v4: %s" % anakin_memory_v4

        # 9. paddle Latency (ms)
        paddle_latency_5117 = self.mysql.select_paddle_latency("5117")
        paddle_latency_v3 = self.mysql.select_paddle_latency("v3")
        paddle_latency_v4 = self.mysql.select_paddle_latency("v4")
        print "paddle_latency_5117: %s" % paddle_latency_5117
        print "paddle_latency_v3: %s" % paddle_latency_v3
        print "paddle_latency_v4: %s" % paddle_latency_v4
        # 10. paddle QPS (ms)
        paddle_qps_5117 = self.mysql.select_paddle_qps("5117")
        paddle_qps_v3 = self.mysql.select_paddle_qps("v3")
        paddle_qps_v4 = self.mysql.select_paddle_qps("v4")
        print "paddle_qps_5117: %s" % paddle_qps_5117
        print "paddle_qps_v3: %s" % paddle_qps_v3
        print "paddle_qps_v4: %s" % paddle_qps_v4
        # 11. paddle ratio (ms)
        paddle_ratio_5117 = self.mysql.select_paddle_ratio("5117")
        paddle_ratio_v3 = self.mysql.select_paddle_ratio("v3")
        paddle_ratio_v4 = self.mysql.select_paddle_ratio("v4")
        print "paddle_ratio_5117: %s" % paddle_ratio_5117
        print "paddle_ratio_v3: %s" % paddle_ratio_v3
        print "paddle_ratio_v4: %s" % paddle_ratio_v4
        # 12. paddle Mem (MB)
        paddle_memory_5117  = self.mysql.select_paddle_memory("5117")
        paddle_memory_v3  = self.mysql.select_paddle_memory("v3")
        paddle_memory_v4  = self.mysql.select_paddle_memory("v4")
        print "paddle_memory_5117: %s" % paddle_memory_5117
        print "paddle_memory_v3: %s" % paddle_memory_v3
        print "paddle_memory_v4: %s" % paddle_memory_v4

        # 9. lego Latency (ms)
        lego_latency_5117 = self.mysql.select_lego_latency("5117")
        lego_latency_v3 = self.mysql.select_lego_latency("v3")
        lego_latency_v4 = self.mysql.select_lego_latency("v4")
        print "lego_latency_5117: %s" % lego_latency_5117
        print "lego_latency_v3: %s" % lego_latency_v3
        print "lego_latency_v4: %s" % lego_latency_v4
        # 10. lego QPS (ms)
        lego_qps_5117 = self.mysql.select_lego_qps("5117")
        lego_qps_v3 = self.mysql.select_lego_qps("v3")
        lego_qps_v4 = self.mysql.select_lego_qps("v4")
        print "lego_qps_5117: %s" % lego_qps_5117
        print "lego_qps_v3: %s" % lego_qps_v3
        print "lego_qps_v4: %s" % lego_qps_v4
        # 11. lego ratio (ms)
        lego_ratio_5117 = self.mysql.select_lego_ratio("5117")
        lego_ratio_v3 = self.mysql.select_lego_ratio("v3")
        lego_ratio_v4 = self.mysql.select_lego_ratio("v4")
        print "lego_ratio_5117: %s" % lego_ratio_5117
        print "lego_ratio_v3: %s" % lego_ratio_v3
        print "lego_ratio_v4: %s" % lego_ratio_v4
        # 12. lego Mem (MB)
        lego_memory_5117  = self.mysql.select_lego_memory("5117")
        lego_memory_v3  = self.mysql.select_lego_memory("v3")
        lego_memory_v4  = self.mysql.select_lego_memory("v4")
        print "lego_memory_5117: %s" % lego_memory_5117
        print "lego_memory_v3: %s" % lego_memory_v3
        print "lego_memory_v4: %s" % lego_memory_v4

        # 13. anakin/paddle latency
        if anakin_latency_5117 and paddle_latency_5117:
            ratio_latency_5117 = str(int((float(anakin_latency_5117) / float(paddle_latency_5117)) * 100)) + "%"
        else:
            ratio_latency_5117 = None
        if anakin_latency_v3 and paddle_latency_v3:
            ratio_latency_v3 = str(int((float(anakin_latency_v3) / float(paddle_latency_v3)) * 100)) + "%"
        else:
            ratio_latency_v3 = None
        if anakin_latency_v4 and paddle_latency_v4:
            ratio_latency_v4 = str(int((float(anakin_latency_v4) / float(paddle_latency_v4)) * 100)) + "%"
        else:
            ratio_latency_v4 = None
        print "ratio_latency_5117: %s" % ratio_latency_5117
        print "ratio_latency_v3: %s" % ratio_latency_v3
        print "ratio_latency_v4: %s" % ratio_latency_v4

        # 14. anakin/paddle qps
        if anakin_qps_5117 and paddle_qps_5117:
            ratio_qps_5117 = str(int((float(paddle_qps_5117) / float(anakin_qps_5117)) * 100)) + "%"
        else:
            ratio_qps_5117 = None

        if anakin_qps_v3 and paddle_qps_v3:
            ratio_qps_v3 = str(int((float(paddle_qps_v3) / float(anakin_qps_v3)) * 100)) + "%"
        else:
            ratio_qps_v3 = None

        if anakin_qps_v4 and paddle_qps_v4:
            ratio_qps_v4 = str(int((float(paddle_qps_v4) / float(anakin_qps_v4)) * 100)) + "%"
        else:
            ratio_qps_v4 = None
        print "ratio_qps_5117: %s" % ratio_qps_5117
        print "ratio_qps_v3: %s" % ratio_qps_v3
        print "ratio_qps_v4: %s" % ratio_qps_v4

        # 13. anakin/lego latency
        if anakin_latency_5117 and lego_latency_5117:
            ratio_latency_5117_2 = str(int((float(anakin_latency_5117) / float(lego_latency_5117)) * 100)) + "%"
        else:
            ratio_latency_5117_2 = None
        if anakin_latency_v3 and lego_latency_v3:
            ratio_latency_v3_2 = str(int((float(anakin_latency_v3) / float(lego_latency_v3)) * 100)) + "%"
        else:
            ratio_latency_v3_2 = None
        if anakin_latency_v4 and lego_latency_v4:
            ratio_latency_v4_2 = str(int((float(anakin_latency_v4) / float(lego_latency_v4)) * 100)) + "%"
        else:
            ratio_latency_v4_2 = None
        print "ratio_latency_5117_2: %s" % ratio_latency_5117_2
        print "ratio_latency_v3_2: %s" % ratio_latency_v3_2
        print "ratio_latency_v4_2: %s" % ratio_latency_v4_2

        # 14. anakin/lego qps
        if anakin_qps_5117 and lego_qps_5117:
            ratio_qps_5117_2 = str(int((float(lego_qps_5117) / float(anakin_qps_5117)) * 100)) + "%"
        else:
            ratio_qps_5117_2 = None

        if anakin_qps_v3 and lego_qps_v3:
            ratio_qps_v3_2 = str(int((float(lego_qps_v3) / float(anakin_qps_v3)) * 100)) + "%"
        else:
            ratio_qps_v3_2 = None

        if anakin_qps_v4 and lego_qps_v4:
            ratio_qps_v4_2 = str(int((float(lego_qps_v4) / float(anakin_qps_v4)) * 100)) + "%"
        else:
            ratio_qps_v4_2 = None
        print "ratio_qps_5117_2: %s" % ratio_qps_5117_2
        print "ratio_qps_v3_2: %s" % ratio_qps_v3_2
        print "ratio_qps_v4_2: %s" % ratio_qps_v4_2


#        # 15. accuracy rate
#        accuracy_rate_5117 = self.mysql.select_accuracy_rate("5117")
#        accuracy_rate_v3 = self.mysql.select_accuracy_rate("v3")
#        accuracy_rate_v4 = self.mysql.select_accuracy_rate("v4")
#        if accuracy_rate_5117 == 0.0:
#            ratio_accuracy_rate_5117 = "0%"
#        elif accuracy_rate_5117 and accuracy_rate_5117 != 0.0:
#            ratio_accuracy_rate_5117 = str(int(accuracy_rate_5117) * 100) + "%"
#        else:
#            ratio_accuracy_rate_5117 = None
#
#        if accuracy_rate_v3 == 0.0:
#            ratio_accuracy_rate_v3 = "0%"
#        elif accuracy_rate_v3 and accuracy_rate_v3 != 0.0:
#            ratio_accuracy_rate_v3 = str(int(accuracy_rate_v3) * 100) + "%"
#        else:
#            ratio_accuracy_rate_v3 = None

#        if accuracy_rate_v4 == 0.0:
#            ratio_accuracy_rate_v4 = "0%"
#        elif accuracy_rate_v4 and accuracy_rate_v4 != 0.0:
#            ratio_accuracy_rate_v4 = str(int(accuracy_rate_v4) * 100) + "%"
#        else:
#            ratio_accuracy_rate_v4 = None
#
#        print "ratio_accuracy_rate_5117: %s" % ratio_accuracy_rate_5117
#        print "ratio_accuracy_rate_v4: %s" % ratio_accuracy_rate_v4
      
        line_data_5117 = {}
        line_data_5117["net_name"] = net_name
        line_data_5117["thread_size"] = thread_size
        line_data_5117["Library_anakin"] = Library_anakin + "_5117"
        line_data_5117["anakin_latency_5117"] = anakin_latency_5117
        line_data_5117["anakin_qps_5117"] = anakin_qps_5117
        line_data_5117["anakin_ratio_5117"] = anakin_ratio_5117
        line_data_5117["anakin_memory_5117"] = anakin_memory_5117

        line_data_5117["Library_paddle"] = Library_paddle + "_5117"
        line_data_5117["paddle_latency_5117"] = paddle_latency_5117
        line_data_5117["paddle_qps_5117"] = paddle_qps_5117
        line_data_5117["paddle_ratio_5117"] = paddle_ratio_5117
        line_data_5117["paddle_memory_5117"] = paddle_memory_5117

        line_data_5117["Library_lego"] = Library_lego + "_5117"
        line_data_5117["lego_latency_5117"] = lego_latency_5117
        line_data_5117["lego_qps_5117"] = lego_qps_5117
        line_data_5117["lego_ratio_5117"] = lego_ratio_5117
        line_data_5117["lego_memory_5117"] = lego_memory_5117

        line_data_5117["ratio_latency_5117"] = ratio_latency_5117
        line_data_5117["ratio_qps_5117"] = ratio_qps_5117
        line_data_5117["ratio_latency_5117_2"] = ratio_latency_5117_2
        line_data_5117["ratio_qps_5117_2"] = ratio_qps_5117_2
#        line_data_5117["ratio_accuracy_rate_5117"] = ratio_accuracy_rate_5117

        line_data_v3 = {}
        line_data_v3["net_name"] = net_name
        line_data_v3["thread_size"] = thread_size

        line_data_v3["Library_anakin"] = Library_anakin + "_v3"
        line_data_v3["anakin_latency_v3"] = anakin_latency_v3
        line_data_v3["anakin_qps_v3"] = anakin_qps_v3
        line_data_v3["anakin_ratio_v3"] = anakin_ratio_v3
        line_data_v3["anakin_memory_v3"] = anakin_memory_v3

        line_data_v3["Library_paddle"] = Library_paddle + "_v3"
        line_data_v3["paddle_latency_v3"] = paddle_latency_v3
        line_data_v3["paddle_qps_v3"] = paddle_qps_v3
        line_data_v3["paddle_ratio_v3"] = paddle_ratio_v3
        line_data_v3["paddle_memory_v3"] = paddle_memory_v3

        line_data_v3["Library_lego"] = Library_lego + "_v3"
        line_data_v3["lego_latency_v3"] = lego_latency_v3
        line_data_v3["lego_qps_v3"] = lego_qps_v3
        line_data_v3["lego_ratio_v3"] = lego_ratio_v3
        line_data_v3["lego_memory_v3"] = lego_memory_v3

        line_data_v3["ratio_latency_v3"] = ratio_latency_v3
        line_data_v3["ratio_qps_v3"] = ratio_qps_v3
        line_data_v3["ratio_latency_v3_2"] = ratio_latency_v3_2
        line_data_v3["ratio_qps_v3_2"] = ratio_qps_v3_2
#        line_data_v3["ratio_accuracy_rate_v3"] = ratio_accuracy_rate_v3

        line_data_v4 = {}
        line_data_v4["net_name"] = net_name
        line_data_v4["thread_size"] = thread_size

        line_data_v4["Library_anakin"] = Library_anakin + "_v4"
        line_data_v4["anakin_latency_v4"] = anakin_latency_v4
        line_data_v4["anakin_qps_v4"] = anakin_qps_v4
        line_data_v4["anakin_ratio_v4"] = anakin_ratio_v4
        line_data_v4["anakin_memory_v4"] = anakin_memory_v4

        line_data_v4["Library_paddle"] = Library_paddle + "_v4"
        line_data_v4["paddle_latency_v4"] = paddle_latency_v4
        line_data_v4["paddle_qps_v4"] = paddle_qps_v4
        line_data_v4["paddle_ratio_v4"] = paddle_ratio_v4
        line_data_v4["paddle_memory_v4"] = paddle_memory_v4

        line_data_v4["Library_lego"] = Library_lego + "_v4"
        line_data_v4["lego_latency_v4"] = lego_latency_v4
        line_data_v4["lego_qps_v4"] = lego_qps_v4
        line_data_v4["lego_ratio_v4"] = lego_ratio_v4
        line_data_v4["lego_memory_v4"] = lego_memory_v4

        line_data_v4["ratio_latency_v4"] = ratio_latency_v4
        line_data_v4["ratio_qps_v4"] = ratio_qps_v4
        line_data_v4["ratio_latency_v4_2"] = ratio_latency_v4_2
        line_data_v4["ratio_qps_v4_2"] = ratio_qps_v4_2
#        line_data_v4["ratio_accuracy_rate_v4"] = ratio_accuracy_rate_v4

        return line_data_5117, line_data_v3, line_data_v4