-
Notifications
You must be signed in to change notification settings - Fork 74
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
[TensorV2] Multiply strided inputs and output #2434
[TensorV2] Multiply strided inputs and output #2434
Conversation
📝 TAOS-CI Version: 1.5.20200925. Thank you for submitting PR #2434. Please a submit 1commit/1PR (one commit per one PR) policy to get comments quickly from reviewers. Your PR must pass all verificiation processes of cibot before starting a review process from reviewers. If you are new member to join this project, please read manuals in documentation folder and wiki page. In order to monitor a progress status of your PR in more detail, visit http://ci.nnstreamer.ai/. |
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.
@djeong20, 💯 All CI checkers are successfully verified. Thanks.
nntrainer/tensor/float_tensor.cpp
Outdated
return ((float *)getData())[i]; | ||
} | ||
|
||
const float FloatTensor::getValue(unsigned int batch, unsigned int c, |
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.
b,c,h,w or batch, channel, height, width ?
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.
b,c,h,w seems more reasonable.
nntrainer/tensor/float_tensor.h
Outdated
* @brief return value at specific location | ||
* @param[in] idx location | ||
*/ | ||
const float getValue(unsigned int i) const noexcept; |
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.
idx ?
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!
This commit adds functionality to retrieving and modifying tensor elements in specific locations. This will provide convenience in implementing the math operation of tensor. **Self-evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong <[email protected]>
This patch adds the implementation of multiplication operation that supports different strided inputs and output. **Self-evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong <[email protected]>
d4ab173
to
c436e3c
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.
@djeong20, 💯 All CI checkers are successfully verified. Thanks.
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!
* @param[in] h height location | ||
* @param[in] w width location | ||
* @param[in] value value to be stored | ||
* @param[in] beta scalar to multiply output with and 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.
Just a suggestion:
How about describing params like beta
something like:
x = x * beta + value
for better intuition? Would it make doc more nasty?
for (unsigned int h = 0; h < height(); ++h) { | ||
for (unsigned int w = 0; w < width(); ++w) { | ||
output.addValue( | ||
b, c, h, w, getValue(b, c, h, w) * m.getValue<_FP16>(b, c, h, w), |
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 need _FP16 in m.getValue
? I thought we do not need to specify the type in TensorV2 level.
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.
We do. m is a TensorV2, not a HalfTensor, which means getValue is a Tensor::getValue that requires template argument.
for (unsigned int h = 0; h < height(); ++h) { | ||
_FP16 *out_data = output.getAddress<_FP16>(b, c, h, 0); | ||
const _FP16 *m_data = m.getAddress<_FP16>(b, c, h, 0); | ||
const _FP16 *in_data = (_FP16 *)getAddress(getIndex(b, c, h, 0)); |
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 need the type casting for getAddress
? This is HalfTensor->getAddress
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.
Yes. Since getAddress is an override method from TensorBase, it returns a void pointer, not _FP16 pointer.
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 need overwrite getAddress function from tensor base? How about add getAddress function without overwriting?
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.
We discussed offline and we will remove getAddress function in tensor_base.h later.
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
Commits to be reviewed in this PR
[TensorV2] Multiply strided inputs and output
This patch adds the implementation of multiplication operation that supports different strided inputs and output.
Self-evaluation:
Signed-off-by:Donghyeon Jeong [email protected]
[TensorV2] Additional functionality to access tensor elements
This commit adds functionality to retrieving and modifying tensor elements in specific locations.
This will provide convenience in implementing the math operation of tensor.
Self-evaluation:
Signed-off-by: Donghyeon Jeong [email protected]