pub struct Tensor { /* private fields */ }Expand description
Owned, cheaply cloneable tensor value used by the runtime abstraction layer.
Implementations§
Source§impl Tensor
impl Tensor
Sourcepub fn into_ort_value(self) -> Result<Value, RuntimeError>
pub fn into_ort_value(self) -> Result<Value, RuntimeError>
Converts this owned tensor into an ort value.
Sourcepub fn as_ort_input(&self) -> Result<SessionInputValue<'_>, RuntimeError>
pub fn as_ort_input(&self) -> Result<SessionInputValue<'_>, RuntimeError>
Returns a borrowed ort input value backed by this tensor’s data.
The returned SessionInputValue borrows from self; the caller must
keep this tensor alive for the duration of the run call.
Source§impl Tensor
impl Tensor
Sourcepub fn new(shape: Shape, data: TensorData) -> Result<Self, RuntimeError>
pub fn new(shape: Shape, data: TensorData) -> Result<Self, RuntimeError>
Creates a tensor, validating that data length matches shape.
Sourcepub fn new_checked(shape: Shape, data: TensorData) -> Self
pub fn new_checked(shape: Shape, data: TensorData) -> Self
Convenience constructor that panics on shape/data mismatch.
Use only when dimensions are statically known; prefer Self::new for
runtime-sized tensors.
pub fn shape(&self) -> &Shape
pub fn element_type(&self) -> ElementType
pub fn view(&self) -> TensorView<'_>
pub fn into_data(self) -> TensorData
Sourcepub fn as_f32_mut(&mut self) -> Option<&mut [f32]>
pub fn as_f32_mut(&mut self) -> Option<&mut [f32]>
Return a mutable view of the underlying f32 buffer, if this tensor is f32.
Sourcepub fn as_i32_mut(&mut self) -> Option<&mut [i32]>
pub fn as_i32_mut(&mut self) -> Option<&mut [i32]>
Return a mutable view of the underlying i32 buffer, if this tensor is i32.
Sourcepub fn as_i64_mut(&mut self) -> Option<&mut [i64]>
pub fn as_i64_mut(&mut self) -> Option<&mut [i64]>
Return a mutable view of the underlying i64 buffer, if this tensor is i64.
Trait Implementations§
impl StructuralPartialEq for Tensor
Auto Trait Implementations§
impl Freeze for Tensor
impl RefUnwindSafe for Tensor
impl Send for Tensor
impl Sync for Tensor
impl Unpin for Tensor
impl UnsafeUnpin for Tensor
impl UnwindSafe for Tensor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more