Skip to content
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

[Test] TensorV2 multiplication unit test #2433

Merged
merged 2 commits into from
Feb 2, 2024

Conversation

djeong20
Copy link
Contributor

This PR includes unit tests for verifying multiplication operations in the TensorV2 class.
Note that all unit tests are the same as tests in unittest_nntrainer_tensor.cpp file.

Self-evaluation:

  1. Build test: [X]Passed [ ]Failed [ ]Skipped
  2. Run test: [X]Passed [ ]Failed [ ]Skipped

@taos-ci
Copy link
Collaborator

taos-ci commented Jan 29, 2024

📝 TAOS-CI Version: 1.5.20200925. Thank you for submitting PR #2433. 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/.

Comment on lines 482 to 486
_FP16 answer_data[] = {static_cast<_FP16>(0), static_cast<_FP16>(1),
static_cast<_FP16>(4), static_cast<_FP16>(9),
static_cast<_FP16>(16), static_cast<_FP16>(25),
static_cast<_FP16>(36), static_cast<_FP16>(49),
static_cast<_FP16>(64), static_cast<_FP16>(81),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these static_cast to _FP16 is making readability very low.
if anyone has a good idea, please give me a suggestion!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you make Macro or Function that can convert to FP16?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for example

template <typename T> // T models Any
struct static_cast_func
{
  template <typename T1> // T1 models type statically convertible to T
  T operator()(const T1& x) const { return static_cast<T>(x); }
};
std::transform(char_buff, char_buff + len, float_buff, static_cast_func<float>());

like this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks :) this really helped a lot

Copy link
Collaborator

@taos-ci taos-ci left a 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.

float *indata = input.getData<float>();
ASSERT_NE(nullptr, indata);

for (int i = 0; i < batch * height * width * channel; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int i = 0; i < batch * height * width * channel; ++i) {
for (int i = 0; i < batch * channel * height * width; ++i) {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

djeong20 and others added 2 commits January 30, 2024 10:20
This PR includes unit tests for verifying multiplication operations in the TensorV2 class.
Note that all unit tests are the same as tests in unittest_nntrainer_tensor.cpp file.

**Self-evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test:   [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Donghyeon Jeong <[email protected]>
…orm()

This commit replaces a manual static_cast operation with a helper struct that can be used with std::transform().
This change improves readability and maintainability by encapsulating the casting logic in a separate struct.

suggessted by @DonghakPark

Co-authored-by: Donghak Park <[email protected]>
Signed-off-by: Donghyeon Jeong <[email protected]>
Copy link
Collaborator

@taos-ci taos-ci left a 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.

Copy link
Member

@SeoHyungjun SeoHyungjun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jijoongmoon jijoongmoon merged commit 4e9fafb into nnstreamer:main Feb 2, 2024
30 checks passed
@djeong20 djeong20 deleted the test/tensor_v2/multiply branch February 8, 2024 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants