예제 #1
0
    model = Model(2048, 101, np.random.randint(20, size=20))
    data = torch.randn((1, 750, 2048))
    macs, params = profile(model, inputs=(data, 'cpu', False,torch.from_numpy(
            np.array([138, 391, 286, 206, 102, 750, 385, 193, 198, 325, 318, 347, 280, 700,
                      228, 202, 147, 254, 283, 185, 219, 321, 310, 583, 62, 226, 175, 750,
                      316, 255, 89, 51])) ))
    FLOPs = macs * 2
    print('FLOPs: %d' % FLOPs)  # 6601728000
    print('params: %d' % params) # 4405450


    from facebookresearch_params_flops_remove_g import params_count, flop_count

    print('facebookresearch params: %d' % params_count(model))  # 4405652
    flop_dict, _ = flop_count(model, (data,))  # 4401152
    flops = sum(flop_dict.values())
    print('facebookresearch flops: %d' % flops)




    model = Model(2048, 101, np.random.randint(20, size=20)).cuda()
    data = torch.randn((1, 750, 2048)).cuda()

    t1 = time.time()
    for i in range(1000):
        res = model(data, torch.device("cuda"), is_training=False, seq_len=torch.from_numpy(
            np.array([138, 391, 286, 206, 102, 750, 385, 193, 198, 325, 318, 347, 280, 700,
                      228, 202, 147, 254, 283, 185, 219, 321, 310, 583, 62, 226, 175, 750,
                      316, 255, 89, 51])).cuda())
예제 #2
0
파일: GTAN.py 프로젝트: yilonghe/A2Net
if __name__ == '__main__':
    import sys
    sys.path.append('/disk3/zt/code/2_TIP_rebuttal/5_FLOPs_inference_time/lib')
    from config import cfg, update_config
    cfg_file = '/disk3/zt/code/2_TIP_rebuttal/5_FLOPs_inference_time/experiments/thumos/A2Net.yaml'
    update_config(cfg_file)

    model = GTAN(cfg)
    data = torch.randn((1, 2048, 512))
    macs, params = profile(model, inputs=(data, ))
    FLOPs = macs * 2
    print('FLOPs: %d' % FLOPs)  # 5011222384
    print('params: %d' % params)  # 107635264

    from facebookresearch_params_flops_remove_g import params_count, flop_count

    print('facebookresearch params: %d' % params_count(model))  # 107635264
    flop_dict, _ = flop_count(model, (data, ))  # 2504884224
    flops = sum(flop_dict.values())
    print('facebookresearch flops: %d' % flops)

    # Inference Time
    import time
    model = GTAN(cfg).cuda()
    data = torch.randn((1, 2048, 512)).cuda()
    t1 = time.time()
    for i in range(1000):
        res = model(data)
    t2 = time.time()
    print("Inference Time:", (t2 - t1) / 1000)  # 0.01113538670539856
예제 #3
0
파일: BMN.py 프로젝트: yilonghe/A2Net
    #     """
    #     return np.sum([p.numel() for p in model.parameters()]).item()
    #
    #
    # print('facebookresearch params: %d' % params_count(model))
    #
    # from fvcore.nn.flop_count import flop_count
    #
    # gflop_dict, _ = flop_count(model, (data,))  #36978564
    # gflops = sum(gflop_dict.values())
    # print('facebookresearch gflops: %d' % gflops) # 91

    from facebookresearch_params_flops_remove_g import params_count, flop_count

    print('facebookresearch params: %d' % params_count(model))  # 36978564
    flop_dict, _ = flop_count(model, (data, ))  # 91248435200
    flops = sum(flop_dict.values())
    print('facebookresearch flops: %d' % flops)

    model = BMN(opt).cuda()
    input = torch.randn((1, 400, 100)).cuda()
    t1 = time.time()
    for i in range(1000):
        a, b, c = model(input)
    t2 = time.time()
    print((t2 - t1) / 1000)
    #   0.016720424890518188
    #   0.020179431200027464
    #   0.020179431200027464
    #   0.02353054356575012
예제 #4
0
파일: A2Net.py 프로젝트: yilonghe/A2Net
    #         model (model): model to count the number of parameters.
    #     """
    #     return np.sum([p.numel() for p in model.parameters()]).item()
    #
    #
    # print('facebookresearch params: %d' % params_count(model))
    #
    # from fvcore.nn.flop_count import flop_count
    #
    # gflop_dict, _ = flop_count(model, (data,))  #65527534
    # gflops = sum(gflop_dict.values())
    # print('facebookresearch gflops: %d' % gflops) # 1

    from facebookresearch_params_flops_remove_g import params_count, flop_count

    print('facebookresearch params: %d' % params_count(model))  #65527534
    flop_dict, _ = flop_count(model, (data, ))  # 1239018496
    flops = sum(flop_dict.values())
    print('facebookresearch flops: %d' % flops)

    # Inference Time
    import time
    model = LocNet(cfg).cuda()
    data = torch.randn((1, 2048, 128)).cuda()
    t1 = time.time()
    for i in range(1000):
        res = model(data)
    t2 = time.time()
    print("Inference Time:",
          (t2 - t1) / 1000)  # 0.013252334356307984  small change every time
예제 #5
0
파일: SSAD.py 프로젝트: yilonghe/A2Net
    cfg_file = '/disk3/zt/code/2_TIP_rebuttal/5_FLOPs_inference_time/experiments/thumos/A2Net.yaml'
    update_config(cfg_file)

    model = SSAD(cfg)
    data = torch.randn((1, 303, 512))
    # out = model(data)
    # for i in out:
    #     print(i.size())
    macs, params = profile(model, inputs=(data, ))
    FLOPs = macs * 2
    print('FLOPs: %d' % FLOPs)  # 905643072
    print('params: %d' % params)  # 3735608

    from facebookresearch_params_flops_remove_g import params_count, flop_count

    print('facebookresearch params: %d' % params_count(model))  # 3735608
    flop_dict, _ = flop_count(model, (data, ))  # 452640768
    flops = sum(flop_dict.values())
    print('facebookresearch flops: %d' % flops)

    # Inference Time
    import time

    model = SSAD(cfg).cuda()
    data = torch.randn((1, 303, 512)).cuda()
    t1 = time.time()
    for i in range(1000):
        res = model(data)
    t2 = time.time()
    print("Inference Time:", (t2 - t1) / 1000)  # 0.00236631178855896