Skip to content

Conversation

jsalotti
Copy link
Contributor

@jsalotti jsalotti commented Nov 18, 2022

Add an argument to aloscene.batch_list, allowing to batch tensors with different children or properties with different values.
Closes #272

  • New feature 1 : Merge with different properties
f1 = Frame(torch.ones(3,10,10))
f2 = Frame(torch.ones(3,10,10))
f1.baseline = 0.5
f2.baseline = 1
f = aloscene.batch_list([f1, f2], intersection=True)
print(f.baseline)

Here, the baseline property has different values for different tensors. Therefore, the property baseline of the batched tensors has baseline set to None.

  • New feature 2 : Merge with different mergeable children
f1 = Frame(torch.ones(3,10,10))
f2 = Frame(torch.ones(3,10,10))
f1.append_disparity(Disparity(torch.ones(1,10,10)))
f = aloscene.batch_list([f1, f2], intersection=True)
print(f.disparity)

Only one of the two frames has a disparity child, therefore the batched tensor will have disparity set to None

Note: this will not drop unmergeable children, because by definition they allow that some tensors have None values for a child before merging


This pull request includes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

@jsalotti jsalotti changed the base branch from master to alobugdays November 18, 2022 15:32
@jsalotti jsalotti changed the title Fix merge tensor dict child [DRAFT] allow batch_list to batch tensors with different children Nov 18, 2022
@jsalotti jsalotti marked this pull request as draft November 21, 2022 12:22
@jsalotti jsalotti self-assigned this Nov 21, 2022
@jsalotti jsalotti requested a review from Data-Iab November 21, 2022 13:49
@jsalotti jsalotti changed the title [DRAFT] allow batch_list to batch tensors with different children allow batch_list to batch tensors with different children Nov 21, 2022
@jsalotti jsalotti marked this pull request as ready for review November 21, 2022 13:52
- throwing an error for unmergeable children with None would
break the current behavior, that motivated the creation of unmergeable
children in the first place.
@thibo73800 thibo73800 self-requested a review November 22, 2022 06:45
Copy link
Contributor

@thibo73800 thibo73800 left a comment

Choose a reason for hiding this comment

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

Can you provide this PR with a new set of unit test to check compatibility with previous behavior + exposing the different new possible scenarios ?

Copy link
Collaborator

@Data-Iab Data-Iab left a comment

Choose a reason for hiding this comment

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

Tested.
Will be merged once @thibo73800 approves

@jsalotti
Copy link
Contributor Author

@Data-Iab Unittests have been added ; and an error fixed. The branch is now ready to be merged.

@Data-Iab Data-Iab merged commit 996e665 into alobugdays Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants