MCPcopy
hub / github.com/tinygrad/tinygrad / test_order_read_write_same_buf

Method test_order_read_write_same_buf

test/backend/test_graph.py:89–106  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

87 for i, buf in enumerate(b): np.testing.assert_equal(expected[i], np.frombuffer(buf.as_memoryview(), np.int32))
88
89 def test_order_read_write_same_buf(self):
90 d0 = Device.DEFAULT
91 b = [make_buffer(d0, fill=True) for _ in range(5)]
92 c: dict[Buffer,UOp] = {}
93
94 calls = [
95 get_ast(d0, 2).call(get_buf_uop(b[0],c), get_buf_uop(b[1],c), get_buf_uop(b[2],c), metadata=()),
96 get_ast(d0, 2).call(get_buf_uop(b[1],c), get_buf_uop(b[3],c), get_buf_uop(b[4],c), metadata=()),
97 ]
98
99 zero_bufs([b[0], b[1]])
100 run_schedule(calls)
101 expected = [np.frombuffer(x.as_memoryview(), np.int32).copy() for x in b]
102
103 for _ in range(RUN_CNT):
104 zero_bufs([b[0], b[1]])
105 make_graph(Device[d0].graph, calls)([], {})
106 for i, buf in enumerate(b): np.testing.assert_equal(expected[i], np.frombuffer(buf.as_memoryview(), np.int32))
107
108 def test_order_write_read_same_buf(self):
109 d0 = Device.DEFAULT

Callers

nothing calls this directly

Calls 10

make_bufferFunction · 0.85
get_astFunction · 0.85
get_buf_uopFunction · 0.85
zero_bufsFunction · 0.85
run_scheduleFunction · 0.85
make_graphFunction · 0.85
as_memoryviewMethod · 0.80
assert_equalMethod · 0.80
callMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected