MCPcopy Index your code
hub / github.com/pytorch/tutorials / inner

Function inner

intermediate_source/pinmem_nonblock.py:155–167  ·  view source on GitHub ↗
(pinned: bool, streamed: bool)

Source from the content-addressed store, hash-verified

153
154# The function we want to profile
155def inner(pinned: bool, streamed: bool):
156 with torch.cuda.stream(s) if streamed else contextlib.nullcontext():
157 if pinned:
158 t1_cuda = t1_cpu_pinned.to(device, non_blocking=True)
159 else:
160 t2_cuda = t2_cpu_paged.to(device, non_blocking=True)
161 t_star_cuda_h2d_event = s.record_event()
162 # This operation can be executed during the CPU to GPU copy if and only if the tensor is pinned and the copy is
163 # done in the other stream
164 t3_cuda_mul = t3_cuda * t3_cuda * t3_cuda
165 t3_cuda_h2d_event = torch.cuda.current_stream().record_event()
166 t_star_cuda_h2d_event.synchronize()
167 t3_cuda_h2d_event.synchronize()
168
169
170# Our profiler: profiles the `inner` function and stores the results in a .json file

Callers 1

benchmark_with_profilerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected