-
Notifications
You must be signed in to change notification settings - Fork 99
Refactor Unit Tests for OpenCL Kernels #3601
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
base: main
Are you sure you want to change the base?
Conversation
This pull request refactors the unit tests for OpenCL kernels. The changes involve splitting the test files into three categories based on functionality. One for INT4-related tests, another for QK_K (GGML format) tests, and a third for the remaining BLAS tests. Additionally, it consolidates common helper functions used across the test files into separate utility header files. **Self-evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong <[email protected]>
182812d to
27fbb41
Compare
| nntrainer::IniWrapper ini; | ||
| }; | ||
|
|
||
| #define GEN_TEST_INPUT_NHWC(input, eqation_i_j_k_l) \ |
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.
How about keeping the whitespace at the end of each line? And remove file diffs?
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 believe the previous version has incorrect formatting, likely due to being formatted with an outdated version.
(The last time this file was edited was a year ago!)
songgot
left a comment
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 👍
| // Initialize Activation | ||
| std::vector<float> activation = generate_random_vector<float, false>(M * K); | ||
| float *activations_f32_ptr = (float *)allocateSVM(M * K * sizeof(float)); | ||
| blas_cc->command_queue_inst_.enqueueSVMMap(activations_f32_ptr, |
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.
After use, Right?
blas_cc->command_queue_inst_.enqueueSVMUnmap(activations_f32_ptr, 0, nullptr, nullptr);
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, you're right. However, I believe that unmap should be called before kernel execution and should be handled here.
| // weight 0 (3072 x 3072) | ||
| void *ws0 = allocateSVM(data_size_n0 / scale_group_size); | ||
| void *wq0 = allocateSVM(data_size_n0 / 2); | ||
| blas_cc->command_queue_inst_.enqueueSVMMap(wq0, data_size_n0 / 2, false); |
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.
Isn't 'true' better than 'false'?
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.
Great refactor! Splitting up that massive unittest_nntrainer_cl.cpp file was definitely needed. It makes the tests so much easier to navigate and maintain.
I really like how you've extracted the common helpers like allocateSVM and the random generators into nntrainer_test_util.h. That's a great example of DRY (Don't Repeat Yourself).
The file split logic (BLAS, INT4, QK_K) makes perfect sense.
Everything looks clean and well-organized. Thank you for improving the codebase structure! LGTM! ✨
This pull request refactors the unit tests for OpenCL kernels.
The changes involve splitting the test files into three categories based on functionality.
One for INT4-related tests, another for QK_K (GGML format) tests, and a third for the remaining BLAS tests.
Additionally, it consolidates common helper functions used across the test files into separate utility header files.
Self-evaluation: