Macro s
macro_rules! s {
[$range:expr] => { ... };
[$($range:expr),+] => { ... };
}
Expand description
Creates a slice specification for tensor indexing operations.
This macro simplifies the creation of tensor slices by allowing various range types to be used together in a concise way. It supports all standard Rust range types as well as negative indexing for accessing elements from the end of a dimension.
§Examples
ⓘ
// Basic slicing
let slice = tensor.slice(s![0..5, .., 3]);
// Using negative indices (counting from the end)
let last_row = tensor.slice(s![-1, ..]);
// Mixed range types
let complex_slice = tensor.slice(s![2..5, .., 0..=3, -2..]);