Add an easy way to create tensor objects.

This commit is contained in:
laurent
2023-06-19 20:59:26 +01:00
parent 01eeb0e72f
commit 26d6288eb6
6 changed files with 77 additions and 14 deletions

View File

@ -2,7 +2,7 @@ use crate::{DType, Device};
// TODO: Think about whether we would be better off with a dtype and
// a buffer as an owned slice of bytes.
pub(crate) enum CpuStorage {
pub enum CpuStorage {
F32(Vec<f32>),
F64(Vec<f64>),
}
@ -17,18 +17,18 @@ impl CpuStorage {
}
#[allow(dead_code)]
pub(crate) enum Storage {
pub enum Storage {
Cpu(CpuStorage),
}
impl Storage {
pub(crate) fn device(&self) -> Device {
pub fn device(&self) -> Device {
match self {
Self::Cpu(_) => Device::Cpu,
}
}
pub(crate) fn dtype(&self) -> DType {
pub fn dtype(&self) -> DType {
match self {
Self::Cpu(storage) => storage.dtype(),
}