bm_sample_points_from_meshes.py 1.15 KB
Newer Older
1
# Copyright (c) Meta Platforms, Inc. and affiliates.
Patrick Labatut's avatar
Patrick Labatut committed
2
3
4
5
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
facebook-github-bot's avatar
facebook-github-bot committed
6
7
8


from itertools import product
9

facebook-github-bot's avatar
facebook-github-bot committed
10
11
12
13
14
15
16
import torch
from fvcore.common.benchmark import benchmark
from test_sample_points_from_meshes import TestSamplePoints


def bm_sample_points() -> None:

17
    backend = ["cpu"]
facebook-github-bot's avatar
facebook-github-bot committed
18
    if torch.cuda.is_available():
19
20
        backend.append("cuda:0")
    kwargs_list = []
facebook-github-bot's avatar
facebook-github-bot committed
21
22
23
    num_meshes = [2, 10, 32]
    num_verts = [100, 1000]
    num_faces = [300, 3000]
24
25
    num_samples = [5000, 10000]
    test_cases = product(num_meshes, num_verts, num_faces, num_samples, backend)
facebook-github-bot's avatar
facebook-github-bot committed
26
    for case in test_cases:
27
        n, v, f, s, b = case
facebook-github-bot's avatar
facebook-github-bot committed
28
        kwargs_list.append(
29
30
31
32
33
34
35
            {
                "num_meshes": n,
                "num_verts": v,
                "num_faces": f,
                "num_samples": s,
                "device": b,
            }
facebook-github-bot's avatar
facebook-github-bot committed
36
37
        )
    benchmark(
38
39
        TestSamplePoints.sample_points_with_init,
        "SAMPLE_MESH",
facebook-github-bot's avatar
facebook-github-bot committed
40
41
42
        kwargs_list,
        warmup_iters=1,
    )
Christoph Lassner's avatar
Christoph Lassner committed
43
44
45
46


if __name__ == "__main__":
    bm_sample_points()