airs_types/tensor/
mod.rs

1use crate::DataType;
2
3pub mod data_type;
4pub mod device;
5mod from_image;
6
7#[derive(Debug, Default)]
8pub struct Tensor {
9    kind: DataType,
10}
11impl Tensor {
12    /// Creates a new tensor with the specified data type.
13    pub fn get_type(&self) -> DataType {
14        self.kind
15    }
16    /// Sets the data type of the tensor.
17    ///
18    /// # Arguments
19    ///
20    /// * `kind`: The data type of the tensor.
21    ///
22    /// # Examples
23    ///
24    /// ```
25    /// use airs_types::Tensor;
26    /// let mut tensor = Tensor::default();
27    /// unsafe { tensor.set_type(airs_types::DataType::Float) };
28    /// ```
29    pub unsafe fn set_type(&mut self, kind: DataType) {
30        self.kind = kind;
31    }
32    pub fn cast_type(&mut self, kind: DataType) {
33        self.kind = kind;
34    }
35    pub fn with_type(mut self, kind: DataType) -> Self {
36        self.cast_type(kind);
37        self
38    }
39    pub fn get_bytes(&self) -> &[u8] {
40        todo!()
41    }
42    pub unsafe fn set_bytes(&mut self, bytes: &[u8]) {
43        todo!()
44    }
45    pub fn with_bytes(mut self, bytes: &[u8]) -> Self {
46        unsafe { self.set_bytes(bytes) };
47        self
48    }
49}