blob: c4648a623823ba84283fb650999512f3c31c852b [file] [log] [blame]
Austin Schuh033df092019-01-21 19:46:48 -08001# Ceres Solver - A fast non-linear least squares minimizer
2# Copyright 2018 Google Inc. All rights reserved.
3# http://ceres-solver.org/
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are met:
7#
8# * Redistributions of source code must retain the above copyright notice,
9# this list of conditions and the following disclaimer.
10# * Redistributions in binary form must reproduce the above copyright notice,
11# this list of conditions and the following disclaimer in the documentation
12# and/or other materials provided with the distribution.
13# * Neither the name of Google Inc. nor the names of its contributors may be
14# used to endorse or promote products derived from this software without
15# specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27# POSSIBILITY OF SUCH DAMAGE.
28#
29# Author: mierle@gmail.com (Keir Mierle)
30#
31# These are Bazel rules to build Ceres. It's currently in Alpha state, and does
32# not support parameterization around threading choice or sparse backends.
33
34load("//:bazel/ceres.bzl", "ceres_library")
35
36ceres_library(
37 name = "ceres",
38 restrict_schur_specializations = False,
39)
40
41cc_library(
42 name = "test_util",
43 srcs = ["internal/ceres/" + x for x in [
44 "evaluator_test_utils.cc",
45 "numeric_diff_test_utils.cc",
46 "test_util.cc",
47 "gmock_gtest_all.cc",
48 "gmock_main.cc",
49 "gmock/gmock.h",
50 "gmock/mock-log.h",
51 "gtest/gtest.h",
52 ]],
53 hdrs = [
54 "internal/ceres/gmock/gmock.h",
55 "internal/ceres/gmock/mock-log.h",
56 "internal/ceres/gtest/gtest.h",
57 ],
58 copts = [
59 "-Wno-sign-compare",
60 "-DCERES_TEST_SRCDIR_SUFFIX=\\\"data/\\\"",
Austin Schuh033df092019-01-21 19:46:48 -080061 ],
62 includes = [
63 "internal",
64 "internal/ceres",
65 ],
66 deps = [
67 "//:ceres",
68 "@com_github_gflags_gflags//:gflags",
69 ],
70)
71
72CERES_TESTS = [
73 "array_utils",
74 "autodiff_cost_function",
75 "autodiff_local_parameterization",
76 "autodiff",
77 "block_jacobi_preconditioner",
78 "block_random_access_dense_matrix",
79 "block_random_access_diagonal_matrix",
80 "block_random_access_sparse_matrix",
81 "block_sparse_matrix",
82 "canonical_views_clustering",
83 "c_api",
84 "compressed_col_sparse_matrix_utils",
85 "compressed_row_sparse_matrix",
86 "concurrent_queue",
87 "conditioned_cost_function",
88 "conjugate_gradients_solver",
89 "corrector",
90 "cost_function_to_functor",
91 "covariance",
92 "cubic_interpolation",
93 "dense_linear_solver",
94 "dense_sparse_matrix",
95 "detect_structure",
96 "dogleg_strategy",
97 "dynamic_autodiff_cost_function",
98 "dynamic_compressed_row_sparse_matrix",
99 "dynamic_numeric_diff_cost_function",
100 "dynamic_sparse_normal_cholesky_solver",
101 "dynamic_sparsity",
102 "evaluation_callback",
103 "evaluator",
104 "gradient_checker",
105 "gradient_checking_cost_function",
106 "gradient_problem_solver",
107 "gradient_problem",
108 "graph_algorithms",
109 "graph",
110 "householder_vector",
111 "implicit_schur_complement",
112 "inner_product_computer",
113 "invert_psd_matrix",
114 "is_close",
115 "iterative_refiner",
116 "iterative_schur_complement_solver",
117 "jet",
118 "levenberg_marquardt_strategy",
119 "line_search_minimizer",
120 "line_search_preprocessor",
121 "local_parameterization",
122 "loss_function",
123 "minimizer",
124 "normal_prior",
125 "numeric_diff_cost_function",
126 "ordered_groups",
127 "parallel_for",
128 "parallel_utils",
129 "parameter_block_ordering",
130 "parameter_block",
131 "partitioned_matrix_view",
132 "polynomial",
133 "problem",
134 "program",
135 "reorder_program",
136 "residual_block",
137 "residual_block_utils",
138 "rotation",
139 "schur_complement_solver",
140 "schur_eliminator",
141 "single_linkage_clustering",
142 "small_blas",
143 "solver",
144 "sparse_cholesky",
145 "sparse_normal_cholesky_solver",
146 "subset_preconditioner",
147 "system",
148 "thread_pool",
149 "tiny_solver_autodiff_function",
150 "tiny_solver_cost_function_adapter",
151 "tiny_solver",
152 "triplet_sparse_matrix",
153 "trust_region_minimizer",
154 "trust_region_preprocessor",
155 "visibility_based_preconditioner",
156 "visibility",
157]
158
159TEST_COPTS = [
160 # Needed to silence GFlags complaints.
161 "-Wno-sign-compare",
162
163 # These two warnings don't work well in conjunction with GMock, and
164 # trigger incorrectly on parts of rotation_test. For now, disable them,
165 # but in the future disable these warnings only for rotation_test.
166 # TODO(keir): When the tests are macro-ified, apply these selectively.
167 "-Wno-address",
168 "-Wno-unused-parameter",
Austin Schuhf386bf92020-12-23 22:16:19 -0800169]
Austin Schuh033df092019-01-21 19:46:48 -0800170
171TEST_DEPS = [
172 "//:ceres",
173 "//:test_util",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700174 "@org_tuxfamily_eigen//:eigen",
Austin Schuh033df092019-01-21 19:46:48 -0800175 "@com_github_gflags_gflags//:gflags",
176]
177
178# Instantiate all the tests with a template.
179[cc_test(
180 name = test_name + "_test",
181 timeout = "short",
182 srcs = ["internal/ceres/" + test_name + "_test.cc"],
183 copts = TEST_COPTS,
184 deps = TEST_DEPS,
185) for test_name in CERES_TESTS]
186
187# Instantiate all the bundle adjustment tests. These are separate to
188# parallelize the execution of the tests; otherwise the tests take a long time.
189#
190# Note: While it is possible to run the Python script to generate the .cc files
191# as part of the build, it introduces an undesirable build-time Python
192# dependency that we'd prefer to avoid.
193[cc_test(
194 name = test_filename.split("/")[-1][:-3], # Remove .cc.
195 timeout = "moderate",
196 srcs = [test_filename],
197 copts = TEST_COPTS,
198
199 # This is the data set that is bundled for the testing.
200 data = [":data/problem-16-22106-pre.txt"],
201 deps = TEST_DEPS,
202) for test_filename in glob([
203 "internal/ceres/generated_bundle_adjustment_tests/*_test.cc",
204])]
205
206# Build the benchmarks.
207[cc_binary(
208 name = benchmark_name,
209 srcs = ["internal/ceres/" + benchmark_name + ".cc"],
210 copts = TEST_COPTS,
211 deps = TEST_DEPS + ["@com_github_google_benchmark//:benchmark"],
212) for benchmark_name in [
Austin Schuh033df092019-01-21 19:46:48 -0800213 "small_blas_gemm_benchmark",
214 "small_blas_gemv_benchmark",
215]]