Skip to content

Is there a way to downcast a float32 tensor to a float16 tensor? #675

Answered by slaren
balisujohn asked this question in Q&A
Discussion options

You must be logged in to vote

You can use ggml_cpy to convert tensors to a different data type, you would need to create a tensor with the same dimensions and a different type and specify it as the destination of the copy. For example:

ggml_cpy(ctx, src, ggml_new_tensor(ctx, GGML_TYPE_F32, 4, src->ne));

There are also functions defined in ggml.h to convert data between fp16 and fp32, ggml_fp16_to_fp32 and ggml_fp16_to_fp32_row.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by balisujohn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants