Skip to content

Commit da0c405

Browse files
committed
Implement next missing tensor's factories.
Related-To: #121 #95
1 parent 2cc1945 commit da0c405

6 files changed

Lines changed: 935 additions & 14 deletions

File tree

skainet-core/skainet-tensors/src/commonMain/kotlin/sk/ainet/core/tensor/factory/FP16TensorFactory.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ import sk.ainet.core.tensor.Tensor
88
* Factory for creating FP16 tensors from byte data.
99
* This is currently a placeholder implementation for future development.
1010
*
11-
* TODO: Implement proper FP16 to FP32 conversion when CpuTensorFP16 is available
12-
* TODO: Add conversion utilities for 16-bit float format
1311
*/
1412
public object FP16TensorFactory : TensorFactoryRegistry.TensorFromBytesFactory<FP16, Float> {
1513

1614
/**
1715
* Creates a tensor from GGUF-style byte data with FP16 values.
1816
*
19-
* TODO: This is a placeholder implementation.
20-
* When CpuTensorFP16 becomes available, this should:
2117
* 1. Convert bytes to FP16 values with proper endianness handling
2218
* 2. Validate input data size matches expected FP16 count (shape.volume * 2 bytes)
2319
* 3. Handle FP16 to FP32 conversion if needed

skainet-core/skainet-tensors/src/commonMain/kotlin/sk/ainet/core/tensor/factory/Int4TensorFactory.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@ import sk.ainet.core.tensor.Tensor
1010
*
1111
* Int4 tensors use packed 4-bit integer values, storing 2 values per byte.
1212
*
13-
* TODO: Add TODO implementation for packed 4-bit integer handling
14-
* TODO: Implement bit unpacking utilities for 4-bit values
15-
* TODO: Plan storage strategy (2 values per byte)
1613
*/
1714
public object Int4TensorFactory : TensorFactoryRegistry.TensorFromBytesFactory<Int4, Byte> {
1815

1916
/**
2017
* Creates a tensor from GGUF-style byte data with packed Int4 values.
2118
*
22-
* TODO: This is a placeholder implementation.
2319
* When CpuTensorInt4 becomes available, this should:
2420
* 1. Implement bit unpacking for 4-bit values (2 values per byte)
2521
* 2. Handle signed 4-bit integers (range -8 to 7)

skainet-core/skainet-tensors/src/commonMain/kotlin/sk/ainet/core/tensor/factory/TernaryTensorFactory.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@ import sk.ainet.core.tensor.Tensor
1010
*
1111
* Ternary tensors use 2-bit values representing three states: -1, 0, 1.
1212
* Storage uses bit packing with 4 values per byte.
13-
*
14-
* TODO: Add TODO implementation for ternary value handling (-1, 0, 1)
15-
* TODO: Implement bit unpacking for 2-bit ternary values
16-
* TODO: Plan storage strategy (4 values per byte)
1713
*/
1814
public object TernaryTensorFactory : TensorFactoryRegistry.TensorFromBytesFactory<Ternary, Byte> {
1915

2016
/**
2117
* Creates a tensor from GGUF-style byte data with packed Ternary values.
2218
*
23-
* TODO: This is a placeholder implementation.
24-
* When CpuTensorTernary becomes available, this should:
2519
* 1. Implement bit unpacking for 2-bit ternary values (4 values per byte)
2620
* 2. Handle ternary value mapping (00 -> -1, 01 -> 0, 10 -> 1, 11 -> invalid)
2721
* 3. Validate input data size matches expected packed size (ceil(shape.volume / 4) bytes)

0 commit comments

Comments
 (0)