macro_rules! flat_obs {
($ty:ident { $($field:ident),+ $(,)? }) => { ... };
}Expand description
Implements FlatObs for an observation struct of several fields (for
Native): the fields, in the order given, flattened one after another,
with the shape [total size].
ยงExamples
use ruxla_core::{Array, Backend, I32, Native, Tree};
use ruxla_env::FlatObs;
#[derive(Clone, Tree)]
struct Obs<B: Backend> {
grid: Array<B, f32>,
steps: I32<B>,
}
ruxla_env::flat_obs!(Obs { grid, steps });
let obs = Obs::<Native> { grid: Array::from_slice(&[1.0, 2.0], [2]), steps: I32::new(7) };
let mut out = [0.0; 3];
obs.write_f32(&mut out);
assert_eq!((obs.shape(), out), (vec![3], [1.0, 2.0, 7.0]));