Skip to content

OpenCL: Add concat, tsembd, upscale, tanh, pad and repeat #13840

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

Merged
merged 2 commits into from
Jun 2, 2025

Conversation

rmatif
Copy link
Contributor

@rmatif rmatif commented May 28, 2025

The previous PR had a lot of conflicts since group norm was added in this commit: a3c3084, and I messed up some git commands.

The ops in the title are now added, and with these additions, OpenCL (hopefully) supports all the ops used in stable-diffusion.cpp.

All tests passed using test-backend-ops. Tested on: Adreno 750, 740, 730.

@lhez @max-krasnyansky

@github-actions github-actions bot added the ggml changes relating to the ggml tensor library for machine learning label May 28, 2025
@rmatif rmatif changed the title OpenCL: Add concat, tsembd, upscale, tanh, pad and repeat #13781 OpenCL: Add concat, tsembd, upscale, tanh, pad and repeat May 28, 2025
@lhez
Copy link
Contributor

lhez commented May 28, 2025

Thank you @rmatif for the PR. I missed your previous one. Taking a looking into the PR now.

y_val_ptr = (global float *)(dst_base + (ulong)current_i3*d_nb3 + (ulong)current_i2*d_nb2 + (ulong)current_i1*d_nb1 + (ulong)current_i0*d_nb0);
*y_val_ptr = *x_val_ptr;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a newline at the end of the file?

current_dst_el_ptr[k] = current_src_el_ptr[k];
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a newline at the end of the file?

local_arg = local_timestep_val * local_freq;
local_embed_data_ptr[local_j] = cos(local_arg);
local_embed_data_ptr[local_j + local_half_dim] = sin(local_arg);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a newline at the end of the file?

*dst_val_ptr = tanh(*src_val_ptr);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a newline at the end of the file?

val_d * dx * dy;

dst_base[index] = result;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a newline at the end of the file?

@@ -0,0 +1,63 @@
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
Copy link
Contributor

@lhez lhez May 30, 2025

Choose a reason for hiding this comment

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

Can you rename this file to tanh.cl? We have been putting each unary op in separate files. This also should be more friendly to compilers on A6x.

@@ -1988,6 +2150,17 @@ static bool ggml_opencl_supports_op(ggml_backend_dev_t dev, const struct ggml_te
case GGML_OP_NORM:
case GGML_OP_RMS_NORM:
return true;
case GGML_OP_REPEAT:
Copy link
Contributor

Choose a reason for hiding this comment

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

The indention seems off for this case.

@rmatif
Copy link
Contributor Author

rmatif commented May 30, 2025

@lhez Thanks for the review, can you check again now please ?

@rmatif rmatif requested a review from lhez May 30, 2025 18:23
@lhez
Copy link
Contributor

lhez commented Jun 2, 2025

I think it looks good.

Copy link
Collaborator

@max-krasnyansky max-krasnyansky left a comment

Choose a reason for hiding this comment

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

Nice!. Thanks for adding more kernels!

@max-krasnyansky max-krasnyansky merged commit bfb1e01 into ggml-org:master Jun 2, 2025
46 checks passed
furyhawk pushed a commit to furyhawk/llama.cpp that referenced this pull request Jun 6, 2025
…3840)

* add concat, pad, repeat, tsembd, tanh, upscale

* small fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ggml changes relating to the ggml tensor library for machine learning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants