MCPcopy Create free account
hub / github.com/NVIDIA/DALI / pytorch_adapter

Function pytorch_adapter

dali/test/python/test_dltensor_operator.py:123–132  ·  view source on GitHub ↗
(fun, in1, in2)

Source from the content-addressed store, hash-verified

121
122
123def pytorch_adapter(fun, in1, in2):
124 with torch.cuda.stream(torch_stream):
125 tin1 = [torch_dlpack.from_dlpack(dltensor) for dltensor in in1]
126 tin2 = [torch_dlpack.from_dlpack(dltensor) for dltensor in in2]
127 tout1, tout2 = fun(tin1, tin2)
128 out1, out2 = [torch_dlpack.to_dlpack(tout) for tout in tout1], [
129 torch_dlpack.to_dlpack(tout) for tout in tout2
130 ]
131 torch_stream.synchronize()
132 return out1, out2
133
134
135def pytorch_wrapper(fun):

Callers 1

pytorch_wrapperFunction · 0.85

Calls 4

funFunction · 0.85
from_dlpackMethod · 0.80
streamMethod · 0.45
synchronizeMethod · 0.45

Tested by

no test coverage detected