pub struct Tensor {
pub shape: TensorShape,
pub data: TensorData,
}Expand description
A typed tensor with shape and data (used in challenges and mining results).
Fields§
§shape: TensorShapeShape (dimension sizes).
data: TensorDataElement data.
Implementations§
Source§impl Tensor
impl Tensor
Sourcepub fn new(shape: TensorShape, data: TensorData) -> TribeResult<Self>
pub fn new(shape: TensorShape, data: TensorData) -> TribeResult<Self>
Builds a tensor; errors if data length does not match shape.
Sourcepub fn zeros(shape: TensorShape) -> Self
pub fn zeros(shape: TensorShape) -> Self
Creates a tensor of zeros with the given shape.
Sourcepub fn from_slot_hash(hash_bytes: &[u8]) -> Self
pub fn from_slot_hash(hash_bytes: &[u8]) -> Self
Builds a 1D tensor from raw hash bytes (normalized to 0..1).
pub fn calculate_hash(&self) -> String
Sourcepub fn clamp_dimensions(&self, max_dim: usize) -> Self
pub fn clamp_dimensions(&self, max_dim: usize) -> Self
Clamp tensor dimensions to a maximum size (for ESP compatibility).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tensor
impl<'de> Deserialize<'de> for Tensor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Tensor
impl RefUnwindSafe for Tensor
impl Send for Tensor
impl Sync for Tensor
impl Unpin for Tensor
impl UnsafeUnpin for Tensor
impl UnwindSafe for Tensor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more