-
Notifications
You must be signed in to change notification settings - Fork 631
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
C API 2.0 Tensor and TensorList #5799
Conversation
04ef2a5
to
e27aa11
Compare
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.
Leaving some initial comments
// Interfaces | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
class ITensor : public _DALITensor, public RefCountedObject { |
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.
Do we use this ISomething
convention in the code elsewhere?
@@ -0,0 +1,414 @@ | |||
// Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
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.
Are you testing non-contiguous tensor lists here?
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'm testing daliTensorListAttachBuffer
with custom offsets.
The test for daliTensorListAttachSamples
is missing. I'll add.
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.
Done.
e27aa11
to
361bf44
Compare
b0511b2
to
539de4e
Compare
} | ||
|
||
////////////////////////////////////////////////////////////////////////////// | ||
// Tensor |
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.
It's missing impl for daliTensorGetShape, right?
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.
It was missing; added.
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.
Done.
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.
@mzient also missing:
daliTensorGetBufferPlacement
daliTensorListGetBufferPlacement
and source methods
daliTensorGetSourceInfo
daliTensorListGetSourceInfo
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.
Done. Also added setters.
bbbca35
to
28a3201
Compare
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.
Looks good overall.
My only major concern is the lack of documentation. Some of the functions perform complex operations details of which are not clear from their signatures. Even a minimalistic doxygen comments would help a lot.
virtual const TensorShape<> &GetShape() const & = 0; | ||
|
||
template <typename Backend> | ||
const std::shared_ptr<Tensor<Backend>> &Unwrap() const &; |
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.
Some function names are self-explanatory, but some are not obvious. How about adding some minimal docstrings?
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.
Done.
throw std::invalid_argument( | ||
"The number of dimensions must not be negative when num_samples is 0."); | ||
else | ||
ndim = samples[0].ndim; |
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.
This is a good feature, but definitely should be documented
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.
It is. See daliTensorListAttachSamples
:
* @param ndim the number of dimensions in each sample;
* if num_samples > 0, this value can be set to -1 and the number of
* dimensions will be taken from samples[0].ndim
dali/c_api_2/data_objects.h
Outdated
throw std::out_of_range(make_string("The sample index ", sample, " is out of range. " | ||
"Valid indices are [0..", shape.num_samples() - 1, "].")); |
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.
Nitpick: This will look strange for 0 samples
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.
True.
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.
Fixed.
18f285c
to
71d2513
Compare
Would it be enough to refer to the relevant C API function? Those are quite thoroughly documented. |
CI MESSAGE: [24487279]: BUILD STARTED |
CI MESSAGE: [24487279]: BUILD PASSED |
Signed-off-by: Michał Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
* Add generic validation. * Move ToOptional to a new utils.h header. Signed-off-by: Michal Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
Signed-off-by: Michał Zientkiewicz <[email protected]>
Signed-off-by: Michał Zientkiewicz <[email protected]>
bdc1621
to
2cd34ef
Compare
CI MESSAGE: [24811190]: BUILD STARTED |
CI MESSAGE: [24811409]: BUILD STARTED |
Signed-off-by: Michał Zientkiewicz <[email protected]>
475a3ac
to
205c558
Compare
CI MESSAGE: [24811504]: BUILD STARTED |
CI MESSAGE: [24811504]: BUILD PASSED |
Category:
New feature (non-breaking change which adds functionality)
Description:
This PR adds wrappers for Tensor and TensorList that are later used to implement the C interface for those objects.
This PR also contains adds missing API functions for setting the tensor/sample source info.
Additional information:
The implementation follows the general scheme:
daliTensorGetDesc
<->ITensor::GetDesc
Affected modules and functionalities:
Key points relevant for the review:
Tests:
Checklist
Documentation
The relevant API functions are documented in
dali.h
. The C++ classes correspond to those 1:1. Copying the documentation would be counterproductive and create opportunity for documentation mismatch between the C header and the implementation.DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A