From c4a5f8d66575d7f2b559243633614d952b8dd16e Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Thu, 10 Apr 2025 17:03:17 +0200 Subject: [PATCH] teflon: Set unused dimensions to 1 So drivers don't need to superfluously watch out for zeroes when multiplying among dimensions. Part-of: --- src/gallium/frontends/teflon/tfl_device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/teflon/tfl_device.c b/src/gallium/frontends/teflon/tfl_device.c index 8dec1629541..87256a9a642 100644 --- a/src/gallium/frontends/teflon/tfl_device.c +++ b/src/gallium/frontends/teflon/tfl_device.c @@ -223,7 +223,13 @@ fill_tensor(struct teflon_delegate *delegate, TfLiteContext *tf_context, struct tensor->resource = create_resource(context, tf_tensor); tensor->index = index; - memcpy(tensor->dims, tf_tensor.dims->data, tf_tensor.dims->size * sizeof(*tensor->dims)); + for (int out_dim = 0; out_dim < 4; out_dim++) { + int in_dim = tf_tensor.dims->size - 4 + out_dim; + if (in_dim >= 0) + tensor->dims[out_dim] = tf_tensor.dims->data[in_dim]; + else + tensor->dims[out_dim] = 1; + } if (tf_tensor.quantization.type == kTfLiteAffineQuantization) { const TfLiteAffineQuantization *quant = (const TfLiteAffineQuantization *)tf_tensor.quantization.params;