opencl: add ABS op#25115
Open
Gezahegne wants to merge 6 commits into
Open
Conversation
|
Hi @Gezahegne, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
Contributor
|
Could you remove the string "SYCL" in the description? Thank you! |
Member
|
Please remove changes in .gitignore and extra txt files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Adds support for the
ABSunary operation (y = |x|) to the OpenCL backend.This implements it for
F32andF16, contiguous and non-contiguous tensors.The implementation mirrors the existing
EXPM1op (same element-wise unarystructure); only the per-element math differs (
exp(x) - 1→fabs(x)).Additional information
Changes
ggml/src/ggml-opencl/kernels/abs.cl(new): 6 kernels —kernel_abs_f32,kernel_abs_f32_4,kernel_abs_f32_nc,kernel_abs_f16,kernel_abs_f16_4,kernel_abs_f16_nc.ggml/src/ggml-opencl/CMakeLists.txt: registerabsinGGML_OPENCL_KERNELS.ggml/src/ggml-opencl/ggml-opencl.cpp:cl_kernel kernel_abs_*handles in the backend context,// absprogram block,ggml_cl_abs()dispatch function (contiguous fast path with_4vectorization when
nelements % 4 == 0, otherwise scalar;_ncfornon-contiguous inputs),
GGML_UNARY_OP_ABStoggml_cl_abs,trueforGGML_UNARY_OP_ABS(F32/F16) insupports_op.docs/ops.md: regenerated — OpenCLABScell flips❌ → ✅.Requirements
YES — used Claude Code to help implement the ABS OpenCL kernels and dispatch by mirroring the existing EXPM1 op, and regenerate docs/ops.md. Reviewed and verified on Intel Arc 140V hardware.