pub trait TensorType: Default + Clone + Display + Debug + 'static {
    // Required methods
    fn data_type() -> DataType;
    fn zero() -> Self;
    fn one() -> Self;
    fn is_repr_c() -> bool;
    fn unpack(data: &[u8], count: usize) -> Result<Vec<Self>>;
    fn pack(data: &[Self], dims: &[u64]) -> Result<*mut TF_Tensor>;
}
Expand description

A Rust type that maps to a DataType.

Currently, all implementors must not implement Drop (or transitively contain anything that does) and must be bit-for-bit compatible with the corresponding C type. Clients must not implement this trait.

This trait doesn’t require num::Zero or num::One because some tensor types (such as bool and String) don’t implement them and we need to supply custom implementations.

Required Methods§

source

fn data_type() -> DataType

Returns the DataType that corresponds to this type.

source

fn zero() -> Self

Returns the zero value.

source

fn one() -> Self

Returns the one value.

source

fn is_repr_c() -> bool

Return true if the data has the same representation in C and Rust and can be written/read directly.

source

fn unpack(data: &[u8], count: usize) -> Result<Vec<Self>>

Unpacks data from C. Returns an error if is_repr_c() is true for this type or some other error occurred.

source

fn pack(data: &[Self], dims: &[u64]) -> Result<*mut TF_Tensor>

Packs data for sending to C. Returns an error if is_repr_c() returns true for this type or some other error occurred.

Implementations on Foreign Types§

source§

impl TensorType for u8

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for u64

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for f32

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for i32

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for Complex<f64>

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for f16

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for u32

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for i64

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for Complex<f32>

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for String

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(data: &[u8], count: usize) -> Result<Vec<Self>>

source§

fn pack(data: &[Self], dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for f64

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for i8

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for bool

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for i16

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

source§

impl TensorType for u16

source§

fn data_type() -> DataType

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn is_repr_c() -> bool

source§

fn unpack(_data: &[u8], _count: usize) -> Result<Vec<Self>>

source§

fn pack(_data: &[Self], _dims: &[u64]) -> Result<*mut TF_Tensor>

Implementors§