-
Notifications
You must be signed in to change notification settings - Fork 159
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
[luci/pass] Introduce ArrayIndex helper #14565
Conversation
Let's introduce Array4DIndex to help calculating 4D array index. ONE-DCO-Signed-off-by: Dayoung Lee <[email protected]>
This comment was marked as outdated.
This comment was marked as outdated.
return i0 * _strides[0] + i1 * _strides[1] + i2 * _strides[2] + i3 * _strides[3]; | ||
} | ||
|
||
uint32_t Array4DIndex::size(void) const { return _dim[0] * _dim[1] * _dim[2] * _dim[3]; } |
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 assumes all elements should be positive numbers.
you have assert(_strides[i] > 0);
in ctor but this is only for debug version.
how about using throw
as zero or negative seems to be invalid numbers.
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.
if we can change to throw
, we can add one more negative test something like invalid_array_4d_NEG
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.
_dim
is unsigned, so exception seems to be redundant.
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.
@jinevening It's right. I'll just add exception to check whether they are zero or not.
Co-authored-by: Hyukjin Jeong <[email protected]> Co-authored-by: SaeHie Park <[email protected]>
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.
LGTM
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.
LGTM thank you!
Let's introduce Array4DIndex to help calculating 4D array index.
ONE-DCO-Signed-off-by: Dayoung Lee [email protected]
For #14552
Dr #14564
To extend the funtionality of
extend broadcast const
pass, I introduce this helper.