Skip to content

Commit 339c18d

Browse files
authored
Merge pull request #52 from foss-for-synopsys-dwc-arc-processors/helpers_bg
Convert tensors: bugs in switching and output filling
2 parents a264e56 + 31f6b27 commit 339c18d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/src/helpers/src/mli_helpers.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,19 @@ mli_status mli_hlp_convert_tensor(mli_tensor *in, mli_tensor *out) {
124124
return MLI_STATUS_BAD_TENSOR;
125125

126126
// Switchnig functionality depending on tensors type
127-
if (in->el_type == out->el_type == MLI_EL_FX_8)
127+
if (in->el_type == MLI_EL_FX_8 && out->el_type == MLI_EL_FX_8)
128128
convert_tensor_fx8_to_fx8((MLI_PTR(int8_t))in->data, (MLI_PTR(int8_t))out->data, in_sz, out_shift);
129-
else if (in->el_type == out->el_type == MLI_EL_FX_16)
129+
else if (in->el_type == MLI_EL_FX_16 && out->el_type == MLI_EL_FX_16)
130130
convert_tensor_fx16_to_fx16((MLI_PTR(int16_t))in->data, (MLI_PTR(int16_t))out->data, in_sz, out_shift);
131131
else if (in->el_type == MLI_EL_FX_8 && out->el_type == MLI_EL_FX_16)
132132
convert_tensor_fx8_to_fx16((MLI_PTR(int8_t))in->data, (MLI_PTR(int16_t))out->data, in_sz, out_shift);
133133
else if (in->el_type == MLI_EL_FX_16 && out->el_type == MLI_EL_FX_8)
134134
convert_tensor_fx16_to_fx8((MLI_PTR(int16_t))in->data, (MLI_PTR(int8_t))out->data, in_sz, out_shift);
135135

136+
// Fill the rest output tensor params
137+
for (int idx = 0; idx < in->rank; idx++)
138+
out->shape[idx] = in->shape[idx];
139+
out->rank = in->rank;
136140
return MLI_STATUS_OK;
137141
}
138142

0 commit comments

Comments
 (0)