symforce.codegen.backends.cuda.cuda_config module#
- class CudaConfig(doc_comment_line_prefix=' * ', line_length=100, use_eigen_types=False, render_template_config=<factory>, cse_optimizations=None, zero_epsilon_behavior=<factory>, normalize_results=True, override_methods=None, extra_imports=None, scalar_type=ScalarType.FLOAT, inline=True, builtin_vector_variables=<factory>)[source]#
Bases:
CodegenConfig
Code generation config for the CUDA backend.
- Parameters:
doc_comment_line_prefix (str) – Prefix applied to each line in a docstring
line_length (int) – Maximum allowed line length in docstrings; used for formatting docstrings.
use_eigen_types (bool) – Use eigen_lcm types for vectors instead of lists
autoformat – Run a code formatter on the generated code
custom_preamble – An optional string to be prepended on the front of the rendered template
cse_optimizations (Literal['basic'] | ~typing.Sequence[~typing.Tuple[~typing.Callable, ~typing.Callable]] | None) – Optimizations argument to pass to
sf.cse
zero_epsilon_behavior (ZeroEpsilonBehavior) – What should codegen do if a default epsilon is not set?
normalize_results (bool) – Should function outputs be explicitly projected onto the manifold before returning?
override_methods (Dict[Function, str] | None) – Add special function overrides in dictionary with symforce function keys (e.g.
sympy.sin
) and a string for the new method (e.g."fast_math::sin_lut"
), note that this bypasses the default namespace (so std:: won’t be added in front automatically). Note that the keys here need to be sympy keys, not symengine (e.g.sympy.sin
NOTsf.sin
with the symengine backend). SymEngine to SymPy conversion does not work forFunction
types. Note that this function works in the code printer, and should only be used for replacing functions that compute the same thing but in a different way, e.g. replacingsin
withmy_lib::sin
. It should not be used for substituting a function with a different function, which will break derivatives and certain simplifications, e.g. you should not use this to replacesin
withcos
orsin
withmy_lib::cos
.extra_imports (List[str] | None) – Add extra imports to the file if you use custom overrides for some functions (e.g. add fast_math.h). Note that these are only added on a call to
generate_function
, i.e. you can’t define custom functions in e.g. the geo package using thisscalar_type (ScalarType) – The scalar type to use (float or double)
inline (bool) – Whether to generate inline functions (in the header) or a separate
.cu
file containing the function definitionbuiltin_vector_variables (Set[str]) – Names of inputs and outputs that should use CUDA’s builtin vector types instead of pointers to scalars
render_template_config (RenderTemplateConfig) –
- scalar_type: ScalarType = FloatType(String('float32'), nbits=Integer(32), nmant=Integer(23), nexp=Integer(8))#
- classmethod backend_name()[source]#
String name for the backend. This should match the directory name in codegen/backends and will be used to namespace by backend in generated code.
- Return type:
- templates_to_render(generated_file_name)[source]#
Given a single symbolic function’s filename, provide one or more Jinja templates to render and the relative output paths where they should go.