Skip to main content

TensorScalar

Trait TensorScalar 

Source
pub trait TensorScalar:
    Copy
    + Clone
    + Send
    + Sync
    + 'static
    + Sealed {
    type Real: TensorScalar;

    // Required methods
    fn dtype() -> DType;
    fn into_tensor(shape: ShapeVec, data: Vec<Self>) -> Tensor;
    fn tensor_slice(tensor: &Tensor) -> Option<&[Self]>;
    fn tensor_mut_slice(tensor: &mut Tensor) -> Option<&mut [Self]>;
    fn into_typed(tensor: Tensor) -> Option<HostTensor<Self>>;
}
Expand description

Sealed trait for scalar types supported by the core tensor data model.

§Examples

use tenferro_tensor_core::{DType, TensorScalar};

assert_eq!(f64::dtype(), DType::F64);
assert_eq!(num_complex::Complex64::dtype(), DType::C64);

Required Associated Types§

Source

type Real: TensorScalar

Real-valued counterpart of this scalar type.

Required Methods§

Source

fn dtype() -> DType

Return the scalar dtype tag.

§Examples
use tenferro_tensor_core::{DType, TensorScalar};

assert_eq!(i64::dtype(), DType::I64);
Source

fn into_tensor(shape: ShapeVec, data: Vec<Self>) -> Tensor

Source

fn tensor_slice(tensor: &Tensor) -> Option<&[Self]>

Source

fn tensor_mut_slice(tensor: &mut Tensor) -> Option<&mut [Self]>

Source

fn into_typed(tensor: Tensor) -> Option<HostTensor<Self>>

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 TensorScalar for bool

Source§

type Real = bool

Source§

fn dtype() -> DType

Source§

fn into_tensor(shape: ShapeVec, data: Vec<Self>) -> Tensor

Source§

fn tensor_slice(tensor: &Tensor) -> Option<&[Self]>

Source§

fn tensor_mut_slice(tensor: &mut Tensor) -> Option<&mut [Self]>

Source§

fn into_typed(tensor: Tensor) -> Option<HostTensor<Self>>

Source§

impl TensorScalar for f32

Source§

type Real = f32

Source§

fn dtype() -> DType

Source§

fn into_tensor(shape: ShapeVec, data: Vec<Self>) -> Tensor

Source§

fn tensor_slice(tensor: &Tensor) -> Option<&[Self]>

Source§

fn tensor_mut_slice(tensor: &mut Tensor) -> Option<&mut [Self]>

Source§

fn into_typed(tensor: Tensor) -> Option<HostTensor<Self>>

Source§

impl TensorScalar for f64

Source§

type Real = f64

Source§

fn dtype() -> DType

Source§

fn into_tensor(shape: ShapeVec, data: Vec<Self>) -> Tensor

Source§

fn tensor_slice(tensor: &Tensor) -> Option<&[Self]>

Source§

fn tensor_mut_slice(tensor: &mut Tensor) -> Option<&mut [Self]>

Source§

fn into_typed(tensor: Tensor) -> Option<HostTensor<Self>>

Source§

impl TensorScalar for i32

Source§

type Real = i32

Source§

fn dtype() -> DType

Source§

fn into_tensor(shape: ShapeVec, data: Vec<Self>) -> Tensor

Source§

fn tensor_slice(tensor: &Tensor) -> Option<&[Self]>

Source§

fn tensor_mut_slice(tensor: &mut Tensor) -> Option<&mut [Self]>

Source§

fn into_typed(tensor: Tensor) -> Option<HostTensor<Self>>

Source§

impl TensorScalar for i64

Source§

type Real = i64

Source§

fn dtype() -> DType

Source§

fn into_tensor(shape: ShapeVec, data: Vec<Self>) -> Tensor

Source§

fn tensor_slice(tensor: &Tensor) -> Option<&[Self]>

Source§

fn tensor_mut_slice(tensor: &mut Tensor) -> Option<&mut [Self]>

Source§

fn into_typed(tensor: Tensor) -> Option<HostTensor<Self>>

Source§

impl TensorScalar for Complex32

Source§

type Real = f32

Source§

fn dtype() -> DType

Source§

fn into_tensor(shape: ShapeVec, data: Vec<Self>) -> Tensor

Source§

fn tensor_slice(tensor: &Tensor) -> Option<&[Self]>

Source§

fn tensor_mut_slice(tensor: &mut Tensor) -> Option<&mut [Self]>

Source§

fn into_typed(tensor: Tensor) -> Option<HostTensor<Self>>

Source§

impl TensorScalar for Complex64

Source§

type Real = f64

Source§

fn dtype() -> DType

Source§

fn into_tensor(shape: ShapeVec, data: Vec<Self>) -> Tensor

Source§

fn tensor_slice(tensor: &Tensor) -> Option<&[Self]>

Source§

fn tensor_mut_slice(tensor: &mut Tensor) -> Option<&mut [Self]>

Source§

fn into_typed(tensor: Tensor) -> Option<HostTensor<Self>>

Implementors§