Tensor
The core tensor abstraction in the SKaiNET framework, representing a fundamental architectural decision to compose tensors from data and operations.
Fundamental Architectural Decision: Tensor Composition
This interface embodies a key architectural principle in the SKaiNET framework: tensors are composed of two distinct, complementary components:
Data Component (
TensorData) - Responsible for:Multi-dimensional data storage and indexing
Memory layout and access patterns
Shape and dimensional metadata
Type-safe element access
Operations Component (
TensorOps) - Responsible for:Mathematical operations and transformations
Computational algorithms
Operation chaining and composition
Performance-optimized implementations
Benefits of This Compositional Architecture
Separation of Concerns: Data management is cleanly separated from computational logic, making the codebase more maintainable and easier to understand.
Flexibility: Different data storage strategies (dense, sparse, distributed) can be combined with different operation implementations (CPU, GPU, specialized hardware) without tight coupling.
Performance Optimization: Data layout can be optimized independently from computational algorithms, enabling targeted performance improvements.
Extensibility: New data formats or operation types can be added without modifying existing code, following the open-closed principle.
Testability: Data and operations can be tested independently, improving test coverage and reducing complexity.
Usage Pattern
The tensor acts as a unified interface that delegates data access to the data component and computational operations to the ops component, providing a seamless experience while maintaining the benefits of compositional design.
Parameters
the data type constraint extending DType, defining the numerical precision
the actual value type that will be stored and accessed
Inheritors
Properties
Functions
Accumulate a gradient tensor onto this tensor.
Extension function for Q4_K matmul.
Extension function for Q8_0 matmul.
Extension function for convenient ternary matmul. Use this when you know the weight is ternary-quantized.