MCPcopy
hub / github.com/tinygrad/tinygrad / test_variable_bs

Method test_variable_bs

test/unit/test_hashing.py:71–77  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

69 self.assertEqual(bytes(Tensor(data).keccak("shake_128").tolist()), hashlib.shake_128(data).digest(16))
70
71 def test_variable_bs(self):
72 data = Tensor([b"abc", b"abc", b"def"], dtype=dtypes.uint8).repeat(2048, 1)
73 bs = UOp.variable("bs", 1, 4096).bind(3)
74 out = data.shrink_to(bs, data.shape[-1]).keccak().shrink_to(3, 32)
75 self.assertEqual(bytes(out[0].tolist()), bytearray.fromhex("3a985da74fe225b2 045c172d6bd390bd 855f086e3e9d525b 46bfe24511431532"))
76 self.assertEqual(bytes(out[1].tolist()), bytearray.fromhex("3a985da74fe225b2 045c172d6bd390bd 855f086e3e9d525b 46bfe24511431532"))
77 self.assertEqual(bytes(out[2].tolist()), bytearray.fromhex("8e0d8f672252acb0 ffc5093db8653b18 1513bf9a2097e737 b4f73533dcaf46df"))
78
79 @slow
80 def test_variable_bs_jit(self):

Callers

nothing calls this directly

Calls 7

TensorClass · 0.90
repeatMethod · 0.80
variableMethod · 0.80
shrink_toMethod · 0.80
keccakMethod · 0.80
bindMethod · 0.45
tolistMethod · 0.45

Tested by

no test coverage detected