Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions timm/data/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ def __init__(
def __iter__(self):
first = True
if self.is_cuda:
stream = torch.cuda.Stream()
stream = torch.cuda.Stream(device=self.device)
stream_context = partial(torch.cuda.stream, stream=stream)
elif self.is_npu:
stream = torch.npu.Stream()
stream = torch.npu.Stream(device=self.device)
stream_context = partial(torch.npu.stream, stream=stream)
else:
stream = None
Expand All @@ -148,9 +148,9 @@ def __iter__(self):

if stream is not None:
if self.is_cuda:
torch.cuda.current_stream().wait_stream(stream)
torch.cuda.current_stream(device=self.device).wait_stream(stream)
elif self.is_npu:
torch.npu.current_stream().wait_stream(stream)
torch.npu.current_stream(device=self.device).wait_stream(stream)

input = next_input
target = next_target
Expand Down
8 changes: 4 additions & 4 deletions timm/data/naflex_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ def __iter__(self) -> Iterator[Tuple[Dict[str, torch.Tensor], torch.Tensor]]:
"""
first = True
if self.is_cuda:
stream = torch.cuda.Stream()
stream = torch.cuda.Stream(device=self.device)
stream_context = partial(torch.cuda.stream, stream=stream)
elif self.is_npu:
stream = torch.npu.Stream()
stream = torch.npu.Stream(device=self.device)
stream_context = partial(torch.npu.stream, stream=stream)
else:
stream = None
Expand Down Expand Up @@ -152,9 +152,9 @@ def __iter__(self) -> Iterator[Tuple[Dict[str, torch.Tensor], torch.Tensor]]:

if stream is not None:
if self.is_cuda:
torch.cuda.current_stream().wait_stream(stream)
torch.cuda.current_stream(device=self.device).wait_stream(stream)
elif self.is_npu:
torch.npu.current_stream().wait_stream(stream)
torch.npu.current_stream(device=self.device).wait_stream(stream)

input_dict = next_input_dict
target = next_target
Expand Down