-
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
Utils and prerequisities for NppRemapKernel
implementation
#4374
Conversation
Signed-off-by: szalpal <mszolucha@nvidia.com>
!build |
CI MESSAGE: [6235052]: BUILD STARTED |
/** @{ */ | ||
/** @brief Construction from contiguous memory */ | ||
|
||
TensorListView(std::nullptr_t, const std::vector<TensorShape<DynamicDimensions>> &shapes) | ||
: Base(TensorListShape<DynamicDimensions>(shapes)) {} | ||
|
||
template <int other_sample_ndim> | ||
TensorListView(std::nullptr_t, const TensorListShape<other_sample_ndim> &shape) | ||
: Base(shape) {} | ||
|
||
template <int other_sample_ndim> | ||
TensorListView(std::nullptr_t, TensorListShape<other_sample_ndim> &&shape) | ||
: Base(std::move(shape)) {} | ||
|
||
/** @} */ | ||
|
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.
These constructors already exist in static_dim
flavour of TensorListView
. Here I'm adding them to DynamicDimensions
flavour as well.
CI MESSAGE: [6235052]: BUILD PASSED |
auto ridx = ndims; | ||
for (size_t idx = 0; idx < ndims; idx++) { | ||
ret[--ridx] = e[idx]; | ||
} | ||
return ret; |
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.
You want to reverse the order here, right?
auto ridx = ndims; | |
for (size_t idx = 0; idx < ndims; idx++) { | |
ret[--ridx] = e[idx]; | |
} | |
return ret; | |
std::reverse(e); | |
return TensorShape<ndims>(e.begin(), e.end()); |
this should work, I guess
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.
maybe better:
TensorShape<ndim> ret;
std::reverse_copy(e.begin(), e.end(), ret.begin());
return ret;
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.
Good point. Followed up in #4375
namespace detail { | ||
|
||
template<typename T, typename Tuple> | ||
struct contains; |
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.
Tbh. I liked the old name has_type
better but it is just a matter of preference, I guess. I know this name was suggested by other reviewer so no point in changing it back and forth :)
Signed-off-by: szalpal mszolucha@nvidia.com
Category:
New feature (non-breaking change which adds functionality)
Refactoring (Redesign of existing code that doesn't affect functionality)
Other (e.g. Documentation, Tests, Configuration)
Description:
Since the #4365 PR grew significantly in size, I decided to extract parts of it into the separate PR to enhance review quality. This PR includes some utilities I've used for
NppRemapKernel
implementation. Specifically:make_tensor_list
functions: creatingTensorListView
from aTensorView
(just wrapping it) and formvector<TensorView>
. The latter overload is possible, since we changed from contiguous memory pattern to non-contiguous one. The tests are included intensor_view_test.cc
.contains_v
- convenient trait, that checks if a tuple has a given type. Surprisingly, such thing doesn't exist instd
...tensor_to_mat
function. It doesn't needStorageCPU
. It just needs, that the memory is CPU-accessible.ShapeFromRoi
that returnTensorShape
that can be associated with givenRoi
. The functions that are already there don't cover the case, when there is no channel dimension. And such situation might happen for 1-channel images - channel dimension doesn't have to exist.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