|
Graphite
|
Represents a group of factors which will be processed together on the GPU. More...
#include <factor.hpp>


Public Types | |
| using | InvP = std::conditional_t< is_low_precision< S >::value, T, S > |
| using | Traits = FTraits |
| using | VertexDescriptorTuple = typename Traits::VertexDescriptors |
| using | VertexTypesTuple = transform_tuple_t< VertexDescriptorTuple, get_vertex_type > |
| using | VertexPointerTuple = transform_tuple_t< VertexDescriptorTuple, get_vertex_pointer_type > |
| using | VertexPointerPointerTuple = transform_tuple_t< VertexDescriptorTuple, get_vertex_pointer_pointer_type > |
| using | ObservationType = typename Traits::Observation |
| using | ConstraintDataType = typename Traits::Data |
| using | LossType = typename Traits::Loss |
Public Types inherited from graphite::BaseFactorDescriptor< T, S > | |
| using | InvP = std::conditional_t< is_low_precision< S >::value, T, S > |
Public Member Functions | |
| template<typename... VertexDescPtrs, typename = std::enable_if_t<sizeof...(VertexDescPtrs) == N>> | |
| FactorDescriptor (VertexDescPtrs... vertex_descriptors) | |
| Constructs a FactorDescriptor with the given vertex descriptors. | |
| void | compute_error () override |
| Computes the residuals across all factors in the descriptor. | |
| void | compute_error_autodiff (StreamPool &streams) override |
| Simultaneously computes the residuals and corresponding Jacobians using automatic differentiation. | |
| void | compute_b_async (T *b, const T *jacobian_scales) override |
| Computes the gradient vector b asynchronously. | |
| void | compute_Jv (T *out, T *in, const T *jacobian_scales, StreamPool &streams) override |
| Computes the product of the Jacobian matrix and a vector. | |
| void | compute_Jtv (T *out, T *in, const T *jacobian_scales, StreamPool &streams) override |
| Computes the product of the transposed Jacobian matrix and a vector. | |
| void | flag_active_vertices_async (const uint8_t level) override |
| void | compute_jacobians (StreamPool &streams) override |
| Computes the Jacobians using manual differentiation. | |
| void | compute_hessian_block_diagonal_async (std::unordered_map< BaseVertexDescriptor< T, S > *, thrust::device_vector< InvP > > &block_diagonals, const T *jacobian_scales, cudaStream_t stream) override |
| Computes the block diagonal of the Hessian matrix asynchronously. | |
| void | compute_hessian_scalar_diagonal_async (T *diagonal, const T *jacobian_scales) override |
| Computes the scalar diagonal of the Hessian matrix asynchronously. | |
| size_t | get_num_descriptors () const override |
| Returns the number of vertex descriptors (same as the number of vertices for each factor). | |
| JacobianStorage< S > * | get_jacobians () override |
| Returns the Jacobian storage for the factor. | |
| void | reserve (size_t size) |
| Reserves memory for the factor. Generally, you should always reserve the memory you need before adding factors, because reallocating GPU memory is expensive. | |
| void | remove_factor (const size_t id) |
| Removes a factor by its id. | |
| size_t | add_factor (const std::array< size_t, N > &ids, const ObservationType &obs=ObservationType(), const S *precision_matrix=nullptr, const ConstraintDataType &constraint_data=ConstraintDataType(), const LossType &loss_func=LossType()) |
| Adds a factor to the descriptor. | |
| void | set_active (size_t id, const uint8_t active_value) |
| Sets the active state of a factor. | |
| void | reset_active () |
| Resets the active state of all factors to 0x1. | |
| size_t | internal_count () const |
| Returns the number of all active and inactive factors. | |
| size_t | active_count () const override |
| Returns the number of active factors. | |
| void | initialize_device_ids (const uint8_t optimization_level) override |
| Initializes the device ids and a list of active factors. | |
| void | to_device () override |
| Prepares descriptor for GPU processing. | |
| void | link_factors (const std::array< BaseVertexDescriptor< T, S > *, N > &vertex_descriptors) |
| Links the factor to the given vertex descriptors. This is already called during construction. | |
| template<std::size_t... I> | |
| VertexPointerPointerTuple | get_vertices_impl (std::index_sequence< I... >) |
| VertexPointerPointerTuple | get_vertices () |
| Returns a tuple of vertex pointers. | |
| void | initialize_jacobian_storage () override |
| Allocates memory for the Jacobians. | |
| virtual size_t | get_residual_size () const override |
| Returns the size of the vector for all active and inactive residuals. | |
| virtual T | chi2 () override |
| Computes the chi-squared value for all active and inactive factors. | |
| T | chi2 (const size_t id) const |
| Returns the chi-squared value for a specific factor. | |
| ConstraintDataType * | get_constraint_data (const size_t id) |
| Returns the constraint data for a specific factor. | |
| std::array< size_t, N > | get_vertex_ids (const size_t id) const |
| Returns the vertex ids connected to a specific factor. | |
| virtual void | scale_jacobians_async (T *jacobian_scales) override |
| Scales the Jacobians asynchronously. | |
| virtual bool | use_autodiff () override |
| Determines whether to use automatic differentiation based on the traits of the factor. | |
| virtual void | set_jacobian_storage (const bool store) |
| Sets whether to store the Jacobians. If false, Jacobians will be computed dynamically (on-the-fly), which requires manual differentiation. | |
| virtual bool | store_jacobians () override |
| Returns whether the Jacobians are stored. | |
| virtual bool | supports_dynamic_jacobians () override |
| Determines whether dynamic Jacobian computation is supported (only supported for manual differentiation). | |
| virtual void | get_hessian_block_coordinates (thrust::device_vector< BlockCoordinates > &block_coords) override |
| Determines which Hessian blocks are filled in (upper triangle). | |
| virtual size_t | setup_hessian_computation (std::unordered_map< BlockCoordinates, size_t > &block_indices, thrust::device_vector< S > &d_hessian, size_t *h_block_offsets, StreamPool &streams) override |
| Sets up data needed to compute the upper triangle of the Hessian matrix on the GPU. | |
| virtual size_t | execute_hessian_computation (std::unordered_map< BlockCoordinates, size_t > &block_indices, thrust::device_vector< S > &d_hessian, size_t *d_block_offsets, StreamPool &streams) override |
| Executes the Hessian block computations for this descriptor using the data from setup_hessian_computation. | |
| void | clear () |
| Clears all data associated with this factor descriptor. | |
Static Public Member Functions | |
| static constexpr size_t | get_num_vertices () |
| Returns the number of vertices connected to each factor. | |
| template<std::size_t... I> | |
| static constexpr std::array< size_t, N > | get_vertex_sizes_impl (std::index_sequence< I... >) |
| static constexpr std::array< size_t, N > | get_vertex_sizes () |
| Returns the sizes (dimensions) of the vertices. | |
Public Attributes | |
| std::array< BaseVertexDescriptor< T, S > *, N > | vertex_descriptors |
| thrust::host_vector< size_t > | host_ids |
| thrust::device_vector< size_t > | device_ids |
| managed_vector< ObservationType > | device_obs |
| thrust::device_vector< T > | residuals |
| managed_vector< S > | precision_matrices |
| managed_vector< ConstraintDataType > | data |
| managed_vector< T > | chi2_vec |
| thrust::device_vector< S > | chi2_derivative |
| managed_vector< LossType > | loss |
| thrust::host_vector< uint8_t > | active |
| thrust::device_vector< uint8_t > | device_active |
| thrust::device_vector< size_t > | active_indices |
| std::array< JacobianStorage< S >, N > | jacobians |
| std::array< S, Traits::dimension *Traits::dimension > | default_precision_matrix |
Static Public Attributes | |
| static constexpr size_t | N |
| static constexpr size_t | error_dim = Traits::dimension |
Static Private Member Functions | |
| static constexpr std::array< S, error_dim *error_dim > | get_default_precision_matrix () |
| Gets the default precision matrix (identity matrix). | |
Private Attributes | |
| std::vector< size_t > | global_ids |
| std::unordered_map< size_t, size_t > | global_to_local_map |
| std::vector< size_t > | local_to_global_map |
| HandleManager< size_t > | hm |
| bool | _store_jacobians |
| size_t | _active_count |
Represents a group of factors which will be processed together on the GPU.
|
inline |
Constructs a FactorDescriptor with the given vertex descriptors.
| VertexDescPtrs | Types of the vertex descriptor pointers. |
| vertex_descriptors | Pointers to the vertex descriptors. |
|
inlineoverridevirtual |
Returns the number of active factors.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inline |
Adds a factor to the descriptor.
| ids | The ids of the vertices connected to the factor. Note that later arguments have default values. |
| obs | The observation associated with the factor. |
| precision_matrix | The precision matrix for the factor (default nullptr is the identity matrix). |
| constraint_data | The constraint data for the factor. |
| loss_func | The loss function for the factor. |
|
inlineoverridevirtual |
Computes the chi-squared value for all active and inactive factors.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inline |
Returns the chi-squared value for a specific factor.
| id | The id of the factor. |
|
inlineoverridevirtual |
Computes the gradient vector b asynchronously.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Computes the residuals across all factors in the descriptor.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Simultaneously computes the residuals and corresponding Jacobians using automatic differentiation.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Computes the block diagonal of the Hessian matrix asynchronously.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Computes the scalar diagonal of the Hessian matrix asynchronously.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Computes the Jacobians using manual differentiation.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Computes the product of the transposed Jacobian matrix and a vector.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Computes the product of the Jacobian matrix and a vector.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Executes the Hessian block computations for this descriptor using the data from setup_hessian_computation.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Implements graphite::BaseFactorDescriptor< T, S >.
|
inline |
Returns the constraint data for a specific factor.
| id | The id of the factor. |
|
inlinestaticconstexprprivate |
Gets the default precision matrix (identity matrix).
|
inlineoverridevirtual |
Determines which Hessian blocks are filled in (upper triangle).
| block_coords | A vector to be filled with the coordinates of the Hessian blocks that are filled in by this factor descriptor. |
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Returns the Jacobian storage for the factor.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Returns the number of vertex descriptors (same as the number of vertices for each factor).
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Returns the size of the vector for all active and inactive residuals.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inline |
Returns the vertex ids connected to a specific factor.
| id | The id of the factor. |
|
inlinestaticconstexpr |
Returns the sizes (dimensions) of the vertices.
|
inline |
Returns a tuple of vertex pointers.
|
inlineoverridevirtual |
Initializes the device ids and a list of active factors.
| optimization_level | The optimization level to use. |
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Allocates memory for the Jacobians.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inline |
Returns the number of all active and inactive factors.
|
inline |
Links the factor to the given vertex descriptors. This is already called during construction.
| vertex_descriptors | The array of vertex descriptors to link. |
|
inline |
Removes a factor by its id.
| id | The id of the factor to remove (i.e. the id returned by add_factor). |
|
inline |
Reserves memory for the factor. Generally, you should always reserve the memory you need before adding factors, because reallocating GPU memory is expensive.
| size | The number of factors to reserve memory for. |
|
inlineoverridevirtual |
Scales the Jacobians asynchronously.
| jacobian_scales | Pointer to the array of scales for the Jacobians. |
Implements graphite::BaseFactorDescriptor< T, S >.
|
inline |
Sets the active state of a factor.
| id | The id of the factor. |
| active_value | The active state value to set (e.g 0). |
|
inlinevirtual |
Sets whether to store the Jacobians. If false, Jacobians will be computed dynamically (on-the-fly), which requires manual differentiation.
| store | True to store the Jacobians (default mode), false to compute them dynamically. |
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Sets up data needed to compute the upper triangle of the Hessian matrix on the GPU.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Returns whether the Jacobians are stored.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Determines whether dynamic Jacobian computation is supported (only supported for manual differentiation).
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Prepares descriptor for GPU processing.
Implements graphite::BaseFactorDescriptor< T, S >.
|
inlineoverridevirtual |
Determines whether to use automatic differentiation based on the traits of the factor.
Implements graphite::BaseFactorDescriptor< T, S >.
|
staticconstexpr |