pub enum CpuTensorRef<'a> {
F32 {
data: &'a [f32],
shape: &'a Shape,
},
F64 {
data: &'a [f64],
shape: &'a Shape,
},
F16 {
data: &'a [f16],
shape: &'a Shape,
},
BF16 {
data: &'a [bf16],
shape: &'a Shape,
},
I8 {
data: &'a [i8],
shape: &'a Shape,
},
I16 {
data: &'a [i16],
shape: &'a Shape,
},
I32 {
data: &'a [i32],
shape: &'a Shape,
},
I64 {
data: &'a [i64],
shape: &'a Shape,
},
U8 {
data: &'a [u8],
shape: &'a Shape,
},
U32 {
data: &'a [u32],
shape: &'a Shape,
},
Bool {
data: &'a [u8],
shape: &'a Shape,
},
}Expand description
Read-only typed view of one input tensor handed to a CpuKernel.
The variant matches the input’s declared dtype on the IR side.
Variants§
Implementations§
Source§impl<'a> CpuTensorRef<'a>
impl<'a> CpuTensorRef<'a>
pub fn shape(&self) -> &Shape
pub fn dtype(&self) -> DType
pub fn as_f32(&self) -> Option<&[f32]>
pub fn expect_f32(&self, role: &str) -> Result<&[f32], String>
pub fn as_f64(&self) -> Option<&[f64]>
pub fn expect_f64(&self, role: &str) -> Result<&[f64], String>
pub fn as_f16(&self) -> Option<&[f16]>
pub fn expect_f16(&self, role: &str) -> Result<&[f16], String>
pub fn as_bf16(&self) -> Option<&[bf16]>
pub fn expect_bf16(&self, role: &str) -> Result<&[bf16], String>
pub fn as_i8(&self) -> Option<&[i8]>
pub fn expect_i8(&self, role: &str) -> Result<&[i8], String>
pub fn as_i16(&self) -> Option<&[i16]>
pub fn expect_i16(&self, role: &str) -> Result<&[i16], String>
pub fn as_i32(&self) -> Option<&[i32]>
pub fn expect_i32(&self, role: &str) -> Result<&[i32], String>
pub fn as_i64(&self) -> Option<&[i64]>
pub fn expect_i64(&self, role: &str) -> Result<&[i64], String>
pub fn as_u8(&self) -> Option<&[u8]>
pub fn expect_u8(&self, role: &str) -> Result<&[u8], String>
pub fn as_u32(&self) -> Option<&[u32]>
pub fn expect_u32(&self, role: &str) -> Result<&[u32], String>
pub fn as_bool(&self) -> Option<&[u8]>
pub fn expect_bool(&self, role: &str) -> Result<&[u8], String>
Auto Trait Implementations§
impl<'a> Freeze for CpuTensorRef<'a>
impl<'a> RefUnwindSafe for CpuTensorRef<'a>
impl<'a> Send for CpuTensorRef<'a>
impl<'a> Sync for CpuTensorRef<'a>
impl<'a> Unpin for CpuTensorRef<'a>
impl<'a> UnsafeUnpin for CpuTensorRef<'a>
impl<'a> UnwindSafe for CpuTensorRef<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more