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

[ blas/OpenCL ] Added multiply OpenCL kernel and unit test #2630

Merged
merged 2 commits into from
Jul 2, 2024

Conversation

s-debadri
Copy link
Contributor

  • sscal equivalent kernel added for multiply.
  • Added standalone unit test unittest_blas_kernels_cl.cpp for easily testing OpenCL kernels.
  • Added an overload of dotCl.

Self evaluation:

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

Signed-off-by: Debadri Samaddar [email protected]

@taos-ci
Copy link

taos-ci commented Jun 11, 2024

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

Copy link

@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.

@s-debadri, 💯 All CI checkers are successfully verified. Thanks.

@s-debadri s-debadri force-pushed the blas_kernel_enhance branch from 9b1e33b to 8baf1c6 Compare June 20, 2024 07:20
Copy link

@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.

@s-debadri, 💯 All CI checkers are successfully verified. Thanks.

@s-debadri s-debadri changed the title [ Wait for #2623 ][ blas/OpenCL ] Added multiply OpenCL kernel and unit test [ blas/OpenCL ] Added multiply OpenCL kernel and unit test Jun 20, 2024
Copy link
Contributor

@djeong20 djeong20 left a comment

Choose a reason for hiding this comment

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

overall, LGTM

@@ -662,6 +662,10 @@ std::string RunLayerContext::getKernelName(LayerKernel layerKernel) {
return "dot_cl_fp16";
case LayerKernel::SGEMM_FP16:
return "sgemm_cl_fp16";
case LayerKernel::SSCAL:
return "sscal_cl";
case LayerKernel::SSCAL_FP16:
Copy link
Contributor

Choose a reason for hiding this comment

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

please keep in mind that sscal_fp16 should later be hscal!

* @brief Process data and dimensions for OpenCL dot operation
* @param[in] input Tensor
* @param[in] m Tensor
* @param[in] result Tensor
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
* @param[in] result Tensor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in latest commit.


/**
* @brief fp16 sscal value element by element immediately
* @param[in] X float * input
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
* @param[in] X float * input
* @param[in] X __fp16 * input

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in latest commit.

Copy link

@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.

@s-debadri, 💯 All CI checkers are successfully verified. Thanks.

@@ -662,6 +662,10 @@ std::string RunLayerContext::getKernelName(LayerKernel layerKernel) {
return "dot_cl_fp16";
case LayerKernel::SGEMM_FP16:
return "sgemm_cl_fp16";
case LayerKernel::SSCAL:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This cl kernel information should be handled in cl context. Otherwise, we cannot support the custom cl layer. We do need CLLernel Class and it should be managed in Cl_Context. and if the layer is created, then N Cl kernel should be mapped to the layer object. and also, if there is a custom cl layer, the cl kernel must be registered to the cl context. I guess the basic cl kernels for dot, sgemm, etc. could be managed as an basic cl math kernels we provide and CLKernel has the list of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, this will be done in future PRs.

@@ -30,6 +30,14 @@ void dotBatchedCl(Tensor const &input, Tensor const &m, Tensor &result,
}
}

Tensor dotCl(Tensor const &input, Tensor const &m, RunLayerContext &context,
Copy link
Collaborator

Choose a reason for hiding this comment

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

RunLayerContext should be used as a data provider. It shouldn't have Kernel related information.
This dotCL level could be the CLKernel Class. I guess. and managed in clAppContext.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, this will be done in future PRs.

s-debadri added 2 commits July 2, 2024 11:55
Added sscal equivalent kernel and multiply function.
Added unit test setup to test standalone kernels.

Signed-off-by: Debadri Samaddar <[email protected]>
Modified doxygen docs as required

Signed-off-by: Debadri Samaddar <[email protected]>
@s-debadri s-debadri force-pushed the blas_kernel_enhance branch from cb9c323 to bce13bd Compare July 2, 2024 06:31
Copy link

@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.

@s-debadri, 💯 All CI checkers are successfully verified. Thanks.

Copy link
Collaborator

@jijoongmoon jijoongmoon 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 9845390 into nnstreamer:main Jul 2, 2024
40 checks passed
@s-debadri s-debadri deleted the blas_kernel_enhance branch July 2, 2024 08:07
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.

5 participants