Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

safranowith
Copy link

This PR introduces the TRUNC unary operator, applying element-wise truncation (truncf / sycl::trunc) on tensors.

Changes:

CPU (ggml-cpu.c)

Added forward implementation: ggml_compute_forward_trunc

Registered op in scheduler: ggml_get_n_tasks

SYCL (ggml-sycl)

Added device function: op_trunc

Added kernel: unary_op_trunc_kernel

Added dispatch wrapper: ggml_sycl_op_trunc

Exposed API: ggml_sycl_trunc

Tests

Included in backend coverage tests

Support matrix can be regenerated:

./build/bin/test-backend-ops support -o TRUNC --output csv > trunc_support.csv
./scripts/create_ops_docs.py

Produces trunc_support.csv verifying backend availability.

Notes

Implemented for F32 (and F16 where SYCL supports it)

Brings consistency with existing unary ops

@safranowith safranowith requested a review from 0cc4m as a code owner September 16, 2025 13:36
@github-actions github-actions bot added documentation Improvements or additions to documentation testing Everything test related Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language Ascend NPU issues specific to Ascend NPUs labels Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ascend NPU issues specific to Ascend NPUs documentation Improvements or additions to documentation ggml changes relating to the ggml tensor library for machine learning SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language testing Everything test related Vulkan Issues specific to the Vulkan backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants