DALI
DALI copied to clipboard
Refactor Tensor Vector
Category: Refactoring
Description:
Refactor TensorVector with intention of using it as the only batch object through DALI.
Main changes:
-
Batch is the source of truth. This breaks away from the design, where depending on the case (contiguous vs noncontiguous) our metadata were kept in the member TensorList or in the first Tensor respectively. This is enabled thanks to better encapsulation where the internal allocation cannot be changed from the outside.
-
When modifying the batch, care was taken to update the properties (now stored in batch) in the same order as they are defined. There are some exception.
-
Now setting and copying samples can be verified against all the properties of the batch - they must match.
-
There are now three options when deciding if the batch should use contiguous allocation. We can either pin the contiguous or noncontiguous modes or allow buffer to change depending on the needs. In the last case, it can be specifically requested during Resize to change to one of the modes.
-
When Resizing the batch, and a new allocation is needed, we try to use one big allocation if allowed by the selected mode. It yields smaller memory fragmentation
-
When we convert the buffer to non-contiguous and it had a contiguous backing allocation, we mark the tensors_ that were pointing to that allocation as not sharing, but still aliasing - so we can call Resize() and get a new allocation without the error that we try to reallocate something that shares data
-
Contents of
tensor_list_as_tensor_vector_test.ccare copied fromtensor_list_test.ccand adjusted to handle both contiguous and noncontiguous cases. It is necessary to verify the TensorVector conformance to the TensorList requirements but the code is almost identical to the already existing one.
Note: The third commit does some grouping and reordering of the member functions to hopefully allow for better documentation.
If this is inconvenient I can split it into another PR.
Small bugfix for SampleView constructor was included here, I can factor it out as well.
Additional information:
Affected modules and functionalities:
TensorVector
Key points relevant for the review:
TensorVector
Tests:
YES - both new tests added and old tests ported to test the TensorVector as if it was a TensorList.
- [x] Existing tests apply
- [x] New tests added
- [ ] Python tests
- [x] GTests
- [ ] Benchmark
- [ ] Other
- [ ] N/A
Checklist
Documentation
- [ ] Existing documentation applies
- [x] Documentation updated
- [x] Docstring
- [ ] Doxygen
- [ ] RST
- [ ] Jupyter
- [ ] Other
- [ ] N/A
DALI team only
Requirements
- [ ] Implements new requirements
- [ ] Affects existing requirements
- [x] N/A
REQ IDs: DALI-2689
JIRA TASK: N/A
CI MESSAGE: [5582837]: BUILD STARTED
CI MESSAGE: [5582837]: BUILD PASSED
!build
CI MESSAGE: [5614349]: BUILD STARTED
CI MESSAGE: [5614349]: BUILD FAILED
!build
CI MESSAGE: [5663966]: BUILD STARTED
CI MESSAGE: [5663966]: BUILD FAILED
!build
CI MESSAGE: [5667155]: BUILD STARTED
CI MESSAGE: [5667155]: BUILD FAILED
CI MESSAGE: [5667155]: BUILD PASSED