BUILD 6.6 KB

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