bm_mesh_io.py 2.42 KB
Newer Older
facebook-github-bot's avatar
facebook-github-bot committed
1
2
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.

3
4
from itertools import product

facebook-github-bot's avatar
facebook-github-bot committed
5
6
7
8
9
10
from fvcore.common.benchmark import benchmark
from test_obj_io import TestMeshObjIO
from test_ply_io import TestMeshPlyIO


def bm_save_load() -> None:
11
    simple_kwargs_list = [
12
13
14
        {"V": 100, "F": 200},
        {"V": 1000, "F": 2000},
        {"V": 10000, "F": 20000},
facebook-github-bot's avatar
facebook-github-bot committed
15
16
    ]
    benchmark(
17
18
19
        TestMeshObjIO.bm_load_simple_obj_with_init,
        "LOAD_SIMPLE_OBJ",
        simple_kwargs_list,
facebook-github-bot's avatar
facebook-github-bot committed
20
21
22
        warmup_iters=1,
    )
    benchmark(
23
24
25
        TestMeshObjIO.bm_save_simple_obj_with_init,
        "SAVE_SIMPLE_OBJ",
        simple_kwargs_list,
facebook-github-bot's avatar
facebook-github-bot committed
26
27
28
        warmup_iters=1,
    )
    benchmark(
29
30
31
32
        TestMeshPlyIO.bm_load_simple_ply_with_init,
        "LOAD_SIMPLE_PLY",
        simple_kwargs_list,
        warmup_iters=1,
facebook-github-bot's avatar
facebook-github-bot committed
33
34
    )
    benchmark(
35
36
37
38
        TestMeshPlyIO.bm_save_simple_ply_with_init,
        "SAVE_SIMPLE_PLY",
        simple_kwargs_list,
        warmup_iters=1,
facebook-github-bot's avatar
facebook-github-bot committed
39
    )
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

    complex_kwargs_list = [{"N": 8}, {"N": 32}, {"N": 128}]
    benchmark(
        TestMeshObjIO.bm_load_complex_obj,
        "LOAD_COMPLEX_OBJ",
        complex_kwargs_list,
        warmup_iters=1,
    )
    benchmark(
        TestMeshObjIO.bm_save_complex_obj,
        "SAVE_COMPLEX_OBJ",
        complex_kwargs_list,
        warmup_iters=1,
    )
    benchmark(
        TestMeshPlyIO.bm_load_complex_ply,
        "LOAD_COMPLEX_PLY",
        complex_kwargs_list,
        warmup_iters=1,
    )
    benchmark(
        TestMeshPlyIO.bm_save_complex_ply,
        "SAVE_COMPLEX_PLY",
        complex_kwargs_list,
        warmup_iters=1,
    )
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

    # Texture loading benchmarks
    kwargs_list = [{"R": 2}, {"R": 4}, {"R": 10}, {"R": 15}, {"R": 20}]
    benchmark(
        TestMeshObjIO.bm_load_texture_atlas,
        "PYTORCH3D_TEXTURE_ATLAS",
        kwargs_list,
        warmup_iters=1,
    )

    kwargs_list = []
    S = [64, 256, 1024]
    F = [100, 1000, 10000]
    R = [5, 10, 20]
    test_cases = product(S, F, R)

    for case in test_cases:
        s, f, r = case
        kwargs_list.append({"S": s, "F": f, "R": r})

    benchmark(
        TestMeshObjIO.bm_bilinear_sampling_vectorized,
        "BILINEAR_VECTORIZED",
        kwargs_list,
        warmup_iters=1,
    )
    benchmark(
        TestMeshObjIO.bm_bilinear_sampling_grid_sample,
        "BILINEAR_GRID_SAMPLE",
        kwargs_list,
        warmup_iters=1,
    )
Christoph Lassner's avatar
Christoph Lassner committed
98
99
100
101


if __name__ == "__main__":
    bm_save_load()