mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-20 22:30:35 +08:00
Benchmark Cameras
Summary: Address comments to add benchmarkings for cameras and the new fisheye cameras. The dependency functions in test_cameras have been updated in Diff 1. The following two snapshots show benchmarking results. Reviewed By: kjchalup Differential Revision: D38991914 fbshipit-source-id: 51fe9bb7237543e4ee112c9f5068a4cf12a9d482
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2283c292a9
commit
03562d87f5
59
tests/benchmarks/bm_cameras.py
Normal file
59
tests/benchmarks/bm_cameras.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# Copyright (c) Meta Platforms, Inc. and 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.
|
||||
|
||||
import itertools
|
||||
|
||||
from fvcore.common.benchmark import benchmark
|
||||
from tests.test_cameras import TestCamerasCommon
|
||||
|
||||
|
||||
def _setUp():
|
||||
case_grid = {
|
||||
"cam_type": [
|
||||
"OpenGLOrthographicCameras",
|
||||
"OpenGLPerspectiveCameras",
|
||||
"SfMOrthographicCameras",
|
||||
"SfMPerspectiveCameras",
|
||||
"FoVOrthographicCameras",
|
||||
"FoVPerspectiveCameras",
|
||||
"OrthographicCameras",
|
||||
"PerspectiveCameras",
|
||||
"FishEyeCameras",
|
||||
],
|
||||
"batch_size": [1, 10],
|
||||
"num_points": [10, 100],
|
||||
"device": ["cpu", "cuda:0"],
|
||||
}
|
||||
test_cases = itertools.product(*case_grid.values())
|
||||
kwargs_list = [dict(zip(case_grid.keys(), case)) for case in test_cases]
|
||||
return kwargs_list
|
||||
|
||||
|
||||
def _bm_cameras_project() -> None:
|
||||
kwargs_list = _setUp()
|
||||
benchmark(
|
||||
TestCamerasCommon.transform_points,
|
||||
"TEST_TRANSFORM_POINTS",
|
||||
kwargs_list,
|
||||
)
|
||||
|
||||
|
||||
def _bm_cameras_unproject() -> None:
|
||||
kwargs_list = _setUp()
|
||||
benchmark(
|
||||
TestCamerasCommon.unproject_points,
|
||||
"TEST_UNPROJECT_POINTS",
|
||||
kwargs_list,
|
||||
)
|
||||
|
||||
|
||||
def bm_cameras() -> None:
|
||||
_bm_cameras_project()
|
||||
_bm_cameras_unproject()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
bm_cameras()
|
||||
Reference in New Issue
Block a user