pub trait TensorIndexing: TensorStructural {
Show 15 methods
// Required methods
fn gather(
&mut self,
operand: &Tensor,
start_indices: &Tensor,
config: &GatherConfig,
) -> Result<Tensor>;
fn scatter(
&mut self,
operand: &Tensor,
scatter_indices: &Tensor,
updates: &Tensor,
config: &ScatterConfig,
) -> Result<Tensor>;
fn slice(&mut self, input: &Tensor, config: &SliceConfig) -> Result<Tensor>;
fn dynamic_slice(
&mut self,
input: &Tensor,
starts: &Tensor,
slice_sizes: &[usize],
) -> Result<Tensor>;
fn dynamic_update_slice(
&mut self,
operand: &Tensor,
update: &Tensor,
starts: &Tensor,
) -> Result<Tensor>;
fn pad(&mut self, input: &Tensor, config: &PadConfig) -> Result<Tensor>;
fn concatenate(&mut self, inputs: &[&Tensor], axis: usize) -> Result<Tensor>;
fn reverse(&mut self, input: &Tensor, axes: &[usize]) -> Result<Tensor>;
// Provided methods
fn scatter_read(
&mut self,
operand: TensorRead<'_>,
scatter_indices: TensorRead<'_>,
updates: TensorRead<'_>,
config: &ScatterConfig,
) -> Result<Tensor> { ... }
fn slice_read(
&mut self,
input: TensorRead<'_>,
config: &SliceConfig,
) -> Result<Tensor> { ... }
fn dynamic_slice_read(
&mut self,
input: TensorRead<'_>,
starts: TensorRead<'_>,
slice_sizes: &[usize],
) -> Result<Tensor> { ... }
fn dynamic_update_slice_read(
&mut self,
operand: TensorRead<'_>,
update: TensorRead<'_>,
starts: TensorRead<'_>,
) -> Result<Tensor> { ... }
fn pad_read(
&mut self,
input: TensorRead<'_>,
config: &PadConfig,
) -> Result<Tensor> { ... }
fn concatenate_read(
&mut self,
inputs: &[TensorRead<'_>],
axis: usize,
) -> Result<Tensor> { ... }
fn reverse_read(
&mut self,
input: TensorRead<'_>,
axes: &[usize],
) -> Result<Tensor> { ... }
}Expand description
Indexing, slicing, and padding operations.
§Examples
use tenferro_tensor::TensorIndexing;
fn accepts_indexing<B: TensorIndexing>(_backend: &mut B) {}Required Methods§
Sourcefn gather(
&mut self,
operand: &Tensor,
start_indices: &Tensor,
config: &GatherConfig,
) -> Result<Tensor>
fn gather( &mut self, operand: &Tensor, start_indices: &Tensor, config: &GatherConfig, ) -> Result<Tensor>
§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn scatter(
&mut self,
operand: &Tensor,
scatter_indices: &Tensor,
updates: &Tensor,
config: &ScatterConfig,
) -> Result<Tensor>
fn scatter( &mut self, operand: &Tensor, scatter_indices: &Tensor, updates: &Tensor, config: &ScatterConfig, ) -> Result<Tensor>
§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn slice(&mut self, input: &Tensor, config: &SliceConfig) -> Result<Tensor>
fn slice(&mut self, input: &Tensor, config: &SliceConfig) -> Result<Tensor>
§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. In
particular, a limit greater than the corresponding input dimension is
reported as crate::ValidationError::InvalidArgument with the
"configuration" argument. It returns crate::Error::BackendFailure
or crate::Error::BackendSource when backend execution or storage
access cannot provide the requested result.
Sourcefn dynamic_slice(
&mut self,
input: &Tensor,
starts: &Tensor,
slice_sizes: &[usize],
) -> Result<Tensor>
fn dynamic_slice( &mut self, input: &Tensor, starts: &Tensor, slice_sizes: &[usize], ) -> Result<Tensor>
§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn dynamic_update_slice(
&mut self,
operand: &Tensor,
update: &Tensor,
starts: &Tensor,
) -> Result<Tensor>
fn dynamic_update_slice( &mut self, operand: &Tensor, update: &Tensor, starts: &Tensor, ) -> Result<Tensor>
§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn pad(&mut self, input: &Tensor, config: &PadConfig) -> Result<Tensor>
fn pad(&mut self, input: &Tensor, config: &PadConfig) -> Result<Tensor>
§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn concatenate(&mut self, inputs: &[&Tensor], axis: usize) -> Result<Tensor>
fn concatenate(&mut self, inputs: &[&Tensor], axis: usize) -> Result<Tensor>
§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn reverse(&mut self, input: &Tensor, axes: &[usize]) -> Result<Tensor>
fn reverse(&mut self, input: &Tensor, axes: &[usize]) -> Result<Tensor>
§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Provided Methods§
Sourcefn scatter_read(
&mut self,
operand: TensorRead<'_>,
scatter_indices: TensorRead<'_>,
updates: TensorRead<'_>,
config: &ScatterConfig,
) -> Result<Tensor>
fn scatter_read( &mut self, operand: TensorRead<'_>, scatter_indices: TensorRead<'_>, updates: TensorRead<'_>, config: &ScatterConfig, ) -> Result<Tensor>
Scatter with every input taken as a read.
The default stages each borrowed view into compact storage (an owned tensor is passed through) and delegates to the owned-input method; a backend whose kernel consumes a borrowed operand should override this so a view is not copied (#2214).
§Examples
use tenferro_tensor::{Tensor, TensorIndexing, ScatterConfig, TensorRead};
fn run(session: &mut dyn TensorIndexing, x: TensorRead<'_>, idx: TensorRead<'_>, updates: TensorRead<'_>, config: &ScatterConfig)
-> tenferro_tensor::Result<Tensor>
{
session.scatter_read(x, idx, updates, config)
}§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn slice_read(
&mut self,
input: TensorRead<'_>,
config: &SliceConfig,
) -> Result<Tensor>
fn slice_read( &mut self, input: TensorRead<'_>, config: &SliceConfig, ) -> Result<Tensor>
Slice with the input taken as a read.
The default stages each borrowed view into compact storage (an owned tensor is passed through) and delegates to the owned-input method; a backend whose kernel consumes a borrowed operand should override this so a view is not copied (#2214).
§Examples
use tenferro_tensor::{Tensor, TensorIndexing, SliceConfig, TensorRead};
fn run(session: &mut dyn TensorIndexing, x: TensorRead<'_>, config: &SliceConfig)
-> tenferro_tensor::Result<Tensor>
{
session.slice_read(x, config)
}§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn dynamic_slice_read(
&mut self,
input: TensorRead<'_>,
starts: TensorRead<'_>,
slice_sizes: &[usize],
) -> Result<Tensor>
fn dynamic_slice_read( &mut self, input: TensorRead<'_>, starts: TensorRead<'_>, slice_sizes: &[usize], ) -> Result<Tensor>
Dynamic slice with every input taken as a read.
The default stages each borrowed view into compact storage (an owned tensor is passed through) and delegates to the owned-input method; a backend whose kernel consumes a borrowed operand should override this so a view is not copied (#2214).
§Examples
use tenferro_tensor::{Tensor, TensorIndexing, TensorRead};
fn run(session: &mut dyn TensorIndexing, x: TensorRead<'_>, starts: TensorRead<'_>)
-> tenferro_tensor::Result<Tensor>
{
session.dynamic_slice_read(x, starts, &[2])
}§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn dynamic_update_slice_read(
&mut self,
operand: TensorRead<'_>,
update: TensorRead<'_>,
starts: TensorRead<'_>,
) -> Result<Tensor>
fn dynamic_update_slice_read( &mut self, operand: TensorRead<'_>, update: TensorRead<'_>, starts: TensorRead<'_>, ) -> Result<Tensor>
Dynamic-update-slice with every input taken as a read.
The default stages each borrowed view into compact storage (an owned tensor is passed through) and delegates to the owned-input method; a backend whose kernel consumes a borrowed operand should override this so a view is not copied (#2214).
§Examples
use tenferro_tensor::{Tensor, TensorIndexing, TensorRead};
fn run(
session: &mut dyn TensorIndexing,
x: TensorRead<'_>,
update: TensorRead<'_>,
starts: TensorRead<'_>,
) -> tenferro_tensor::Result<Tensor> {
session.dynamic_update_slice_read(x, update, starts)
}§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn pad_read(
&mut self,
input: TensorRead<'_>,
config: &PadConfig,
) -> Result<Tensor>
fn pad_read( &mut self, input: TensorRead<'_>, config: &PadConfig, ) -> Result<Tensor>
Pad with the input taken as a read.
The default stages each borrowed view into compact storage (an owned tensor is passed through) and delegates to the owned-input method; a backend whose kernel consumes a borrowed operand should override this so a view is not copied (#2214).
§Examples
use tenferro_tensor::{Tensor, TensorIndexing, PadConfig, TensorRead};
fn run(session: &mut dyn TensorIndexing, x: TensorRead<'_>, config: &PadConfig)
-> tenferro_tensor::Result<Tensor>
{
session.pad_read(x, config)
}§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn concatenate_read(
&mut self,
inputs: &[TensorRead<'_>],
axis: usize,
) -> Result<Tensor>
fn concatenate_read( &mut self, inputs: &[TensorRead<'_>], axis: usize, ) -> Result<Tensor>
Concatenate with every input taken as a read.
The default stages each borrowed view into compact storage (an owned tensor is passed through) and delegates to the owned-input method; a backend whose kernel consumes a borrowed operand should override this so a view is not copied (#2214).
§Examples
use tenferro_tensor::{Tensor, TensorIndexing, TensorRead};
fn run(session: &mut dyn TensorIndexing, a: TensorRead<'_>, b: TensorRead<'_>)
-> tenferro_tensor::Result<Tensor>
{
session.concatenate_read(&[a, b], 0)
}§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcefn reverse_read(
&mut self,
input: TensorRead<'_>,
axes: &[usize],
) -> Result<Tensor>
fn reverse_read( &mut self, input: TensorRead<'_>, axes: &[usize], ) -> Result<Tensor>
Reverse with the input taken as a read.
The default stages each borrowed view into compact storage (an owned tensor is passed through) and delegates to the owned-input method; a backend whose kernel consumes a borrowed operand should override this so a view is not copied (#2214).
§Examples
use tenferro_tensor::{Tensor, TensorIndexing, TensorRead};
fn run(session: &mut dyn TensorIndexing, x: TensorRead<'_>)
-> tenferro_tensor::Result<Tensor>
{
session.reverse_read(x, &[0])
}§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".