MCPcopy
hub / github.com/tinygrad/tinygrad / test_copies_2_devs

Method test_copies_2_devs

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

Source from the content-addressed store, hash-verified

187
188 @needs_second_gpu
189 def test_copies_2_devs(self):
190 self.skip_if_not_multigraph()
191 d0, d1 = Device.DEFAULT, f"{Device.DEFAULT}:1"
192 b0 = [make_buffer(d0, fill=True) for _ in range(3)]
193 b1 = [make_buffer(d1, fill=True)]
194 c: dict[Buffer,UOp] = {}
195
196 calls = [
197 UOp(Ops.COPY).call(get_buf_uop(b1[0],c), get_buf_uop(b0[0],c), metadata=()),
198 get_ast(d0, 2).call(get_buf_uop(b0[2],c), get_buf_uop(b0[0],c), get_buf_uop(b0[1],c), metadata=()),
199 ]
200
201 out = [b1[0], b0[2]]
202 zero_bufs(out)
203 run_schedule(calls)
204 expected = {buf: np.frombuffer(buf.as_memoryview(), np.int32).copy() for buf in b0 + b1}
205
206 for _ in range(RUN_CNT):
207 zero_bufs(out)
208 make_graph(Device[d0].graph, calls)([], {})
209 for buf in b0 + b1: np.testing.assert_equal(expected[buf], np.frombuffer(buf.as_memoryview(), np.int32))
210
211 def test_graph_offset_bufs(self):
212 self.skip_if_not_multigraph()

Callers

nothing calls this directly

Calls 12

UOpClass · 0.90
make_bufferFunction · 0.85
get_buf_uopFunction · 0.85
get_astFunction · 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