-
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
C API 2.0 Tensor and TensorList #5799
base: main
Are you sure you want to change the base?
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.
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.
5eda037
to
18f285c
Compare
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]>
18f285c
to
71d2513
Compare
Would it be enough to refer to the relevant C API function? Those are quite thoroughly documented. |
Signed-off-by: Michal Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
CI MESSAGE: [24487279]: BUILD STARTED |
CI MESSAGE: [24487279]: 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.
Additional information:
Affected modules and functionalities:
Key points relevant for the review:
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A