pub fn select_indices_on_session(
session: &mut Session<'_>,
tensor: &IdxTensor,
selected_indices: &[DynIndex],
positions: &[usize],
) -> Result<IdxTensor, IdxTensorError>Expand description
Select fixed coordinates of a dense host tensor on a caller-held explicit session.
The session counterpart of IdxTensor::select_indices: the operand is
published as compact host storage on session and the selection is the
runtime-free host movement the compact route already uses. All four floating
dtypes are served, and the result is compact host storage.
§Errors
Returns a typed IdxTensorError for the same malformed selections as the
compatibility route and for the representation/dtype refusals the session
admission applies (a tracked or device-resident operand, a structured or
diagonal payload, or a non-floating dtype).
§Examples
use tensor4all_core::{select_indices_on_session, DynIndex, IdxTensor};
use tensor4all_tensorbackend::CpuExecutionContext;
use tensor4all_tensorbackend::CpuBackend;
let context = CpuExecutionContext::from_backend(CpuBackend::with_threads(1)?);
let i = DynIndex::new_dyn(2);
let j = DynIndex::new_dyn(3);
let tensor = IdxTensor::from_dense(
vec![i, j.clone()],
vec![1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0],
)?;
let selected = context.with_concrete_session(|session| {
select_indices_on_session(session, &tensor, std::slice::from_ref(&j), &[1])
})??;
assert_eq!(selected.dense_host_values::<f64>()?, vec![3.0, 4.0]);