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

fn data_type() -> DataType

Returns the DataType that corresponds to this type.

fn zero() -> Self

Returns the zero value.

fn one() -> Self

Returns the one value.

fn is_repr_c() -> bool

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

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.

fn packed_size(data: &[Self]) -> usize

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

fn pack(data: &[Self], buffer: &mut [u8]) -> Result<()>

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

Loading content...

Implementations on Foreign Types

impl TensorType for f32[src]

type InnerType = TensorDataCRepr<f32>

impl TensorType for f64[src]

type InnerType = TensorDataCRepr<f64>

impl TensorType for i32[src]

type InnerType = TensorDataCRepr<i32>

impl TensorType for u8[src]

type InnerType = TensorDataCRepr<u8>

impl TensorType for u16[src]

type InnerType = TensorDataCRepr<u16>

impl TensorType for u32[src]

type InnerType = TensorDataCRepr<u32>

impl TensorType for u64[src]

type InnerType = TensorDataCRepr<u64>

impl TensorType for i16[src]

type InnerType = TensorDataCRepr<i16>

impl TensorType for i8[src]

type InnerType = TensorDataCRepr<i8>

impl TensorType for Complex<f32>[src]

type InnerType = TensorDataCRepr<Complex<f32>>

impl TensorType for Complex<f64>[src]

type InnerType = TensorDataCRepr<Complex<f64>>

impl TensorType for i64[src]

type InnerType = TensorDataCRepr<i64>

impl TensorType for bool[src]

type InnerType = TensorDataCRepr<bool>

impl TensorType for String[src]

type InnerType = TensorDataNoCRepr<String>

Loading content...

Implementors

impl TensorType for BFloat16[src]

type InnerType = TensorDataCRepr<BFloat16>

impl TensorType for QInt16[src]

type InnerType = TensorDataCRepr<QInt16>

impl TensorType for QInt32[src]

type InnerType = TensorDataCRepr<QInt32>

impl TensorType for QInt8[src]

type InnerType = TensorDataCRepr<QInt8>

impl TensorType for QUInt16[src]

type InnerType = TensorDataCRepr<QUInt16>

impl TensorType for QUInt8[src]

type InnerType = TensorDataCRepr<QUInt8>

Loading content...