MCPcopy
hub / github.com/tinygrad/tinygrad / test_order_copy_writed

Method test_order_copy_writed

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

Source from the content-addressed store, hash-verified

125 for i, buf in enumerate(b): np.testing.assert_equal(expected[i], np.frombuffer(buf.as_memoryview(), np.int32))
126
127 def test_order_copy_writed(self):
128 self.skip_if_not_multigraph()
129 d0 = Device.DEFAULT
130 b = [make_buffer(d0, fill=True) for _ in range(4)]
131 c: dict[Buffer,UOp] = {}
132
133 calls = [
134 get_ast(d0, 2).call(get_buf_uop(b[0],c), get_buf_uop(b[1],c), get_buf_uop(b[2],c), metadata=()),
135 UOp(Ops.COPY).call(get_buf_uop(b[3],c), get_buf_uop(b[0],c), metadata=()),
136 ]
137
138 zero_bufs([b[0], b[3]])
139 run_schedule(calls)
140 expected = [np.frombuffer(x.as_memoryview(), np.int32).copy() for x in b]
141
142 for _ in range(RUN_CNT):
143 zero_bufs([b[0], b[3]])
144 make_graph(Device[d0].graph, calls)([], {})
145 for i, buf in enumerate(b): np.testing.assert_equal(expected[i], np.frombuffer(buf.as_memoryview(), np.int32))
146
147 def test_order_copy_then_read(self):
148 self.skip_if_not_multigraph()

Callers

nothing calls this directly

Calls 12

UOpClass · 0.90
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