mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-21 06:40:35 +08:00
move benchmarks to separate directory
Summary: Move benchmarks to a separate directory as tests/ is getting big. Reviewed By: nikhilaravi Differential Revision: D32885462 fbshipit-source-id: a832662a494ee341ab77d95493c95b0af0a83f43
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a6508ac3df
commit
a0e2d2e3c3
65
tests/benchmarks/bm_chamfer.py
Normal file
65
tests/benchmarks/bm_chamfer.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
# 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.
|
||||
|
||||
from itertools import product
|
||||
|
||||
import torch
|
||||
from fvcore.common.benchmark import benchmark
|
||||
from test_chamfer import TestChamfer
|
||||
|
||||
|
||||
def bm_chamfer() -> None:
|
||||
# Currently disabled.
|
||||
return
|
||||
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}
|
||||
)
|
||||
|
||||
benchmark(
|
||||
TestChamfer.chamfer_naive_with_init,
|
||||
"CHAMFER_NAIVE",
|
||||
kwargs_list_naive,
|
||||
warmup_iters=1,
|
||||
)
|
||||
|
||||
if torch.cuda.is_available():
|
||||
device = "cuda:0"
|
||||
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,
|
||||
"device": device,
|
||||
}
|
||||
)
|
||||
benchmark(TestChamfer.chamfer_with_init, "CHAMFER", kwargs_list, warmup_iters=1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
bm_chamfer()
|
||||
Reference in New Issue
Block a user