Skip to main content

Element

Trait Element 

Source
pub trait Element:
    Copy
    + Send
    + Sync
    + PartialEq
    + PartialOrd
    + Default
    + Debug
    + 'static
    + Sealed
    + Ops
    + BufferElement {
    type Real: Element;

    const DTYPE: DType;

    // Required methods
    fn re(self) -> Self::Real;
    fn im(self) -> Self::Real;
    fn from_parts(re: Self::Real, im: Self::Real) -> Self;
    fn to_value(self) -> Value;
    fn from_value(v: Value) -> Self;
    fn write_bytes(self, out: &mut Vec<u8>);
    fn read_bytes(bytes: &[u8]) -> Self;
    fn to_bits(self) -> u64;
    fn from_bits(bits: u64) -> Self;
}
Expand description

A Rust type that is an element type of ruxla. It is implemented for bool, the integer types, f16, bf16, f32, f64, c64, and c128.

Required Associated Constants§

Source

const DTYPE: DType

The element type.

Required Associated Types§

Source

type Real: Element

The type of the real and imaginary parts of a complex type, or the type itself for other types (the type of abs).

Required Methods§

Source

fn re(self) -> Self::Real

The real part (the value itself for other types than complex).

Source

fn im(self) -> Self::Real

The imaginary part (zero for other types than complex).

Source

fn from_parts(re: Self::Real, im: Self::Real) -> Self

The complex number with the given parts (for other types than complex, the real part; the imaginary part is ignored).

Source

fn to_value(self) -> Value

Widens the value without loss.

Source

fn from_value(v: Value) -> Self

Converts a value, with the semantics of XLA’s convert (see cast).

Source

fn write_bytes(self, out: &mut Vec<u8>)

Writes the native-endian bytes of the value.

Source

fn read_bytes(bytes: &[u8]) -> Self

Reads a value from native-endian bytes of the right length.

Source

fn to_bits(self) -> u64

The bit pattern, zero-extended to 64 bits (bool is 0 or 1).

Source

fn from_bits(bits: u64) -> Self

The value of a bit pattern in the low bits (the rest is ignored).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Element for bf16

Source§

const DTYPE: DType = DType::BF16

Source§

type Real = bf16

Source§

fn re(self) -> bf16

Source§

fn im(self) -> bf16

Source§

fn from_parts(re: bf16, _: bf16) -> bf16

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> bf16

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> bf16

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> bf16

Source§

impl Element for bool

Source§

const DTYPE: DType = DType::Bool

Source§

type Real = bool

Source§

fn re(self) -> bool

Source§

fn im(self) -> bool

Source§

fn from_parts(re: bool, _: bool) -> bool

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> bool

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> bool

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> bool

Source§

impl Element for f16

Source§

const DTYPE: DType = DType::F16

Source§

type Real = f16

Source§

fn re(self) -> f16

Source§

fn im(self) -> f16

Source§

fn from_parts(re: f16, _: f16) -> f16

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> f16

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> f16

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> f16

Source§

impl Element for f32

Source§

const DTYPE: DType = DType::F32

Source§

type Real = f32

Source§

fn re(self) -> f32

Source§

fn im(self) -> f32

Source§

fn from_parts(re: f32, _: f32) -> f32

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> f32

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> f32

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> f32

Source§

impl Element for f64

Source§

const DTYPE: DType = DType::F64

Source§

type Real = f64

Source§

fn re(self) -> f64

Source§

fn im(self) -> f64

Source§

fn from_parts(re: f64, _: f64) -> f64

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> f64

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> f64

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> f64

Source§

impl Element for i8

Source§

const DTYPE: DType = DType::I8

Source§

type Real = i8

Source§

fn re(self) -> i8

Source§

fn im(self) -> i8

Source§

fn from_parts(re: i8, _: i8) -> i8

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> i8

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> i8

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> i8

Source§

impl Element for i16

Source§

const DTYPE: DType = DType::I16

Source§

type Real = i16

Source§

fn re(self) -> i16

Source§

fn im(self) -> i16

Source§

fn from_parts(re: i16, _: i16) -> i16

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> i16

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> i16

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> i16

Source§

impl Element for i32

Source§

const DTYPE: DType = DType::I32

Source§

type Real = i32

Source§

fn re(self) -> i32

Source§

fn im(self) -> i32

Source§

fn from_parts(re: i32, _: i32) -> i32

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> i32

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> i32

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> i32

Source§

impl Element for i64

Source§

const DTYPE: DType = DType::I64

Source§

type Real = i64

Source§

fn re(self) -> i64

Source§

fn im(self) -> i64

Source§

fn from_parts(re: i64, _: i64) -> i64

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> i64

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> i64

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> i64

Source§

impl Element for u8

Source§

const DTYPE: DType = DType::U8

Source§

type Real = u8

Source§

fn re(self) -> u8

Source§

fn im(self) -> u8

Source§

fn from_parts(re: u8, _: u8) -> u8

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> u8

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> u8

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> u8

Source§

impl Element for u16

Source§

const DTYPE: DType = DType::U16

Source§

type Real = u16

Source§

fn re(self) -> u16

Source§

fn im(self) -> u16

Source§

fn from_parts(re: u16, _: u16) -> u16

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> u16

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> u16

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> u16

Source§

impl Element for u32

Source§

const DTYPE: DType = DType::U32

Source§

type Real = u32

Source§

fn re(self) -> u32

Source§

fn im(self) -> u32

Source§

fn from_parts(re: u32, _: u32) -> u32

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> u32

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> u32

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> u32

Source§

impl Element for u64

Source§

const DTYPE: DType = DType::U64

Source§

type Real = u64

Source§

fn re(self) -> u64

Source§

fn im(self) -> u64

Source§

fn from_parts(re: u64, _: u64) -> u64

Source§

fn to_value(self) -> Value

Source§

fn from_value(v: Value) -> u64

Source§

fn write_bytes(self, out: &mut Vec<u8>)

Source§

fn read_bytes(bytes: &[u8]) -> u64

Source§

fn to_bits(self) -> u64

Source§

fn from_bits(bits: u64) -> u64

Implementors§

Source§

impl Element for Complex<f32>

Source§

const DTYPE: DType = DType::C64

Source§

type Real = f32

Source§

impl Element for Complex<f64>

Source§

const DTYPE: DType = DType::C128

Source§

type Real = f64