tensorflow

Trait TensorType

Source
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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

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 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 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 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 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 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 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 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>

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 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 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 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 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 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>

Implementors§