[][src]Trait tensorflow::TensorType

pub trait TensorType: Default + Clone + Display + Debug + 'static {
    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 packed_size(data: &[Self]) -> usize;
fn pack(data: &[Self], buffer: &mut [u8]) -> Result<()>; }

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

Returns the DataType that corresponds to this type.

Returns the zero value.

Returns the one value.

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

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

Returns the number of bytes in the packed representation. If is_repr_c() returns true, this will return 0.

Packs data for sending to C. Returns an error if is_repr_c() returns true for this type or some other error occurred. The size of the buffer must be at least as large as the value returned by packed_size(data).

Implementations on Foreign Types

impl TensorType for f32
[src]

impl TensorType for f64
[src]

impl TensorType for i32
[src]

impl TensorType for u8
[src]

impl TensorType for u16
[src]

impl TensorType for u32
[src]

impl TensorType for u64
[src]

impl TensorType for i16
[src]

impl TensorType for i8
[src]

impl TensorType for Complex<f32>
[src]

impl TensorType for Complex<f64>
[src]

impl TensorType for i64
[src]

impl TensorType for bool
[src]

impl TensorType for String
[src]

Implementors

impl TensorType for BFloat16
[src]

impl TensorType for QInt16
[src]

impl TensorType for QInt32
[src]

impl TensorType for QInt8
[src]

impl TensorType for QUInt16
[src]

impl TensorType for QUInt8
[src]