Skip to main content

validate_read_into_destination

Function validate_read_into_destination 

Source
pub fn validate_read_into_destination(
    op: &'static str,
    inputs: &[TensorRead<'_>],
    out: &TensorWrite<'_>,
) -> Result<()>
Expand description

Validate that a caller-owned destination does not overlap any read input.

The check is intentionally conservative for host views: two views backed by the same host allocation are treated as overlapping because the allocation identity is the only stable boundary contract available to erased backend code. Backend allocations use their domain/allocation identity when the provider exposes it.

§Errors

Returns tenferro_tensor_core::ValidationError::InvalidArgument when the destination storage overlaps an input, or Error::RuntimeState when storage identity cannot be established safely.

§Examples

use tenferro_tensor::{Tensor, TensorRead, TensorWrite};
use tenferro_tensor::backend::validate_read_into_destination;

let input = Tensor::from_vec_col_major(vec![1], vec![1.0_f64])?;
let mut output = Tensor::from_vec_col_major(vec![1], vec![0.0_f64])?;
validate_read_into_destination(
    "example",
    &[TensorRead::from_tensor(&input)],
    &TensorWrite::from_tensor(&mut output),
)?;