mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-15 04:23:43 +08:00
e6f1167410
version: sunnypilot v2026.003.000 (dev)
date: 2026-09-14T15:43:50
master commit: a5f44653d7
15 lines
443 B
Python
15 lines
443 B
Python
import unittest
|
|
from extra.f16_decompress import u32_to_f16
|
|
from tinygrad.tensor import Tensor
|
|
from tinygrad import dtypes
|
|
import numpy as np
|
|
|
|
class TestF16Decompression(unittest.TestCase):
|
|
def test_u32_to_f16(self):
|
|
a = Tensor.randn(50, dtype=dtypes.float16)
|
|
f16_as_u32 = a.bitcast(dtypes.uint32)
|
|
f16 = u32_to_f16(f16_as_u32)
|
|
ref = a.numpy()
|
|
out = f16.numpy().astype(np.float16)
|
|
np.testing.assert_allclose(out, ref)
|