-
Notifications
You must be signed in to change notification settings - Fork 630
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
Use current class __next__ implementation in __init__, to avoid special handling of first batch in child classes #2363
Conversation
…d special handling of first batch when writing iterator wrapper classes Signed-off-by: Joaquin Anton <janton@nvidia.com>
!build |
CI MESSAGE: [1703801]: BUILD STARTED |
@@ -230,7 +230,7 @@ def __init__(self, | |||
with p._check_api_type_scope(types.PipelineAPIType.ITERATOR): | |||
p.schedule_run() | |||
self._first_batch = None | |||
self._first_batch = self.next() | |||
self._first_batch = DALIGenericIterator.next(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._first_batch = DALIGenericIterator.next(self) | |
self._first_batch = DALIGenericIterator.__next__(self) |
Because:
def next(self):
"""
Returns the next batch of data.
"""
return self.__next__()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a test for that after all.
CI MESSAGE: [1703801]: BUILD FAILED |
Signed-off-by: Joaquin Anton <janton@nvidia.com>
|
||
pipe = Pipeline(batch_size = 16, num_threads = 1, device_id = 0) | ||
with pipe: | ||
data = fn.uniform(range=(-1, 1), shape=(20, 30, 3), seed=1234) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data = fn.uniform(range=(-1, 1), shape=(20, 30, 3), seed=1234) | |
data = fn.uniform(range=(-1, 1), shape=(2, 2, 2), seed=1234) |
I think we can make it as simple as possible
super(IteratorWrapper, self).__init__(*args, **kwargs) | ||
|
||
def __next__(self): | ||
assert(self._allow_next) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a comment why this works.
Signed-off-by: Joaquin Anton <janton@nvidia.com>
!build |
CI MESSAGE: [1707353]: BUILD STARTED |
CI MESSAGE: [1707353]: BUILD PASSED |
Signed-off-by: Joaquin Anton janton@nvidia.com
Why we need this PR?
Currently, custom iterators that override next() function need to be aware that the first batch was produced during init, which invokes the child class next, therefore the first iteration produces a "wrapped" batch while the following don't.
What happened in this PR?
Fill relevant points, put NA otherwise. Replace anything inside []
Use current class next function in DALIGenericIterator
FW iterators
N/A
N/A
N/A
JIRA TASK: [DALI-1635]