-
Notifications
You must be signed in to change notification settings - Fork 160
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When generating Rust code from a function that returns a matrix, the generated function returns a vector with the same number of elements as the matrix.
To Reproduce
Steps to reproduce the behavior, e.g.:
Take this script:
import symforce
symforce.set_epsilon_to_number()
import symforce.symbolic as sf
from symforce import codegen
from symforce.codegen.backends.rust.rust_config import RustConfig
from symforce.notebook_util import display_code_file
def create_matrix() -> sf.Matrix:
return sf.Matrix55(
1, 2, 3, 4, 5,
6, 7, 8, 9, 10,
11, 12, 13, 14, 15,
16, 17, 18, 19, 20,
21, 22, 23, 24, 25,
)
output_dir = "./generated"
config = RustConfig()
codegen = codegen.Codegen.function(
create_matrix,
config=RustConfig(),
)
data = codegen.generate_function(output_dir)This generates the following Rust file
// -----------------------------------------------------------------------------
// This file was autogenerated by symforce from template:
// function/FUNCTION.rs.jinja
// Do NOT modify by hand.
// -----------------------------------------------------------------------------
pub mod sym {
#[allow(unused_parens)]
///
/// This function was autogenerated from a symbolic function. Do not modify by hand.
///
/// Symbolic function: create_matrix
///
/// Outputs:
/// res: Matrix55
pub fn create_matrix() -> nalgebra::SVector<f64, 25> {
// Total ops: 0
// Intermediate terms (0)
// Output terms (1)
nalgebra::SVector::<f64, 25>::new(
1_f64, 6_f64, 11_f64, 16_f64, 21_f64, 2_f64, 7_f64, 12_f64, 17_f64, 22_f64, 3_f64,
8_f64, 13_f64, 18_f64, 23_f64, 4_f64, 9_f64, 14_f64, 19_f64, 24_f64, 5_f64, 10_f64,
15_f64, 20_f64, 25_f64,
)
}
} // mod symAs you can see the generated function returns a nalgebra::SVector<f64, 25> while it should return a nalgebra::SMatrix<f64, 25, 25>.
Expected behavior
The generated function should use the correct return type.
Environment (please complete the following information):
- OS and version: Pop!_OS 22.04 LTS
- Python version: 3.10
- SymForce Version: 0.10.1
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working