c9dc55111e8fdf4ab89cdd7976b17b7336bb2770,benchmark.py,,,#,53

Before Change


        "pooling_layer": [[-j] for j in range(1, 13)]
    }

    fp = open("benchmark-%d-fp16-%s.result" % (common["num_worker"], common["fp16"]), "w")
    for var_name, var_lst in experiments.items():
        // set common args
        for k, v in common.items():

After Change



if __name__ == "__main__":

    experiments = {k: common["test_%s" % k] for k in
                   ["client_batch_size", "max_batch_size", "max_seq_len", "num_client", "pooling_layer"]}

    fp = open("benchmark-%d-fp16-%s.result" % (args.num_worker, args.fp16), "w")
    for var_name, var_lst in experiments.items():
        // set common args
        for k, v in common.items():
            setattr(args, k, v)

        avg_speed = []
        for var in var_lst:
            // override exp args
            setattr(args, var_name, var)
            server = BertServer(args)
            server.start()

            // sleep until server is ready
            time.sleep(args.wait_till_ready)
            all_clients = [BenchmarkClient() for _ in range(args.num_client)]

            tprint("num_client: %d" % len(all_clients))
            for bc in all_clients:
                bc.start()

            all_thread_speed = []
            for bc in all_clients:
                bc.join()
                cur_speed = args.client_batch_size / bc.avg_time
                all_thread_speed.append(cur_speed)

            max_speed = int(max(all_thread_speed))
            min_speed = int(min(all_thread_speed))
            t_avg_speed = int(mean(all_thread_speed))

            tprint("%s: %s\t%.3f\t%d/s" % (var_name, var, bc.avg_time, t_avg_speed))
            tprint("max speed: %d\t min speed: %d" % (max_speed, min_speed))
            avg_speed.append(t_avg_speed)
            server.close()

        fp.write("//////// Speed wrt. `%s`\n\n" % var_name)
        fp.write("|`%s`|seqs/s|\n" % var_name)
        fp.write("|---|---|\n")
        for i, j in zip(var_lst, avg_speed):
            fp.write("|%s|%d|\n" % (i, j))
            fp.flush()
        fp.write("\n")
    fp.close()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: hanxiao/bert-as-service
Commit Name: c9dc55111e8fdf4ab89cdd7976b17b7336bb2770
Time: 2019-01-21
Author: hanhxiao@tencent.com
File Name: benchmark.py
Class Name:
Method Name:


Project Name: streamlit/streamlit
Commit Name: e206973444a488dd75e420f8550a41ed61864ba8
Time: 2019-08-13
Author: erik.hopf@gmail.com
File Name: docs/api-examples-source/widget.radio.py
Class Name:
Method Name:


Project Name: dmlc/gluon-nlp
Commit Name: 5ea0c27f524a3e684d9a2e6f012e30e6da2de8aa
Time: 2019-06-18
Author: linhaibin.eric@gmail.com
File Name: scripts/bert/finetune_classifier.py
Class Name:
Method Name: test