"docs/integrations/xcode.mdx" did not exist on "6d02a43a75cd3364b3c230e9070f1413e60f0d02"
bm_chamfer.py 1.62 KB
Newer Older
facebook-github-bot's avatar
facebook-github-bot committed
1
2
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.

Nikhila Ravi's avatar
Nikhila Ravi committed
3
from itertools import product
facebook-github-bot's avatar
facebook-github-bot committed
4
5
6
7
8
9
10

import torch
from fvcore.common.benchmark import benchmark
from test_chamfer import TestChamfer


def bm_chamfer() -> None:
Christoph Lassner's avatar
Christoph Lassner committed
11
12
    # Currently disabled.
    return
Nikhila Ravi's avatar
Nikhila Ravi committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    devices = ["cpu"]
    if torch.cuda.is_available():
        devices.append("cuda:0")

    kwargs_list_naive = []
    batch_size = [1, 32]
    return_normals = [True, False]
    test_cases = product(batch_size, return_normals, devices)

    for case in test_cases:
        b, n, d = case
        kwargs_list_naive.append(
            {"batch_size": b, "P1": 32, "P2": 64, "return_normals": n, "device": d}
        )

facebook-github-bot's avatar
facebook-github-bot committed
28
29
30
31
32
33
34
35
    benchmark(
        TestChamfer.chamfer_naive_with_init,
        "CHAMFER_NAIVE",
        kwargs_list_naive,
        warmup_iters=1,
    )

    if torch.cuda.is_available():
Nikhila Ravi's avatar
Nikhila Ravi committed
36
        device = "cuda:0"
Nikhila Ravi's avatar
Nikhila Ravi committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
        kwargs_list = []
        batch_size = [1, 32]
        P1 = [32, 1000, 10000]
        P2 = [64, 3000, 30000]
        return_normals = [True, False]
        homogeneous = [True, False]
        test_cases = product(batch_size, P1, P2, return_normals, homogeneous)

        for case in test_cases:
            b, p1, p2, n, h = case
            kwargs_list.append(
                {
                    "batch_size": b,
                    "P1": p1,
                    "P2": p2,
                    "return_normals": n,
                    "homogeneous": h,
Nikhila Ravi's avatar
Nikhila Ravi committed
54
                    "device": device,
Nikhila Ravi's avatar
Nikhila Ravi committed
55
56
                }
            )
57
        benchmark(TestChamfer.chamfer_with_init, "CHAMFER", kwargs_list, warmup_iters=1)
Christoph Lassner's avatar
Christoph Lassner committed
58
59
60
61


if __name__ == "__main__":
    bm_chamfer()