Austin Schuh | 033df09 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 1 | # 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 | |
| 34 | load("//:bazel/ceres.bzl", "ceres_library") |
Austin Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame] | 35 | load("@//tools/build_rules:select.bzl", "cpu_select") |
Austin Schuh | 033df09 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 36 | |
| 37 | ceres_library( |
| 38 | name = "ceres", |
| 39 | restrict_schur_specializations = False, |
| 40 | ) |
| 41 | |
| 42 | cc_library( |
| 43 | name = "test_util", |
| 44 | srcs = ["internal/ceres/" + x for x in [ |
| 45 | "evaluator_test_utils.cc", |
| 46 | "numeric_diff_test_utils.cc", |
| 47 | "test_util.cc", |
| 48 | "gmock_gtest_all.cc", |
| 49 | "gmock_main.cc", |
| 50 | "gmock/gmock.h", |
| 51 | "gmock/mock-log.h", |
| 52 | "gtest/gtest.h", |
| 53 | ]], |
| 54 | hdrs = [ |
| 55 | "internal/ceres/gmock/gmock.h", |
| 56 | "internal/ceres/gmock/mock-log.h", |
| 57 | "internal/ceres/gtest/gtest.h", |
| 58 | ], |
| 59 | copts = [ |
| 60 | "-Wno-sign-compare", |
| 61 | "-DCERES_TEST_SRCDIR_SUFFIX=\\\"data/\\\"", |
| 62 | "-Wno-format-nonliteral", |
| 63 | ], |
| 64 | includes = [ |
| 65 | "internal", |
| 66 | "internal/ceres", |
| 67 | ], |
| 68 | deps = [ |
| 69 | "//:ceres", |
| 70 | "@com_github_gflags_gflags//:gflags", |
| 71 | ], |
| 72 | ) |
| 73 | |
| 74 | CERES_TESTS = [ |
| 75 | "array_utils", |
| 76 | "autodiff_cost_function", |
| 77 | "autodiff_local_parameterization", |
| 78 | "autodiff", |
| 79 | "block_jacobi_preconditioner", |
| 80 | "block_random_access_dense_matrix", |
| 81 | "block_random_access_diagonal_matrix", |
| 82 | "block_random_access_sparse_matrix", |
| 83 | "block_sparse_matrix", |
| 84 | "canonical_views_clustering", |
| 85 | "c_api", |
| 86 | "compressed_col_sparse_matrix_utils", |
| 87 | "compressed_row_sparse_matrix", |
| 88 | "concurrent_queue", |
| 89 | "conditioned_cost_function", |
| 90 | "conjugate_gradients_solver", |
| 91 | "corrector", |
| 92 | "cost_function_to_functor", |
| 93 | "covariance", |
| 94 | "cubic_interpolation", |
| 95 | "dense_linear_solver", |
| 96 | "dense_sparse_matrix", |
| 97 | "detect_structure", |
| 98 | "dogleg_strategy", |
| 99 | "dynamic_autodiff_cost_function", |
| 100 | "dynamic_compressed_row_sparse_matrix", |
| 101 | "dynamic_numeric_diff_cost_function", |
| 102 | "dynamic_sparse_normal_cholesky_solver", |
| 103 | "dynamic_sparsity", |
| 104 | "evaluation_callback", |
| 105 | "evaluator", |
| 106 | "gradient_checker", |
| 107 | "gradient_checking_cost_function", |
| 108 | "gradient_problem_solver", |
| 109 | "gradient_problem", |
| 110 | "graph_algorithms", |
| 111 | "graph", |
| 112 | "householder_vector", |
| 113 | "implicit_schur_complement", |
| 114 | "inner_product_computer", |
| 115 | "invert_psd_matrix", |
| 116 | "is_close", |
| 117 | "iterative_refiner", |
| 118 | "iterative_schur_complement_solver", |
| 119 | "jet", |
| 120 | "levenberg_marquardt_strategy", |
| 121 | "line_search_minimizer", |
| 122 | "line_search_preprocessor", |
| 123 | "local_parameterization", |
| 124 | "loss_function", |
| 125 | "minimizer", |
| 126 | "normal_prior", |
| 127 | "numeric_diff_cost_function", |
| 128 | "ordered_groups", |
| 129 | "parallel_for", |
| 130 | "parallel_utils", |
| 131 | "parameter_block_ordering", |
| 132 | "parameter_block", |
| 133 | "partitioned_matrix_view", |
| 134 | "polynomial", |
| 135 | "problem", |
| 136 | "program", |
| 137 | "reorder_program", |
| 138 | "residual_block", |
| 139 | "residual_block_utils", |
| 140 | "rotation", |
| 141 | "schur_complement_solver", |
| 142 | "schur_eliminator", |
| 143 | "single_linkage_clustering", |
| 144 | "small_blas", |
| 145 | "solver", |
| 146 | "sparse_cholesky", |
| 147 | "sparse_normal_cholesky_solver", |
| 148 | "subset_preconditioner", |
| 149 | "system", |
| 150 | "thread_pool", |
| 151 | "tiny_solver_autodiff_function", |
| 152 | "tiny_solver_cost_function_adapter", |
| 153 | "tiny_solver", |
| 154 | "triplet_sparse_matrix", |
| 155 | "trust_region_minimizer", |
| 156 | "trust_region_preprocessor", |
| 157 | "visibility_based_preconditioner", |
| 158 | "visibility", |
| 159 | ] |
| 160 | |
| 161 | TEST_COPTS = [ |
| 162 | # Needed to silence GFlags complaints. |
| 163 | "-Wno-sign-compare", |
| 164 | |
| 165 | # These two warnings don't work well in conjunction with GMock, and |
| 166 | # trigger incorrectly on parts of rotation_test. For now, disable them, |
| 167 | # but in the future disable these warnings only for rotation_test. |
| 168 | # TODO(keir): When the tests are macro-ified, apply these selectively. |
| 169 | "-Wno-address", |
| 170 | "-Wno-unused-parameter", |
| 171 | "-Wno-format-nonliteral", |
| 172 | "-Wno-missing-braces", |
| 173 | "-Wno-missing-field-initializers", |
Austin Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame] | 174 | ] + cpu_select({ |
| 175 | "roborio": ["-Wno-nonnull-compare"], |
| 176 | "else": [], |
| 177 | }) |
Austin Schuh | 033df09 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 178 | |
| 179 | TEST_DEPS = [ |
| 180 | "//:ceres", |
| 181 | "//:test_util", |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 182 | "@org_tuxfamily_eigen//:eigen", |
Austin Schuh | 033df09 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 183 | "@com_github_gflags_gflags//:gflags", |
| 184 | ] |
| 185 | |
| 186 | # Instantiate all the tests with a template. |
| 187 | [cc_test( |
| 188 | name = test_name + "_test", |
| 189 | timeout = "short", |
| 190 | srcs = ["internal/ceres/" + test_name + "_test.cc"], |
| 191 | copts = TEST_COPTS, |
| 192 | deps = TEST_DEPS, |
| 193 | ) for test_name in CERES_TESTS] |
| 194 | |
| 195 | # Instantiate all the bundle adjustment tests. These are separate to |
| 196 | # parallelize the execution of the tests; otherwise the tests take a long time. |
| 197 | # |
| 198 | # Note: While it is possible to run the Python script to generate the .cc files |
| 199 | # as part of the build, it introduces an undesirable build-time Python |
| 200 | # dependency that we'd prefer to avoid. |
| 201 | [cc_test( |
| 202 | name = test_filename.split("/")[-1][:-3], # Remove .cc. |
| 203 | timeout = "moderate", |
| 204 | srcs = [test_filename], |
| 205 | copts = TEST_COPTS, |
| 206 | |
| 207 | # This is the data set that is bundled for the testing. |
| 208 | data = [":data/problem-16-22106-pre.txt"], |
| 209 | deps = TEST_DEPS, |
| 210 | ) for test_filename in glob([ |
| 211 | "internal/ceres/generated_bundle_adjustment_tests/*_test.cc", |
| 212 | ])] |
| 213 | |
| 214 | # Build the benchmarks. |
| 215 | [cc_binary( |
| 216 | name = benchmark_name, |
| 217 | srcs = ["internal/ceres/" + benchmark_name + ".cc"], |
| 218 | copts = TEST_COPTS, |
| 219 | deps = TEST_DEPS + ["@com_github_google_benchmark//:benchmark"], |
| 220 | ) for benchmark_name in [ |
| 221 | "autodiff_cost_function_benchmark", |
| 222 | "small_blas_gemm_benchmark", |
| 223 | "small_blas_gemv_benchmark", |
| 224 | ]] |