Source code for symforce.codegen.backends.pytorch.pytorch_config
# ----------------------------------------------------------------------------# SymForce - Copyright 2022, Skydio, Inc.# This source code is under the Apache 2.0 license found in the LICENSE file.# ----------------------------------------------------------------------------fromdataclassesimportdataclassfrompathlibimportPathfromsympy.printing.codeprinterimportCodePrinterfromsymforceimporttypingasTfromsymforce.codegen.backends.pytorchimportpytorch_code_printerfromsymforce.codegen.codegen_configimportCodegenConfigCURRENT_DIR=Path(__file__).parent
[docs]@dataclassclassPyTorchConfig(CodegenConfig):""" Code generation config for the PyTorch backend. Args: doc_comment_line_prefix: Prefix applied to each line in a docstring line_length: Maximum allowed line length in docstrings; used for formatting docstrings. use_eigen_types: 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: Optimizations argument to pass to :func:`sf.cse <symforce.symbolic.cse>` zero_epsilon_behavior: What should codegen do if a default epsilon is not set? normalize_results: Should function outputs be explicitly projected onto the manifold before returning? """doc_comment_line_prefix:str=""line_length:int=100use_eigen_types:bool=False
[docs]@staticmethoddefformat_eigen_lcm_accessor(key:str,i:int)->str:""" Format accessor for eigen_lcm types. """raiseNotImplementedError("Can't pass eigen_lcm types to PyTorch functions")