ggml-zdnn: fix sequencing of transforms

Signed-off-by: Aaron Teo <aaron.teo1@ibm.com>
This commit is contained in:
Aaron Teo
2025-07-28 16:46:17 +08:00
parent cf0e190c40
commit 032dce5a6a

View File

@@ -55,9 +55,9 @@ static bool ggml_zdnn_op_mul_mat(struct ggml_backend_zdnn_context * ctx, const g
&weights_extra->pre_tfm_desc,
weights->ne[1], weights->ne[0]
);
ZDNN_CHECK(zdnn_transform_ztensor(&weights_extra->ztensor, weights->data));
ZDNN_CHECK(zdnn_generate_transformed_desc(&weights_extra->pre_tfm_desc, &weights_extra->tfm_desc));
ZDNN_CHECK(zdnn_init_ztensor_with_malloc(&weights_extra->pre_tfm_desc, &weights_extra->tfm_desc, &weights_extra->ztensor));
ZDNN_CHECK(zdnn_transform_ztensor(&weights_extra->ztensor, weights->data));
// have to do this here because although it was transformed, the shape is wrong
if (&inputs_extra->ztensor.is_transformed) zdnn_reset_ztensor(&inputs_extra->ztensor);
@@ -67,9 +67,9 @@ static bool ggml_zdnn_op_mul_mat(struct ggml_backend_zdnn_context * ctx, const g
&inputs_extra->pre_tfm_desc,
inputs->ne[1], inputs->ne[0]
);
ZDNN_CHECK(zdnn_transform_ztensor(&inputs_extra->ztensor, inputs->data));
ZDNN_CHECK(zdnn_generate_transformed_desc(&inputs_extra->pre_tfm_desc, &inputs_extra->tfm_desc));
ZDNN_CHECK(zdnn_init_ztensor_with_malloc(&inputs_extra->pre_tfm_desc, &inputs_extra->tfm_desc, &inputs_extra->ztensor));
ZDNN_CHECK(zdnn_transform_ztensor(&inputs_extra->ztensor, inputs->data));
// have to transform the bias ztensor here because only GGML_OP_NONE goes through set_tensor
ZDNN_CHECK(zdnn_transform_ztensor(&bias_extra->ztensor, bias_extra->data));