[−][src]Trait tensorflow::TensorType
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)
.