Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize DataLoader iteration in WrappedDataLoader #2375

Merged
merged 3 commits into from
Jun 1, 2023

Conversation

HemanthSai7
Copy link
Contributor

@HemanthSai7 HemanthSai7 commented Jun 1, 2023

Fixes #1757

Description

The commit removes redundant iter() calls in the WrappedDataLoader class, optimizing the iteration process. Previously, iter() was called when initializing the iterator and again within the for loop, which was unnecessary. The code is now clearer and more efficient by eliminating the redundant call.

Previously

def __iter__(self):
        batches = iter(self.dl)
        for b in batches:
            yield (self.func(*b))

Modified

def __iter__(self):
        for b in self.dl:
            yield (self.func(*b))

Checklist

  • The issue that is being fixed is referred to in the description (see above "Fixes Misleading call of 'iter' in the 'WrappedDataLoader' #1757")
  • Only one issue is addressed in this pull request
  • Labels from the issue that this PR is fixing are added to this pull request
  • No unnecessary issues are included in this pull request.

cc @suraj813 @svekars

@netlify
Copy link

netlify bot commented Jun 1, 2023

Deploy Preview for pytorch-tutorials-preview ready!

Name Link
🔨 Latest commit 027e795
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-tutorials-preview/deploys/64790712c5adbe000817db55
😎 Deploy Preview https://deploy-preview-2375--pytorch-tutorials-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added intro docathon-h1-2023 A label for the docathon in H1 2023 medium and removed cla signed labels Jun 1, 2023
Copy link
Contributor

@svekars svekars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@svekars svekars merged commit e1ec4bd into pytorch:main Jun 1, 2023
@HemanthSai7 HemanthSai7 deleted the issue#1757 branch June 2, 2023 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docathon-h1-2023 A label for the docathon in H1 2023 intro medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading call of 'iter' in the 'WrappedDataLoader'
3 participants